From 1bb72ab9e27e5437373b15e643a4602d009bf7ed Mon Sep 17 00:00:00 2001 From: Harrison Shoff Date: Fri, 12 Feb 2016 11:09:39 -0800 Subject: [PATCH 01/32] [Deps] update `eslint` to v2, `eslint-plugin-react` to v4 --- packages/eslint-config-airbnb/package.json | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/eslint-config-airbnb/package.json b/packages/eslint-config-airbnb/package.json index 6b5cad58b5..dd54ae754e 100644 --- a/packages/eslint-config-airbnb/package.json +++ b/packages/eslint-config-airbnb/package.json @@ -43,14 +43,14 @@ "homepage": "https://github.com/airbnb/javascript", "devDependencies": { "babel-tape-runner": "1.2.0", - "eslint": "^1.10.3", - "eslint-plugin-react": "^3.16.1", + "eslint": "^2.2.0", + "eslint-plugin-react": "^4.0.0", "react": "^0.14.7", "tape": "^4.4.0", "parallelshell": "^2.0.0" }, "peerDependencies": { - "eslint": "^1.0.0", - "eslint-plugin-react": "^3.16.1" + "eslint": "^2.2.0", + "eslint-plugin-react": "^4.0.0" } } From d49a1ed670bc1d26a78edc99b9a3b553db9bc13e Mon Sep 17 00:00:00 2001 From: Harrison Shoff Date: Fri, 12 Feb 2016 11:10:30 -0800 Subject: [PATCH 02/32] [eslint-v2] no-empty-label => no-labels --- packages/eslint-config-airbnb/rules/best-practices.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/eslint-config-airbnb/rules/best-practices.js b/packages/eslint-config-airbnb/rules/best-practices.js index a221d4d999..1359e58ba6 100644 --- a/packages/eslint-config-airbnb/rules/best-practices.js +++ b/packages/eslint-config-airbnb/rules/best-practices.js @@ -32,7 +32,7 @@ module.exports = { // disallow else after a return in an if 'no-else-return': 2, // disallow use of labels for anything other then loops and switches - 'no-empty-label': 2, + "no-labels": [2, {"allowLoop": false, "allowSwitch": false}], // disallow comparisons to null without a type-checking operator 'no-eq-null': 0, // disallow use of eval() From 1efb11ca93e6fd3d22c3a09825fcd4c7c3c896e8 Mon Sep 17 00:00:00 2001 From: Harrison Shoff Date: Fri, 12 Feb 2016 11:11:22 -0800 Subject: [PATCH 03/32] [eslint-v2] space-after/before/return/throw/case => keyword-spacing --- packages/eslint-config-airbnb/rules/style.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/packages/eslint-config-airbnb/rules/style.js b/packages/eslint-config-airbnb/rules/style.js index 25c5326857..e97e0d25f8 100644 --- a/packages/eslint-config-airbnb/rules/style.js +++ b/packages/eslint-config-airbnb/rules/style.js @@ -100,10 +100,12 @@ module.exports = { 'semi': [2, 'always'], // sort variables within the same declaration block 'sort-vars': 0, - // require a space before certain keywords - 'space-before-keywords': [2, 'always'], - // require a space after certain keywords - 'space-after-keywords': [2, 'always'], + // require a space before & after certain keywords + "keyword-spacing": [2, {"before": true, "after": true, "overrides": { + 'return': {'after': true}, + 'throw': {'after': true}, + 'case': {'after': true} + }}], // require or disallow space before blocks 'space-before-blocks': 2, // require or disallow space before function opening parenthesis @@ -113,8 +115,6 @@ module.exports = { 'space-in-parens': [2, 'never'], // require spaces around operators 'space-infix-ops': 2, - // require a space after return, throw, and case - 'space-return-throw-case': 2, // Require or disallow spaces before/after unary operators 'space-unary-ops': 0, // require or disallow a space immediately following the // or /* in a comment From da4213c6dd6b842f72171fc669007185e03902d8 Mon Sep 17 00:00:00 2001 From: Harrison Shoff Date: Fri, 12 Feb 2016 11:29:20 -0800 Subject: [PATCH 04/32] [eslint-v2] fix no-labels rule --- packages/eslint-config-airbnb/rules/best-practices.js | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/packages/eslint-config-airbnb/rules/best-practices.js b/packages/eslint-config-airbnb/rules/best-practices.js index 1359e58ba6..d87d70d82c 100644 --- a/packages/eslint-config-airbnb/rules/best-practices.js +++ b/packages/eslint-config-airbnb/rules/best-practices.js @@ -32,7 +32,7 @@ module.exports = { // disallow else after a return in an if 'no-else-return': 2, // disallow use of labels for anything other then loops and switches - "no-labels": [2, {"allowLoop": false, "allowSwitch": false}], + 'no-labels': [2, { 'allowLoop': true, 'allowSwitch': true }], // disallow comparisons to null without a type-checking operator 'no-eq-null': 0, // disallow use of eval() @@ -53,8 +53,6 @@ module.exports = { 'no-invalid-this': 0, // disallow usage of __iterator__ property 'no-iterator': 2, - // disallow use of labeled statements - 'no-labels': 2, // disallow unnecessary nested blocks 'no-lone-blocks': 2, // disallow creation of functions within loops From dff50992380894e9056fe03b5300f83c47b4c761 Mon Sep 17 00:00:00 2001 From: Harrison Shoff Date: Fri, 12 Feb 2016 11:30:11 -0800 Subject: [PATCH 05/32] [eslint-v2] set es6 env to true --- packages/eslint-config-airbnb/rules/es6.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/eslint-config-airbnb/rules/es6.js b/packages/eslint-config-airbnb/rules/es6.js index f28a436ba3..508257a5bf 100644 --- a/packages/eslint-config-airbnb/rules/es6.js +++ b/packages/eslint-config-airbnb/rules/es6.js @@ -1,6 +1,6 @@ module.exports = { 'env': { - 'es6': false + 'es6': true }, 'ecmaFeatures': { 'arrowFunctions': true, From 4f32315b24e9545a4e5f8c226a989dbafc1c2099 Mon Sep 17 00:00:00 2001 From: Harrison Shoff Date: Fri, 12 Feb 2016 11:36:08 -0800 Subject: [PATCH 06/32] [eslint-v2] ecmaFeatures => parserOptions --- packages/eslint-config-airbnb/rules/es6.js | 24 ++++++---------------- 1 file changed, 6 insertions(+), 18 deletions(-) diff --git a/packages/eslint-config-airbnb/rules/es6.js b/packages/eslint-config-airbnb/rules/es6.js index 508257a5bf..508885708b 100644 --- a/packages/eslint-config-airbnb/rules/es6.js +++ b/packages/eslint-config-airbnb/rules/es6.js @@ -2,24 +2,12 @@ module.exports = { 'env': { 'es6': true }, - 'ecmaFeatures': { - 'arrowFunctions': true, - 'blockBindings': true, - 'classes': true, - 'defaultParams': true, - 'destructuring': true, - 'forOf': true, - 'generators': false, - 'modules': true, - 'objectLiteralComputedProperties': true, - 'objectLiteralDuplicateProperties': false, - 'objectLiteralShorthandMethods': true, - 'objectLiteralShorthandProperties': true, - 'restParams': true, - 'spread': true, - 'superInFunctions': true, - 'templateStrings': true, - 'jsx': true + 'parserOptions': { + 'ecmaVersion': 6, + 'sourceType': 'module', + 'ecmaFeatures': { + 'jsx': true + } }, 'rules': { // enforces no braces where they can be omitted From 3aa8c584871474a5bacbc32158e8e76d1ccf94df Mon Sep 17 00:00:00 2001 From: Harrison Shoff Date: Fri, 12 Feb 2016 11:36:26 -0800 Subject: [PATCH 07/32] [eslint-v2] fix keyword-spacing style and sorting --- packages/eslint-config-airbnb/rules/style.js | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/packages/eslint-config-airbnb/rules/style.js b/packages/eslint-config-airbnb/rules/style.js index e97e0d25f8..0e8036ec51 100644 --- a/packages/eslint-config-airbnb/rules/style.js +++ b/packages/eslint-config-airbnb/rules/style.js @@ -31,6 +31,16 @@ module.exports = { 'jsx-quotes': [2, 'prefer-double'], // enforces spacing between keys and values in object literal properties 'key-spacing': [2, { 'beforeColon': false, 'afterColon': true }], + // require a space before & after certain keywords + 'keyword-spacing': [2, { + 'before': true, + 'after': true, + 'overrides': { + 'return': { 'after': true }, + 'throw': { 'after': true }, + 'case': { 'after': true } + } + }], // enforces empty lines around comments 'lines-around-comment': 0, // disallow mixed 'LF' and 'CRLF' as linebreaks @@ -100,12 +110,6 @@ module.exports = { 'semi': [2, 'always'], // sort variables within the same declaration block 'sort-vars': 0, - // require a space before & after certain keywords - "keyword-spacing": [2, {"before": true, "after": true, "overrides": { - 'return': {'after': true}, - 'throw': {'after': true}, - 'case': {'after': true} - }}], // require or disallow space before blocks 'space-before-blocks': 2, // require or disallow space before function opening parenthesis From 75807b9d5ead326be45f4719d81bda52d2bbb32a Mon Sep 17 00:00:00 2001 From: Harrison Shoff Date: Fri, 12 Feb 2016 11:42:15 -0800 Subject: [PATCH 08/32] [eslint-v2] no gens, no dup props in obj literal --- packages/eslint-config-airbnb/rules/es6.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/packages/eslint-config-airbnb/rules/es6.js b/packages/eslint-config-airbnb/rules/es6.js index 508885708b..08b5889172 100644 --- a/packages/eslint-config-airbnb/rules/es6.js +++ b/packages/eslint-config-airbnb/rules/es6.js @@ -6,7 +6,9 @@ module.exports = { 'ecmaVersion': 6, 'sourceType': 'module', 'ecmaFeatures': { - 'jsx': true + 'jsx': true, + 'generators': false, + 'objectLiteralDuplicateProperties': false } }, 'rules': { From 5109c849268020266b300229d7efd2de50f94c21 Mon Sep 17 00:00:00 2001 From: Harrison Shoff Date: Sat, 13 Feb 2016 13:41:52 -0800 Subject: [PATCH 09/32] [eslint-v2] fix no-labels rule --- packages/eslint-config-airbnb/rules/best-practices.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/eslint-config-airbnb/rules/best-practices.js b/packages/eslint-config-airbnb/rules/best-practices.js index d87d70d82c..00f7d2d988 100644 --- a/packages/eslint-config-airbnb/rules/best-practices.js +++ b/packages/eslint-config-airbnb/rules/best-practices.js @@ -32,7 +32,7 @@ module.exports = { // disallow else after a return in an if 'no-else-return': 2, // disallow use of labels for anything other then loops and switches - 'no-labels': [2, { 'allowLoop': true, 'allowSwitch': true }], + 'no-labels': [2, { 'allowLoop': false, 'allowSwitch': false }], // disallow comparisons to null without a type-checking operator 'no-eq-null': 0, // disallow use of eval() From 1cbc628c49fe8e9540028f8a560b43ebdd08c82b Mon Sep 17 00:00:00 2001 From: Harrison Shoff Date: Sat, 13 Feb 2016 13:57:38 -0800 Subject: [PATCH 10/32] [eslint-v2][constructors] disallow unnecessary constructors --- README.md | 24 ++++++++++++++++++++++ packages/eslint-config-airbnb/rules/es6.js | 3 +++ 2 files changed, 27 insertions(+) diff --git a/README.md b/README.md index 32c966ce98..952b135a24 100644 --- a/README.md +++ b/README.md @@ -883,6 +883,30 @@ Other Style Guides } ``` + - [9.5](#9.5) Classes have a default constructor if one is not specified. An empty constructor function or one that just delegates to a parent class is unnecessary. + + ```javascript + // bad + class Jedi { + constructor() {} + + getName() { + return this.name; + } + } + + // good + class Rey extends Jedi { + constructor(...args) { + super(...args); + } + + getName() { + return this.name; + } + } + ``` + **[⬆ back to top](#table-of-contents)** diff --git a/packages/eslint-config-airbnb/rules/es6.js b/packages/eslint-config-airbnb/rules/es6.js index 08b5889172..f55d6b9bac 100644 --- a/packages/eslint-config-airbnb/rules/es6.js +++ b/packages/eslint-config-airbnb/rules/es6.js @@ -34,6 +34,9 @@ module.exports = { 'no-this-before-super': 0, // require let or const instead of var 'no-var': 2, + // disallow unnecessary constructor + // http://eslint.org/docs/rules/no-useless-constructor + 'no-useless-constructor': 2, // require method and property shorthand syntax for object literals // https://github.com/eslint/eslint/blob/master/docs/rules/object-shorthand.md 'object-shorthand': [2, 'always'], From 91b83650b006764d1b235b79c265151c8b00ba19 Mon Sep 17 00:00:00 2001 From: Harrison Shoff Date: Sun, 14 Feb 2016 02:34:47 -0800 Subject: [PATCH 11/32] [eslint-v2][constructors] fix bad + good examples --- README.md | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 952b135a24..46e783580b 100644 --- a/README.md +++ b/README.md @@ -895,14 +895,17 @@ Other Style Guides } } - // good class Rey extends Jedi { constructor(...args) { super(...args); } + } - getName() { - return this.name; + // good + class Rey extends Jedi { + constructor(...args) { + super(...args); + this.name = 'Rey'; } } ``` From c05b2da9db51dc160b45c72faf317cb2f5604660 Mon Sep 17 00:00:00 2001 From: Harrison Shoff Date: Sun, 14 Feb 2016 02:50:51 -0800 Subject: [PATCH 12/32] [eslint-v2] add new rules, disabled: - `id-blacklist` - `no-extra-label` - `no-implicit-globals` - `no-restricted-imports` - `no-unmodified-loop-condition` - `no-unused-labels` - `sort-imports` - `yield-star-spacing` --- .../eslint-config-airbnb/rules/best-practices.js | 16 ++++++++++++++-- packages/eslint-config-airbnb/rules/es6.js | 11 ++++++++++- packages/eslint-config-airbnb/rules/variables.js | 3 +++ 3 files changed, 27 insertions(+), 3 deletions(-) diff --git a/packages/eslint-config-airbnb/rules/best-practices.js b/packages/eslint-config-airbnb/rules/best-practices.js index 00f7d2d988..845904206e 100644 --- a/packages/eslint-config-airbnb/rules/best-practices.js +++ b/packages/eslint-config-airbnb/rules/best-practices.js @@ -20,6 +20,9 @@ module.exports = { 'eqeqeq': 2, // make sure for-in loops have an if statement 'guard-for-in': 2, + // Blacklist certain identifiers to prevent them being used + // http://eslint.org/docs/rules/id-blacklist + 'id-blacklist': 0, // disallow the use of alert, confirm, and prompt 'no-alert': 1, // disallow use of arguments.caller or arguments.callee @@ -31,8 +34,9 @@ module.exports = { 'no-div-regex': 0, // disallow else after a return in an if 'no-else-return': 2, - // disallow use of labels for anything other then loops and switches - 'no-labels': [2, { 'allowLoop': false, 'allowSwitch': false }], + // disallow Unnecessary Labels + // http://eslint.org/docs/rules/no-extra-label + 'no-extra-label': 0, // disallow comparisons to null without a type-checking operator 'no-eq-null': 0, // disallow use of eval() @@ -53,6 +57,8 @@ module.exports = { 'no-invalid-this': 0, // disallow usage of __iterator__ property 'no-iterator': 2, + // disallow use of labels for anything other then loops and switches + 'no-labels': [2, { 'allowLoop': false, 'allowSwitch': false }], // disallow unnecessary nested blocks 'no-lone-blocks': 2, // disallow creation of functions within loops @@ -94,8 +100,14 @@ module.exports = { 'no-sequences': 2, // restrict what can be thrown as an exception 'no-throw-literal': 2, + // disallow unmodified conditions of loops + // http://eslint.org/docs/rules/no-unmodified-loop-condition + 'no-unmodified-loop-condition': 0, // disallow usage of expressions in statement position 'no-unused-expressions': 2, + // disallow unused labels + // http://eslint.org/docs/rules/no-unused-labels + 'no-unused-labels': 0, // disallow unnecessary .call() and .apply() 'no-useless-call': 0, // disallow use of void operator diff --git a/packages/eslint-config-airbnb/rules/es6.js b/packages/eslint-config-airbnb/rules/es6.js index f55d6b9bac..11e212b5eb 100644 --- a/packages/eslint-config-airbnb/rules/es6.js +++ b/packages/eslint-config-airbnb/rules/es6.js @@ -30,6 +30,9 @@ module.exports = { 'no-class-assign': 0, // disallow modifying variables that are declared using const 'no-const-assign': 2, + // disallow specific imports + // http://eslint.org/docs/rules/no-restricted-imports + 'no-restricted-imports': 0, // disallow to use this/super before super() calling in constructors. 'no-this-before-super': 0, // require let or const instead of var @@ -52,6 +55,12 @@ module.exports = { // http://eslint.org/docs/rules/prefer-template 'prefer-template': 2, // disallow generator functions that do not have yield - 'require-yield': 0 + 'require-yield': 0, + // import sorting + // http://eslint.org/docs/rules/sort-imports + 'sort-imports': 0, + // enforce spacing around the * in yield* expressions + // http://eslint.org/docs/rules/yield-star-spacing + 'yield-star-spacing': 0 } }; diff --git a/packages/eslint-config-airbnb/rules/variables.js b/packages/eslint-config-airbnb/rules/variables.js index 59914313f9..b9073f72c5 100644 --- a/packages/eslint-config-airbnb/rules/variables.js +++ b/packages/eslint-config-airbnb/rules/variables.js @@ -6,6 +6,9 @@ module.exports = { 'no-catch-shadow': 0, // disallow deletion of variables 'no-delete-var': 2, + // disallow var and named functions in global scope + // http://eslint.org/docs/rules/no-implicit-globals + 'no-implicit-globals': 0, // disallow labels that share a name with a variable 'no-label-var': 0, // disallow shadowing of names such as arguments From a126d0b85c8b2afcdd309c39f45c14815bb1ab23 Mon Sep 17 00:00:00 2001 From: Harrison Shoff Date: Sun, 14 Feb 2016 12:56:03 -0800 Subject: [PATCH 13/32] [eslint-v2] enforce yield-start-spacing, no-unused-labels, no-extra-label --- packages/eslint-config-airbnb/rules/best-practices.js | 4 ++-- packages/eslint-config-airbnb/rules/es6.js | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/eslint-config-airbnb/rules/best-practices.js b/packages/eslint-config-airbnb/rules/best-practices.js index 845904206e..5a50af000a 100644 --- a/packages/eslint-config-airbnb/rules/best-practices.js +++ b/packages/eslint-config-airbnb/rules/best-practices.js @@ -36,7 +36,7 @@ module.exports = { 'no-else-return': 2, // disallow Unnecessary Labels // http://eslint.org/docs/rules/no-extra-label - 'no-extra-label': 0, + 'no-extra-label': 2, // disallow comparisons to null without a type-checking operator 'no-eq-null': 0, // disallow use of eval() @@ -107,7 +107,7 @@ module.exports = { 'no-unused-expressions': 2, // disallow unused labels // http://eslint.org/docs/rules/no-unused-labels - 'no-unused-labels': 0, + 'no-unused-labels': 2, // disallow unnecessary .call() and .apply() 'no-useless-call': 0, // disallow use of void operator diff --git a/packages/eslint-config-airbnb/rules/es6.js b/packages/eslint-config-airbnb/rules/es6.js index 11e212b5eb..8ba6e5e3c9 100644 --- a/packages/eslint-config-airbnb/rules/es6.js +++ b/packages/eslint-config-airbnb/rules/es6.js @@ -61,6 +61,6 @@ module.exports = { 'sort-imports': 0, // enforce spacing around the * in yield* expressions // http://eslint.org/docs/rules/yield-star-spacing - 'yield-star-spacing': 0 + 'yield-star-spacing': [2, 'after'] } }; From fbd9c35dd37c2466b809a89c79703583de77d275 Mon Sep 17 00:00:00 2001 From: Harrison Shoff Date: Sun, 14 Feb 2016 11:14:38 -0800 Subject: [PATCH 14/32] [eslint-v2][arrays] add array-callback-return rule --- README.md | 45 +++++++++++++++++++ .../rules/best-practices.js | 3 ++ 2 files changed, 48 insertions(+) diff --git a/README.md b/README.md index 46e783580b..b52dbdcc23 100644 --- a/README.md +++ b/README.md @@ -346,6 +346,51 @@ Other Style Guides const nodes = Array.from(foo); ``` + - [4.5](#4.5) Use return statements in array method callbacks. It's ok to omit the return if the function body consists of a single statement following [8.2](#8.2). eslint: [array-callback-return](http://eslint.org/docs/rules/array-callback-return) + + ```javascript + // good + [1, 2, 3].map((x) => { + const y = x + 1; + return x * y; + }); + + // good + [1, 2, 3].map(x => x + 1); + + // bad + const flat = {}; + [[0, 1], [2, 3], [4, 5]].reduce((memo, item, index) => { + const flatten = memo.concat(item); + flat[index] = memo.concat(item); + }); + + // good + const flat = {}; + [[0, 1], [2, 3], [4, 5]].reduce((memo, item, index) => { + const flatten = memo.concat(item); + flat[index] = flatten; + return flatten; + }); + + // bad + [1, 2, 3].filter((x) => { + if (x > 2) { + return true; + } else { + return false; + } + }); + + // good + [1, 2, 3].filter((x) => { + if (x > 2) { + return true; + } + return false; + }); + ``` + **[⬆ back to top](#table-of-contents)** ## Destructuring diff --git a/packages/eslint-config-airbnb/rules/best-practices.js b/packages/eslint-config-airbnb/rules/best-practices.js index 5a50af000a..6f66792478 100644 --- a/packages/eslint-config-airbnb/rules/best-practices.js +++ b/packages/eslint-config-airbnb/rules/best-practices.js @@ -2,6 +2,9 @@ module.exports = { 'rules': { // enforces getter/setter pairs in objects 'accessor-pairs': 0, + // enforces return statements in callbacks of array's methods + // http://eslint.org/docs/rules/array-callback-return + 'array-callback-return': 2, // treat var statements as if they were block scoped 'block-scoped-var': 2, // specify the maximum cyclomatic complexity allowed in a program From 172dffbb52ae6b61fe41c9a4c14d4be68070111f Mon Sep 17 00:00:00 2001 From: Harrison Shoff Date: Sun, 14 Feb 2016 11:48:04 -0800 Subject: [PATCH 15/32] [eslint-v2][whitespace] add newline-per-chained-call rule --- README.md | 8 ++++++-- packages/eslint-config-airbnb/rules/style.js | 3 +++ 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index b52dbdcc23..7290e0aca3 100644 --- a/README.md +++ b/README.md @@ -387,6 +387,7 @@ Other Style Guides if (x > 2) { return true; } + return false; }); ``` @@ -1664,8 +1665,8 @@ Other Style Guides })(this);↵ ``` - - [18.6](#18.6) Use indentation when making long method chains. Use a leading dot, which - emphasizes that the line is a method call, not a new statement. + - [18.6](#18.6) Use indentation when making long method chains (more than 2 method chains). Use a leading dot, which + emphasizes that the line is a method call, not a new statement. eslint: [newline-per-chained-call](http://eslint.org/docs/rules/newline-per-chained-call) ```javascript // bad @@ -1702,6 +1703,9 @@ Other Style Guides .append('svg:g') .attr('transform', 'translate(' + (radius + margin) + ',' + (radius + margin) + ')') .call(tron.led); + + // good + const leds = stage.selectAll('.led').data(data); ``` - [18.7](#18.7) Leave a blank line after blocks and before the next statement. jscs: [`requirePaddingNewLinesAfterBlocks`](http://jscs.info/rule/requirePaddingNewLinesAfterBlocks) diff --git a/packages/eslint-config-airbnb/rules/style.js b/packages/eslint-config-airbnb/rules/style.js index 0e8036ec51..4e8710c347 100644 --- a/packages/eslint-config-airbnb/rules/style.js +++ b/packages/eslint-config-airbnb/rules/style.js @@ -59,6 +59,9 @@ module.exports = { 'new-parens': 0, // allow/disallow an empty newline after var statement 'newline-after-var': 0, + // enforces new line after each method call in the chain to make it more readable and easy to maintain + // http://eslint.org/docs/rules/newline-per-chained-call + 'newline-per-chained-call': [2, { "ignoreChainWithDepth": 3 }], // disallow use of the Array constructor 'no-array-constructor': 0, // disallow use of the continue statement From 6a03a32915533eb09151c754333ccf0f724d05ad Mon Sep 17 00:00:00 2001 From: Harrison Shoff Date: Sun, 14 Feb 2016 14:47:23 -0800 Subject: [PATCH 16/32] [eslint-v2][arrow functions] add no-confusing-arrow rule --- README.md | 13 +++++++++++++ packages/eslint-config-airbnb/rules/es6.js | 3 +++ 2 files changed, 16 insertions(+) diff --git a/README.md b/README.md index 7290e0aca3..e5ed8a3754 100644 --- a/README.md +++ b/README.md @@ -817,6 +817,19 @@ Other Style Guides }); ``` + - [8.5](#8.5) Avoid confusing arrow function syntax (`=>`) with comparison operators (`<=`, `>=`). eslint: [no-confusing-arrow](http://eslint.org/docs/rules/no-confusing-arrow) + + ```js + // bad + const isActive = item => item.height > 256 ? true : false; + + // bad + const isActive = (item) => item.height > 256 ? true : false; + + // good + const isActive = item => { return item.height > 256 ? true : false; } + ``` + **[⬆ back to top](#table-of-contents)** diff --git a/packages/eslint-config-airbnb/rules/es6.js b/packages/eslint-config-airbnb/rules/es6.js index 8ba6e5e3c9..88fbf2eb89 100644 --- a/packages/eslint-config-airbnb/rules/es6.js +++ b/packages/eslint-config-airbnb/rules/es6.js @@ -28,6 +28,9 @@ module.exports = { 'generator-star-spacing': 0, // disallow modifying variables of class declarations 'no-class-assign': 0, + // disallow arrow functions where they could be confused with comparisons + // http://eslint.org/docs/rules/no-confusing-arrow + 'no-confusing-arrow': 2, // disallow modifying variables that are declared using const 'no-const-assign': 2, // disallow specific imports From ba10353e9b34f44afbd8b4a2ecdff923356a2ae7 Mon Sep 17 00:00:00 2001 From: Harrison Shoff Date: Sun, 14 Feb 2016 14:50:49 -0800 Subject: [PATCH 17/32] [eslint-v2][arrow functions] improve examples --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index e5ed8a3754..e2b48378ae 100644 --- a/README.md +++ b/README.md @@ -821,13 +821,13 @@ Other Style Guides ```js // bad - const isActive = item => item.height > 256 ? true : false; + const itemHeight = item => item.height > 256 ? item.largeSize : item.smallSize; // bad - const isActive = (item) => item.height > 256 ? true : false; + const itemHeight = (item) => item.height > 256 ? item.largeSize : item.smallSize; // good - const isActive = item => { return item.height > 256 ? true : false; } + const itemHeight = item => { return item.height > 256 ? item.largeSize : item.smallSize; } ``` **[⬆ back to top](#table-of-contents)** From 3762c9add826e47587242460db331d8203cea069 Mon Sep 17 00:00:00 2001 From: Harrison Shoff Date: Sun, 14 Feb 2016 14:58:28 -0800 Subject: [PATCH 18/32] [eslint-v2] add no-new-symbol rule --- packages/eslint-config-airbnb/rules/es6.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/packages/eslint-config-airbnb/rules/es6.js b/packages/eslint-config-airbnb/rules/es6.js index 88fbf2eb89..be2ebe5c7c 100644 --- a/packages/eslint-config-airbnb/rules/es6.js +++ b/packages/eslint-config-airbnb/rules/es6.js @@ -33,6 +33,9 @@ module.exports = { 'no-confusing-arrow': 2, // disallow modifying variables that are declared using const 'no-const-assign': 2, + // disallow symbol constructor + // http://eslint.org/docs/rules/no-new-symbol + 'no-new-symbol': 2, // disallow specific imports // http://eslint.org/docs/rules/no-restricted-imports 'no-restricted-imports': 0, From 92df6357b3ed3326eaca33454b112d06dbd76f0e Mon Sep 17 00:00:00 2001 From: Harrison Shoff Date: Sun, 14 Feb 2016 18:30:28 -0800 Subject: [PATCH 19/32] [eslint-v2][variables] add no-self-assign --- packages/eslint-config-airbnb/rules/variables.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/packages/eslint-config-airbnb/rules/variables.js b/packages/eslint-config-airbnb/rules/variables.js index b9073f72c5..3bfcc83fde 100644 --- a/packages/eslint-config-airbnb/rules/variables.js +++ b/packages/eslint-config-airbnb/rules/variables.js @@ -11,6 +11,9 @@ module.exports = { 'no-implicit-globals': 0, // disallow labels that share a name with a variable 'no-label-var': 0, + // disallow self assignment + // http://eslint.org/docs/rules/no-self-assign + 'no-self-assign': 2, // disallow shadowing of names such as arguments 'no-shadow-restricted-names': 2, // disallow declaration of variables already declared in the outer scope From e6cbcf4cc56b04edbb22eef2856fce78bf4625b1 Mon Sep 17 00:00:00 2001 From: Harrison Shoff Date: Sun, 14 Feb 2016 18:35:23 -0800 Subject: [PATCH 20/32] [eslint-v2][whitespace] add no-whitespace-before-property rule --- README.md | 2 +- packages/eslint-config-airbnb/rules/style.js | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index e2b48378ae..99f9b3dff7 100644 --- a/README.md +++ b/README.md @@ -1679,7 +1679,7 @@ Other Style Guides ``` - [18.6](#18.6) Use indentation when making long method chains (more than 2 method chains). Use a leading dot, which - emphasizes that the line is a method call, not a new statement. eslint: [newline-per-chained-call](http://eslint.org/docs/rules/newline-per-chained-call) + emphasizes that the line is a method call, not a new statement. eslint: [newline-per-chained-call](http://eslint.org/docs/rules/newline-per-chained-call) [no-whitespace-before-property](http://eslint.org/docs/rules/no-whitespace-before-property) ```javascript // bad diff --git a/packages/eslint-config-airbnb/rules/style.js b/packages/eslint-config-airbnb/rules/style.js index 4e8710c347..85c1fd706d 100644 --- a/packages/eslint-config-airbnb/rules/style.js +++ b/packages/eslint-config-airbnb/rules/style.js @@ -90,6 +90,9 @@ module.exports = { // also, prefer `a || b` over `a ? a : b` // http://eslint.org/docs/rules/no-unneeded-ternary 'no-unneeded-ternary': [2, { 'defaultAssignment': false }], + // disallow whitespace before properties + // http://eslint.org/docs/rules/no-whitespace-before-property + 'no-whitespace-before-property': 2, // require padding inside curly braces 'object-curly-spacing': [2, 'always'], // allow just one var statement per function From c5b4f05879be4cd48c1737ad9bfdb00ed8a87ee0 Mon Sep 17 00:00:00 2001 From: Harrison Shoff Date: Sun, 14 Feb 2016 18:39:32 -0800 Subject: [PATCH 21/32] [eslint-v2] add one-var-declaration-per-line --- packages/eslint-config-airbnb/rules/style.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/packages/eslint-config-airbnb/rules/style.js b/packages/eslint-config-airbnb/rules/style.js index 85c1fd706d..a5d9e094de 100644 --- a/packages/eslint-config-airbnb/rules/style.js +++ b/packages/eslint-config-airbnb/rules/style.js @@ -97,6 +97,9 @@ module.exports = { 'object-curly-spacing': [2, 'always'], // allow just one var statement per function 'one-var': [2, 'never'], + // require a newline around variable declaration + // http://eslint.org/docs/rules/one-var-declaration-per-line + 'one-var-declaration-per-line': [2, 'always'], // require assignment operator shorthand where possible or prohibit it entirely 'operator-assignment': 0, // enforce operators to be placed before or after line breaks From e1a087fbb1eeb861acce7bab67476ccd4dd080e0 Mon Sep 17 00:00:00 2001 From: Harrison Shoff Date: Sun, 14 Feb 2016 18:45:44 -0800 Subject: [PATCH 22/32] [eslint-v2] add prefer-rest-params --- README.md | 2 +- packages/eslint-config-airbnb/rules/es6.js | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 99f9b3dff7..795608e126 100644 --- a/README.md +++ b/README.md @@ -581,7 +581,7 @@ Other Style Guides ``` - - [7.6](#7.6) Never use `arguments`, opt to use rest syntax `...` instead. + - [7.6](#7.6) Never use `arguments`, opt to use rest syntax `...` instead. [prefer-rest-params](http://eslint.org/docs/rules/prefer-rest-params) > Why? `...` is explicit about which arguments you want pulled. Plus rest arguments are a real Array and not Array-like like `arguments`. diff --git a/packages/eslint-config-airbnb/rules/es6.js b/packages/eslint-config-airbnb/rules/es6.js index be2ebe5c7c..ae835a6ab9 100644 --- a/packages/eslint-config-airbnb/rules/es6.js +++ b/packages/eslint-config-airbnb/rules/es6.js @@ -57,6 +57,9 @@ module.exports = { 'prefer-spread': 0, // suggest using Reflect methods where applicable 'prefer-reflect': 0, + // use rest parameters instead of arguments + // http://eslint.org/docs/rules/prefer-rest-params + 'prefer-rest-params': 2, // suggest using template literals instead of string concatenation // http://eslint.org/docs/rules/prefer-template 'prefer-template': 2, From 1f12a12be474bc9f61b2b1556549e865f3be114c Mon Sep 17 00:00:00 2001 From: Harrison Shoff Date: Sun, 14 Feb 2016 18:48:31 -0800 Subject: [PATCH 23/32] [eslint-v2] fix empty constructor example --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 795608e126..909954c934 100644 --- a/README.md +++ b/README.md @@ -956,14 +956,14 @@ Other Style Guides class Rey extends Jedi { constructor(...args) { - super(...args); + super(args); } } // good class Rey extends Jedi { constructor(...args) { - super(...args); + super(args); this.name = 'Rey'; } } From 65609373bfe33e5d86b2ac04ff2fd7f0aaa6a8a2 Mon Sep 17 00:00:00 2001 From: Harrison Shoff Date: Sun, 14 Feb 2016 18:56:49 -0800 Subject: [PATCH 24/32] [eslint-v2][template strings] add template-curly-spacing rule, fix #716 --- README.md | 7 ++++++- packages/eslint-config-airbnb/rules/es6.js | 3 +++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 909954c934..d9bab06129 100644 --- a/README.md +++ b/README.md @@ -493,7 +493,7 @@ Other Style Guides ``` - - [6.4](#6.4) When programmatically building up strings, use template strings instead of concatenation. eslint: [`prefer-template`](http://eslint.org/docs/rules/prefer-template.html) jscs: [`requireTemplateStrings`](http://jscs.info/rule/requireTemplateStrings) + - [6.4](#6.4) When programmatically building up strings, use template strings instead of concatenation. eslint: [`prefer-template`](http://eslint.org/docs/rules/prefer-template.html) [`template-curly-spacing`](http://eslint.org/docs/rules/template-curly-spacing) jscs: [`requireTemplateStrings`](http://jscs.info/rule/requireTemplateStrings) > Why? Template strings give you a readable, concise syntax with proper newlines and string interpolation features. @@ -508,6 +508,11 @@ Other Style Guides return ['How are you, ', name, '?'].join(); } + // bad + function sayHi(name) { + return `How are you, ${ name }?`; + } + // good function sayHi(name) { return `How are you, ${name}?`; diff --git a/packages/eslint-config-airbnb/rules/es6.js b/packages/eslint-config-airbnb/rules/es6.js index ae835a6ab9..e88b2d5059 100644 --- a/packages/eslint-config-airbnb/rules/es6.js +++ b/packages/eslint-config-airbnb/rules/es6.js @@ -68,6 +68,9 @@ module.exports = { // import sorting // http://eslint.org/docs/rules/sort-imports 'sort-imports': 0, + // enforce usage of spacing in template strings + // http://eslint.org/docs/rules/template-curly-spacing + 'template-curly-spacing': 2, // enforce spacing around the * in yield* expressions // http://eslint.org/docs/rules/yield-star-spacing 'yield-star-spacing': [2, 'after'] From e0959d0f1d35105a9db8d972e0f844daf0dfa072 Mon Sep 17 00:00:00 2001 From: Harrison Shoff Date: Sun, 14 Feb 2016 19:04:12 -0800 Subject: [PATCH 25/32] [eslint-v2] fix rule links in readme --- README.md | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index d9bab06129..e423c59499 100644 --- a/README.md +++ b/README.md @@ -346,7 +346,7 @@ Other Style Guides const nodes = Array.from(foo); ``` - - [4.5](#4.5) Use return statements in array method callbacks. It's ok to omit the return if the function body consists of a single statement following [8.2](#8.2). eslint: [array-callback-return](http://eslint.org/docs/rules/array-callback-return) + - [4.5](#4.5) Use return statements in array method callbacks. It's ok to omit the return if the function body consists of a single statement following [8.2](#8.2). eslint: [`array-callback-return`](http://eslint.org/docs/rules/array-callback-return) ```javascript // good @@ -586,7 +586,7 @@ Other Style Guides ``` - - [7.6](#7.6) Never use `arguments`, opt to use rest syntax `...` instead. [prefer-rest-params](http://eslint.org/docs/rules/prefer-rest-params) + - [7.6](#7.6) Never use `arguments`, opt to use rest syntax `...` instead. [`prefer-rest-params`](http://eslint.org/docs/rules/prefer-rest-params) > Why? `...` is explicit about which arguments you want pulled. Plus rest arguments are a real Array and not Array-like like `arguments`. @@ -822,7 +822,7 @@ Other Style Guides }); ``` - - [8.5](#8.5) Avoid confusing arrow function syntax (`=>`) with comparison operators (`<=`, `>=`). eslint: [no-confusing-arrow](http://eslint.org/docs/rules/no-confusing-arrow) + - [8.5](#8.5) Avoid confusing arrow function syntax (`=>`) with comparison operators (`<=`, `>=`). eslint: [`no-confusing-arrow`](http://eslint.org/docs/rules/no-confusing-arrow) ```js // bad @@ -947,7 +947,7 @@ Other Style Guides } ``` - - [9.5](#9.5) Classes have a default constructor if one is not specified. An empty constructor function or one that just delegates to a parent class is unnecessary. + - [9.5](#9.5) Classes have a default constructor if one is not specified. An empty constructor function or one that just delegates to a parent class is unnecessary. [`no-useless-constructor`](http://eslint.org/docs/rules/no-useless-constructor) ```javascript // bad @@ -959,6 +959,7 @@ Other Style Guides } } + // bad class Rey extends Jedi { constructor(...args) { super(args); @@ -1684,7 +1685,7 @@ Other Style Guides ``` - [18.6](#18.6) Use indentation when making long method chains (more than 2 method chains). Use a leading dot, which - emphasizes that the line is a method call, not a new statement. eslint: [newline-per-chained-call](http://eslint.org/docs/rules/newline-per-chained-call) [no-whitespace-before-property](http://eslint.org/docs/rules/no-whitespace-before-property) + emphasizes that the line is a method call, not a new statement. eslint: [`newline-per-chained-call`](http://eslint.org/docs/rules/newline-per-chained-call) [`no-whitespace-before-property`](http://eslint.org/docs/rules/no-whitespace-before-property) ```javascript // bad From ff0adbe2918dbc5b26814f61853227318d787965 Mon Sep 17 00:00:00 2001 From: Harrison Shoff Date: Sat, 20 Feb 2016 12:59:00 -0800 Subject: [PATCH 26/32] [eslint-v2][react] acceptTranspilerName => ignoreTranspilerName --- packages/eslint-config-airbnb/rules/react.js | 5 ++++- packages/eslint-config-airbnb/rules/style.js | 5 +++-- packages/eslint-config-airbnb/test/test-react-order.js | 3 ++- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/packages/eslint-config-airbnb/rules/react.js b/packages/eslint-config-airbnb/rules/react.js index e1e1c25993..2b59ca200e 100644 --- a/packages/eslint-config-airbnb/rules/react.js +++ b/packages/eslint-config-airbnb/rules/react.js @@ -10,7 +10,7 @@ module.exports = { 'rules': { // Prevent missing displayName in a React component definition // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/display-name.md - 'react/display-name': [0, { 'acceptTranspilerName': false }], + 'react/display-name': [0, { 'ignoreTranspilerName': true }], // Forbid certain propTypes (any, array, object) // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/forbid-prop-types.md 'react/forbid-prop-types': [0, { 'forbid': ['any', 'array', 'object'] }], @@ -116,6 +116,9 @@ module.exports = { // Prevent extra closing tags for components without children // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/self-closing-comp.md 'react/self-closing-comp': 2, + // Enforce spaces before the closing bracket of self-closing JSX elements + // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-space-before-closing.md + 'react/jsx-space-before-closing': [2, 'always'], // Enforce component methods order // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/sort-comp.md 'react/sort-comp': [2, { diff --git a/packages/eslint-config-airbnb/rules/style.js b/packages/eslint-config-airbnb/rules/style.js index a5d9e094de..c147aae8b7 100644 --- a/packages/eslint-config-airbnb/rules/style.js +++ b/packages/eslint-config-airbnb/rules/style.js @@ -59,9 +59,10 @@ module.exports = { 'new-parens': 0, // allow/disallow an empty newline after var statement 'newline-after-var': 0, - // enforces new line after each method call in the chain to make it more readable and easy to maintain + // enforces new line after each method call in the chain to make it + // more readable and easy to maintain // http://eslint.org/docs/rules/newline-per-chained-call - 'newline-per-chained-call': [2, { "ignoreChainWithDepth": 3 }], + 'newline-per-chained-call': [2, { 'ignoreChainWithDepth': 3 }], // disallow use of the Array constructor 'no-array-constructor': 0, // disallow use of the continue statement diff --git a/packages/eslint-config-airbnb/test/test-react-order.js b/packages/eslint-config-airbnb/test/test-react-order.js index 77448cf86a..f5b2d452fe 100644 --- a/packages/eslint-config-airbnb/test/test-react-order.js +++ b/packages/eslint-config-airbnb/test/test-react-order.js @@ -14,7 +14,8 @@ const cli = new CLIEngine({ function lint(text) { // @see http://eslint.org/docs/developer-guide/nodejs-api.html#executeonfiles // @see http://eslint.org/docs/developer-guide/nodejs-api.html#executeontext - return cli.executeOnText(text).results[0]; + const linter = cli.executeOnText(text); + return linter.results[0]; } function wrapComponent(body) { From 133fc51e21321c3eba0cda5f6fa008ff55940d8c Mon Sep 17 00:00:00 2001 From: Harrison Shoff Date: Sat, 20 Feb 2016 13:02:15 -0800 Subject: [PATCH 27/32] [eslint-v2][react] add static-methods to top of sort-comp order --- packages/eslint-config-airbnb/rules/react.js | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/eslint-config-airbnb/rules/react.js b/packages/eslint-config-airbnb/rules/react.js index 2b59ca200e..a9facdd732 100644 --- a/packages/eslint-config-airbnb/rules/react.js +++ b/packages/eslint-config-airbnb/rules/react.js @@ -123,6 +123,7 @@ module.exports = { // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/sort-comp.md 'react/sort-comp': [2, { 'order': [ + 'static-methods', 'lifecycle', '/^on.+$/', '/^(get|set)(?!(InitialState$|DefaultProps$|ChildContext$)).+$/', From 07948531dccc62d21f190ed4a2edc035642da01a Mon Sep 17 00:00:00 2001 From: Harrison Shoff Date: Sat, 20 Feb 2016 13:05:49 -0800 Subject: [PATCH 28/32] [eslint-v2][react] set ignoreTranspilerName to false --- packages/eslint-config-airbnb/rules/react.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/eslint-config-airbnb/rules/react.js b/packages/eslint-config-airbnb/rules/react.js index a9facdd732..99e4c02010 100644 --- a/packages/eslint-config-airbnb/rules/react.js +++ b/packages/eslint-config-airbnb/rules/react.js @@ -10,7 +10,7 @@ module.exports = { 'rules': { // Prevent missing displayName in a React component definition // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/display-name.md - 'react/display-name': [0, { 'ignoreTranspilerName': true }], + 'react/display-name': [0, { 'ignoreTranspilerName': false }], // Forbid certain propTypes (any, array, object) // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/forbid-prop-types.md 'react/forbid-prop-types': [0, { 'forbid': ['any', 'array', 'object'] }], From 822c0dfdfe16ead8d4e3da8c35c007901e94f4eb Mon Sep 17 00:00:00 2001 From: Harrison Shoff Date: Sat, 20 Feb 2016 13:10:42 -0800 Subject: [PATCH 29/32] [eslint-v2][react] jsx-sort-prop-types => sort-prop-types --- packages/eslint-config-airbnb/rules/react.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/eslint-config-airbnb/rules/react.js b/packages/eslint-config-airbnb/rules/react.js index 99e4c02010..b7a9889e69 100644 --- a/packages/eslint-config-airbnb/rules/react.js +++ b/packages/eslint-config-airbnb/rules/react.js @@ -54,8 +54,8 @@ module.exports = { // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-pascal-case.md 'react/jsx-pascal-case': 0, // Enforce propTypes declarations alphabetical sorting - // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-sort-prop-types.md - 'react/jsx-sort-prop-types': [0, { + // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/sort-prop-types.md + 'react/sort-prop-types': [0, { 'ignoreCase': false, 'callbacksLast': false, }], From b79e9512801f798698f15baaaec92c328c0af6c0 Mon Sep 17 00:00:00 2001 From: Harrison Shoff Date: Sat, 20 Feb 2016 23:33:39 -0800 Subject: [PATCH 30/32] [eslint-v2][arrays] update array-callback-return good/bad ex --- README.md | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index e423c59499..e89fc1cd6a 100644 --- a/README.md +++ b/README.md @@ -374,9 +374,10 @@ Other Style Guides }); // bad - [1, 2, 3].filter((x) => { - if (x > 2) { - return true; + inbox].filter((msg) => { + const { subject, author } = msg; + if (subject === 'Mockingbird') { + return author === 'Harper Lee'; } else { return false; } @@ -384,12 +385,14 @@ Other Style Guides // good [1, 2, 3].filter((x) => { - if (x > 2) { - return true; - } + inbox].filter((msg) => { + const { subject, author } = msg; + if (subject === 'Mockingbird') { + return author === 'Harper Lee'; + } - return false; - }); + return false; + }); ``` **[⬆ back to top](#table-of-contents)** From 3983d380edd22fe7546f9fef2d04fc69a5db04f7 Mon Sep 17 00:00:00 2001 From: Harrison Shoff Date: Sat, 20 Feb 2016 23:39:29 -0800 Subject: [PATCH 31/32] [eslint-v2][arrays] fix example --- README.md | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index e89fc1cd6a..e10cca35ea 100644 --- a/README.md +++ b/README.md @@ -374,7 +374,7 @@ Other Style Guides }); // bad - inbox].filter((msg) => { + inbox.filter((msg) => { const { subject, author } = msg; if (subject === 'Mockingbird') { return author === 'Harper Lee'; @@ -384,15 +384,14 @@ Other Style Guides }); // good - [1, 2, 3].filter((x) => { - inbox].filter((msg) => { - const { subject, author } = msg; - if (subject === 'Mockingbird') { - return author === 'Harper Lee'; - } + inbox.filter((msg) => { + const { subject, author } = msg; + if (subject === 'Mockingbird') { + return author === 'Harper Lee'; + } - return false; - }); + return false; + }); ``` **[⬆ back to top](#table-of-contents)** From 0f32b96c125784e0db507682d3fb2fe05098e903 Mon Sep 17 00:00:00 2001 From: Harrison Shoff Date: Sat, 20 Feb 2016 13:24:55 -0800 Subject: [PATCH 32/32] [changelog] update changelog for 6.0.0 --- packages/eslint-config-airbnb/CHANGELOG.md | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/packages/eslint-config-airbnb/CHANGELOG.md b/packages/eslint-config-airbnb/CHANGELOG.md index 7c47c680f5..fcb16ec26c 100644 --- a/packages/eslint-config-airbnb/CHANGELOG.md +++ b/packages/eslint-config-airbnb/CHANGELOG.md @@ -1,3 +1,21 @@ +6.0.0 / 2016-02-21 +================== +- [breaking] enable `array-callback-return` +- [breaking] enable `no-confusing-arrow` +- [breaking] enable `no-new-symbol` +- [breaking] enable `no-restricted-imports` +- [breaking] enable `no-useless-constructor` +- [breaking] enable `prefer-rest-params` +- [breaking] enable `template-curly-spaces` +- [breaking] enable `newline-per-chained-call` +- [breaking] enable `one-var-declaration-per-line` +- [breaking] enable `no-self-assign` +- [breaking] enable `no-whitespace-before-property` +- [breaking] [react] enable `react/jsx-space-before-closing` +- [breaking] [react] enable `static-methods` at top of `react/sort-comp` +- [breaking] [react] don't `ignoreTranspilerName` for `react/display-name` +- [peer+dev deps] update `eslint`, `eslint-plugin-react` + 5.0.1 / 2016-02-13 ================== - [fix] `eslint` peerDep should not include breaking changes