{"action":"created","comment":{"url":"https://api.github.com/repos/coveo/source.coveo.com/pulls/comments/67689484","id":67689484,"diff_hunk":"@@ -0,0 +1,170 @@\n+---\n+layout: post\n+\n+title: \"How to prevent frequent JavaScript mistakes\"\n+\n+tags:\n+  - JavaScript\n+  - Lint\n+  - ESLint\n+  - Code style\n+\n+author:\n+  name: Lucien Bénié\n+  bio: Salesforce integration wizard\n+  github: https://github.com/lbenie\n+  imageURL: https://avatars.githubusercontent.com/lbenie\n+---\n+\n+When writing JavaScript, I spend a lot of time fixing simple mistakes. Unlike\n+compiled languages you are more likely to make mistakes. It is easy for syntax\n+errors to sneak into your code without realizing it until you actually try and\n+run your code.\n+\n+How many times have I got an `undefined` variable because I refactored some code\n+and forgot to rename *that* variable.\n+\n+Even though it has been more than 5 years since I wrote my first `Hello World`.\n+The feeling remains the same -- Why did I make this mistake *again* ?\n+\n+<!-- more -->\n+\n+To help me fix some of those mistakes, I tried a few linting tools over the\n+years. From the overly strict [JSLint](http://www.jslint.com/) to the more\n+flexible variant [JSHint](http://jshint.com/) and [JSCS](http://jscs.info/). I\n+recently discovered [ESLint](http://eslint.org/) and fell in love with its\n+extensibility and features.\n+\n+> JSCS and ESLint have merged since April 14th you can check their blog posts [JSCS](https://medium.com/@markelog/jscs-end-of-the-line-bc9bf0b3fdb2#.glmbaqz0c) and [ESLint](http://eslint.org/blog/2016/04/welcoming-jscs-to-eslint).\n+\n+# Overview\n+\n+Linting is a process of checking the source code for *programmatic* as well as\n+*stylistic* errors. A `Lint` or a `Linter` is a program that supports linting.\n+They are available for most languages like CSS, Python, JavaScript, HTML, etc...\n+\n+## ESLint\n+\n+[ESLint](http://eslint.org/) is the most recent of the four linting tools\n+previously mentioned. It was created by **Nicholas C. Zakas** in june 2013.\n+\n+> Its goal is to provide a pluggable linting utility for JavaScript.\n+\n+Designed to be heavily extensible, it comes with a large set of custom rules and\n+it is really easy to install. It gives precise and concise output by including\n+the rule name out of the box. You are always aware of which rule was causing an\n+error.\n+\n+`Eslint` provides good documentation for its rules. The rules list is easy to\n+follow and is grouped into logical categories. Each rule gives details about\n+what it *enforces* or *not* and provides examples of **good** and **bad**\n+written code for it.\n+\n+### Pros\n+\n+-   Customizable: every rule can be toggled, and many rules have extra settings\n+that can be tweaked\n+-   ES6/JSX support out of the box\n+-   Supports custom reporters\n+-   Has many plugins available and is very extensible\n+-   Include many rules not available in other linters\n+\n+### Cons\n+-   Slow, compared to JSHint or JSCS, but faster than these two if combined\n+-   Requires some configuration to get started\n+\n+## Extensibility\n+\n+Since `ESLint` is extremely extensible, I have created a [shareable config rule\n+set](https://github.com/coveo/eslint-config-coveo) to help my fellow colleagues\n+here at [Coveo](www.coveo.com) who write Pure JavaScript.\n+\n+### Open-sourcing\n+\n+`eslint-config-coveo` started as an internal project for my team (Salesforce\n+integration) then we decided -- Hey... why not open-source it?\n+\n+With that in mind, I created a gulp task wrapper that uses **our** rule set\n+defined from [that shareable\n+config](https://github.com/coveo/eslint-config-coveo). You can find the project\n+`pretty-javascript` [here](https://github.com/coveo/pretty-javascript).\n+\n+**Having said all that**\n+\n+For anyone who wants to write JavaScript like we do it at **Coveo** follow these\n+simple steps to get you up and running.\n+\n+-    Install `pretty-javascript` and `gulp` packages from `npm`\n+\n+```sh\n+npm install --save-dev pretty-javascript gulp\n+```\n+\n+-   Create an `eslint` configuration file\n+\n+.eslintrc.yaml\n+\n+```yaml\n+---\n+  extends: coveo\n+  rules:\n+    ... (they can be overriden)\n+```\n+\n+**OR**\n+\n+.eslintrc.json\n+\n+```json\n+{\n+  \"extends\": \"coveo\",\n+  \"rules\": {\n+    ... (they can be overriden)\n+  }\n+}\n+```\n+\n+-   Create a gulp task to run `eslint`\n+\n+gulpfile.js\n+\n+```js\n+var gulp = require('gulp');\n+var linter = require('pretty-javascript');\n+\n+gulp.task('lint', function() {\n+  gulp\n+    .src('src/**/*.js')\n+    .pipe(linter());\n+});\n+```\n+\n+Sit back, relax and enjoy watching your silly mistakes from your terminal\n+output!\n+\n+## TypeScript\n+\n+For TypeScript lovers, Coveo also provides a gulp task wrapper to lint\n+TypeScript. The project *pretty-typescript* can be found\n+[here](https://github.com/coveo/pretty-typescript) (huge kudos to Dominique\n+Bégin).\n+\n+Similarly to *pretty-javascript*, you only have to include `pretty-typescript` and `gulp` from `npm`.\n+\n+```sh\n+npm install --save-dev pretty-typescript gulp\n+```\n+\n+Then simply add a task to lint your TypeScript code in your `gulpfile` as follow :","path":"_posts/2016-06-16-open-source-coveo-javascript-linter.md","position":158,"original_position":158,"commit_id":"b57cd1c6ed5e34d9ad5f27f0683e356c71c007ab","original_commit_id":"b57cd1c6ed5e34d9ad5f27f0683e356c71c007ab","user":{"login":"francoislg","id":8355585,"avatar_url":"https://avatars.githubusercontent.com/u/8355585?v=3","gravatar_id":"","url":"https://api.github.com/users/francoislg","html_url":"https://github.com/francoislg","followers_url":"https://api.github.com/users/francoislg/followers","following_url":"https://api.github.com/users/francoislg/following{/other_user}","gists_url":"https://api.github.com/users/francoislg/gists{/gist_id}","starred_url":"https://api.github.com/users/francoislg/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/francoislg/subscriptions","organizations_url":"https://api.github.com/users/francoislg/orgs","repos_url":"https://api.github.com/users/francoislg/repos","events_url":"https://api.github.com/users/francoislg/events{/privacy}","received_events_url":"https://api.github.com/users/francoislg/received_events","type":"User","site_admin":false},"body":"\"as follows: \" or \"as the following: \"","created_at":"2016-06-20T13:33:50Z","updated_at":"2016-06-20T13:33:50Z","html_url":"https://github.com/coveo/source.coveo.com/pull/77#discussion_r67689484","pull_request_url":"https://api.github.com/repos/coveo/source.coveo.com/pulls/77","_links":{"self":{"href":"https://api.github.com/repos/coveo/source.coveo.com/pulls/comments/67689484"},"html":{"href":"https://github.com/coveo/source.coveo.com/pull/77#discussion_r67689484"},"pull_request":{"href":"https://api.github.com/repos/coveo/source.coveo.com/pulls/77"}}},"pull_request":{"url":"https://api.github.com/repos/coveo/source.coveo.com/pulls/77","id":74263913,"html_url":"https://github.com/coveo/source.coveo.com/pull/77","diff_url":"https://github.com/coveo/source.coveo.com/pull/77.diff","patch_url":"https://github.com/coveo/source.coveo.com/pull/77.patch","issue_url":"https://api.github.com/repos/coveo/source.coveo.com/issues/77","number":77,"state":"open","locked":false,"title":"new post","user":{"login":"lbenie","id":7316046,"avatar_url":"https://avatars.githubusercontent.com/u/7316046?v=3","gravatar_id":"","url":"https://api.github.com/users/lbenie","html_url":"https://github.com/lbenie","followers_url":"https://api.github.com/users/lbenie/followers","following_url":"https://api.github.com/users/lbenie/following{/other_user}","gists_url":"https://api.github.com/users/lbenie/gists{/gist_id}","starred_url":"https://api.github.com/users/lbenie/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lbenie/subscriptions","organizations_url":"https://api.github.com/users/lbenie/orgs","repos_url":"https://api.github.com/users/lbenie/repos","events_url":"https://api.github.com/users/lbenie/events{/privacy}","received_events_url":"https://api.github.com/users/lbenie/received_events","type":"User","site_admin":false},"body":"First technical post","created_at":"2016-06-17T15:46:55Z","updated_at":"2016-06-20T13:33:51Z","closed_at":null,"merged_at":null,"merge_commit_sha":"d30d64c16f0755c0a9d71dd41993292f971d5557","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/coveo/source.coveo.com/pulls/77/commits","review_comments_url":"https://api.github.com/repos/coveo/source.coveo.com/pulls/77/comments","review_comment_url":"https://api.github.com/repos/coveo/source.coveo.com/pulls/comments{/number}","comments_url":"https://api.github.com/repos/coveo/source.coveo.com/issues/77/comments","statuses_url":"https://api.github.com/repos/coveo/source.coveo.com/statuses/b57cd1c6ed5e34d9ad5f27f0683e356c71c007ab","head":{"label":"lbenie:gh-pages","ref":"gh-pages","sha":"b57cd1c6ed5e34d9ad5f27f0683e356c71c007ab","user":{"login":"lbenie","id":7316046,"avatar_url":"https://avatars.githubusercontent.com/u/7316046?v=3","gravatar_id":"","url":"https://api.github.com/users/lbenie","html_url":"https://github.com/lbenie","followers_url":"https://api.github.com/users/lbenie/followers","following_url":"https://api.github.com/users/lbenie/following{/other_user}","gists_url":"https://api.github.com/users/lbenie/gists{/gist_id}","starred_url":"https://api.github.com/users/lbenie/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lbenie/subscriptions","organizations_url":"https://api.github.com/users/lbenie/orgs","repos_url":"https://api.github.com/users/lbenie/repos","events_url":"https://api.github.com/users/lbenie/events{/privacy}","received_events_url":"https://api.github.com/users/lbenie/received_events","type":"User","site_admin":false},"repo":{"id":61243478,"name":"source.coveo.com","full_name":"lbenie/source.coveo.com","owner":{"login":"lbenie","id":7316046,"avatar_url":"https://avatars.githubusercontent.com/u/7316046?v=3","gravatar_id":"","url":"https://api.github.com/users/lbenie","html_url":"https://github.com/lbenie","followers_url":"https://api.github.com/users/lbenie/followers","following_url":"https://api.github.com/users/lbenie/following{/other_user}","gists_url":"https://api.github.com/users/lbenie/gists{/gist_id}","starred_url":"https://api.github.com/users/lbenie/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lbenie/subscriptions","organizations_url":"https://api.github.com/users/lbenie/orgs","repos_url":"https://api.github.com/users/lbenie/repos","events_url":"https://api.github.com/users/lbenie/events{/privacy}","received_events_url":"https://api.github.com/users/lbenie/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/lbenie/source.coveo.com","description":"Our technical blog.","fork":true,"url":"https://api.github.com/repos/lbenie/source.coveo.com","forks_url":"https://api.github.com/repos/lbenie/source.coveo.com/forks","keys_url":"https://api.github.com/repos/lbenie/source.coveo.com/keys{/key_id}","collaborators_url":"https://api.github.com/repos/lbenie/source.coveo.com/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/lbenie/source.coveo.com/teams","hooks_url":"https://api.github.com/repos/lbenie/source.coveo.com/hooks","issue_events_url":"https://api.github.com/repos/lbenie/source.coveo.com/issues/events{/number}","events_url":"https://api.github.com/repos/lbenie/source.coveo.com/events","assignees_url":"https://api.github.com/repos/lbenie/source.coveo.com/assignees{/user}","branches_url":"https://api.github.com/repos/lbenie/source.coveo.com/branches{/branch}","tags_url":"https://api.github.com/repos/lbenie/source.coveo.com/tags","blobs_url":"https://api.github.com/repos/lbenie/source.coveo.com/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/lbenie/source.coveo.com/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/lbenie/source.coveo.com/git/refs{/sha}","trees_url":"https://api.github.com/repos/lbenie/source.coveo.com/git/trees{/sha}","statuses_url":"https://api.github.com/repos/lbenie/source.coveo.com/statuses/{sha}","languages_url":"https://api.github.com/repos/lbenie/source.coveo.com/languages","stargazers_url":"https://api.github.com/repos/lbenie/source.coveo.com/stargazers","contributors_url":"https://api.github.com/repos/lbenie/source.coveo.com/contributors","subscribers_url":"https://api.github.com/repos/lbenie/source.coveo.com/subscribers","subscription_url":"https://api.github.com/repos/lbenie/source.coveo.com/subscription","commits_url":"https://api.github.com/repos/lbenie/source.coveo.com/commits{/sha}","git_commits_url":"https://api.github.com/repos/lbenie/source.coveo.com/git/commits{/sha}","comments_url":"https://api.github.com/repos/lbenie/source.coveo.com/comments{/number}","issue_comment_url":"https://api.github.com/repos/lbenie/source.coveo.com/issues/comments{/number}","contents_url":"https://api.github.com/repos/lbenie/source.coveo.com/contents/{+path}","compare_url":"https://api.github.com/repos/lbenie/source.coveo.com/compare/{base}...{head}","merges_url":"https://api.github.com/repos/lbenie/source.coveo.com/merges","archive_url":"https://api.github.com/repos/lbenie/source.coveo.com/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/lbenie/source.coveo.com/downloads","issues_url":"https://api.github.com/repos/lbenie/source.coveo.com/issues{/number}","pulls_url":"https://api.github.com/repos/lbenie/source.coveo.com/pulls{/number}","milestones_url":"https://api.github.com/repos/lbenie/source.coveo.com/milestones{/number}","notifications_url":"https://api.github.com/repos/lbenie/source.coveo.com/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/lbenie/source.coveo.com/labels{/name}","releases_url":"https://api.github.com/repos/lbenie/source.coveo.com/releases{/id}","deployments_url":"https://api.github.com/repos/lbenie/source.coveo.com/deployments","created_at":"2016-06-15T21:49:28Z","updated_at":"2016-06-15T21:49:29Z","pushed_at":"2016-06-20T12:43:30Z","git_url":"git://github.com/lbenie/source.coveo.com.git","ssh_url":"git@github.com:lbenie/source.coveo.com.git","clone_url":"https://github.com/lbenie/source.coveo.com.git","svn_url":"https://github.com/lbenie/source.coveo.com","homepage":"source.coveo.com","size":23232,"stargazers_count":0,"watchers_count":0,"language":"CSS","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":true,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"gh-pages"}},"base":{"label":"coveo:gh-pages","ref":"gh-pages","sha":"487ae8259999cf9696fd038f606fb8e5b894b731","user":{"login":"coveo","id":8632328,"avatar_url":"https://avatars.githubusercontent.com/u/8632328?v=3","gravatar_id":"","url":"https://api.github.com/users/coveo","html_url":"https://github.com/coveo","followers_url":"https://api.github.com/users/coveo/followers","following_url":"https://api.github.com/users/coveo/following{/other_user}","gists_url":"https://api.github.com/users/coveo/gists{/gist_id}","starred_url":"https://api.github.com/users/coveo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/coveo/subscriptions","organizations_url":"https://api.github.com/users/coveo/orgs","repos_url":"https://api.github.com/users/coveo/repos","events_url":"https://api.github.com/users/coveo/events{/privacy}","received_events_url":"https://api.github.com/users/coveo/received_events","type":"Organization","site_admin":false},"repo":{"id":23815317,"name":"source.coveo.com","full_name":"coveo/source.coveo.com","owner":{"login":"coveo","id":8632328,"avatar_url":"https://avatars.githubusercontent.com/u/8632328?v=3","gravatar_id":"","url":"https://api.github.com/users/coveo","html_url":"https://github.com/coveo","followers_url":"https://api.github.com/users/coveo/followers","following_url":"https://api.github.com/users/coveo/following{/other_user}","gists_url":"https://api.github.com/users/coveo/gists{/gist_id}","starred_url":"https://api.github.com/users/coveo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/coveo/subscriptions","organizations_url":"https://api.github.com/users/coveo/orgs","repos_url":"https://api.github.com/users/coveo/repos","events_url":"https://api.github.com/users/coveo/events{/privacy}","received_events_url":"https://api.github.com/users/coveo/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/coveo/source.coveo.com","description":"Our technical blog.","fork":false,"url":"https://api.github.com/repos/coveo/source.coveo.com","forks_url":"https://api.github.com/repos/coveo/source.coveo.com/forks","keys_url":"https://api.github.com/repos/coveo/source.coveo.com/keys{/key_id}","collaborators_url":"https://api.github.com/repos/coveo/source.coveo.com/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/coveo/source.coveo.com/teams","hooks_url":"https://api.github.com/repos/coveo/source.coveo.com/hooks","issue_events_url":"https://api.github.com/repos/coveo/source.coveo.com/issues/events{/number}","events_url":"https://api.github.com/repos/coveo/source.coveo.com/events","assignees_url":"https://api.github.com/repos/coveo/source.coveo.com/assignees{/user}","branches_url":"https://api.github.com/repos/coveo/source.coveo.com/branches{/branch}","tags_url":"https://api.github.com/repos/coveo/source.coveo.com/tags","blobs_url":"https://api.github.com/repos/coveo/source.coveo.com/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/coveo/source.coveo.com/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/coveo/source.coveo.com/git/refs{/sha}","trees_url":"https://api.github.com/repos/coveo/source.coveo.com/git/trees{/sha}","statuses_url":"https://api.github.com/repos/coveo/source.coveo.com/statuses/{sha}","languages_url":"https://api.github.com/repos/coveo/source.coveo.com/languages","stargazers_url":"https://api.github.com/repos/coveo/source.coveo.com/stargazers","contributors_url":"https://api.github.com/repos/coveo/source.coveo.com/contributors","subscribers_url":"https://api.github.com/repos/coveo/source.coveo.com/subscribers","subscription_url":"https://api.github.com/repos/coveo/source.coveo.com/subscription","commits_url":"https://api.github.com/repos/coveo/source.coveo.com/commits{/sha}","git_commits_url":"https://api.github.com/repos/coveo/source.coveo.com/git/commits{/sha}","comments_url":"https://api.github.com/repos/coveo/source.coveo.com/comments{/number}","issue_comment_url":"https://api.github.com/repos/coveo/source.coveo.com/issues/comments{/number}","contents_url":"https://api.github.com/repos/coveo/source.coveo.com/contents/{+path}","compare_url":"https://api.github.com/repos/coveo/source.coveo.com/compare/{base}...{head}","merges_url":"https://api.github.com/repos/coveo/source.coveo.com/merges","archive_url":"https://api.github.com/repos/coveo/source.coveo.com/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/coveo/source.coveo.com/downloads","issues_url":"https://api.github.com/repos/coveo/source.coveo.com/issues{/number}","pulls_url":"https://api.github.com/repos/coveo/source.coveo.com/pulls{/number}","milestones_url":"https://api.github.com/repos/coveo/source.coveo.com/milestones{/number}","notifications_url":"https://api.github.com/repos/coveo/source.coveo.com/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/coveo/source.coveo.com/labels{/name}","releases_url":"https://api.github.com/repos/coveo/source.coveo.com/releases{/id}","deployments_url":"https://api.github.com/repos/coveo/source.coveo.com/deployments","created_at":"2014-09-09T01:43:19Z","updated_at":"2016-06-16T12:35:19Z","pushed_at":"2016-06-20T12:43:30Z","git_url":"git://github.com/coveo/source.coveo.com.git","ssh_url":"git@github.com:coveo/source.coveo.com.git","clone_url":"https://github.com/coveo/source.coveo.com.git","svn_url":"https://github.com/coveo/source.coveo.com","homepage":"source.coveo.com","size":23217,"stargazers_count":5,"watchers_count":5,"language":"CSS","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":true,"forks_count":29,"mirror_url":null,"open_issues_count":3,"forks":29,"open_issues":3,"watchers":5,"default_branch":"gh-pages"}},"_links":{"self":{"href":"https://api.github.com/repos/coveo/source.coveo.com/pulls/77"},"html":{"href":"https://github.com/coveo/source.coveo.com/pull/77"},"issue":{"href":"https://api.github.com/repos/coveo/source.coveo.com/issues/77"},"comments":{"href":"https://api.github.com/repos/coveo/source.coveo.com/issues/77/comments"},"review_comments":{"href":"https://api.github.com/repos/coveo/source.coveo.com/pulls/77/comments"},"review_comment":{"href":"https://api.github.com/repos/coveo/source.coveo.com/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/coveo/source.coveo.com/pulls/77/commits"},"statuses":{"href":"https://api.github.com/repos/coveo/source.coveo.com/statuses/b57cd1c6ed5e34d9ad5f27f0683e356c71c007ab"}}}}
{"actor":{"display_login":"francoislg"}}