{"action":"created","issue":{"url":"https://api.github.com/repos/mrdoob/three.js/issues/6007","labels_url":"https://api.github.com/repos/mrdoob/three.js/issues/6007/labels{/name}","comments_url":"https://api.github.com/repos/mrdoob/three.js/issues/6007/comments","events_url":"https://api.github.com/repos/mrdoob/three.js/issues/6007/events","html_url":"https://github.com/mrdoob/three.js/pull/6007","id":56111261,"number":6007,"title":"Example for using ESLint to help enforce your style rules","user":{"login":"greggman","id":234804,"avatar_url":"https://avatars.githubusercontent.com/u/234804?v=3","gravatar_id":"","url":"https://api.github.com/users/greggman","html_url":"https://github.com/greggman","followers_url":"https://api.github.com/users/greggman/followers","following_url":"https://api.github.com/users/greggman/following{/other_user}","gists_url":"https://api.github.com/users/greggman/gists{/gist_id}","starred_url":"https://api.github.com/users/greggman/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/greggman/subscriptions","organizations_url":"https://api.github.com/users/greggman/orgs","repos_url":"https://api.github.com/users/greggman/repos","events_url":"https://api.github.com/users/greggman/events{/privacy}","received_events_url":"https://api.github.com/users/greggman/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":13,"created_at":"2015-01-31T03:55:04Z","updated_at":"2015-02-10T01:59:28Z","closed_at":"2015-01-31T19:05:23Z","pull_request":{"url":"https://api.github.com/repos/mrdoob/three.js/pulls/6007","html_url":"https://github.com/mrdoob/three.js/pull/6007","diff_url":"https://github.com/mrdoob/three.js/pull/6007.diff","patch_url":"https://github.com/mrdoob/three.js/pull/6007.patch"},"body":"I just got done setting this up for one of my projects and I thought I'd show you how to set it up for yours if you're interested. I'm not expecting you to pull this request (you can if you want) but rather if you don't like it as is you can reference it.\r\n\r\nSo, if you get this branch, cd to the root folder and type\r\n\r\n    npm install\r\n    sudo npm install grunt-cli -g   // assuming you don't have grunt installed already\r\n\r\nthen you can now do\r\n\r\n    grunt eslint\r\n\r\nand it checks many or most of your style rules. See `utils/build/eslint/eslint.json` that most of the rules are off right now because the code is breaking them all over the place :P Ideally if you add this to the official three.js repo we could turn on one rule, fix all the warnings, then make a pull request and repeat until its all one style. \r\n\r\nIt's currently only checking the `src` folder. Ideally we'd turn it on for the `examples` and `test` folders as well. One thing I need to look into is how easy it would be it lint inline html scripts for the examples folder but hey, one step at a time.\r\n\r\nSo ... first that makes it easy to manually check if the code mostly matches your style guide but...\r\n\r\n## travis-ci\r\n\r\nif you setup a free account on travis-ci.org and turn it on\r\nfor the three.js repo it will lint any pull request automatically \r\nand have the results directly in the pull request on github.\r\n\r\nI turned it on on my copy of three.js repo. \r\n[You can see it ran here](https://travis-ci.org/greggman/three.js)\r\n\r\n## git integration\r\n\r\nYou can also setup a git pre-commit script to run \"grunt eslint\" before\r\ncommitting. That's a local only thing meaning it won't propagate to other\r\nusers but it might be useful for yourself if you want to make sure you don't\r\ncommit something that breaks your own rules\r\n\r\n## custom rules\r\n\r\n[ESLint](http://eslint.org) allows custom rules. The easiest way to make a custom rule is to copy one of the built in rules. So for example\r\n\r\n    cp node_modules/eslint/lib/rules/brace-style.js utils/build/eslint/rules/three-brace-style.js\r\n\r\nNow there's a rule called `three-brace-style`. You could modify it so it enforced a blank line after `{` and before `}`\r\n\r\n## overriding rules\r\n\r\nSometimes you need to override a rule for special code. You can do that with a comment in the code. For example if you wanted to allow an unused var you could do this\r\n\r\n    /*eslint no-unused-vars: 0*/\r\n\r\n## where to put these files\r\n\r\nI thought I should put all of these files in `utils/eslint` or `utils/build/eslint`. The advantage to the latter is that you already have a `package.json` file there that I'm guessing you use. The reason I put a few files in the root though is because that way they work with travis-ci without much work. If you move them somewhere else I suspect there's a bunch of work to do to get travis-ci to handle that case. Of course it's up to you.\r\n"},"comment":{"url":"https://api.github.com/repos/mrdoob/three.js/issues/comments/73630671","html_url":"https://github.com/mrdoob/three.js/pull/6007#issuecomment-73630671","issue_url":"https://api.github.com/repos/mrdoob/three.js/issues/6007","id":73630671,"user":{"login":"mrdoob","id":97088,"avatar_url":"https://avatars.githubusercontent.com/u/97088?v=3","gravatar_id":"","url":"https://api.github.com/users/mrdoob","html_url":"https://github.com/mrdoob","followers_url":"https://api.github.com/users/mrdoob/followers","following_url":"https://api.github.com/users/mrdoob/following{/other_user}","gists_url":"https://api.github.com/users/mrdoob/gists{/gist_id}","starred_url":"https://api.github.com/users/mrdoob/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mrdoob/subscriptions","organizations_url":"https://api.github.com/users/mrdoob/orgs","repos_url":"https://api.github.com/users/mrdoob/repos","events_url":"https://api.github.com/users/mrdoob/events{/privacy}","received_events_url":"https://api.github.com/users/mrdoob/received_events","type":"User","site_admin":false},"created_at":"2015-02-10T01:59:28Z","updated_at":"2015-02-10T01:59:28Z","body":"Yep! This is great!\r\nWouldn't mind adopting travis just so these things stop coming O:)"}}