From 5fd7c6f08c0650ed67297fc83c8a0590c9a92cc8 Mon Sep 17 00:00:00 2001 From: Estelle Date: Mon, 23 Mar 2015 18:48:19 -0700 Subject: [PATCH 001/554] added naming convention of UPPERCASE names --- README.md | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/README.md b/README.md index 2c6c5c6c7d..1116dcb4ba 100644 --- a/README.md +++ b/README.md @@ -3139,6 +3139,33 @@ Other Style Guides ]; ``` + + - [23.10](#naming--uppercase) Use UPPERCASE for nested object namespacing, global variables, and constants. + + + ```javascript + // bad + const namespace = namespace || {}; + + namespace.util.Widget = { + // ...stuff... + } + + // bad + const apiKey = '44b345234534t455245njkl523452-vbb9'; + + // good + const NAMESPACE = NAMESPACE || {}; + + NAMESPACE.util.Widget = { + // ...stuff... + } + + // good + const API_KEY = '44b345234534t455245njkl523452-vbb9'; + ``` + + **[⬆ back to top](#table-of-contents)** ## Accessors From 5dec8272e03ce792f3c1a5dc8cf94042609e0615 Mon Sep 17 00:00:00 2001 From: koooge Date: Thu, 3 Aug 2017 17:57:58 +0200 Subject: [PATCH 002/554] [eslint config] [base] [breaking] move `comma-dangle` to Stylistic Issues --- packages/eslint-config-airbnb-base/rules/errors.js | 9 --------- packages/eslint-config-airbnb-base/rules/style.js | 9 +++++++++ 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/packages/eslint-config-airbnb-base/rules/errors.js b/packages/eslint-config-airbnb-base/rules/errors.js index 02befbb5af..786b88ae1e 100644 --- a/packages/eslint-config-airbnb-base/rules/errors.js +++ b/packages/eslint-config-airbnb-base/rules/errors.js @@ -1,14 +1,5 @@ module.exports = { rules: { - // require trailing commas in multiline object literals - 'comma-dangle': ['error', { - arrays: 'always-multiline', - objects: 'always-multiline', - imports: 'always-multiline', - exports: 'always-multiline', - functions: 'always-multiline', - }], - // Enforce “for” loop update clause moving the counter in the right direction // http://eslint.org/docs/rules/for-direction // TODO: enable, semver-major until v3 is dropped; semver-minor otherwise diff --git a/packages/eslint-config-airbnb-base/rules/style.js b/packages/eslint-config-airbnb-base/rules/style.js index 42e820870e..82ef7018c2 100644 --- a/packages/eslint-config-airbnb-base/rules/style.js +++ b/packages/eslint-config-airbnb-base/rules/style.js @@ -38,6 +38,15 @@ module.exports = { }, }], + // require trailing commas in multiline object literals + 'comma-dangle': ['error', { + arrays: 'always-multiline', + objects: 'always-multiline', + imports: 'always-multiline', + exports: 'always-multiline', + functions: 'always-multiline', + }], + // enforce spacing before and after comma 'comma-spacing': ['error', { before: false, after: true }], From f5cd2869d35268cc158409195b561b28feca5d94 Mon Sep 17 00:00:00 2001 From: David Walsh Date: Tue, 4 Jul 2017 12:40:53 +1000 Subject: [PATCH 003/554] [guide] [eslint config] [base] [breaking] Rules prohibiting global isNaN, isFinite. - Update README with new Standard Library section. --- README.md | 45 ++++++++++++++++++- .../rules/best-practices.js | 24 ++++++++++ .../rules/variables.js | 3 +- 3 files changed, 68 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index b9887ff20a..4125081c2f 100644 --- a/README.md +++ b/README.md @@ -44,6 +44,7 @@ Other Style Guides 1. [jQuery](#jquery) 1. [ECMAScript 5 Compatibility](#ecmascript-5-compatibility) 1. [ECMAScript 6+ (ES 2015+) Styles](#ecmascript-6-es-2015-styles) + 1. [Standard Library](#standard-library) 1. [Testing](#testing) 1. [Performance](#performance) 1. [Resources](#resources) @@ -3148,10 +3149,50 @@ Other Style Guides **[⬆ back to top](#table-of-contents)** +## Standard Library + + The [Standard Library](https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects) + contains utilities that are functionally broken but remain for legacy reasons. + + + - [29.1](#standard-library--isnan) Use `Number.isNaN` instead of global `isNaN`. + eslint: [`no-restricted-globals`](http://eslint.org/docs/rules/no-restricted-globals) + + > Why? The global `isNaN` coerces non-numbers to numbers, returning true for anything that coerces to NaN. + If this behavior is desired, make it explicit. + + ```javascript + // bad + isNaN('1.2'); // false + isNaN('1.2.3'); // true + + // good + Number.isNaN('1.2.3'); // false + Number.isNaN(Number('1.2.3')); // true + ``` + + + - [29.2](#standard-library--isfinite) Use `Number.isFinite` instead of global `isFinite`. + eslint: [`no-restricted-globals`](http://eslint.org/docs/rules/no-restricted-globals) + + > Why? The global `isFinite` coerces non-numbers to numbers, returning true for anything that coerces to a finite number. + If this behavior is desired, make it explicit. + + ```javascript + // bad + isFinite('2e3'); // true + + // good + Number.isFinite('2e3'); // false + Number.isFinite(parseInt('2e3', 10)); // true + ``` + +**[⬆ back to top](#table-of-contents)** + ## Testing - - [29.1](#testing--yup) **Yup.** + - [30.1](#testing--yup) **Yup.** ```javascript function foo() { @@ -3160,7 +3201,7 @@ Other Style Guides ``` - - [29.2](#testing--for-real) **No, but seriously**: + - [30.2](#testing--for-real) **No, but seriously**: - Whichever testing framework you use, you should be writing tests! - Strive to write many small pure functions, and minimize where mutations occur. - Be cautious about stubs and mocks - they can make your tests more brittle. diff --git a/packages/eslint-config-airbnb-base/rules/best-practices.js b/packages/eslint-config-airbnb-base/rules/best-practices.js index 02ea3e23b3..11b18a2efd 100644 --- a/packages/eslint-config-airbnb-base/rules/best-practices.js +++ b/packages/eslint-config-airbnb-base/rules/best-practices.js @@ -194,6 +194,30 @@ module.exports = { object: 'arguments', property: 'callee', message: 'arguments.callee is deprecated', + }, { + object: 'global', + property: 'isFinite', + message: 'Please use Number.isFinite instead', + }, { + object: 'self', + property: 'isFinite', + message: 'Please use Number.isFinite instead', + }, { + object: 'window', + property: 'isFinite', + message: 'Please use Number.isFinite instead', + }, { + object: 'global', + property: 'isNaN', + message: 'Please use Number.isNaN instead', + }, { + object: 'self', + property: 'isNaN', + message: 'Please use Number.isNaN instead', + }, { + object: 'window', + property: 'isNaN', + message: 'Please use Number.isNaN instead', }, { property: '__defineGetter__', message: 'Please use Object.defineProperty instead.', diff --git a/packages/eslint-config-airbnb-base/rules/variables.js b/packages/eslint-config-airbnb-base/rules/variables.js index fe38ea5d60..805563a51a 100644 --- a/packages/eslint-config-airbnb-base/rules/variables.js +++ b/packages/eslint-config-airbnb-base/rules/variables.js @@ -16,8 +16,7 @@ module.exports = { 'no-label-var': 'error', // disallow specific globals - // TODO: enable, semver-major - 'no-restricted-globals': ['off'].concat(restrictedGlobals), + 'no-restricted-globals': ['error', 'isFinite', 'isNaN'].concat(restrictedGlobals), // disallow declaration of variables already declared in the outer scope 'no-shadow': 'error', From 5aa203eaa88fb7febfb1ccf8736e896ca0959049 Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Fri, 1 Sep 2017 22:25:31 -0700 Subject: [PATCH 004/554] [eslint config] [base] [deps] [breaking] require `eslint` v4 - enable `function-paren-newline`, `for-direction`, `getter-return`, `no-compare-neg-zero`, `semi-style`, `object-curly-newline`, `no-buffer-constructor`, `no-restricted-globals`, `switch-colon-spacing`, `template-tag-spacing`, `prefer-promise-reject-errors`, `prefer-restructuring` - improve `indent`, `no-multi-spaces`, `no-trailing-spaces`, `no-underscore-dangle` --- .travis.yml | 4 --- .../eslint-config-airbnb-base/package.json | 4 +-- .../rules/best-practices.js | 5 ++- .../eslint-config-airbnb-base/rules/errors.js | 9 ++--- .../eslint-config-airbnb-base/rules/es6.js | 3 +- .../eslint-config-airbnb-base/rules/node.js | 3 +- .../eslint-config-airbnb-base/rules/style.js | 33 +++++++++++-------- 7 files changed, 28 insertions(+), 33 deletions(-) diff --git a/.travis.yml b/.travis.yml index 7d887ca685..9e1091574d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -19,7 +19,6 @@ env: matrix: - 'TEST=true ESLINT=3 PACKAGE=eslint-config-airbnb' - 'TEST=true ESLINT=4 PACKAGE=eslint-config-airbnb' - - 'TEST=true ESLINT=3 PACKAGE=eslint-config-airbnb-base' - 'TEST=true ESLINT=4 PACKAGE=eslint-config-airbnb-base' matrix: fast_finish: true @@ -28,8 +27,6 @@ matrix: env: PREPUBLISH=true ESLINT=3 PACKAGE=eslint-config-airbnb - node_js: "node" env: PREPUBLISH=true ESLINT=4 PACKAGE=eslint-config-airbnb - - node_js: "node" - env: PREPUBLISH=true ESLINT=3 PACKAGE=eslint-config-airbnb-base - node_js: "node" env: PREPUBLISH=true ESLINT=4 PACKAGE=eslint-config-airbnb-base allow_failures: @@ -37,5 +34,4 @@ matrix: - node_js: "5" - env: PREPUBLISH=true ESLINT=3 PACKAGE=eslint-config-airbnb - env: PREPUBLISH=true ESLINT=4 PACKAGE=eslint-config-airbnb - - env: PREPUBLISH=true ESLINT=3 PACKAGE=eslint-config-airbnb-base - env: PREPUBLISH=true ESLINT=4 PACKAGE=eslint-config-airbnb-base diff --git a/packages/eslint-config-airbnb-base/package.json b/packages/eslint-config-airbnb-base/package.json index 90078eb1d0..f23359e969 100644 --- a/packages/eslint-config-airbnb-base/package.json +++ b/packages/eslint-config-airbnb-base/package.json @@ -51,7 +51,7 @@ "babel-preset-airbnb": "^2.4.0", "babel-tape-runner": "^2.0.1", "editorconfig-tools": "^0.1.1", - "eslint": "^4.5.0", + "eslint": "^4.6.0", "eslint-find-rules": "^3.1.1", "eslint-plugin-import": "^2.7.0", "in-publish": "^2.0.0", @@ -59,7 +59,7 @@ "tape": "^4.8.0" }, "peerDependencies": { - "eslint": "^3.19.0 || ^4.5.0", + "eslint": "^4.6.0", "eslint-plugin-import": "^2.7.0" }, "engines": { diff --git a/packages/eslint-config-airbnb-base/rules/best-practices.js b/packages/eslint-config-airbnb-base/rules/best-practices.js index 11b18a2efd..83808bb879 100644 --- a/packages/eslint-config-airbnb-base/rules/best-practices.js +++ b/packages/eslint-config-airbnb-base/rules/best-practices.js @@ -143,7 +143,7 @@ module.exports = { // disallow use of multiple spaces 'no-multi-spaces': ['error', { - // ignoreEOLComments: false, // TODO: uncomment once v3 is dropped + ignoreEOLComments: false, }], // disallow use of multiline strings @@ -294,8 +294,7 @@ module.exports = { // require using Error objects as Promise rejection reasons // http://eslint.org/docs/rules/prefer-promise-reject-errors - // TODO: enable, semver-major - 'prefer-promise-reject-errors': ['off', { allowEmptyReject: true }], + 'prefer-promise-reject-errors': ['error', { allowEmptyReject: true }], // require use of the second argument for parseInt() radix: 'error', diff --git a/packages/eslint-config-airbnb-base/rules/errors.js b/packages/eslint-config-airbnb-base/rules/errors.js index 786b88ae1e..19b815a09b 100644 --- a/packages/eslint-config-airbnb-base/rules/errors.js +++ b/packages/eslint-config-airbnb-base/rules/errors.js @@ -2,13 +2,11 @@ module.exports = { rules: { // Enforce “for” loop update clause moving the counter in the right direction // http://eslint.org/docs/rules/for-direction - // TODO: enable, semver-major until v3 is dropped; semver-minor otherwise - 'for-direction': 'off', + 'for-direction': 'error', // Enforces that a return statement is present in property getters // http://eslint.org/docs/rules/getter-return - // TODO: enable, semver-major when v3 is dropped - 'getter-return': ['off', { allowImplicit: true }], + 'getter-return': ['error', { allowImplicit: true }], // Disallow await inside of loops // http://eslint.org/docs/rules/no-await-in-loop @@ -16,8 +14,7 @@ module.exports = { // Disallow comparisons to negative zero // http://eslint.org/docs/rules/no-compare-neg-zero - // TODO: enable (semver-major) - 'no-compare-neg-zero': 'off', + 'no-compare-neg-zero': 'error', // disallow assignment in conditional expressions 'no-cond-assign': ['error', 'always'], diff --git a/packages/eslint-config-airbnb-base/rules/es6.js b/packages/eslint-config-airbnb-base/rules/es6.js index a77f3a6641..f53814d1e7 100644 --- a/packages/eslint-config-airbnb-base/rules/es6.js +++ b/packages/eslint-config-airbnb-base/rules/es6.js @@ -110,8 +110,7 @@ module.exports = { // Prefer destructuring from arrays and objects // http://eslint.org/docs/rules/prefer-destructuring - // TODO: enable - 'prefer-destructuring': ['off', { + 'prefer-destructuring': ['error', { VariableDeclarator: { array: false, object: true, diff --git a/packages/eslint-config-airbnb-base/rules/node.js b/packages/eslint-config-airbnb-base/rules/node.js index d890a67c1b..9413b5483a 100644 --- a/packages/eslint-config-airbnb-base/rules/node.js +++ b/packages/eslint-config-airbnb-base/rules/node.js @@ -16,8 +16,7 @@ module.exports = { // disallow use of the Buffer() constructor // http://eslint.org/docs/rules/no-buffer-constructor - // TODO: enable, semver-major - 'no-buffer-constructor': 'off', + 'no-buffer-constructor': 'error', // disallow mixing regular variable and require declarations 'no-mixed-requires': ['off', false], diff --git a/packages/eslint-config-airbnb-base/rules/style.js b/packages/eslint-config-airbnb-base/rules/style.js index 82ef7018c2..bcd83778e1 100644 --- a/packages/eslint-config-airbnb-base/rules/style.js +++ b/packages/eslint-config-airbnb-base/rules/style.js @@ -82,6 +82,10 @@ module.exports = { // TODO: enable 'func-style': ['off', 'expression'], + // enforce consistent line breaks inside function parentheses + // https://eslint.org/docs/rules/function-paren-newline + 'function-paren-newline': ['error', 'multiline'], + // Blacklist certain identifiers to prevent them being used // http://eslint.org/docs/rules/id-blacklist 'id-blacklist': 'off', @@ -100,9 +104,6 @@ module.exports = { VariableDeclarator: 1, outerIIFEBody: 1, // MemberExpression: null, - // CallExpression: { - // parameters: null, - // }, FunctionDeclaration: { parameters: 1, body: 1 @@ -110,7 +111,15 @@ module.exports = { FunctionExpression: { parameters: 1, body: 1 - } + }, + CallExpression: { + 'arguments': 1 + }, + ArrayExpression: 1, + ObjectExpression: 1, + ImportDeclaration: 1, + flatTernaryExpressions: false, + ignoredNodes: ['JSXElement *'] }], // specify whether double or single quotes should be used in JSX attributes @@ -305,7 +314,7 @@ module.exports = { // disallow trailing whitespace at the end of lines 'no-trailing-spaces': ['error', { skipBlankLines: false, - // ignoreComments: false, // TODO: uncomment once v3 is dropped + ignoreComments: false, }], // disallow dangling underscores in identifiers @@ -313,7 +322,7 @@ module.exports = { allow: [], allowAfterThis: false, allowAfterSuper: false, - // enforceInMethodNames: false, // TODO: uncoment and enable, semver-minor once v3 is dropped + enforceInMethodNames: false, }], // disallow the use of Boolean literals in conditional expressions @@ -334,8 +343,7 @@ module.exports = { // enforce line breaks between braces // http://eslint.org/docs/rules/object-curly-newline - // TODO: enable once https://github.com/eslint/eslint/issues/6488 is resolved and v3 is dropped - 'object-curly-newline': ['off', { + 'object-curly-newline': ['error', { ObjectExpression: { minProperties: 3, multiline: true, consistent: true }, ObjectPattern: { minProperties: 3, multiline: true, consistent: true } }], @@ -386,8 +394,7 @@ module.exports = { // Enforce location of semicolons // http://eslint.org/docs/rules/semi-style - // TODO: enable, semver-major until v3 is dropped, semver-minor otherwise - 'semi-style': ['off', 'last'], + 'semi-style': ['error', 'last'], // requires object keys to be sorted 'sort-keys': ['off', 'asc', { caseSensitive: false, natural: true }], @@ -437,13 +444,11 @@ module.exports = { // Enforce spacing around colons of switch statements // http://eslint.org/docs/rules/switch-colon-spacing - // TODO: enable, semver-major - 'switch-colon-spacing': ['off', { after: true, before: false }], + 'switch-colon-spacing': ['error', { after: true, before: false }], // Require or disallow spacing between template tags and their literals // http://eslint.org/docs/rules/template-tag-spacing - // TODO: enable, semver-major - 'template-tag-spacing': ['off', 'never'], + 'template-tag-spacing': ['error', 'never'], // require or disallow the Unicode Byte Order Mark // http://eslint.org/docs/rules/unicode-bom From f878edad256fabd4fdcdfdffabd884744b0924d4 Mon Sep 17 00:00:00 2001 From: Thomas Grainger Date: Fri, 5 May 2017 11:42:43 +0100 Subject: [PATCH 005/554] [eslint config] [base] [patch] also disallow padding in classes and switches --- README.md | 10 +++++++++- packages/eslint-config-airbnb-base/rules/style.js | 4 ++-- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 4125081c2f..27070b7792 100644 --- a/README.md +++ b/README.md @@ -2396,7 +2396,7 @@ Other Style Guides } - // also bad + // bad if (baz) { console.log(qux); @@ -2405,6 +2405,14 @@ Other Style Guides } + // bad + class Foo { + + constructor(bar) { + this.bar = bar; + } + } + // good function bar() { console.log(foo); diff --git a/packages/eslint-config-airbnb-base/rules/style.js b/packages/eslint-config-airbnb-base/rules/style.js index bcd83778e1..d36309a808 100644 --- a/packages/eslint-config-airbnb-base/rules/style.js +++ b/packages/eslint-config-airbnb-base/rules/style.js @@ -368,8 +368,8 @@ module.exports = { // enforce operators to be placed before or after line breaks 'operator-linebreak': 'off', - // enforce padding within blocks - 'padded-blocks': ['error', 'never'], + // disallow padding within blocks + 'padded-blocks': ['error', { blocks: 'never', classes: 'never', switches: 'never' }], // Require or disallow padding lines between statements // http://eslint.org/docs/rules/padding-line-between-statements From 324bf9c834dead53d6c06ffdf50f764e7d35beb3 Mon Sep 17 00:00:00 2001 From: Vlad Shcherbin Date: Fri, 19 May 2017 15:04:22 +0300 Subject: [PATCH 006/554] Fix option typo --- packages/eslint-config-airbnb/CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/eslint-config-airbnb/CHANGELOG.md b/packages/eslint-config-airbnb/CHANGELOG.md index 770f56fefb..4900db6c74 100644 --- a/packages/eslint-config-airbnb/CHANGELOG.md +++ b/packages/eslint-config-airbnb/CHANGELOG.md @@ -8,7 +8,7 @@ - [breaking] `update eslint-plugin-jsx-a11y` to v5, enable new rules - [breaking] `update eslint-plugin-react` to v7, enable new rules - [minor] enable rules: `jsx-max-props-per-line`, `void-dom-elements-no-children` -- [patch] Turn `ignorePureComponent` option on for react/prefer-stateless-function (#1378, #1398) +- [patch] Turn `ignorePureComponents` option on for react/prefer-stateless-function (#1378, #1398) - [deps] update `eslint`, `eslint-plugin-react`, `eslint-config-airbnb-base` 14.1.0 / 2017-02-05 From 0dd3dbd7b62061e1ca3d1c5467ed3fbca1e5daf6 Mon Sep 17 00:00:00 2001 From: Siddharth Doshi Date: Sat, 20 May 2017 15:41:37 +0530 Subject: [PATCH 007/554] [eslint config] [base] [breaking] Blacklist confusing globals --- packages/eslint-config-airbnb-base/package.json | 3 +++ packages/eslint-config-airbnb-base/rules/variables.js | 4 +++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/packages/eslint-config-airbnb-base/package.json b/packages/eslint-config-airbnb-base/package.json index d604e51ea8..92fa71298c 100644 --- a/packages/eslint-config-airbnb-base/package.json +++ b/packages/eslint-config-airbnb-base/package.json @@ -62,5 +62,8 @@ }, "engines": { "node": ">= 4" + }, + "dependencies": { + "eslint-restricted-globals": "^0.1.1" } } diff --git a/packages/eslint-config-airbnb-base/rules/variables.js b/packages/eslint-config-airbnb-base/rules/variables.js index 3fc5f6ef93..fc0b5b11d4 100644 --- a/packages/eslint-config-airbnb-base/rules/variables.js +++ b/packages/eslint-config-airbnb-base/rules/variables.js @@ -1,3 +1,5 @@ +const restrictedGlobals = require('eslint-restricted-globals'); + module.exports = { rules: { // enforce or disallow variable initializations at definition @@ -14,7 +16,7 @@ module.exports = { 'no-label-var': 'error', // disallow specific globals - 'no-restricted-globals': 'off', + 'no-restricted-globals': ['error'].concat(restrictedGlobals), // disallow declaration of variables already declared in the outer scope 'no-shadow': 'error', From f86aacae447725d6d0edd787d620fad54ac1b187 Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Tue, 23 May 2017 12:53:26 -0700 Subject: [PATCH 008/554] [eslint config] [fix] jsx should be enabled via parserOptions, not via a root ecmaFeatures. From https://github.com/airbnb/javascript/issues/1410#issuecomment-303368921 --- packages/eslint-config-airbnb/rules/react-a11y.js | 8 ++++++-- packages/eslint-config-airbnb/rules/react.js | 4 +--- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/packages/eslint-config-airbnb/rules/react-a11y.js b/packages/eslint-config-airbnb/rules/react-a11y.js index 8bc1426f0f..77fcb93d9c 100644 --- a/packages/eslint-config-airbnb/rules/react-a11y.js +++ b/packages/eslint-config-airbnb/rules/react-a11y.js @@ -3,9 +3,13 @@ module.exports = { 'jsx-a11y', 'react' ], - ecmaFeatures: { - jsx: true + + parserOptions: { + ecmaFeatures: { + jsx: true, + }, }, + rules: { // Enforce that anchors have content // https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/anchor-has-content.md diff --git a/packages/eslint-config-airbnb/rules/react.js b/packages/eslint-config-airbnb/rules/react.js index 0b159de81e..4392d678ea 100644 --- a/packages/eslint-config-airbnb/rules/react.js +++ b/packages/eslint-config-airbnb/rules/react.js @@ -2,14 +2,12 @@ module.exports = { plugins: [ 'react', ], + parserOptions: { ecmaFeatures: { jsx: true, }, }, - ecmaFeatures: { - jsx: true, - }, // View link below for react rules documentation // https://github.com/yannickcr/eslint-plugin-react#list-of-supported-rules From 44ca3c2b3a1650ae5b8961ff3d5f3d166fde52db Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Tue, 23 May 2017 12:54:02 -0700 Subject: [PATCH 009/554] [eslint config] [deps] update `eslint-plugin-jsx-a11y` --- packages/eslint-config-airbnb/package.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/eslint-config-airbnb/package.json b/packages/eslint-config-airbnb/package.json index eb656660d2..dd5c99a010 100644 --- a/packages/eslint-config-airbnb/package.json +++ b/packages/eslint-config-airbnb/package.json @@ -55,7 +55,7 @@ "eslint": "^3.19.0", "eslint-find-rules": "^1.14.3", "eslint-plugin-import": "^2.2.0", - "eslint-plugin-jsx-a11y": "^5.0.1", + "eslint-plugin-jsx-a11y": "^5.0.3", "eslint-plugin-react": "^7.0.1", "in-publish": "^2.0.0", "react": ">= 0.13.0", @@ -64,7 +64,7 @@ }, "peerDependencies": { "eslint": "^3.19.0", - "eslint-plugin-jsx-a11y": "^5.0.1", + "eslint-plugin-jsx-a11y": "^5.0.3", "eslint-plugin-import": "^2.2.0", "eslint-plugin-react": "^7.0.1" }, From 0f8f30dcd0b8292a9e49148fa6f77046aadbeee2 Mon Sep 17 00:00:00 2001 From: Daniel Axelrod Date: Sun, 21 May 2017 16:10:51 -0400 Subject: [PATCH 010/554] [6.5] Add no-eval eslint rule to docs Add reference to the eslint `no-eval` rule to the README. This rule is already set to `error` in best-practices.js in eslint-airbnb-config-base. --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index b902d4ddd8..2a851fae40 100644 --- a/README.md +++ b/README.md @@ -592,7 +592,7 @@ Other Style Guides ``` - - [6.4](#strings--eval) Never use `eval()` on a string, it opens too many vulnerabilities. + - [6.4](#strings--eval) Never use `eval()` on a string, it opens too many vulnerabilities. eslint: [`no-eval`](http://eslint.org/docs/rules/no-eval) - [6.5](#strings--escaping) Do not unnecessarily escape characters in strings. eslint: [`no-useless-escape`](http://eslint.org/docs/rules/no-useless-escape) From f3c9639abe26bd03339f13dc1ab21868399c5beb Mon Sep 17 00:00:00 2001 From: Ken Powers Date: Wed, 24 May 2017 15:43:56 -0400 Subject: [PATCH 011/554] [eslint config] [base] [patch] Allow jsx extensions for test files --- packages/eslint-config-airbnb-base/rules/imports.js | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/packages/eslint-config-airbnb-base/rules/imports.js b/packages/eslint-config-airbnb-base/rules/imports.js index b081b59b6b..3b6c6cef60 100644 --- a/packages/eslint-config-airbnb-base/rules/imports.js +++ b/packages/eslint-config-airbnb-base/rules/imports.js @@ -73,10 +73,9 @@ module.exports = { 'tests/**', // also common npm pattern 'spec/**', // mocha, rspec-like pattern '**/__tests__/**', // jest pattern - 'test.js', // repos with a single test file - 'test-*.js', // repos with multiple top-level test files - '**/*.test.js', // tests where the extension denotes that it is a test - '**/*.spec.js', // tests where the extension denotes that it is a test + 'test.{js,jsx}', // repos with a single test file + 'test-*.{js,jsx}', // repos with multiple top-level test files + '**/*.{test,spec}.{js,jsx}', // tests where the extension denotes that it is a test '**/webpack.config.js', // webpack config '**/webpack.config.*.js', // webpack config '**/rollup.config.js', // rollup config From ac6de2fdb8c185597998aa4bf1cc35358d4a3d28 Mon Sep 17 00:00:00 2001 From: Joe Lencioni Date: Fri, 2 Jun 2017 12:05:41 -0700 Subject: [PATCH 012/554] Bump copyright year 2016 -> 2017 in license --- LICENSE.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/LICENSE.md b/LICENSE.md index 87081c1339..2867dece2b 100644 --- a/LICENSE.md +++ b/LICENSE.md @@ -1,6 +1,6 @@ MIT License -Copyright (c) 2016 Airbnb +Copyright (c) 2017 Airbnb Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal From 98f2224ec2f4378028cbb61a62dbbaa44a2fcc56 Mon Sep 17 00:00:00 2001 From: Daniel Axelrod Date: Fri, 2 Jun 2017 17:10:16 +0000 Subject: [PATCH 013/554] Add linting for Markdown prose Codify existing practices for writing Markdown in style guides and enforce them via Markdownlint. A new npm script "lint" in the top level package.json runs before tests or as the first step of the "travis" script. Only modify documents in cases where they had bugs or isolated cases of inconsistency: README.md: 10: MD007 Unordered list indentation Inconsistent with all other top level lists README.md: 10: MD032 Lists should be surrounded by blank lines Some Markdown parsers don't handle this correctly README.md: 3156-3161: MD005 Inconsistent indentation for list items at the same level Bug, looks like it's intended to be another list level but GitHub renders it at the same level as the "No but seriously" README.md & css-in-javascript/README.md: throughout: MD012 Multiple consecutive blank lines README.md: throughout: MD004 Unordered list style Some nested lists used plusses, now everything consistently uses dashes. --- README.md | 85 +++++++------------- css-in-javascript/README.md | 1 - linters/.markdownlint.json | 154 ++++++++++++++++++++++++++++++++++++ package.json | 8 +- 4 files changed, 190 insertions(+), 58 deletions(-) create mode 100644 linters/.markdownlint.json diff --git a/README.md b/README.md index 2a851fae40..00742a0855 100644 --- a/README.md +++ b/README.md @@ -7,11 +7,12 @@ [![Gitter](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/airbnb/javascript?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge) Other Style Guides - - [ES5 (Deprecated)](https://github.com/airbnb/javascript/tree/es5-deprecated/es5) - - [React](react/) - - [CSS-in-JavaScript](css-in-javascript/) - - [CSS & Sass](https://github.com/airbnb/css) - - [Ruby](https://github.com/airbnb/ruby) + + - [ES5 (Deprecated)](https://github.com/airbnb/javascript/tree/es5-deprecated/es5) + - [React](react/) + - [CSS-in-JavaScript](css-in-javascript/) + - [CSS & Sass](https://github.com/airbnb/css) + - [Ruby](https://github.com/airbnb/ruby) ## Table of Contents @@ -58,11 +59,11 @@ Other Style Guides - [1.1](#types--primitives) **Primitives**: When you access a primitive type you work directly on its value. - + `string` - + `number` - + `boolean` - + `null` - + `undefined` + - `string` + - `number` + - `boolean` + - `null` + - `undefined` ```javascript const foo = 1; @@ -76,9 +77,9 @@ Other Style Guides - [1.2](#types--complex) **Complex**: When you access a complex type you work on a reference to its value. - + `object` - + `array` - + `function` + - `object` + - `array` + - `function` ```javascript const foo = [1, 2]; @@ -524,7 +525,6 @@ Other Style Guides const { left, top } = processInput(input); ``` - **[⬆ back to top](#table-of-contents)** ## Strings @@ -610,7 +610,6 @@ Other Style Guides **[⬆ back to top](#table-of-contents)** - ## Functions @@ -1016,7 +1015,6 @@ Other Style Guides **[⬆ back to top](#table-of-contents)** - ## Classes & Constructors @@ -1035,7 +1033,6 @@ Other Style Guides return value; }; - // good class Queue { constructor(contents = []) { @@ -1110,7 +1107,6 @@ Other Style Guides .setHeight(20); ``` - - [9.4](#constructors--tostring) It's okay to write a custom toString() method, just make sure it works successfully and causes no side effects. @@ -1182,10 +1178,8 @@ Other Style Guides } ``` - **[⬆ back to top](#table-of-contents)** - ## Modules @@ -1449,7 +1443,6 @@ Other Style Guides **[⬆ back to top](#table-of-contents)** - ## Properties @@ -1486,7 +1479,6 @@ Other Style Guides **[⬆ back to top](#table-of-contents)** - ## Variables @@ -1656,7 +1648,6 @@ Other Style Guides **[⬆ back to top](#table-of-contents)** - ## Hoisting @@ -1756,7 +1747,6 @@ Other Style Guides **[⬆ back to top](#table-of-contents)** - ## Comparison Operators & Equality @@ -1765,12 +1755,12 @@ Other Style Guides - [15.2](#comparison--if) Conditional statements such as the `if` statement evaluate their expression using coercion with the `ToBoolean` abstract method and always follow these simple rules: - + **Objects** evaluate to **true** - + **Undefined** evaluates to **false** - + **Null** evaluates to **false** - + **Booleans** evaluate to **the value of the boolean** - + **Numbers** evaluate to **false** if **+0, -0, or NaN**, otherwise **true** - + **Strings** evaluate to **false** if an empty string `''`, otherwise **true** + - **Objects** evaluate to **true** + - **Undefined** evaluates to **false** + - **Null** evaluates to **false** + - **Booleans** evaluate to **the value of the boolean** + - **Numbers** evaluate to **false** if **+0, -0, or NaN**, otherwise **true** + - **Strings** evaluate to **false** if an empty string `''`, otherwise **true** ```javascript if ([0] && []) { @@ -1910,7 +1900,6 @@ Other Style Guides **[⬆ back to top](#table-of-contents)** - ## Blocks @@ -1960,10 +1949,8 @@ Other Style Guides } ``` - **[⬆ back to top](#table-of-contents)** - ## Control Statements @@ -2018,10 +2005,8 @@ Other Style Guides } ``` - **[⬆ back to top](#table-of-contents)** - ## Comments @@ -2162,7 +2147,6 @@ Other Style Guides **[⬆ back to top](#table-of-contents)** - ## Whitespace @@ -2624,7 +2608,6 @@ Other Style Guides **[⬆ back to top](#table-of-contents)** - ## Semicolons @@ -2654,7 +2637,6 @@ Other Style Guides **[⬆ back to top](#table-of-contents)** - ## Type Casting & Coercion @@ -2741,7 +2723,6 @@ Other Style Guides **[⬆ back to top](#table-of-contents)** - ## Naming Conventions @@ -2933,7 +2914,6 @@ Other Style Guides **[⬆ back to top](#table-of-contents)** - ## Accessors @@ -3003,7 +2983,6 @@ Other Style Guides **[⬆ back to top](#table-of-contents)** - ## Events @@ -3035,7 +3014,6 @@ Other Style Guides **[⬆ back to top](#table-of-contents)** - ## jQuery @@ -3105,7 +3083,6 @@ Other Style Guides **[⬆ back to top](#table-of-contents)** - ## ECMAScript 5 Compatibility @@ -3153,16 +3130,15 @@ Other Style Guides - [29.2](#testing--for-real) **No, but seriously**: - - Whichever testing framework you use, you should be writing tests! - - Strive to write many small pure functions, and minimize where mutations occur. - - Be cautious about stubs and mocks - they can make your tests more brittle. - - We primarily use [`mocha`](https://www.npmjs.com/package/mocha) at Airbnb. [`tape`](https://www.npmjs.com/package/tape) is also used occasionally for small, separate modules. - - 100% test coverage is a good goal to strive for, even if it's not always practical to reach it. - - Whenever you fix a bug, _write a regression test_. A bug fixed without a regression test is almost certainly going to break again in the future. + - Whichever testing framework you use, you should be writing tests! + - Strive to write many small pure functions, and minimize where mutations occur. + - Be cautious about stubs and mocks - they can make your tests more brittle. + - We primarily use [`mocha`](https://www.npmjs.com/package/mocha) at Airbnb. [`tape`](https://www.npmjs.com/package/tape) is also used occasionally for small, separate modules. + - 100% test coverage is a good goal to strive for, even if it's not always practical to reach it. + - Whenever you fix a bug, _write a regression test_. A bug fixed without a regression test is almost certainly going to break again in the future. **[⬆ back to top](#table-of-contents)** - ## Performance - [On Layout & Web Performance](https://www.kellegous.com/j/2013/01/26/layout-performance/) @@ -3177,7 +3153,6 @@ Other Style Guides **[⬆ back to top](#table-of-contents)** - ## Resources **Learning ES6** @@ -3194,9 +3169,9 @@ Other Style Guides **Tools** - Code Style Linters - + [ESlint](http://eslint.org/) - [Airbnb Style .eslintrc](https://github.com/airbnb/javascript/blob/master/linters/.eslintrc) - + [JSHint](http://jshint.com/) - [Airbnb Style .jshintrc](https://github.com/airbnb/javascript/blob/master/linters/.jshintrc) - + [JSCS](https://github.com/jscs-dev/node-jscs) - [Airbnb Style Preset](https://github.com/jscs-dev/node-jscs/blob/master/presets/airbnb.json) (Deprecated, please use [ESlint](https://github.com/airbnb/javascript/tree/master/packages/eslint-config-airbnb-base)) + - [ESlint](http://eslint.org/) - [Airbnb Style .eslintrc](https://github.com/airbnb/javascript/blob/master/linters/.eslintrc) + - [JSHint](http://jshint.com/) - [Airbnb Style .jshintrc](https://github.com/airbnb/javascript/blob/master/linters/.jshintrc) + - [JSCS](https://github.com/jscs-dev/node-jscs) - [Airbnb Style Preset](https://github.com/jscs-dev/node-jscs/blob/master/presets/airbnb.json) (Deprecated, please use [ESlint](https://github.com/airbnb/javascript/tree/master/packages/eslint-config-airbnb-base)) - Neutrino preset - [neutrino-preset-airbnb-base](https://neutrino.js.org/presets/neutrino-preset-airbnb-base/) **Other Style Guides** @@ -3257,7 +3232,6 @@ Other Style Guides - [JavaScript Air](https://javascriptair.com/) - [JavaScript Jabber](https://devchat.tv/js-jabber/) - **[⬆ back to top](#table-of-contents)** ## In the Wild @@ -3385,7 +3359,6 @@ Other Style Guides - [View Contributors](https://github.com/airbnb/javascript/graphs/contributors) - ## License (The MIT License) diff --git a/css-in-javascript/README.md b/css-in-javascript/README.md index 9c53bc3e0e..13099410a9 100644 --- a/css-in-javascript/README.md +++ b/css-in-javascript/README.md @@ -176,7 +176,6 @@ export default withStyles(() => styles)(MyComponent); - // good function MyComponent({ styles }) { return ( diff --git a/linters/.markdownlint.json b/linters/.markdownlint.json new file mode 100644 index 0000000000..e7a019fed8 --- /dev/null +++ b/linters/.markdownlint.json @@ -0,0 +1,154 @@ +{ + "comment": "Be explicit by listing every available rule. https://github.com/DavidAnson/markdownlint/blob/master/doc/Rules.md", + "comment": "Note that there will be numeric gaps, not every MD number is implemented in markdownlint.", + + "comment": "MD001: Header levels should only increment by one level at a time", + "header-increment": true, + + "comment": "MD002: First header should be a top level header", + "first-header-h1": true, + + "comment": "MD003: Header style: start with hashes", + "header-style": { + "style": "atx" + }, + + "comment": "MD004: Unordered list style", + "ul-style": { + "style": "dash" + }, + + "comment": "MD005: Consistent indentation for list items at the same level", + "list-indent": true, + + "comment": "MD006: Consider starting bulleted lists at the beginning of the line", + "ul-start-left": false, + + "comment": "MD007: Unordered list indentation: 2 spaces", + "ul-indent": { + "indent": 2 + }, + + "comment": "MD009: Disallow trailing spaces", + "no-trailing-spaces": { + "br-spaces": 0, + "comment": "Empty lines inside list items should not be indented", + "list_item_empty_lines": false + }, + + "comment": "MD010: No hard tabs, not even in code blocks", + "no-hard-tabs": { + "code_blocks": true + }, + + "comment": "MD011: Prevent reversed link syntax", + "no-reversed-links": true, + + "comment": "MD012: Disallow multiple consecutive blank lines", + "no-multiple-blanks": { + "maximum": 1 + }, + + "comment": "MD013: Line length", + "line-length": false, + + "comment": "MD014: Disallow dollar signs used before commands without showing output", + "commands-show-output": true, + + "comment": "MD018: Disallow space after hash on atx style header", + "no-missing-space-atx": true, + + "comment": "MD019: Dissalow multiple spaces after hash on atx style header", + "no-multiple-space-atx": true, + + "comment": "MD020: No space inside hashes on closed atx style header", + "no-missing-space-closed-atx": true, + + "comment": "MD021: Disallow multiple spaces inside hashes on closed atx style header", + "no-multiple-space-closed-atx": true, + + "comment": "MD022: Headers should be surrounded by blank lines", + "comment": "Some headers have preceeding HTML anchors. Unfortunate that we have to disable this, as it otherwise catches a real problem that trips up some Markdown renderers", + "blanks-around-headers": false, + + "comment": "MD023: Headers must start at the beginning of the line", + "header-start-left": true, + + "comment": "MD024: Disallow multiple headers with the same content", + "no-duplicate-header": true, + + "comment": "MD025: Disallow multiple top level headers in the same document", + "comment": "Gotta have a matching closing brace at the end", + "single-h1": false, + + "comment": "MD026: Disallow trailing punctuation in header", + "comment": "Gotta have a semicolon after the ending closing brace", + "no-trailing-punctuation": { + "punctuation" : ".,:!?" + }, + "comment": "MD027: Dissalow multiple spaces after blockquote symbol", + "no-multiple-space-blockquote": true, + + "comment": "MD028: Blank line inside blockquote", + "comment": "Some 'Why?' and 'Why not?' blocks are separated by a blank line", + "no-blanks-blockquote": false, + + "comment": "MD029: Ordered list item prefix", + "ol-prefix": { + "style": "one" + }, + + "comment": "MD030: Spaces after list markers", + "list-marker-space": { + "ul_single": 1, + "ol_single": 1, + "ul_multi": 1, + "ol_multi": 1 + }, + + "comment": "MD031: Fenced code blocks should be surrounded by blank lines", + "blanks-around-fences": true, + + "comment": "MD032: Lists should be surrounded by blank lines", + "comment": "Some lists have preceeding HTML anchors. Unfortunate that we have to disable this, as it otherwise catches a real problem that trips up some Markdown renderers", + "blanks-around-lists": false, + + "comment": "MD033: Disallow inline HTML", + "comment": "HTML is needed for explicit anchors", + "no-inline-html": false, + + "comment": "MD034: No bare URLs used", + "no-bare-urls": true, + + "comment": "MD035: Horizontal rule style", + "hr-style": { + "style": "consistent" + }, + + "comment": "MD036: Do not use emphasis instead of a header", + "no-emphasis-as-header": false, + + "comment": "MD037: Disallow spaces inside emphasis markers", + "no-space-in-emphasis": true, + + "comment": "MD038: Disallow spaces inside code span elements", + "no-space-in-code": true, + + "comment": "MD039: Disallow spaces inside link text", + "no-space-in-links": true, + + "comment": "MD040: Fenced code blocks should have a language specified", + "fenced-code-language": true, + + "comment": "MD041: First line in file should be a top level header", + "first-line-h1": true, + + "comment": "MD042: No empty links", + "no-empty-links": true, + + "comment": "MD043: Required header structure", + "required-headers": false, + + "comment": "MD044: Proper names should have the correct capitalization", + "proper-names": false +} diff --git a/package.json b/package.json index a977f26b3d..b50dd7a121 100644 --- a/package.json +++ b/package.json @@ -6,9 +6,12 @@ "preinstall": "npm run install:config && npm run install:config:base", "install:config": "cd packages/eslint-config-airbnb && npm prune && npm install", "install:config:base": "cd packages/eslint-config-airbnb-base && npm prune && npm install", + "lint": "markdownlint --config linters/.markdownlint.json README.md */README.md", + "pretest": "npm run --silent lint", "test": "npm run --silent test:config && npm run --silent test:config:base", "test:config": "cd packages/eslint-config-airbnb; npm test", "test:config:base": "cd packages/eslint-config-airbnb-base; npm test", + "pretravis": "npm run --silent lint", "travis": "npm run --silent travis:config && npm run --silent travis:config:base", "travis:config": "cd packages/eslint-config-airbnb; npm run travis", "travis:config:base": "cd packages/eslint-config-airbnb-base; npm run travis" @@ -31,5 +34,8 @@ "bugs": { "url": "https://github.com/airbnb/javascript/issues" }, - "homepage": "https://github.com/airbnb/javascript" + "homepage": "https://github.com/airbnb/javascript", + "devDependencies": { + "markdownlint-cli": "^0.3.1" + } } From 5ba31498feaec1c977008b62c2768f4ea5d498df Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Sat, 3 Jun 2017 23:37:10 -0700 Subject: [PATCH 014/554] Only apps should have lockfiles. --- .gitignore | 6 ++++++ .npmrc | 1 + packages/eslint-config-airbnb-base/.npmrc | 1 + packages/eslint-config-airbnb/.npmrc | 1 + 4 files changed, 9 insertions(+) create mode 100644 .npmrc create mode 120000 packages/eslint-config-airbnb-base/.npmrc create mode 120000 packages/eslint-config-airbnb/.npmrc diff --git a/.gitignore b/.gitignore index 3c3629e647..ac10dfe528 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,7 @@ +# gitignore + node_modules + +# Only apps should have lockfiles +yarn.lock +package-lock.json diff --git a/.npmrc b/.npmrc new file mode 100644 index 0000000000..43c97e719a --- /dev/null +++ b/.npmrc @@ -0,0 +1 @@ +package-lock=false diff --git a/packages/eslint-config-airbnb-base/.npmrc b/packages/eslint-config-airbnb-base/.npmrc new file mode 120000 index 0000000000..cba44bb384 --- /dev/null +++ b/packages/eslint-config-airbnb-base/.npmrc @@ -0,0 +1 @@ +../../.npmrc \ No newline at end of file diff --git a/packages/eslint-config-airbnb/.npmrc b/packages/eslint-config-airbnb/.npmrc new file mode 120000 index 0000000000..cba44bb384 --- /dev/null +++ b/packages/eslint-config-airbnb/.npmrc @@ -0,0 +1 @@ +../../.npmrc \ No newline at end of file From 1a38734d63a3624887de6c5ffa5602b4da9d3db4 Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Sat, 3 Jun 2017 23:38:22 -0700 Subject: [PATCH 015/554] [Tests] npm v4.6+ breaks in node < v1; npm 5+ breaks in node < v4 --- .travis.yml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index f492123d64..ba1b67ece5 100644 --- a/.travis.yml +++ b/.travis.yml @@ -9,8 +9,10 @@ env: - 'TEST_DIR=packages/eslint-config-airbnb-base' before_install: - 'cd $TEST_DIR' - - 'if [ "${TRAVIS_NODE_VERSION}" != "0.9" ]; then case "$(npm --version)" in 1.*) npm install -g npm@1.4.28 ;; 2.*) npm install -g npm@2 ;; esac ; fi' - - 'if [ "${TRAVIS_NODE_VERSION}" != "0.6" ] && [ "${TRAVIS_NODE_VERSION}" != "0.9" ]; then npm install -g npm; fi' + - 'if [ "${TRAVIS_NODE_VERSION}" = "0.6" ]; then npm install -g npm@1.3 ; elif [ "${TRAVIS_NODE_VERSION}" != "0.9" ]; then case "$(npm --version)" in 1.*) npm install -g npm@1.4.28 ;; 2.*) npm install -g npm@2 ;; esac ; fi' + - 'if [ "${TRAVIS_NODE_VERSION%${TRAVIS_NODE_VERSION#[0-9]}}" = "0" ] || [ "${TRAVIS_NODE_VERSION:0:4}" = "iojs" ]; then npm install -g npm@4.5 ; elif [ "${TRAVIS_NODE_VERSION}" != "0.6" ] && [ "${TRAVIS_NODE_VERSION}" != "0.9" ]; then npm install -g npm; fi' +install: + - 'if [ "${TRAVIS_NODE_VERSION}" = "0.6" ]; then nvm install 0.8 && npm install -g npm@1.3 && npm install -g npm@1.4.28 && npm install -g npm@2 && npm install && nvm use "${TRAVIS_NODE_VERSION}"; else npm install; fi;' script: - 'npm run travis' sudo: false From 721af5498fade08b3a5fe9e613aa6e33baa51e37 Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Sat, 3 Jun 2017 23:39:24 -0700 Subject: [PATCH 016/554] [Tests] on `node` `v8` --- .travis.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.travis.yml b/.travis.yml index ba1b67ece5..d28e6fd12e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,5 +1,6 @@ language: node_js node_js: + - "8" - "7" - "6" - "5" @@ -18,3 +19,6 @@ script: sudo: false matrix: fast_finish: true + allow_failures: + - node_js: "7" + - node_js: "5" From 00c9e52aec17b9a44fbf03494a931346e8f090de Mon Sep 17 00:00:00 2001 From: Radu Serbanescu Date: Wed, 7 Jun 2017 13:18:38 +0300 Subject: [PATCH 017/554] [eslint config] [base] [minor] Balanced spacing for inline block comments Fixes #1425. --- packages/eslint-config-airbnb-base/rules/style.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/eslint-config-airbnb-base/rules/style.js b/packages/eslint-config-airbnb-base/rules/style.js index 237f16899d..c617e57fd3 100644 --- a/packages/eslint-config-airbnb-base/rules/style.js +++ b/packages/eslint-config-airbnb-base/rules/style.js @@ -395,7 +395,7 @@ module.exports = { block: { exceptions: ['-', '+'], markers: ['=', '!'], // space here to support sprockets directives - balanced: false, + balanced: true, } }], From 1bbac742862720fd6905712ccf87cae45f327307 Mon Sep 17 00:00:00 2001 From: Gustavo Isensee Date: Tue, 13 Jun 2017 00:59:43 -0300 Subject: [PATCH 018/554] Updated "how to define propTypes..." Imported from new prop-types module. --- react/README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/react/README.md b/react/README.md index 16bf2420ac..b86f743f23 100644 --- a/react/README.md +++ b/react/README.md @@ -557,7 +557,8 @@ - How to define `propTypes`, `defaultProps`, `contextTypes`, etc... ```jsx - import React, { PropTypes } from 'react'; + import React from 'react'; + import PropTypes from 'prop-types'; const propTypes = { id: PropTypes.number.isRequired, From fd8cbec8e0b312dcf31a579fe3b1e7098ae0bfe7 Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Tue, 13 Jun 2017 01:06:34 -0700 Subject: [PATCH 019/554] [guide] change straight quotes to curly quotes --- README.md | 38 +++++++++++++++++++------------------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/README.md b/README.md index 00742a0855..69a7b9982f 100644 --- a/README.md +++ b/README.md @@ -227,7 +227,7 @@ Other Style Guides - [3.5](#objects--grouped-shorthand) Group your shorthand properties at the beginning of your object declaration. - > Why? It's easier to tell which properties are using the shorthand. + > Why? It’s easier to tell which properties are using the shorthand. ```javascript const anakinSkywalker = 'Anakin Skywalker'; @@ -369,7 +369,7 @@ Other Style Guides ``` - - [4.5](#arrays--callback-return) 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](#arrows--implicit-return). eslint: [`array-callback-return`](http://eslint.org/docs/rules/array-callback-return) + - [4.5](#arrays--callback-return) 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](#arrows--implicit-return). eslint: [`array-callback-return`](http://eslint.org/docs/rules/array-callback-return) ```javascript // good @@ -615,7 +615,7 @@ Other Style Guides - [7.1](#functions--declarations) Use named function expressions instead of function declarations. eslint: [`func-style`](http://eslint.org/docs/rules/func-style) jscs: [`disallowFunctionDeclarations`](http://jscs.info/rule/disallowFunctionDeclarations) - > Why? Function declarations are hoisted, which means that it’s easy - too easy - to reference the function before it is defined in the file. This harms readability and maintainability. If you find that a function’s definition is large or complex enough that it is interfering with understanding the rest of the file, then perhaps it’s time to extract it to its own module! Don’t forget to name the expression - anonymous functions can make it harder to locate the problem in an Error's call stack. ([Discussion](https://github.com/airbnb/javascript/issues/794)) + > Why? Function declarations are hoisted, which means that it’s easy - too easy - to reference the function before it is defined in the file. This harms readability and maintainability. If you find that a function’s definition is large or complex enough that it is interfering with understanding the rest of the file, then perhaps it’s time to extract it to its own module! Don’t forget to name the expression - anonymous functions can make it harder to locate the problem in an Error’s call stack. ([Discussion](https://github.com/airbnb/javascript/issues/794)) ```javascript // bad @@ -650,7 +650,7 @@ Other Style Guides - [7.3](#functions--in-blocks) Never declare a function in a non-function block (`if`, `while`, etc). Assign the function to a variable instead. Browsers will allow you to do it, but they all interpret it differently, which is bad news bears. eslint: [`no-loop-func`](http://eslint.org/docs/rules/no-loop-func.html) - - [7.4](#functions--note-on-blocks) **Note:** ECMA-262 defines a `block` as a list of statements. A function declaration is not a statement. [Read ECMA-262's note on this issue](http://www.ecma-international.org/publications/files/ECMA-ST/Ecma-262.pdf#page=97). + - [7.4](#functions--note-on-blocks) **Note:** ECMA-262 defines a `block` as a list of statements. A function declaration is not a statement. [Read ECMA-262’s note on this issue](http://www.ecma-international.org/publications/files/ECMA-ST/Ecma-262.pdf#page=97). ```javascript // bad @@ -838,7 +838,7 @@ Other Style Guides - [7.14](#functions--spread-vs-apply) Prefer the use of the spread operator `...` to call variadic functions. eslint: [`prefer-spread`](http://eslint.org/docs/rules/prefer-spread) - > Why? It's cleaner, you don't need to supply a context, and you can not easily compose `new` with `apply`. + > Why? It’s cleaner, you don't need to supply a context, and you can not easily compose `new` with `apply`. ```javascript // bad @@ -964,7 +964,7 @@ Other Style Guides ``` - - [8.4](#arrows--one-arg-parens) If your function takes a single argument and doesn’t use braces, omit the parentheses. Otherwise, always include parentheses around arguments for clarity and consistency. Note: it is also acceptable to always use parentheses, in which case use the ["always" option](http://eslint.org/docs/rules/arrow-parens#always) for eslint or do not include [`disallowParenthesesAroundArrowParam`](http://jscs.info/rule/disallowParenthesesAroundArrowParam) for jscs. eslint: [`arrow-parens`](http://eslint.org/docs/rules/arrow-parens.html) jscs: [`disallowParenthesesAroundArrowParam`](http://jscs.info/rule/disallowParenthesesAroundArrowParam) + - [8.4](#arrows--one-arg-parens) If your function takes a single argument and doesn’t use braces, omit the parentheses. Otherwise, always include parentheses around arguments for clarity and consistency. Note: it is also acceptable to always use parentheses, in which case use the [“always” option](http://eslint.org/docs/rules/arrow-parens#always) for eslint or do not include [`disallowParenthesesAroundArrowParam`](http://jscs.info/rule/disallowParenthesesAroundArrowParam) for jscs. eslint: [`arrow-parens`](http://eslint.org/docs/rules/arrow-parens.html) jscs: [`disallowParenthesesAroundArrowParam`](http://jscs.info/rule/disallowParenthesesAroundArrowParam) > Why? Less visual clutter. @@ -1108,7 +1108,7 @@ Other Style Guides ``` - - [9.4](#constructors--tostring) It's okay to write a custom toString() method, just make sure it works successfully and causes no side effects. + - [9.4](#constructors--tostring) It’s okay to write a custom toString() method, just make sure it works successfully and causes no side effects. ```javascript class Jedi { @@ -1185,7 +1185,7 @@ Other Style Guides - [10.1](#modules--use-them) Always use modules (`import`/`export`) over a non-standard module system. You can always transpile to your preferred module system. - > Why? Modules are the future, let's start using the future now. + > Why? Modules are the future, let’s start using the future now. ```javascript // bad @@ -1336,7 +1336,7 @@ Other Style Guides ## Iterators and Generators - - [11.1](#iterators--nope) Don't use iterators. Prefer JavaScript's higher-order functions instead of loops like `for-in` or `for-of`. eslint: [`no-iterator`](http://eslint.org/docs/rules/no-iterator.html) [`no-restricted-syntax`](http://eslint.org/docs/rules/no-restricted-syntax) + - [11.1](#iterators--nope) Don't use iterators. Prefer JavaScript’s higher-order functions instead of loops like `for-in` or `for-of`. eslint: [`no-iterator`](http://eslint.org/docs/rules/no-iterator.html) [`no-restricted-syntax`](http://eslint.org/docs/rules/no-restricted-syntax) > Why? This enforces our immutable rule. Dealing with pure functions that return values is easier to reason about than side effects. @@ -1495,7 +1495,7 @@ Other Style Guides - [13.2](#variables--one-const) Use one `const` or `let` declaration per variable. eslint: [`one-var`](http://eslint.org/docs/rules/one-var.html) jscs: [`disallowMultipleVarDecl`](http://jscs.info/rule/disallowMultipleVarDecl) - > Why? It's easier to add new variable declarations this way, and you never have to worry about swapping out a `;` for a `,` or introducing punctuation-only diffs. You can also step through each declaration with the debugger, instead of jumping through all of them at once. + > Why? It’s easier to add new variable declarations this way, and you never have to worry about swapping out a `;` for a `,` or introducing punctuation-only diffs. You can also step through each declaration with the debugger, instead of jumping through all of them at once. ```javascript // bad @@ -1651,7 +1651,7 @@ Other Style Guides ## Hoisting - - [14.1](#hoisting--about) `var` declarations get hoisted to the top of their scope, their assignment does not. `const` and `let` declarations are blessed with a new concept called [Temporal Dead Zones (TDZ)](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/let#Temporal_dead_zone_and_errors_with_let). It's important to know why [typeof is no longer safe](http://es-discourse.com/t/why-typeof-is-no-longer-safe/15). + - [14.1](#hoisting--about) `var` declarations get hoisted to the top of their scope, their assignment does not. `const` and `let` declarations are blessed with a new concept called [Temporal Dead Zones (TDZ)](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/let#Temporal_dead_zone_and_errors_with_let). It’s important to know why [typeof is no longer safe](http://es-discourse.com/t/why-typeof-is-no-longer-safe/15). ```javascript // we know this wouldn't work (assuming there @@ -1928,7 +1928,7 @@ Other Style Guides ``` - - [16.2](#blocks--cuddled-elses) If you're using multi-line blocks with `if` and `else`, put `else` on the same line as your `if` block's closing brace. eslint: [`brace-style`](http://eslint.org/docs/rules/brace-style.html) jscs: [`disallowNewlineBeforeBlockStatements`](http://jscs.info/rule/disallowNewlineBeforeBlockStatements) + - [16.2](#blocks--cuddled-elses) If you're using multi-line blocks with `if` and `else`, put `else` on the same line as your `if` block’s closing brace. eslint: [`brace-style`](http://eslint.org/docs/rules/brace-style.html) jscs: [`disallowNewlineBeforeBlockStatements`](http://jscs.info/rule/disallowNewlineBeforeBlockStatements) ```javascript // bad @@ -1954,7 +1954,7 @@ Other Style Guides ## Control Statements - - [17.1](#control-statements) In case your control statement (`if`, `while` etc.) gets too long or exceeds the maximum line length, each (grouped) condition could be put into a new line. It's up to you whether the logical operator should begin or end the line. + - [17.1](#control-statements) In case your control statement (`if`, `while` etc.) gets too long or exceeds the maximum line length, each (grouped) condition could be put into a new line. It’s up to you whether the logical operator should begin or end the line. ```javascript // bad @@ -2040,7 +2040,7 @@ Other Style Guides ``` - - [18.2](#comments--singleline) Use `//` for single line comments. Place single line comments on a newline above the subject of the comment. Put an empty line before the comment unless it's on the first line of a block. + - [18.2](#comments--singleline) Use `//` for single line comments. Place single line comments on a newline above the subject of the comment. Put an empty line before the comment unless it’s on the first line of a block. ```javascript // bad @@ -2859,7 +2859,7 @@ Other Style Guides ``` - - [23.7](#naming--camelCase-default-export) Use camelCase when you export-default a function. Your filename should be identical to your function's name. + - [23.7](#naming--camelCase-default-export) Use camelCase when you export-default a function. Your filename should be identical to your function’s name. ```javascript function makeStyleGuide() { @@ -2962,7 +2962,7 @@ Other Style Guides ``` - - [24.4](#accessors--consistent) It's okay to create get() and set() functions, but be consistent. + - [24.4](#accessors--consistent) It’s okay to create get() and set() functions, but be consistent. ```javascript class Jedi { @@ -3086,7 +3086,7 @@ Other Style Guides ## ECMAScript 5 Compatibility - - [27.1](#es5-compat--kangax) Refer to [Kangax](https://twitter.com/kangax/)'s ES5 [compatibility table](https://kangax.github.io/es5-compat-table/). + - [27.1](#es5-compat--kangax) Refer to [Kangax](https://twitter.com/kangax/)’s ES5 [compatibility table](https://kangax.github.io/es5-compat-table/). **[⬆ back to top](#table-of-contents)** @@ -3134,7 +3134,7 @@ Other Style Guides - Strive to write many small pure functions, and minimize where mutations occur. - Be cautious about stubs and mocks - they can make your tests more brittle. - We primarily use [`mocha`](https://www.npmjs.com/package/mocha) at Airbnb. [`tape`](https://www.npmjs.com/package/tape) is also used occasionally for small, separate modules. - - 100% test coverage is a good goal to strive for, even if it's not always practical to reach it. + - 100% test coverage is a good goal to strive for, even if it’s not always practical to reach it. - Whenever you fix a bug, _write a regression test_. A bug fixed without a regression test is almost certainly going to break again in the future. **[⬆ back to top](#table-of-contents)** @@ -3388,6 +3388,6 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ## Amendments -We encourage you to fork this guide and change the rules to fit your team's style guide. Below, you may list some amendments to the style guide. This allows you to periodically update your style guide without having to deal with merge conflicts. +We encourage you to fork this guide and change the rules to fit your team’s style guide. Below, you may list some amendments to the style guide. This allows you to periodically update your style guide without having to deal with merge conflicts. # }; From c43fc749c4213e4574a4b4a3d0fe8784d5cd5b5e Mon Sep 17 00:00:00 2001 From: Fernando Pasik Date: Tue, 13 Jun 2017 22:06:55 +0100 Subject: [PATCH 020/554] [eslint config] [docs] Remove TODO in prefer-reflect as it's deprecated --- packages/eslint-config-airbnb-base/rules/es6.js | 1 - 1 file changed, 1 deletion(-) diff --git a/packages/eslint-config-airbnb-base/rules/es6.js b/packages/eslint-config-airbnb-base/rules/es6.js index 8b7ac24d14..14d777e640 100644 --- a/packages/eslint-config-airbnb-base/rules/es6.js +++ b/packages/eslint-config-airbnb-base/rules/es6.js @@ -124,7 +124,6 @@ module.exports = { // suggest using Reflect methods where applicable // http://eslint.org/docs/rules/prefer-reflect - // TODO: enable? 'prefer-reflect': 'off', // use rest parameters instead of arguments From 4499ee0094239c1e02506ee30c2a3945aa032591 Mon Sep 17 00:00:00 2001 From: Felipe Vargas Date: Mon, 12 Jun 2017 15:41:11 -0700 Subject: [PATCH 021/554] [guide] No arrow function implicit return with side effects --- README.md | 30 ++++++++++++++++++++++++++---- 1 file changed, 26 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 69a7b9982f..8ff1a8f2ce 100644 --- a/README.md +++ b/README.md @@ -369,7 +369,7 @@ Other Style Guides ``` - - [4.5](#arrays--callback-return) 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](#arrows--implicit-return). eslint: [`array-callback-return`](http://eslint.org/docs/rules/array-callback-return) + - [4.5](#arrays--callback-return) Use return statements in array method callbacks. It’s ok to omit the return if the function body consists of a single statement returning an expression without side effects, following [8.2](#arrows--implicit-return). eslint: [`array-callback-return`](http://eslint.org/docs/rules/array-callback-return) ```javascript // good @@ -915,7 +915,7 @@ Other Style Guides ``` - - [8.2](#arrows--implicit-return) If the function body consists of a single expression, omit the braces and use the implicit return. Otherwise, keep the braces and use a `return` statement. eslint: [`arrow-parens`](http://eslint.org/docs/rules/arrow-parens.html), [`arrow-body-style`](http://eslint.org/docs/rules/arrow-body-style.html) jscs: [`disallowParenthesesAroundArrowParam`](http://jscs.info/rule/disallowParenthesesAroundArrowParam), [`requireShorthandArrowFunctions`](http://jscs.info/rule/requireShorthandArrowFunctions) + - [8.2](#arrows--implicit-return) If the function body consists of a single statement returning an [expression](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Expressions_and_Operators#Expressions) without side effects, omit the braces and use the implicit return. Otherwise, keep the braces and use a `return` statement. eslint: [`arrow-parens`](http://eslint.org/docs/rules/arrow-parens.html), [`arrow-body-style`](http://eslint.org/docs/rules/arrow-body-style.html) jscs: [`disallowParenthesesAroundArrowParam`](http://jscs.info/rule/disallowParenthesesAroundArrowParam), [`requireShorthandArrowFunctions`](http://jscs.info/rule/requireShorthandArrowFunctions) > Why? Syntactic sugar. It reads well when multiple functions are chained together. @@ -939,6 +939,24 @@ Other Style Guides [1, 2, 3].map((number, index) => ({ [index]: number, })); + + // No implicit return with side effects + function foo(callback) { + const val = callback(); + if (val === true) { + // Do something if callback returns true + } + } + + let bool = false; + + // bad + foo(() => bool = true); + + // good + foo(() => { + bool = true; + } ``` @@ -1354,7 +1372,9 @@ Other Style Guides // good let sum = 0; - numbers.forEach(num => sum += num); + numbers.forEach((num) => { + sum += num; + ); sum === 15; // best (use the functional force) @@ -1369,7 +1389,9 @@ Other Style Guides // good const increasedByOne = []; - numbers.forEach(num => increasedByOne.push(num + 1)); + numbers.forEach((num) => { + increasedByOne.push(num + 1); + ); // best (keeping it functional) const increasedByOne = numbers.map(num => num + 1); From cd4ec6245ef0b3d3fcb9bbef89bf34ea0ec0c7fb Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Wed, 14 Jun 2017 12:09:46 -0700 Subject: [PATCH 022/554] [guide] change more straight quotes to curly quotes --- README.md | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/README.md b/README.md index 8ff1a8f2ce..21e17fae7e 100644 --- a/README.md +++ b/README.md @@ -97,7 +97,7 @@ Other Style Guides - [2.1](#references--prefer-const) Use `const` for all of your references; avoid using `var`. eslint: [`prefer-const`](http://eslint.org/docs/rules/prefer-const.html), [`no-const-assign`](http://eslint.org/docs/rules/no-const-assign.html) - > Why? This ensures that you can't reassign your references, which can lead to bugs and difficult to comprehend code. + > Why? This ensures that you can’t reassign your references, which can lead to bugs and difficult to comprehend code. ```javascript // bad @@ -708,7 +708,7 @@ Other Style Guides ```javascript // really bad function handleThings(opts) { - // No! We shouldn't mutate function arguments. + // No! We shouldn’t mutate function arguments. // Double bad: if opts is falsy it'll be set to an object which may // be what you want but it can introduce subtle bugs. opts = opts || {}; @@ -838,7 +838,7 @@ Other Style Guides - [7.14](#functions--spread-vs-apply) Prefer the use of the spread operator `...` to call variadic functions. eslint: [`prefer-spread`](http://eslint.org/docs/rules/prefer-spread) - > Why? It’s cleaner, you don't need to supply a context, and you can not easily compose `new` with `apply`. + > Why? It’s cleaner, you don’t need to supply a context, and you can not easily compose `new` with `apply`. ```javascript // bad @@ -1354,7 +1354,7 @@ Other Style Guides ## Iterators and Generators - - [11.1](#iterators--nope) Don't use iterators. Prefer JavaScript’s higher-order functions instead of loops like `for-in` or `for-of`. eslint: [`no-iterator`](http://eslint.org/docs/rules/no-iterator.html) [`no-restricted-syntax`](http://eslint.org/docs/rules/no-restricted-syntax) + - [11.1](#iterators--nope) Don’t use iterators. Prefer JavaScript’s higher-order functions instead of loops like `for-in` or `for-of`. eslint: [`no-iterator`](http://eslint.org/docs/rules/no-iterator.html) [`no-restricted-syntax`](http://eslint.org/docs/rules/no-restricted-syntax) > Why? This enforces our immutable rule. Dealing with pure functions that return values is easier to reason about than side effects. @@ -1398,9 +1398,9 @@ Other Style Guides ``` - - [11.2](#generators--nope) Don't use generators for now. + - [11.2](#generators--nope) Don’t use generators for now. - > Why? They don't transpile well to ES5. + > Why? They don’t transpile well to ES5. - [11.3](#generators--spacing) If you must use generators, or if you disregard [our advice](#generators--nope), make sure their function signature is spaced properly. eslint: [`generator-star-spacing`](http://eslint.org/docs/rules/generator-star-spacing) @@ -1602,7 +1602,7 @@ Other Style Guides } ``` - - [13.5](#variables--no-chain-assignment) Don't chain variable assignments. + - [13.5](#variables--no-chain-assignment) Don’t chain variable assignments. > Why? Chaining variable assignments creates implicit global variables. @@ -1676,7 +1676,7 @@ Other Style Guides - [14.1](#hoisting--about) `var` declarations get hoisted to the top of their scope, their assignment does not. `const` and `let` declarations are blessed with a new concept called [Temporal Dead Zones (TDZ)](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/let#Temporal_dead_zone_and_errors_with_let). It’s important to know why [typeof is no longer safe](http://es-discourse.com/t/why-typeof-is-no-longer-safe/15). ```javascript - // we know this wouldn't work (assuming there + // we know this wouldn’t work (assuming there // is no notDefined global variable) function example() { console.log(notDefined); // => throws a ReferenceError @@ -2147,7 +2147,7 @@ Other Style Guides constructor() { super(); - // FIXME: shouldn't use a global here + // FIXME: shouldn’t use a global here total = 0; } } @@ -2535,7 +2535,7 @@ Other Style Guides - [20.2](#commas--dangling) Additional trailing comma: **Yup.** eslint: [`comma-dangle`](http://eslint.org/docs/rules/comma-dangle.html) jscs: [`requireTrailingComma`](http://jscs.info/rule/requireTrailingComma) - > Why? This leads to cleaner git diffs. Also, transpilers like Babel will remove the additional trailing comma in the transpiled code which means you don't have to worry about the [trailing comma problem](https://github.com/airbnb/javascript/blob/es5-deprecated/es5/README.md#commas) in legacy browsers. + > Why? This leads to cleaner git diffs. Also, transpilers like Babel will remove the additional trailing comma in the transpiled code which means you don’t have to worry about the [trailing comma problem](https://github.com/airbnb/javascript/blob/es5-deprecated/es5/README.md#commas) in legacy browsers. ```diff // bad - git diff without trailing comma @@ -2674,7 +2674,7 @@ Other Style Guides const totalScore = this.reviewScore + ''; // invokes this.reviewScore.valueOf() // bad - const totalScore = this.reviewScore.toString(); // isn't guaranteed to return a string + const totalScore = this.reviewScore.toString(); // isn’t guaranteed to return a string // good const totalScore = String(this.reviewScore); @@ -2804,7 +2804,7 @@ Other Style Guides - [23.4](#naming--leading-underscore) Do not use trailing or leading underscores. eslint: [`no-underscore-dangle`](http://eslint.org/docs/rules/no-underscore-dangle.html) jscs: [`disallowDanglingUnderscores`](http://jscs.info/rule/disallowDanglingUnderscores) - > Why? JavaScript does not have the concept of privacy in terms of properties or methods. Although a leading underscore is a common convention to mean “private”, in fact, these properties are fully public, and as such, are part of your public API contract. This convention might lead developers to wrongly think that a change won't count as breaking, or that tests aren't needed. tl;dr: if you want something to be “private”, it must not be observably present. + > Why? JavaScript does not have the concept of privacy in terms of properties or methods. Although a leading underscore is a common convention to mean “private”, in fact, these properties are fully public, and as such, are part of your public API contract. This convention might lead developers to wrongly think that a change won’t count as breaking, or that tests aren’t needed. tl;dr: if you want something to be “private”, it must not be observably present. ```javascript // bad @@ -2817,7 +2817,7 @@ Other Style Guides ``` - - [23.5](#naming--self-this) Don't save references to `this`. Use arrow functions or [Function#bind](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/bind). jscs: [`disallowNodeTypes`](http://jscs.info/rule/disallowNodeTypes) + - [23.5](#naming--self-this) Don’t save references to `this`. Use arrow functions or [Function#bind](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/bind). jscs: [`disallowNodeTypes`](http://jscs.info/rule/disallowNodeTypes) ```javascript // bad @@ -3234,7 +3234,7 @@ Other Style Guides - [Third Party JavaScript](https://www.manning.com/books/third-party-javascript) - Ben Vinegar and Anton Kovalyov - [Effective JavaScript: 68 Specific Ways to Harness the Power of JavaScript](http://amzn.com/0321812182) - David Herman - [Eloquent JavaScript](http://eloquentjavascript.net/) - Marijn Haverbeke - - [You Don't Know JS: ES6 & Beyond](http://shop.oreilly.com/product/0636920033769.do) - Kyle Simpson + - [You Don’t Know JS: ES6 & Beyond](http://shop.oreilly.com/product/0636920033769.do) - Kyle Simpson **Blogs** From 7bb8c9f905b4bc34e57ef39002cbfb32818cd003 Mon Sep 17 00:00:00 2001 From: Ben Schroeder Date: Wed, 14 Jun 2017 09:13:43 -0400 Subject: [PATCH 023/554] [guide] Fix iterator code example error The first "good" example was missing a closing bracket (line 1377). --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 21e17fae7e..6a64de53af 100644 --- a/README.md +++ b/README.md @@ -1374,7 +1374,7 @@ Other Style Guides let sum = 0; numbers.forEach((num) => { sum += num; - ); + }); sum === 15; // best (use the functional force) From 0c9e22e039d7a1ad8a522768991db2ad431d3d69 Mon Sep 17 00:00:00 2001 From: Rahul Gandhi Date: Sat, 17 Jun 2017 18:18:40 +0530 Subject: [PATCH 024/554] [guide] replacing undefined with ReferenceError Fixes #1457 --- README.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 6a64de53af..06347f5708 100644 --- a/README.md +++ b/README.md @@ -1616,7 +1616,7 @@ Other Style Guides let a = b = c = 1; }()); - console.log(a); // undefined + console.log(a); // throws ReferenceError console.log(b); // 1 console.log(c); // 1 @@ -1627,9 +1627,9 @@ Other Style Guides let c = a; }()); - console.log(a); // undefined - console.log(b); // undefined - console.log(c); // undefined + console.log(a); // throws ReferenceError + console.log(b); // throws ReferenceError + console.log(c); // throws ReferenceError // the same applies for `const` ``` From 3a9e1c830f9141207322254fc83ec3efae7b790b Mon Sep 17 00:00:00 2001 From: elmehri Date: Thu, 15 Jun 2017 16:52:48 +0100 Subject: [PATCH 025/554] [eslint config] [base] [patch] Support Protractor config files in import/no-extraneous-dependencies --- packages/eslint-config-airbnb-base/rules/imports.js | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/eslint-config-airbnb-base/rules/imports.js b/packages/eslint-config-airbnb-base/rules/imports.js index 3b6c6cef60..ab324b79ca 100644 --- a/packages/eslint-config-airbnb-base/rules/imports.js +++ b/packages/eslint-config-airbnb-base/rules/imports.js @@ -83,6 +83,7 @@ module.exports = { '**/gulpfile.js', // gulp config '**/gulpfile.*.js', // gulp config '**/Gruntfile', // grunt config + '**/protractor.conf.*.js', // protractor config ], optionalDependencies: false, }], From 57ff032b0740ba2a46af4bc40cf5638a3e62a365 Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Sun, 18 Jun 2017 09:27:33 -0700 Subject: [PATCH 026/554] [eslint config] [base] [minor] `no-return-assign`: strengthen linting against returning assignments. --- packages/eslint-config-airbnb-base/rules/best-practices.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/eslint-config-airbnb-base/rules/best-practices.js b/packages/eslint-config-airbnb-base/rules/best-practices.js index c9f729c75f..3d97bb6e55 100644 --- a/packages/eslint-config-airbnb-base/rules/best-practices.js +++ b/packages/eslint-config-airbnb-base/rules/best-practices.js @@ -205,7 +205,7 @@ module.exports = { }], // disallow use of assignment in return statement - 'no-return-assign': 'error', + 'no-return-assign': ['error', 'always'], // disallow redundant `return await` 'no-return-await': 'error', From 4380284b05337f6e48798ff4fd76ab606d5adf94 Mon Sep 17 00:00:00 2001 From: Jason Ellis Date: Tue, 20 Jun 2017 09:37:19 -0500 Subject: [PATCH 027/554] [guide] Add missing close parenthesis and semicolon to section 8.2 --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 06347f5708..e59dc9b940 100644 --- a/README.md +++ b/README.md @@ -956,7 +956,7 @@ Other Style Guides // good foo(() => { bool = true; - } + }); ``` From cd720b4c7bededa4edda232e9e9e6b5e3b5a438d Mon Sep 17 00:00:00 2001 From: Dan Dascalescu Date: Thu, 22 Jun 2017 09:19:08 -0700 Subject: [PATCH 028/554] [eslint config] [*] [docs] add yarn instructions Fixes #1462. --- packages/eslint-config-airbnb-base/README.md | 8 +++++--- packages/eslint-config-airbnb/README.md | 4 +++- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/packages/eslint-config-airbnb-base/README.md b/packages/eslint-config-airbnb-base/README.md index e27f3f3431..968cec06cd 100644 --- a/packages/eslint-config-airbnb-base/README.md +++ b/packages/eslint-config-airbnb-base/README.md @@ -2,7 +2,7 @@ [![npm version](https://badge.fury.io/js/eslint-config-airbnb-base.svg)](http://badge.fury.io/js/eslint-config-airbnb-base) -This package provides Airbnb's base JS .eslintrc as an extensible shared config. +This package provides Airbnb's base JS .eslintrc (without React plugins) as an extensible shared config. ## Usage @@ -12,13 +12,15 @@ We export two ESLint configurations for your usage. Our default export contains all of our ESLint rules, including ECMAScript 6+. It requires `eslint` and `eslint-plugin-import`. +If you use yarn, run `yarn add --dev eslint-config-airbnb-base eslint-plugin-import`, or see below for npm instructions. + 1. Install the correct versions of each package, which are listed by the command: ```sh npm info "eslint-config-airbnb-base@latest" peerDependencies ``` - Linux/OSX users can simply run + Linux/OSX users can run ```sh ( export PKG=eslint-config-airbnb-base; @@ -45,7 +47,7 @@ Our default export contains all of our ESLint rules, including ECMAScript 6+. It npm install --save-dev eslint-config-airbnb-base eslint@^#.#.# eslint-plugin-import@^#.#.# ``` -2. Add `"extends": "airbnb-base"` to your .eslintrc +2. Add `"extends": "airbnb-base"` to your .eslintrc. ### eslint-config-airbnb-base/legacy diff --git a/packages/eslint-config-airbnb/README.md b/packages/eslint-config-airbnb/README.md index 173e5c324c..7996b4ac56 100644 --- a/packages/eslint-config-airbnb/README.md +++ b/packages/eslint-config-airbnb/README.md @@ -10,7 +10,9 @@ We export three ESLint configurations for your usage. ### eslint-config-airbnb -Our default export contains all of our ESLint rules, including ECMAScript 6+ and React. It requires `eslint`, `eslint-plugin-import`, `eslint-plugin-react`, and `eslint-plugin-jsx-a11y`. +Our default export contains all of our ESLint rules, including ECMAScript 6+ and React. It requires `eslint`, `eslint-plugin-import`, `eslint-plugin-react`, and `eslint-plugin-jsx-a11y`. If you don't need React, see [eslint-config-airbnb-base](https://npmjs.com/eslint-config-airbnb-base). + +If you use yarn, run `yarn add --dev eslint-config-airbnb-base eslint-plugin-import eslint-plugin-react eslint-plugin-jsx-a11`, and see below for npm instructions. 1. Install the correct versions of each package, which are listed by the command: From 2666db559dc0ef41887a1138cff4f59b3879892a Mon Sep 17 00:00:00 2001 From: Dan Dascalescu Date: Fri, 23 Jun 2017 22:16:35 -0700 Subject: [PATCH 029/554] Fix typo in a11y for yarn --- packages/eslint-config-airbnb/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/eslint-config-airbnb/README.md b/packages/eslint-config-airbnb/README.md index 7996b4ac56..a3a7c71340 100644 --- a/packages/eslint-config-airbnb/README.md +++ b/packages/eslint-config-airbnb/README.md @@ -12,7 +12,7 @@ We export three ESLint configurations for your usage. Our default export contains all of our ESLint rules, including ECMAScript 6+ and React. It requires `eslint`, `eslint-plugin-import`, `eslint-plugin-react`, and `eslint-plugin-jsx-a11y`. If you don't need React, see [eslint-config-airbnb-base](https://npmjs.com/eslint-config-airbnb-base). -If you use yarn, run `yarn add --dev eslint-config-airbnb-base eslint-plugin-import eslint-plugin-react eslint-plugin-jsx-a11`, and see below for npm instructions. +If you use yarn, run `yarn add --dev eslint-config-airbnb-base eslint-plugin-import eslint-plugin-react eslint-plugin-jsx-a11y`, and see below for npm instructions. 1. Install the correct versions of each package, which are listed by the command: From 84487061205285be7aa2e22a8ba704da4d99e6cc Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Tue, 4 Jul 2017 12:32:01 -0700 Subject: [PATCH 030/554] [eslint config] [deps] update `babel-preset-airbnb`, `eslint-find-rules`, `eslint-plugin-import`, `eslint-plugin-jsx-a11y`, `eslint-plugin-react`, `tape` --- packages/eslint-config-airbnb/package.json | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/packages/eslint-config-airbnb/package.json b/packages/eslint-config-airbnb/package.json index dd5c99a010..993b476495 100644 --- a/packages/eslint-config-airbnb/package.json +++ b/packages/eslint-config-airbnb/package.json @@ -49,24 +49,24 @@ "eslint-config-airbnb-base": "^11.2.0" }, "devDependencies": { - "babel-preset-airbnb": "^2.2.3", + "babel-preset-airbnb": "^2.4.0", "babel-tape-runner": "^2.0.1", "editorconfig-tools": "^0.1.1", "eslint": "^3.19.0", - "eslint-find-rules": "^1.14.3", - "eslint-plugin-import": "^2.2.0", - "eslint-plugin-jsx-a11y": "^5.0.3", - "eslint-plugin-react": "^7.0.1", + "eslint-find-rules": "^3.1.1", + "eslint-plugin-import": "^2.6.1", + "eslint-plugin-jsx-a11y": "^5.1.1", + "eslint-plugin-react": "^7.1.0", "in-publish": "^2.0.0", "react": ">= 0.13.0", "safe-publish-latest": "^1.1.1", - "tape": "^4.6.3" + "tape": "^4.7.0" }, "peerDependencies": { "eslint": "^3.19.0", - "eslint-plugin-jsx-a11y": "^5.0.3", - "eslint-plugin-import": "^2.2.0", - "eslint-plugin-react": "^7.0.1" + "eslint-plugin-jsx-a11y": "^5.1.1", + "eslint-plugin-import": "^2.6.1", + "eslint-plugin-react": "^7.1.0" }, "engines": { "node": ">= 4" From c68fa632624f088b4bbe81192a50554b0c6af970 Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Tue, 4 Jul 2017 12:36:18 -0700 Subject: [PATCH 031/554] [eslint config] v15.0.2 --- packages/eslint-config-airbnb/CHANGELOG.md | 5 +++++ packages/eslint-config-airbnb/package.json | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/packages/eslint-config-airbnb/CHANGELOG.md b/packages/eslint-config-airbnb/CHANGELOG.md index 4900db6c74..ca35490985 100644 --- a/packages/eslint-config-airbnb/CHANGELOG.md +++ b/packages/eslint-config-airbnb/CHANGELOG.md @@ -1,3 +1,8 @@ +15.0.2 / 2017-07-04 +================== +- [fix] jsx should be enabled via parserOptions, not via a root ecmaFeatures +- [deps] update `babel-preset-airbnb`, `eslint-find-rules`, `eslint-plugin-import`, `eslint-plugin-jsx-a11y`, `eslint-plugin-react`, `tape` + 15.0.1 / 2017-05-15 ================== - [fix] set default React version to 15.0 (#1415) diff --git a/packages/eslint-config-airbnb/package.json b/packages/eslint-config-airbnb/package.json index 993b476495..7d4f0b941e 100644 --- a/packages/eslint-config-airbnb/package.json +++ b/packages/eslint-config-airbnb/package.json @@ -1,6 +1,6 @@ { "name": "eslint-config-airbnb", - "version": "15.0.1", + "version": "15.0.2", "description": "Airbnb's ESLint config, following our styleguide", "main": "index.js", "scripts": { From d806859320b198eeb850966ed5d091828bc55b64 Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Tue, 4 Jul 2017 12:49:09 -0700 Subject: [PATCH 032/554] [Tests] run prepublish tests as allowed failures --- .travis.yml | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/.travis.yml b/.travis.yml index d28e6fd12e..cc7f3495a7 100644 --- a/.travis.yml +++ b/.travis.yml @@ -5,20 +5,28 @@ node_js: - "6" - "5" - "4" -env: - - 'TEST_DIR=packages/eslint-config-airbnb' - - 'TEST_DIR=packages/eslint-config-airbnb-base' before_install: - - 'cd $TEST_DIR' - 'if [ "${TRAVIS_NODE_VERSION}" = "0.6" ]; then npm install -g npm@1.3 ; elif [ "${TRAVIS_NODE_VERSION}" != "0.9" ]; then case "$(npm --version)" in 1.*) npm install -g npm@1.4.28 ;; 2.*) npm install -g npm@2 ;; esac ; fi' - 'if [ "${TRAVIS_NODE_VERSION%${TRAVIS_NODE_VERSION#[0-9]}}" = "0" ] || [ "${TRAVIS_NODE_VERSION:0:4}" = "iojs" ]; then npm install -g npm@4.5 ; elif [ "${TRAVIS_NODE_VERSION}" != "0.6" ] && [ "${TRAVIS_NODE_VERSION}" != "0.9" ]; then npm install -g npm; fi' install: + - 'cd "packages/${PACKAGE}"' - 'if [ "${TRAVIS_NODE_VERSION}" = "0.6" ]; then nvm install 0.8 && npm install -g npm@1.3 && npm install -g npm@1.4.28 && npm install -g npm@2 && npm install && nvm use "${TRAVIS_NODE_VERSION}"; else npm install; fi;' script: - - 'npm run travis' + - 'if [ -n "${PREPUBLISH-}" ]; then npm run prepublish; else npm run travis; fi' sudo: false +env: + matrix: + - 'TEST=true PACKAGE=eslint-config-airbnb' + - 'TEST=true PACKAGE=eslint-config-airbnb-base' matrix: fast_finish: true + include: + - node_js: "node" + env: PREPUBLISH=true PACKAGE=eslint-config-airbnb + - node_js: "node" + env: PREPUBLISH=true PACKAGE=eslint-config-airbnb-base allow_failures: - node_js: "7" - node_js: "5" + - env: PREPUBLISH=true PACKAGE=eslint-config-airbnb + - env: PREPUBLISH=true PACKAGE=eslint-config-airbnb-base From e5b403cd49aa2aa44a592d8fdfe0b6dd61ff9553 Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Tue, 4 Jul 2017 14:36:47 -0700 Subject: [PATCH 033/554] [eslint config] [base] [deps] update `babel-preset-airbnb`, `eslint-find-rules`, `eslint-plugin-import`, `tape` --- packages/eslint-config-airbnb-base/package.json | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/packages/eslint-config-airbnb-base/package.json b/packages/eslint-config-airbnb-base/package.json index 92fa71298c..2424f2a857 100644 --- a/packages/eslint-config-airbnb-base/package.json +++ b/packages/eslint-config-airbnb-base/package.json @@ -46,19 +46,19 @@ }, "homepage": "https://github.com/airbnb/javascript", "devDependencies": { - "babel-preset-airbnb": "^2.2.3", + "babel-preset-airbnb": "^2.4.0", "babel-tape-runner": "^2.0.1", "editorconfig-tools": "^0.1.1", "eslint": "^3.19.0", - "eslint-find-rules": "^1.14.3", - "eslint-plugin-import": "^2.2.0", + "eslint-find-rules": "^3.1.1", + "eslint-plugin-import": "^2.6.1", "in-publish": "^2.0.0", "safe-publish-latest": "^1.1.1", - "tape": "^4.6.3" + "tape": "^4.7.0" }, "peerDependencies": { "eslint": "^3.19.0", - "eslint-plugin-import": "^2.2.0" + "eslint-plugin-import": "^2.6.1" }, "engines": { "node": ">= 4" From 7768e01625fd7136872dca2a8bf7ef407fd19df5 Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Tue, 4 Jul 2017 14:30:29 -0700 Subject: [PATCH 034/554] [eslint config] [*] Add missing rules --- .../eslint-config-airbnb-base/rules/imports.js | 11 +++++++++++ packages/eslint-config-airbnb/rules/react-a11y.js | 9 +++++++++ packages/eslint-config-airbnb/rules/react.js | 15 +++++++++++++++ 3 files changed, 35 insertions(+) diff --git a/packages/eslint-config-airbnb-base/rules/imports.js b/packages/eslint-config-airbnb-base/rules/imports.js index ab324b79ca..0150724f6b 100644 --- a/packages/eslint-config-airbnb-base/rules/imports.js +++ b/packages/eslint-config-airbnb-base/rules/imports.js @@ -191,5 +191,16 @@ module.exports = { // Prevent importing the default as if it were named // https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/no-named-default.md 'import/no-named-default': 'error', + + // Reports if a module's default export is unnamed + // https://github.com/benmosher/eslint-plugin-import/blob/d9b712ac7fd1fddc391f7b234827925c160d956f/docs/rules/no-anonymous-default-export.md + 'import/no-anonymous-default-export': ['off', { + allowArray: false, + allowArrowFunction: false, + allowAnonymousClass: false, + allowAnonymousFunction: false, + allowLiteral: false, + allowObject: false, + }], }, }; diff --git a/packages/eslint-config-airbnb/rules/react-a11y.js b/packages/eslint-config-airbnb/rules/react-a11y.js index 77fcb93d9c..4cdf1cf39c 100644 --- a/packages/eslint-config-airbnb/rules/react-a11y.js +++ b/packages/eslint-config-airbnb/rules/react-a11y.js @@ -188,5 +188,14 @@ module.exports = { tags: [], roles: ['tabpanel'], }], + + // ensure tags are valid + // https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/0745af376cdc8686d85a361ce36952b1fb1ccf6e/docs/rules/anchor-is-valid.md + // TODO: enable, semver-major + 'jsx-a11y/anchor-is-valid': ['off', { + components: ['Link'], + specialLink: [], + aspects: ['noHref', 'invalidHref', 'preferButton'], + }], }, }; diff --git a/packages/eslint-config-airbnb/rules/react.js b/packages/eslint-config-airbnb/rules/react.js index 4392d678ea..96e5f4a75d 100644 --- a/packages/eslint-config-airbnb/rules/react.js +++ b/packages/eslint-config-airbnb/rules/react.js @@ -48,6 +48,11 @@ module.exports = { // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-closing-bracket-location.md 'react/jsx-closing-bracket-location': ['error', 'line-aligned'], + // Validate closing tag location in JSX + // https://github.com/yannickcr/eslint-plugin-react/blob/9e13ae2c51e44872b45cc15bf1ac3a72105bdd0e/docs/rules/jsx-closing-tag-location.md + // TODO: enable, semver-minor + 'react/jsx-closing-tag-location': 'off', + // Enforce or disallow spaces inside of curly braces in JSX attributes // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-curly-spacing.md 'react/jsx-curly-spacing': ['error', 'never', { allowMultiline: true }], @@ -315,6 +320,16 @@ module.exports = { // Prevent void DOM elements from receiving children // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/void-dom-elements-no-children.md 'react/void-dom-elements-no-children': 'error', + + // Enforce all defaultProps have a corresponding non-required PropType + // https://github.com/yannickcr/eslint-plugin-react/blob/9e13ae2c51e44872b45cc15bf1ac3a72105bdd0e/docs/rules/default-props-match-prop-types.md + // TODO: enable, semver-minor + 'react/default-props-match-prop-types': ['off', { allowRequiredDefaults: false }], + + // Prevent usage of shouldComponentUpdate when extending React.PureComponent + // https://github.com/yannickcr/eslint-plugin-react/blob/9e13ae2c51e44872b45cc15bf1ac3a72105bdd0e/docs/rules/no-redundant-should-component-update.md + // TODO: enable, semver-major + 'react/no-redundant-should-component-update': 'off', }, settings: { From fc7fae620f625701a5614fb9cf9ec1e9c49bcc70 Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Tue, 4 Jul 2017 16:15:18 -0700 Subject: [PATCH 035/554] [Tests] add pretravis/posttravis scripts --- .travis.yml | 2 +- packages/eslint-config-airbnb-base/package.json | 4 +++- packages/eslint-config-airbnb/package.json | 4 +++- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index cc7f3495a7..27a719227a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -12,7 +12,7 @@ install: - 'cd "packages/${PACKAGE}"' - 'if [ "${TRAVIS_NODE_VERSION}" = "0.6" ]; then nvm install 0.8 && npm install -g npm@1.3 && npm install -g npm@1.4.28 && npm install -g npm@2 && npm install && nvm use "${TRAVIS_NODE_VERSION}"; else npm install; fi;' script: - - 'if [ -n "${PREPUBLISH-}" ]; then npm run prepublish; else npm run travis; fi' + - 'if [ -n "${PREPUBLISH-}" ]; then npm run pretravis && npm run prepublish && npm run posttravis; else npm run travis; fi' sudo: false env: matrix: diff --git a/packages/eslint-config-airbnb-base/package.json b/packages/eslint-config-airbnb-base/package.json index 2424f2a857..70ff6a46b4 100644 --- a/packages/eslint-config-airbnb-base/package.json +++ b/packages/eslint-config-airbnb-base/package.json @@ -10,7 +10,9 @@ "prepublish": "(in-install || eslint-find-rules --unused) && (not-in-publish || npm test) && safe-publish-latest", "pretest": "npm run --silent lint", "test": "npm run --silent tests-only", - "travis": "npm run --silent test" + "pretravis": ":", + "travis": "npm run --silent test", + "posttravis": ":" }, "repository": { "type": "git", diff --git a/packages/eslint-config-airbnb/package.json b/packages/eslint-config-airbnb/package.json index 7d4f0b941e..7c5df67583 100644 --- a/packages/eslint-config-airbnb/package.json +++ b/packages/eslint-config-airbnb/package.json @@ -10,7 +10,9 @@ "prepublish": "(in-install || eslint-find-rules --unused) && (not-in-publish || npm test) && safe-publish-latest", "pretest": "npm run --silent lint", "test": "npm run --silent tests-only", - "travis": "cd ../eslint-config-airbnb-base && npm install && npm link && cd - && npm link eslint-config-airbnb-base && npm run --silent test ; npm unlink eslint-config-airbnb-base >/dev/null &" + "pretravis": "cd ../eslint-config-airbnb-base && npm install && npm link && cd - && npm link --no-save eslint-config-airbnb-base", + "travis": "npm run --silent test", + "posttravis": "npm unlink eslint-config-airbnb-base >/dev/null &" }, "repository": { "type": "git", From 22c97fa6787ce7df7124782bea1b3fe29fe76e01 Mon Sep 17 00:00:00 2001 From: Valentina Pegler Date: Wed, 12 Jul 2017 18:12:38 +0200 Subject: [PATCH 036/554] [inthewild] Add LEINWAND to the organizations list --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index e59dc9b940..d2098852ff 100644 --- a/README.md +++ b/README.md @@ -3306,6 +3306,7 @@ Other Style Guides - **JSSolutions**: [JSSolutions/javascript](https://github.com/JSSolutions/javascript) - **KickorStick**: [kickorstick/javascript](https://github.com/kickorstick/javascript) - **Kinetica Solutions**: [kinetica/javascript](https://github.com/kinetica/Javascript-style-guide) + - **LEINWAND**: [LEINWAND/javascript](https://github.com/LEINWAND/javascript) - **Lonely Planet**: [lonelyplanet/javascript](https://github.com/lonelyplanet/javascript) - **M2GEN**: [M2GEN/javascript](https://github.com/M2GEN/javascript) - **Mighty Spring**: [mightyspring/javascript](https://github.com/mightyspring/javascript) From 6331c2c3e2751b02af2636bce88bbb4a5489e9a5 Mon Sep 17 00:00:00 2001 From: Chaitanya Mutyala Date: Wed, 12 Jul 2017 10:43:11 -0700 Subject: [PATCH 037/554] [guide] Typo fix on example --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index d2098852ff..0a9103e958 100644 --- a/README.md +++ b/README.md @@ -1391,7 +1391,7 @@ Other Style Guides const increasedByOne = []; numbers.forEach((num) => { increasedByOne.push(num + 1); - ); + }); // best (keeping it functional) const increasedByOne = numbers.map(num => num + 1); From cdc1c4fb76a67827c0aa52fd67cdda122828f583 Mon Sep 17 00:00:00 2001 From: Chris Atkin Date: Sun, 23 Jul 2017 14:30:32 +0100 Subject: [PATCH 038/554] [inthewild] Add Sainsbury's Supermarkets to the organizations list --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 0a9103e958..0fbd0ffe8f 100644 --- a/README.md +++ b/README.md @@ -3327,6 +3327,7 @@ Other Style Guides - **React**: [facebook.github.io/react/contributing/how-to-contribute.html#style-guide](https://facebook.github.io/react/contributing/how-to-contribute.html#style-guide) - **REI**: [reidev/js-style-guide](https://github.com/rei/code-style-guides/blob/master/docs/javascript.md) - **Ripple**: [ripple/javascript-style-guide](https://github.com/ripple/javascript-style-guide) + - **Sainsbury's Supermarkets**: [github/jsainsburyplc](https://github.com/jsainsburyplc) - **SeekingAlpha**: [seekingalpha/javascript-style-guide](https://github.com/seekingalpha/javascript-style-guide) - **Shutterfly**: [shutterfly/javascript](https://github.com/shutterfly/javascript) - **Sourcetoad**: [sourcetoad/javascript](https://github.com/sourcetoad/javascript) From b4995b6416faa714299a39976a0b7107ad7b2afe Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Sun, 23 Jul 2017 13:04:22 -0700 Subject: [PATCH 039/554] [eslint config] [base] revert breaking part of #1420 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit I’ll re-enable it in the next major. --- packages/eslint-config-airbnb-base/rules/variables.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/eslint-config-airbnb-base/rules/variables.js b/packages/eslint-config-airbnb-base/rules/variables.js index fc0b5b11d4..fe38ea5d60 100644 --- a/packages/eslint-config-airbnb-base/rules/variables.js +++ b/packages/eslint-config-airbnb-base/rules/variables.js @@ -16,7 +16,8 @@ module.exports = { 'no-label-var': 'error', // disallow specific globals - 'no-restricted-globals': ['error'].concat(restrictedGlobals), + // TODO: enable, semver-major + 'no-restricted-globals': ['off'].concat(restrictedGlobals), // disallow declaration of variables already declared in the outer scope 'no-shadow': 'error', From 399420f46f1c1161106655ade5f7c9b95723574b Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Sun, 23 Jul 2017 10:39:12 -0700 Subject: [PATCH 040/554] [Tests] add an explicit eslint version to travis.yml --- .travis.yml | 13 +++++++------ packages/eslint-config-airbnb-base/package.json | 2 +- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/.travis.yml b/.travis.yml index 27a719227a..ae03a0ee56 100644 --- a/.travis.yml +++ b/.travis.yml @@ -11,22 +11,23 @@ before_install: install: - 'cd "packages/${PACKAGE}"' - 'if [ "${TRAVIS_NODE_VERSION}" = "0.6" ]; then nvm install 0.8 && npm install -g npm@1.3 && npm install -g npm@1.4.28 && npm install -g npm@2 && npm install && nvm use "${TRAVIS_NODE_VERSION}"; else npm install; fi;' + - 'if [ -n "${ESLINT}" ]; then npm install --no-save "eslint@${ESLINT}"; fi' script: - 'if [ -n "${PREPUBLISH-}" ]; then npm run pretravis && npm run prepublish && npm run posttravis; else npm run travis; fi' sudo: false env: matrix: - - 'TEST=true PACKAGE=eslint-config-airbnb' - - 'TEST=true PACKAGE=eslint-config-airbnb-base' + - 'TEST=true ESLINT=3 PACKAGE=eslint-config-airbnb' + - 'TEST=true ESLINT=3 PACKAGE=eslint-config-airbnb-base' matrix: fast_finish: true include: - node_js: "node" - env: PREPUBLISH=true PACKAGE=eslint-config-airbnb + env: PREPUBLISH=true ESLINT=3 PACKAGE=eslint-config-airbnb - node_js: "node" - env: PREPUBLISH=true PACKAGE=eslint-config-airbnb-base + env: PREPUBLISH=true ESLINT=3 PACKAGE=eslint-config-airbnb-base allow_failures: - node_js: "7" - node_js: "5" - - env: PREPUBLISH=true PACKAGE=eslint-config-airbnb - - env: PREPUBLISH=true PACKAGE=eslint-config-airbnb-base + - env: PREPUBLISH=true ESLINT=3 PACKAGE=eslint-config-airbnb + - env: PREPUBLISH=true ESLINT=3 PACKAGE=eslint-config-airbnb-base diff --git a/packages/eslint-config-airbnb-base/package.json b/packages/eslint-config-airbnb-base/package.json index 70ff6a46b4..d57b9e579d 100644 --- a/packages/eslint-config-airbnb-base/package.json +++ b/packages/eslint-config-airbnb-base/package.json @@ -51,7 +51,7 @@ "babel-preset-airbnb": "^2.4.0", "babel-tape-runner": "^2.0.1", "editorconfig-tools": "^0.1.1", - "eslint": "^3.19.0", + "eslint": "^4.3.0", "eslint-find-rules": "^3.1.1", "eslint-plugin-import": "^2.6.1", "in-publish": "^2.0.0", From 811392725efde953d8126ed22c3b475e4f8b3ea9 Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Sun, 23 Jul 2017 11:35:51 -0700 Subject: [PATCH 041/554] [Deps] allow eslint v3 or v4; update `eslint-plugin-import` Part of #1447. --- .travis.yml | 4 ++ .../eslint-config-airbnb-base/package.json | 6 +-- .../rules/best-practices.js | 4 +- .../eslint-config-airbnb-base/rules/errors.js | 12 +++++ .../eslint-config-airbnb-base/rules/es6.js | 10 ++++- .../eslint-config-airbnb-base/rules/node.js | 5 +++ .../eslint-config-airbnb-base/rules/style.js | 44 ++++++++++++++++--- 7 files changed, 73 insertions(+), 12 deletions(-) diff --git a/.travis.yml b/.travis.yml index ae03a0ee56..4256a0dcfd 100644 --- a/.travis.yml +++ b/.travis.yml @@ -19,6 +19,7 @@ env: matrix: - 'TEST=true ESLINT=3 PACKAGE=eslint-config-airbnb' - 'TEST=true ESLINT=3 PACKAGE=eslint-config-airbnb-base' + - 'TEST=true ESLINT=4 PACKAGE=eslint-config-airbnb-base' matrix: fast_finish: true include: @@ -26,8 +27,11 @@ matrix: env: PREPUBLISH=true ESLINT=3 PACKAGE=eslint-config-airbnb - node_js: "node" env: PREPUBLISH=true ESLINT=3 PACKAGE=eslint-config-airbnb-base + - node_js: "node" + env: PREPUBLISH=true ESLINT=4 PACKAGE=eslint-config-airbnb-base allow_failures: - node_js: "7" - node_js: "5" - env: PREPUBLISH=true ESLINT=3 PACKAGE=eslint-config-airbnb - env: PREPUBLISH=true ESLINT=3 PACKAGE=eslint-config-airbnb-base + - env: PREPUBLISH=true ESLINT=4 PACKAGE=eslint-config-airbnb-base diff --git a/packages/eslint-config-airbnb-base/package.json b/packages/eslint-config-airbnb-base/package.json index d57b9e579d..8fe35062fd 100644 --- a/packages/eslint-config-airbnb-base/package.json +++ b/packages/eslint-config-airbnb-base/package.json @@ -53,14 +53,14 @@ "editorconfig-tools": "^0.1.1", "eslint": "^4.3.0", "eslint-find-rules": "^3.1.1", - "eslint-plugin-import": "^2.6.1", + "eslint-plugin-import": "^2.7.0", "in-publish": "^2.0.0", "safe-publish-latest": "^1.1.1", "tape": "^4.7.0" }, "peerDependencies": { - "eslint": "^3.19.0", - "eslint-plugin-import": "^2.6.1" + "eslint": "^3.19.0 || ^4.3.0", + "eslint-plugin-import": "^2.7.0" }, "engines": { "node": ">= 4" diff --git a/packages/eslint-config-airbnb-base/rules/best-practices.js b/packages/eslint-config-airbnb-base/rules/best-practices.js index 3d97bb6e55..02ea3e23b3 100644 --- a/packages/eslint-config-airbnb-base/rules/best-practices.js +++ b/packages/eslint-config-airbnb-base/rules/best-practices.js @@ -142,7 +142,9 @@ module.exports = { }], // disallow use of multiple spaces - 'no-multi-spaces': 'error', + 'no-multi-spaces': ['error', { + // ignoreEOLComments: false, // TODO: uncomment once v3 is dropped + }], // disallow use of multiline strings 'no-multi-str': 'error', diff --git a/packages/eslint-config-airbnb-base/rules/errors.js b/packages/eslint-config-airbnb-base/rules/errors.js index 8f618e0661..02befbb5af 100644 --- a/packages/eslint-config-airbnb-base/rules/errors.js +++ b/packages/eslint-config-airbnb-base/rules/errors.js @@ -9,6 +9,16 @@ module.exports = { functions: 'always-multiline', }], + // Enforce “for” loop update clause moving the counter in the right direction + // http://eslint.org/docs/rules/for-direction + // TODO: enable, semver-major until v3 is dropped; semver-minor otherwise + 'for-direction': 'off', + + // Enforces that a return statement is present in property getters + // http://eslint.org/docs/rules/getter-return + // TODO: enable, semver-major when v3 is dropped + 'getter-return': ['off', { allowImplicit: true }], + // Disallow await inside of loops // http://eslint.org/docs/rules/no-await-in-loop 'no-await-in-loop': 'error', @@ -61,6 +71,8 @@ module.exports = { conditionalAssign: true, nestedBinaryExpressions: false, returnAssign: false, + ignoreJSX: 'all', // delegate to eslint-plugin-react + enforceForArrowConditionals: false, }], // disallow unnecessary semicolons diff --git a/packages/eslint-config-airbnb-base/rules/es6.js b/packages/eslint-config-airbnb-base/rules/es6.js index 14d777e640..a77f3a6641 100644 --- a/packages/eslint-config-airbnb-base/rules/es6.js +++ b/packages/eslint-config-airbnb-base/rules/es6.js @@ -112,8 +112,14 @@ module.exports = { // http://eslint.org/docs/rules/prefer-destructuring // TODO: enable 'prefer-destructuring': ['off', { - array: true, - object: true, + VariableDeclarator: { + array: false, + object: true, + }, + AssignmentExpression: { + array: true, + object: true, + }, }, { enforceForRenamedProperties: false, }], diff --git a/packages/eslint-config-airbnb-base/rules/node.js b/packages/eslint-config-airbnb-base/rules/node.js index e4a71a6a5a..d890a67c1b 100644 --- a/packages/eslint-config-airbnb-base/rules/node.js +++ b/packages/eslint-config-airbnb-base/rules/node.js @@ -14,6 +14,11 @@ module.exports = { // enforces error handling in callbacks (node environment) 'handle-callback-err': 'off', + // disallow use of the Buffer() constructor + // http://eslint.org/docs/rules/no-buffer-constructor + // TODO: enable, semver-major + 'no-buffer-constructor': 'off', + // disallow mixing regular variable and require declarations 'no-mixed-requires': ['off', false], diff --git a/packages/eslint-config-airbnb-base/rules/style.js b/packages/eslint-config-airbnb-base/rules/style.js index c617e57fd3..42e820870e 100644 --- a/packages/eslint-config-airbnb-base/rules/style.js +++ b/packages/eslint-config-airbnb-base/rules/style.js @@ -1,5 +1,15 @@ module.exports = { rules: { + // enforce line breaks after opening and before closing array brackets + // http://eslint.org/docs/rules/array-bracket-newline + // TODO: enable? semver-major + 'array-bracket-newline': ['off', { multiline: true, minItems: 3 }], + + // enforce line breaks between array elements + // http://eslint.org/docs/rules/array-element-newline + // TODO: enable? semver-major + 'array-element-newline': ['off', { multiline: true, minItems: 3 }], + // enforce spacing inside array brackets 'array-bracket-spacing': ['error', 'never'], @@ -82,7 +92,7 @@ module.exports = { outerIIFEBody: 1, // MemberExpression: null, // CallExpression: { - // parameters: null, + // parameters: null, // }, FunctionDeclaration: { parameters: 1, @@ -284,10 +294,18 @@ module.exports = { 'no-ternary': 'off', // disallow trailing whitespace at the end of lines - 'no-trailing-spaces': 'error', + 'no-trailing-spaces': ['error', { + skipBlankLines: false, + // ignoreComments: false, // TODO: uncomment once v3 is dropped + }], // disallow dangling underscores in identifiers - 'no-underscore-dangle': ['error', { allowAfterThis: false }], + 'no-underscore-dangle': ['error', { + allow: [], + allowAfterThis: false, + allowAfterSuper: false, + // enforceInMethodNames: false, // TODO: uncoment and enable, semver-minor once v3 is dropped + }], // disallow the use of Boolean literals in conditional expressions // also, prefer `a || b` over `a ? a : b` @@ -307,10 +325,10 @@ module.exports = { // enforce line breaks between braces // http://eslint.org/docs/rules/object-curly-newline - // TODO: enable once https://github.com/eslint/eslint/issues/6488 is resolved + // TODO: enable once https://github.com/eslint/eslint/issues/6488 is resolved and v3 is dropped 'object-curly-newline': ['off', { - ObjectExpression: { minProperties: 0, multiline: true }, - ObjectPattern: { minProperties: 0, multiline: true } + ObjectExpression: { minProperties: 3, multiline: true, consistent: true }, + ObjectPattern: { minProperties: 3, multiline: true, consistent: true } }], // enforce "same line" or "multiple line" on object properties. @@ -336,6 +354,10 @@ module.exports = { // enforce padding within blocks 'padded-blocks': ['error', 'never'], + // Require or disallow padding lines between statements + // http://eslint.org/docs/rules/padding-line-between-statements + 'padding-line-between-statements': 'off', + // require quotes around object literal property names // http://eslint.org/docs/rules/quote-props.html 'quote-props': ['error', 'as-needed', { keywords: false, unnecessary: true, numbers: false }], @@ -353,6 +375,11 @@ module.exports = { // enforce spacing before and after semicolons 'semi-spacing': ['error', { before: false, after: true }], + // Enforce location of semicolons + // http://eslint.org/docs/rules/semi-style + // TODO: enable, semver-major until v3 is dropped, semver-minor otherwise + 'semi-style': ['off', 'last'], + // requires object keys to be sorted 'sort-keys': ['off', 'asc', { caseSensitive: false, natural: true }], @@ -399,6 +426,11 @@ module.exports = { } }], + // Enforce spacing around colons of switch statements + // http://eslint.org/docs/rules/switch-colon-spacing + // TODO: enable, semver-major + 'switch-colon-spacing': ['off', { after: true, before: false }], + // Require or disallow spacing between template tags and their literals // http://eslint.org/docs/rules/template-tag-spacing // TODO: enable, semver-major From 55219bfdcf417700f677c5f31a8584a6b8c34c6b Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Sun, 23 Jul 2017 13:08:57 -0700 Subject: [PATCH 042/554] v11.3.0 --- packages/eslint-config-airbnb-base/CHANGELOG.md | 12 ++++++++++++ packages/eslint-config-airbnb-base/package.json | 2 +- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/packages/eslint-config-airbnb-base/CHANGELOG.md b/packages/eslint-config-airbnb-base/CHANGELOG.md index 9407b90a6d..80e394da8d 100644 --- a/packages/eslint-config-airbnb-base/CHANGELOG.md +++ b/packages/eslint-config-airbnb-base/CHANGELOG.md @@ -1,3 +1,15 @@ +11.3.0 / 2017-07-23 +================== + - [deps] allow eslint v3 or v4 (#1447) + - [deps] update `eslint-plugin-import` + - [minor] Balanced spacing for inline block comments (#1440) + - [minor] `no-return-assign`: strengthen linting against returning assignments + - [patch] Allow jsx extensions for test files (#1427) + - [patch] `no-restricted-globals`: add confusing globals; leave disabled for now (#1420) + - [patch] Support Protractor config files in import/no-extraneous-dependencies (#1456) + - [docs] Remove TODO in prefer-reflect as it's deprecated (#1452) + - [docs] add yarn instructions (#1463, #1464) + 11.2.0 / 2017-05-14 ================== - [minor] Disallow unused global variables diff --git a/packages/eslint-config-airbnb-base/package.json b/packages/eslint-config-airbnb-base/package.json index 8fe35062fd..008b1e198b 100644 --- a/packages/eslint-config-airbnb-base/package.json +++ b/packages/eslint-config-airbnb-base/package.json @@ -1,6 +1,6 @@ { "name": "eslint-config-airbnb-base", - "version": "11.2.0", + "version": "11.3.0", "description": "Airbnb's base JS ESLint config, following our styleguide", "main": "index.js", "scripts": { From 18255d14d45bafd17038b2d9032006fe9e1e1003 Mon Sep 17 00:00:00 2001 From: Tonni Date: Mon, 26 Jun 2017 23:00:26 +0800 Subject: [PATCH 043/554] [guide] Add documentation for exponentiation operator (`**`). --- README.md | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 0fbd0ffe8f..59d2c994ac 100644 --- a/README.md +++ b/README.md @@ -1498,6 +1498,16 @@ Other Style Guides const isJedi = getProp('jedi'); ``` + + - [12.3](#es2016-properties--exponentiation-operator) Use exponentiation operator `**` when calculating exponentiations. eslint: [`no-restricted-properties`](http://eslint.org/docs/rules/no-restricted-properties). + + ```javascript + // bad + const binary = Math.pow(2, 10); + + // good + const binary = 2 ** 10; + ``` **[⬆ back to top](#table-of-contents)** @@ -3116,7 +3126,7 @@ Other Style Guides ## ECMAScript 6+ (ES 2015+) Styles - - [28.1](#es6-styles) This is a collection of links to the various ES6 features. + - [28.1](#es6-styles) This is a collection of links to the various ES6+ features. 1. [Arrow Functions](#arrow-functions) 1. [Classes](#classes--constructors) @@ -3129,6 +3139,7 @@ Other Style Guides 1. [Rest](#es6-rest) 1. [Array Spreads](#es6-array-spreads) 1. [Let and Const](#references) +1. [Exponentiation Operator](#es2016-properties--exponentiation-operator) 1. [Iterators and Generators](#iterators-and-generators) 1. [Modules](#modules) From b687a9ceb8030dcdc467adb51c33e37a9a1c6101 Mon Sep 17 00:00:00 2001 From: elmehri Date: Tue, 29 Aug 2017 15:27:08 +0100 Subject: [PATCH 044/554] [eslint config] [base] [patch] support Protractor config files in import/no-extraneous-dependencies --- packages/eslint-config-airbnb-base/rules/imports.js | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/eslint-config-airbnb-base/rules/imports.js b/packages/eslint-config-airbnb-base/rules/imports.js index 2700194efe..81b845a871 100644 --- a/packages/eslint-config-airbnb-base/rules/imports.js +++ b/packages/eslint-config-airbnb-base/rules/imports.js @@ -84,6 +84,7 @@ module.exports = { '**/gulpfile.js', // gulp config '**/gulpfile.*.js', // gulp config '**/Gruntfile{,.js}', // grunt config + '**/protractor.conf.js', // protractor config '**/protractor.conf.*.js', // protractor config ], optionalDependencies: false, From 9d91990221d47b2782f586370451033460e0a32b Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Fri, 1 Sep 2017 22:59:54 -0700 Subject: [PATCH 045/554] [Tests] stop testing on eslint v3 --- .travis.yml | 4 ---- 1 file changed, 4 deletions(-) diff --git a/.travis.yml b/.travis.yml index 9e1091574d..c083bda347 100644 --- a/.travis.yml +++ b/.travis.yml @@ -17,14 +17,11 @@ script: sudo: false env: matrix: - - 'TEST=true ESLINT=3 PACKAGE=eslint-config-airbnb' - 'TEST=true ESLINT=4 PACKAGE=eslint-config-airbnb' - 'TEST=true ESLINT=4 PACKAGE=eslint-config-airbnb-base' matrix: fast_finish: true include: - - node_js: "node" - env: PREPUBLISH=true ESLINT=3 PACKAGE=eslint-config-airbnb - node_js: "node" env: PREPUBLISH=true ESLINT=4 PACKAGE=eslint-config-airbnb - node_js: "node" @@ -32,6 +29,5 @@ matrix: allow_failures: - node_js: "7" - node_js: "5" - - env: PREPUBLISH=true ESLINT=3 PACKAGE=eslint-config-airbnb - env: PREPUBLISH=true ESLINT=4 PACKAGE=eslint-config-airbnb - env: PREPUBLISH=true ESLINT=4 PACKAGE=eslint-config-airbnb-base From 63d1ae175e01391ded18c0a4d03c0eca4c49edbe Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Fri, 1 Sep 2017 23:00:41 -0700 Subject: [PATCH 046/554] [Tests] fix linting error caused by updated base config --- packages/eslint-config-airbnb-base/rules/style.js | 6 +++--- packages/eslint-config-airbnb-base/test/test-base.js | 4 ++-- packages/eslint-config-airbnb/rules/react.js | 6 +++++- 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/packages/eslint-config-airbnb-base/rules/style.js b/packages/eslint-config-airbnb-base/rules/style.js index d36309a808..4aa35aeafe 100644 --- a/packages/eslint-config-airbnb-base/rules/style.js +++ b/packages/eslint-config-airbnb-base/rules/style.js @@ -113,7 +113,7 @@ module.exports = { body: 1 }, CallExpression: { - 'arguments': 1 + arguments: 1 }, ArrayExpression: 1, ObjectExpression: 1, @@ -344,8 +344,8 @@ module.exports = { // enforce line breaks between braces // http://eslint.org/docs/rules/object-curly-newline 'object-curly-newline': ['error', { - ObjectExpression: { minProperties: 3, multiline: true, consistent: true }, - ObjectPattern: { minProperties: 3, multiline: true, consistent: true } + ObjectExpression: { minProperties: 4, multiline: true, consistent: true }, + ObjectPattern: { minProperties: 4, multiline: true, consistent: true } }], // enforce "same line" or "multiple line" on object properties. diff --git a/packages/eslint-config-airbnb-base/test/test-base.js b/packages/eslint-config-airbnb-base/test/test-base.js index 810c8000b0..6936e0eb24 100644 --- a/packages/eslint-config-airbnb-base/test/test-base.js +++ b/packages/eslint-config-airbnb-base/test/test-base.js @@ -11,9 +11,9 @@ fs.readdirSync(path.join(__dirname, '../rules')).forEach((name) => { files[name] = require(`../rules/${name}`); // eslint-disable-line global-require }); -Object.keys(files).forEach(( +Object.keys(files).forEach(( // eslint-disable-line function-paren-newline name, // trailing function comma is to test parsing -) => { +) => { // eslint-disable-line function-paren-newline const config = files[name]; test(`${name}: does not reference react`, (t) => { diff --git a/packages/eslint-config-airbnb/rules/react.js b/packages/eslint-config-airbnb/rules/react.js index 96b1d25644..15324c8608 100644 --- a/packages/eslint-config-airbnb/rules/react.js +++ b/packages/eslint-config-airbnb/rules/react.js @@ -186,7 +186,11 @@ module.exports = { // Prevent missing props validation in a React component definition // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/prop-types.md - 'react/prop-types': ['error', { ignore: [], customValidators: [], skipUndeclared: false }], + 'react/prop-types': ['error', { + ignore: [], + customValidators: [], + skipUndeclared: false + }], // Prevent missing React when using JSX // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/react-in-jsx-scope.md From 1f5ca4c976b906a94d4faa2e01dfff2c9a106bfb Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Fri, 1 Sep 2017 22:57:11 -0700 Subject: [PATCH 047/554] [eslint config] [base] v12.0.0 --- packages/eslint-config-airbnb-base/CHANGELOG.md | 10 ++++++++++ packages/eslint-config-airbnb-base/package.json | 2 +- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/packages/eslint-config-airbnb-base/CHANGELOG.md b/packages/eslint-config-airbnb-base/CHANGELOG.md index 6dcd4587a5..5e268d704b 100644 --- a/packages/eslint-config-airbnb-base/CHANGELOG.md +++ b/packages/eslint-config-airbnb-base/CHANGELOG.md @@ -1,3 +1,13 @@ +12.0.0 / 2017-09-02 +================== + - [deps] [breaking] require `eslint` v4 + - enable `function-paren-newline`, `for-direction`, `getter-return`, `no-compare-neg-zero`, `semi-style`, `object-curly-newline`, `no-buffer-constructor`, `no-restricted-globals`, `switch-colon-spacing`, `template-tag-spacing`, `prefer-promise-reject-errors`, `prefer-restructuring` + - improve `indent`, `no-multi-spaces`, `no-trailing-spaces`, `no-underscore-dangle` + - [breaking] move `comma-dangle` to Stylistic Issues (#1514) + - [breaking] Rules prohibiting global isNaN, isFinite (#1477) + - [patch] also disallow padding in classes and switches (#1403) + - [patch] support Protractor config files in import/no-extraneous-dependencies (#1543) + 11.3.2 / 2017-08-22 ================== - [patch] Add jest.config.js to import/no-extraneous-dependencies devDeps (#1522) diff --git a/packages/eslint-config-airbnb-base/package.json b/packages/eslint-config-airbnb-base/package.json index f23359e969..6c18415998 100644 --- a/packages/eslint-config-airbnb-base/package.json +++ b/packages/eslint-config-airbnb-base/package.json @@ -1,6 +1,6 @@ { "name": "eslint-config-airbnb-base", - "version": "11.3.2", + "version": "12.0.0", "description": "Airbnb's base JS ESLint config, following our styleguide", "main": "index.js", "scripts": { From 7b30681227ffec7e5ff958a43f0ba31633ad045d Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Sat, 2 Sep 2017 10:24:51 -0700 Subject: [PATCH 048/554] [eslint config] [breaking] [deps] require `eslint` `v4`, update `eslint-config-airbnb-base` --- packages/eslint-config-airbnb/package.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/eslint-config-airbnb/package.json b/packages/eslint-config-airbnb/package.json index d1aa120358..e424218002 100644 --- a/packages/eslint-config-airbnb/package.json +++ b/packages/eslint-config-airbnb/package.json @@ -48,13 +48,13 @@ }, "homepage": "https://github.com/airbnb/javascript", "dependencies": { - "eslint-config-airbnb-base": "^11.3.2" + "eslint-config-airbnb-base": "^12.0.0" }, "devDependencies": { "babel-preset-airbnb": "^2.4.0", "babel-tape-runner": "^2.0.1", "editorconfig-tools": "^0.1.1", - "eslint": "^3.19.0 || ^4.5.0", + "eslint": "^4.6.0", "eslint-find-rules": "^3.1.1", "eslint-plugin-import": "^2.7.0", "eslint-plugin-jsx-a11y": "^5.1.1", @@ -65,7 +65,7 @@ "tape": "^4.8.0" }, "peerDependencies": { - "eslint": "^3.19.0 || ^4.5.0", + "eslint": "^4.6.0", "eslint-plugin-jsx-a11y": "^5.1.1", "eslint-plugin-import": "^2.7.0", "eslint-plugin-react": "^7.3.0" From 074b2f81b810519421a875bff94e15be118c2cd2 Mon Sep 17 00:00:00 2001 From: Stephen Wyatt Bush Date: Wed, 5 Jul 2017 15:47:54 -0700 Subject: [PATCH 049/554] [eslint config] [breaking] [deps] Upgrade `eslint-plugin-jsx-a11y` to `v6` - enable more a11y rules --- packages/eslint-config-airbnb/package.json | 4 ++-- packages/eslint-config-airbnb/rules/react-a11y.js | 15 ++++----------- 2 files changed, 6 insertions(+), 13 deletions(-) diff --git a/packages/eslint-config-airbnb/package.json b/packages/eslint-config-airbnb/package.json index e424218002..5edc1665fe 100644 --- a/packages/eslint-config-airbnb/package.json +++ b/packages/eslint-config-airbnb/package.json @@ -57,7 +57,7 @@ "eslint": "^4.6.0", "eslint-find-rules": "^3.1.1", "eslint-plugin-import": "^2.7.0", - "eslint-plugin-jsx-a11y": "^5.1.1", + "eslint-plugin-jsx-a11y": "^6.0.2", "eslint-plugin-react": "^7.3.0", "in-publish": "^2.0.0", "react": ">= 0.13.0", @@ -66,7 +66,7 @@ }, "peerDependencies": { "eslint": "^4.6.0", - "eslint-plugin-jsx-a11y": "^5.1.1", + "eslint-plugin-jsx-a11y": "^6.0.2", "eslint-plugin-import": "^2.7.0", "eslint-plugin-react": "^7.3.0" }, diff --git a/packages/eslint-config-airbnb/rules/react-a11y.js b/packages/eslint-config-airbnb/rules/react-a11y.js index 4cdf1cf39c..6e1c395656 100644 --- a/packages/eslint-config-airbnb/rules/react-a11y.js +++ b/packages/eslint-config-airbnb/rules/react-a11y.js @@ -13,7 +13,7 @@ module.exports = { rules: { // Enforce that anchors have content // https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/anchor-has-content.md - 'jsx-a11y/anchor-has-content': ['error', { components: [''] }], + 'jsx-a11y/anchor-has-content': ['error', { components: [] }], // Require ARIA roles to be valid and non-abstract // https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/aria-role.md @@ -32,10 +32,6 @@ module.exports = { // https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/aria-unsupported-elements.md 'jsx-a11y/aria-unsupported-elements': 'error', - // disallow href "#" - // https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/href-no-hash.md - 'jsx-a11y/href-no-hash': ['error', { components: ['a'] }], - // Enforce that all elements that require alternative text have meaningful information // https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/alt-text.md 'jsx-a11y/alt-text': ['error', { @@ -55,9 +51,8 @@ module.exports = { 'jsx-a11y/label-has-for': ['error', { components: ['label'] }], // require that mouseover/out come with focus/blur, for keyboard-only users - // TODO: evaluate // https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/mouse-events-have-key-events.md - 'jsx-a11y/mouse-events-have-key-events': 'off', + 'jsx-a11y/mouse-events-have-key-events': 'error', // Prevent use of `accessKey` // https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/no-access-key.md @@ -109,8 +104,7 @@ module.exports = { // require onClick be accompanied by onKeyUp/onKeyDown/onKeyPress // https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/click-events-have-key-events.md - // TODO: enable? - 'jsx-a11y/click-events-have-key-events': 'off', + 'jsx-a11y/click-events-have-key-events': 'error', // Enforce that DOM elements without semantic behavior not have interaction handlers // https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/no-static-element-interactions.md @@ -191,8 +185,7 @@ module.exports = { // ensure tags are valid // https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/0745af376cdc8686d85a361ce36952b1fb1ccf6e/docs/rules/anchor-is-valid.md - // TODO: enable, semver-major - 'jsx-a11y/anchor-is-valid': ['off', { + 'jsx-a11y/anchor-is-valid': ['error', { components: ['Link'], specialLink: [], aspects: ['noHref', 'invalidHref', 'preferButton'], From 583544356ad043da72eea26045b20471ea00885e Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Sun, 23 Jul 2017 22:26:33 -0700 Subject: [PATCH 050/554] [eslint config] [deps] update `eslint-plugin-import`, `eslint-config-airbnb-base` --- packages/eslint-config-airbnb/package.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/eslint-config-airbnb/package.json b/packages/eslint-config-airbnb/package.json index 7c5df67583..161581986c 100644 --- a/packages/eslint-config-airbnb/package.json +++ b/packages/eslint-config-airbnb/package.json @@ -48,7 +48,7 @@ }, "homepage": "https://github.com/airbnb/javascript", "dependencies": { - "eslint-config-airbnb-base": "^11.2.0" + "eslint-config-airbnb-base": "^11.3.0" }, "devDependencies": { "babel-preset-airbnb": "^2.4.0", @@ -56,7 +56,7 @@ "editorconfig-tools": "^0.1.1", "eslint": "^3.19.0", "eslint-find-rules": "^3.1.1", - "eslint-plugin-import": "^2.6.1", + "eslint-plugin-import": "^2.7.0", "eslint-plugin-jsx-a11y": "^5.1.1", "eslint-plugin-react": "^7.1.0", "in-publish": "^2.0.0", @@ -67,7 +67,7 @@ "peerDependencies": { "eslint": "^3.19.0", "eslint-plugin-jsx-a11y": "^5.1.1", - "eslint-plugin-import": "^2.6.1", + "eslint-plugin-import": "^2.7.0", "eslint-plugin-react": "^7.1.0" }, "engines": { From 16c73d0a7a92c38d7a03db621dbf42f0c5576fd2 Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Sun, 23 Jul 2017 22:33:05 -0700 Subject: [PATCH 051/554] [eslint config] [deps] allow eslint v3 or v4 Closes #1447. --- .travis.yml | 4 ++++ packages/eslint-config-airbnb/package.json | 4 ++-- packages/eslint-config-airbnb/test/test-react-order.js | 3 +-- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/.travis.yml b/.travis.yml index 4256a0dcfd..7d887ca685 100644 --- a/.travis.yml +++ b/.travis.yml @@ -18,6 +18,7 @@ sudo: false env: matrix: - 'TEST=true ESLINT=3 PACKAGE=eslint-config-airbnb' + - 'TEST=true ESLINT=4 PACKAGE=eslint-config-airbnb' - 'TEST=true ESLINT=3 PACKAGE=eslint-config-airbnb-base' - 'TEST=true ESLINT=4 PACKAGE=eslint-config-airbnb-base' matrix: @@ -25,6 +26,8 @@ matrix: include: - node_js: "node" env: PREPUBLISH=true ESLINT=3 PACKAGE=eslint-config-airbnb + - node_js: "node" + env: PREPUBLISH=true ESLINT=4 PACKAGE=eslint-config-airbnb - node_js: "node" env: PREPUBLISH=true ESLINT=3 PACKAGE=eslint-config-airbnb-base - node_js: "node" @@ -33,5 +36,6 @@ matrix: - node_js: "7" - node_js: "5" - env: PREPUBLISH=true ESLINT=3 PACKAGE=eslint-config-airbnb + - env: PREPUBLISH=true ESLINT=4 PACKAGE=eslint-config-airbnb - env: PREPUBLISH=true ESLINT=3 PACKAGE=eslint-config-airbnb-base - env: PREPUBLISH=true ESLINT=4 PACKAGE=eslint-config-airbnb-base diff --git a/packages/eslint-config-airbnb/package.json b/packages/eslint-config-airbnb/package.json index 161581986c..1b06b38a97 100644 --- a/packages/eslint-config-airbnb/package.json +++ b/packages/eslint-config-airbnb/package.json @@ -54,7 +54,7 @@ "babel-preset-airbnb": "^2.4.0", "babel-tape-runner": "^2.0.1", "editorconfig-tools": "^0.1.1", - "eslint": "^3.19.0", + "eslint": "^3.19.0 || ^4.3.0", "eslint-find-rules": "^3.1.1", "eslint-plugin-import": "^2.7.0", "eslint-plugin-jsx-a11y": "^5.1.1", @@ -65,7 +65,7 @@ "tape": "^4.7.0" }, "peerDependencies": { - "eslint": "^3.19.0", + "eslint": "^3.19.0 || ^4.3.0", "eslint-plugin-jsx-a11y": "^5.1.1", "eslint-plugin-import": "^2.7.0", "eslint-plugin-react": "^7.1.0" diff --git a/packages/eslint-config-airbnb/test/test-react-order.js b/packages/eslint-config-airbnb/test/test-react-order.js index 0257a40a92..0e7fd9e6ec 100644 --- a/packages/eslint-config-airbnb/test/test-react-order.js +++ b/packages/eslint-config-airbnb/test/test-react-order.js @@ -49,8 +49,7 @@ test('validate react prop order', (t) => { setBar() {} someMethod() {} renderDogs() {} - render() { return
; } -`)); + render() { return
; }`)); t.notOk(result.warningCount, 'no warnings'); t.notOk(result.errorCount, 'no errors'); From 2c0126543ff93e060e00faf9c3e98e40f58b0d1e Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Mon, 24 Jul 2017 00:00:58 -0700 Subject: [PATCH 052/554] [eslint config] v15.1.0 --- packages/eslint-config-airbnb/CHANGELOG.md | 5 +++++ packages/eslint-config-airbnb/package.json | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/packages/eslint-config-airbnb/CHANGELOG.md b/packages/eslint-config-airbnb/CHANGELOG.md index ca35490985..a1c3b5d188 100644 --- a/packages/eslint-config-airbnb/CHANGELOG.md +++ b/packages/eslint-config-airbnb/CHANGELOG.md @@ -1,3 +1,8 @@ +15.1.0 / 2017-07-24 +================== +- [deps] allow eslint v3 or v4 (#1447) +- [deps] update `eslint-plugin-import`, `eslint-config-airbnb-base` + 15.0.2 / 2017-07-04 ================== - [fix] jsx should be enabled via parserOptions, not via a root ecmaFeatures diff --git a/packages/eslint-config-airbnb/package.json b/packages/eslint-config-airbnb/package.json index 1b06b38a97..4f48b8fee2 100644 --- a/packages/eslint-config-airbnb/package.json +++ b/packages/eslint-config-airbnb/package.json @@ -1,6 +1,6 @@ { "name": "eslint-config-airbnb", - "version": "15.0.2", + "version": "15.1.0", "description": "Airbnb's ESLint config, following our styleguide", "main": "index.js", "scripts": { From 0d938aecf20e2a6ad586e08155e177a25d12bc5e Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Mon, 24 Jul 2017 11:58:15 -0700 Subject: [PATCH 053/554] [eslint config] [base] [fix] `legacy`: remove top-level `ecmaFeatures` --- packages/eslint-config-airbnb-base/legacy.js | 2 -- 1 file changed, 2 deletions(-) diff --git a/packages/eslint-config-airbnb-base/legacy.js b/packages/eslint-config-airbnb-base/legacy.js index a73de7d8f7..7cc2441ab3 100644 --- a/packages/eslint-config-airbnb-base/legacy.js +++ b/packages/eslint-config-airbnb-base/legacy.js @@ -13,8 +13,6 @@ module.exports = { mocha: false, jasmine: false }, - ecmaFeatures: {}, - globals: {}, rules: { 'comma-dangle': ['error', 'never'], 'prefer-numeric-literals': 'off', From 106a58ec1ad903d702c2490880793aac577d8fb4 Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Mon, 24 Jul 2017 12:07:43 -0700 Subject: [PATCH 054/554] [eslint config] [base] v11.3.1 --- packages/eslint-config-airbnb-base/CHANGELOG.md | 4 ++++ packages/eslint-config-airbnb-base/package.json | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/packages/eslint-config-airbnb-base/CHANGELOG.md b/packages/eslint-config-airbnb-base/CHANGELOG.md index 80e394da8d..b238e2e329 100644 --- a/packages/eslint-config-airbnb-base/CHANGELOG.md +++ b/packages/eslint-config-airbnb-base/CHANGELOG.md @@ -1,3 +1,7 @@ +11.3.1 / 2017-07-24 +================== + - [fix] `legacy`: remove top-level `ecmaFeatures` + 11.3.0 / 2017-07-23 ================== - [deps] allow eslint v3 or v4 (#1447) diff --git a/packages/eslint-config-airbnb-base/package.json b/packages/eslint-config-airbnb-base/package.json index 008b1e198b..b4a676ac05 100644 --- a/packages/eslint-config-airbnb-base/package.json +++ b/packages/eslint-config-airbnb-base/package.json @@ -1,6 +1,6 @@ { "name": "eslint-config-airbnb-base", - "version": "11.3.0", + "version": "11.3.1", "description": "Airbnb's base JS ESLint config, following our styleguide", "main": "index.js", "scripts": { From 3cc6269c86ab5eb5cf4f307eb6573a7734b7fbfd Mon Sep 17 00:00:00 2001 From: Asher Dale Date: Thu, 20 Jul 2017 11:21:29 -0400 Subject: [PATCH 055/554] Updated README, deleted extra 'back to top' There was an extra 'back to top' link in between sections 4.5 and 4.6 in the 'Arrays' section. --- README.md | 2 -- 1 file changed, 2 deletions(-) diff --git a/README.md b/README.md index 59d2c994ac..6a7f905af9 100644 --- a/README.md +++ b/README.md @@ -417,8 +417,6 @@ Other Style Guides }); ``` -**[⬆ back to top](#table-of-contents)** - - [4.6](#arrays--bracket-newline) Use line breaks after open and before close array brackets if an array has multiple lines From a371d73414bfe534ce24d852877bed8135ebcc0a Mon Sep 17 00:00:00 2001 From: Asher Dale Date: Tue, 25 Jul 2017 15:46:30 -0400 Subject: [PATCH 056/554] Update README, fixed badly-styled eslint links There were links to eslint rules in a style that didn't match the style of the rest of the document. Specifically, most links in the document use the following style: "eslint: ['no-unneeded-ternary']", but there were badly styled links that looks like this: "eslint rule: ['no-unneeded-ternary']." Additionally, the badly styled links were on their own line, whereas all the other links are not placed on their own line. --- README.md | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index 6a7f905af9..2264a12558 100644 --- a/README.md +++ b/README.md @@ -1838,12 +1838,10 @@ Other Style Guides - [15.4](#comparison--moreinfo) For more information see [Truth Equality and JavaScript](https://javascriptweblog.wordpress.com/2011/02/07/truth-equality-and-javascript/#more-2108) by Angus Croll. - - [15.5](#comparison--switch-blocks) Use braces to create blocks in `case` and `default` clauses that contain lexical declarations (e.g. `let`, `const`, `function`, and `class`). + - [15.5](#comparison--switch-blocks) Use braces to create blocks in `case` and `default` clauses that contain lexical declarations (e.g. `let`, `const`, `function`, and `class`). eslint rules: [`no-case-declarations`](http://eslint.org/docs/rules/no-case-declarations.html) > Why? Lexical declarations are visible in the entire `switch` block but only get initialized when assigned, which only happens when its `case` is reached. This causes problems when multiple `case` clauses attempt to define the same thing. - eslint rules: [`no-case-declarations`](http://eslint.org/docs/rules/no-case-declarations.html). - ```javascript // bad switch (foo) { @@ -1888,9 +1886,7 @@ Other Style Guides ``` - - [15.6](#comparison--nested-ternaries) Ternaries should not be nested and generally be single line expressions. - - eslint rules: [`no-nested-ternary`](http://eslint.org/docs/rules/no-nested-ternary.html). + - [15.6](#comparison--nested-ternaries) Ternaries should not be nested and generally be single line expressions. eslint: [`no-nested-ternary`](http://eslint.org/docs/rules/no-nested-ternary.html) ```javascript // bad @@ -1912,9 +1908,7 @@ Other Style Guides ``` - - [15.7](#comparison--unneeded-ternary) Avoid unneeded ternary statements. - - eslint rules: [`no-unneeded-ternary`](http://eslint.org/docs/rules/no-unneeded-ternary.html). + - [15.7](#comparison--unneeded-ternary) Avoid unneeded ternary statements. eslint: [`no-unneeded-ternary`](http://eslint.org/docs/rules/no-unneeded-ternary.html) ```javascript // bad From 9393e6ab10f38dbf4b020fed81c20152ac9b8558 Mon Sep 17 00:00:00 2001 From: Asher Dale Date: Tue, 25 Jul 2017 15:50:10 -0400 Subject: [PATCH 057/554] Update README, finished fixing eslint styling Update README, finished fixing eslint styling (look at previous commit description for info). --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 2264a12558..f0b3eaa6c6 100644 --- a/README.md +++ b/README.md @@ -1838,7 +1838,7 @@ Other Style Guides - [15.4](#comparison--moreinfo) For more information see [Truth Equality and JavaScript](https://javascriptweblog.wordpress.com/2011/02/07/truth-equality-and-javascript/#more-2108) by Angus Croll. - - [15.5](#comparison--switch-blocks) Use braces to create blocks in `case` and `default` clauses that contain lexical declarations (e.g. `let`, `const`, `function`, and `class`). eslint rules: [`no-case-declarations`](http://eslint.org/docs/rules/no-case-declarations.html) + - [15.5](#comparison--switch-blocks) Use braces to create blocks in `case` and `default` clauses that contain lexical declarations (e.g. `let`, `const`, `function`, and `class`). eslint: [`no-case-declarations`](http://eslint.org/docs/rules/no-case-declarations.html) > Why? Lexical declarations are visible in the entire `switch` block but only get initialized when assigned, which only happens when its `case` is reached. This causes problems when multiple `case` clauses attempt to define the same thing. From a206c52854ec8de387289ceb3d88fefc7ff2b030 Mon Sep 17 00:00:00 2001 From: Will Clark Date: Tue, 25 Jul 2017 11:41:34 +0200 Subject: [PATCH 058/554] [eslint config] [base] [patch] Improve Gruntfile glob pattern To cover `Gruntfile` and `Gruntfile.js` instead of just `Gruntfile`. --- packages/eslint-config-airbnb-base/rules/imports.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/eslint-config-airbnb-base/rules/imports.js b/packages/eslint-config-airbnb-base/rules/imports.js index 0150724f6b..6116c6f67c 100644 --- a/packages/eslint-config-airbnb-base/rules/imports.js +++ b/packages/eslint-config-airbnb-base/rules/imports.js @@ -82,7 +82,7 @@ module.exports = { '**/rollup.config.*.js', // rollup config '**/gulpfile.js', // gulp config '**/gulpfile.*.js', // gulp config - '**/Gruntfile', // grunt config + '**/Gruntfile{,.js}', // grunt config '**/protractor.conf.*.js', // protractor config ], optionalDependencies: false, From e4f35ac959ce531e128d97cea051ddd76dd5aa6c Mon Sep 17 00:00:00 2001 From: Chris Atkin Date: Mon, 31 Jul 2017 17:12:27 +0100 Subject: [PATCH 059/554] Removing "GitHub" from In The Wild reference This removes the word "GitHub" from an In The Wild reference link, to prevent association with the main GitHub organisation. --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index f0b3eaa6c6..408a150cb6 100644 --- a/README.md +++ b/README.md @@ -3330,7 +3330,7 @@ Other Style Guides - **React**: [facebook.github.io/react/contributing/how-to-contribute.html#style-guide](https://facebook.github.io/react/contributing/how-to-contribute.html#style-guide) - **REI**: [reidev/js-style-guide](https://github.com/rei/code-style-guides/blob/master/docs/javascript.md) - **Ripple**: [ripple/javascript-style-guide](https://github.com/ripple/javascript-style-guide) - - **Sainsbury's Supermarkets**: [github/jsainsburyplc](https://github.com/jsainsburyplc) + - **Sainsbury's Supermarkets**: [jsainsburyplc](https://github.com/jsainsburyplc) - **SeekingAlpha**: [seekingalpha/javascript-style-guide](https://github.com/seekingalpha/javascript-style-guide) - **Shutterfly**: [shutterfly/javascript](https://github.com/shutterfly/javascript) - **Sourcetoad**: [sourcetoad/javascript](https://github.com/sourcetoad/javascript) From 16faade698a185d3a84f4c2c8ef70ec4cf712936 Mon Sep 17 00:00:00 2001 From: Eric Pan Date: Mon, 31 Jul 2017 11:19:07 -0700 Subject: [PATCH 060/554] [eslint config] [*] [docs] Specify yarn-specific install instructions Attempts to clarify and address issue https://github.com/airbnb/javascript/issues/1508#issuecomment-319113807 Recommends yarn users to list peer dependencies and then install each peer dependency with specified version. Prior yarn instructions led users to install the latest version of each peer dependency which, in some cases, led to errors if the latest version of a peer dependency did not have rules that this package uses. --- packages/eslint-config-airbnb-base/README.md | 2 +- packages/eslint-config-airbnb/README.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/eslint-config-airbnb-base/README.md b/packages/eslint-config-airbnb-base/README.md index 968cec06cd..881b86b2db 100644 --- a/packages/eslint-config-airbnb-base/README.md +++ b/packages/eslint-config-airbnb-base/README.md @@ -12,7 +12,7 @@ We export two ESLint configurations for your usage. Our default export contains all of our ESLint rules, including ECMAScript 6+. It requires `eslint` and `eslint-plugin-import`. -If you use yarn, run `yarn add --dev eslint-config-airbnb-base eslint-plugin-import`, or see below for npm instructions. +If you use yarn, run `npm info "eslint-config-airbnb-base@latest" peerDependencies` to list the peer dependencies and versions, then run `yarn add --dev @` for each listed peer dependency. See below for npm instructions. 1. Install the correct versions of each package, which are listed by the command: diff --git a/packages/eslint-config-airbnb/README.md b/packages/eslint-config-airbnb/README.md index a3a7c71340..567c929a31 100644 --- a/packages/eslint-config-airbnb/README.md +++ b/packages/eslint-config-airbnb/README.md @@ -12,7 +12,7 @@ We export three ESLint configurations for your usage. Our default export contains all of our ESLint rules, including ECMAScript 6+ and React. It requires `eslint`, `eslint-plugin-import`, `eslint-plugin-react`, and `eslint-plugin-jsx-a11y`. If you don't need React, see [eslint-config-airbnb-base](https://npmjs.com/eslint-config-airbnb-base). -If you use yarn, run `yarn add --dev eslint-config-airbnb-base eslint-plugin-import eslint-plugin-react eslint-plugin-jsx-a11y`, and see below for npm instructions. +If you use yarn, run `npm info "eslint-config-airbnb@latest" peerDependencies` to list the peer dependencies and versions, then run `yarn add --dev @` for each listed peer dependency. See below for npm instructions. 1. Install the correct versions of each package, which are listed by the command: From dbdbde0b81622d2f76c3babb9ddcfdbdf880190e Mon Sep 17 00:00:00 2001 From: marhub Date: Mon, 7 Aug 2017 12:48:54 +0200 Subject: [PATCH 061/554] Remove polish translation MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Remove link to polish translation as it's outdated ( last commit from 2-3 years ago ). For example in polish translation you can read that you should use one "var" keyword to declare your vars. example: ```js // źle ( bad ) var items = getItems(); var goSportsTeam = true; var dragonball = 'z'; // dobrze ( good ) var items = getItems(), goSportsTeam = true, dragonball = 'z'; ``` --- README.md | 1 - 1 file changed, 1 deletion(-) diff --git a/README.md b/README.md index 408a150cb6..f1cfe81db2 100644 --- a/README.md +++ b/README.md @@ -3367,7 +3367,6 @@ Other Style Guides - ![it](https://raw.githubusercontent.com/gosquared/flags/master/flags/flags/shiny/24/Italy.png) **Italian**: [sinkswim/javascript-style-guide](https://github.com/sinkswim/javascript-style-guide) - ![jp](https://raw.githubusercontent.com/gosquared/flags/master/flags/flags/shiny/24/Japan.png) **Japanese**: [mitsuruog/javascript-style-guide](https://github.com/mitsuruog/javascript-style-guide) - ![kr](https://raw.githubusercontent.com/gosquared/flags/master/flags/flags/shiny/24/South-Korea.png) **Korean**: [tipjs/javascript-style-guide](https://github.com/tipjs/javascript-style-guide) - - ![pl](https://raw.githubusercontent.com/gosquared/flags/master/flags/flags/shiny/24/Poland.png) **Polish**: [mjurczyk/javascript](https://github.com/mjurczyk/javascript) - ![ru](https://raw.githubusercontent.com/gosquared/flags/master/flags/flags/shiny/24/Russia.png) **Russian**: [leonidlebedev/javascript-airbnb](https://github.com/leonidlebedev/javascript-airbnb) - ![es](https://raw.githubusercontent.com/gosquared/flags/master/flags/flags/shiny/24/Spain.png) **Spanish**: [paolocarrasco/javascript-style-guide](https://github.com/paolocarrasco/javascript-style-guide) - ![th](https://raw.githubusercontent.com/gosquared/flags/master/flags/flags/shiny/24/Thailand.png) **Thai**: [lvarayut/javascript-style-guide](https://github.com/lvarayut/javascript-style-guide) From b5e14dc5d06ddbadc0bc932b7f988f9552fb667e Mon Sep 17 00:00:00 2001 From: Jared Deckard Date: Mon, 7 Aug 2017 15:36:22 -0500 Subject: [PATCH 062/554] Explain why default exports are preferred --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index f1cfe81db2..562eebc955 100644 --- a/README.md +++ b/README.md @@ -1285,6 +1285,7 @@ Other Style Guides - [10.6](#modules--prefer-default-export) In modules with a single export, prefer default export over named export. eslint: [`import/prefer-default-export`](https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/prefer-default-export.md) + > Why? To encourage more files that only ever export one thing, which is better for readability and maintainability. ```javascript // bad From 6bd73560eea8f3c00c8185f96799f69ad4ba1fcb Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Wed, 9 Aug 2017 17:35:23 -0700 Subject: [PATCH 063/554] [eslint config] [deps] update `eslint` v4, `eslint-plugin-react`, `tape` --- packages/eslint-config-airbnb/package.json | 10 ++++----- packages/eslint-config-airbnb/rules/react.js | 23 ++++++++++++++++++-- 2 files changed, 26 insertions(+), 7 deletions(-) diff --git a/packages/eslint-config-airbnb/package.json b/packages/eslint-config-airbnb/package.json index 4f48b8fee2..41fa65abbb 100644 --- a/packages/eslint-config-airbnb/package.json +++ b/packages/eslint-config-airbnb/package.json @@ -54,21 +54,21 @@ "babel-preset-airbnb": "^2.4.0", "babel-tape-runner": "^2.0.1", "editorconfig-tools": "^0.1.1", - "eslint": "^3.19.0 || ^4.3.0", + "eslint": "^3.19.0 || ^4.4.1", "eslint-find-rules": "^3.1.1", "eslint-plugin-import": "^2.7.0", "eslint-plugin-jsx-a11y": "^5.1.1", - "eslint-plugin-react": "^7.1.0", + "eslint-plugin-react": "^7.2.0", "in-publish": "^2.0.0", "react": ">= 0.13.0", "safe-publish-latest": "^1.1.1", - "tape": "^4.7.0" + "tape": "^4.8.0" }, "peerDependencies": { - "eslint": "^3.19.0 || ^4.3.0", + "eslint": "^3.19.0 || ^4.4.1", "eslint-plugin-jsx-a11y": "^5.1.1", "eslint-plugin-import": "^2.7.0", - "eslint-plugin-react": "^7.1.0" + "eslint-plugin-react": "^7.2.0" }, "engines": { "node": ">= 4" diff --git a/packages/eslint-config-airbnb/rules/react.js b/packages/eslint-config-airbnb/rules/react.js index 96e5f4a75d..c5503a17b1 100644 --- a/packages/eslint-config-airbnb/rules/react.js +++ b/packages/eslint-config-airbnb/rules/react.js @@ -42,7 +42,7 @@ module.exports = { // Enforce boolean attributes notation in JSX // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-boolean-value.md - 'react/jsx-boolean-value': ['error', 'never'], + 'react/jsx-boolean-value': ['error', 'never', { always: [] }], // Validate closing bracket location in JSX // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-closing-bracket-location.md @@ -90,7 +90,7 @@ module.exports = { // Prevent usage of unwrapped JSX strings // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-no-literals.md - 'react/jsx-no-literals': 'off', + 'react/jsx-no-literals': ['off', { noStrings: true }], // Disallow undeclared variables in JSX // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-no-undef.md @@ -208,6 +208,8 @@ module.exports = { 'static-methods', 'lifecycle', '/^on.+$/', + 'getters', + 'setters', '/^(get|set)(?!(InitialState$|DefaultProps$|ChildContext$)).+$/', 'everything-else', '/^render.+$/', @@ -330,6 +332,23 @@ module.exports = { // https://github.com/yannickcr/eslint-plugin-react/blob/9e13ae2c51e44872b45cc15bf1ac3a72105bdd0e/docs/rules/no-redundant-should-component-update.md // TODO: enable, semver-major 'react/no-redundant-should-component-update': 'off', + + // Prevent unused state values + // https://github.com/yannickcr/eslint-plugin-react/pull/1103/files + // TODO: enable? semver-major + 'react/no-unused-state': 'off', + + // Enforces consistent naming for boolean props + // https://github.com/yannickcr/eslint-plugin-react/blob/73abadb697034b5ccb514d79fb4689836fe61f91/docs/rules/boolean-prop-naming.md + 'react/boolean-prop-naming': ['off', { + propTypeNames: ['bool', 'mutuallyExclusiveTrueProps'], + rule: '^(is|has)[A-Z]([A-Za-z0-9]?)+', + }], + + // Prevents common casing typos + // https://github.com/yannickcr/eslint-plugin-react/blob/73abadb697034b5ccb514d79fb4689836fe61f91/docs/rules/no-typos.md + // TODO: enable, semver-major + 'react/no-typos': 'off', }, settings: { From 1cddb4f2c0069000c235817069cc4449ce2ed681 Mon Sep 17 00:00:00 2001 From: Mark Larah Date: Mon, 14 Aug 2017 19:49:29 -0700 Subject: [PATCH 064/554] [eslint config] [base] [patch] Add jest.config.js to import/no-extraneous-dependencies devDeps --- packages/eslint-config-airbnb-base/rules/imports.js | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/eslint-config-airbnb-base/rules/imports.js b/packages/eslint-config-airbnb-base/rules/imports.js index 6116c6f67c..2700194efe 100644 --- a/packages/eslint-config-airbnb-base/rules/imports.js +++ b/packages/eslint-config-airbnb-base/rules/imports.js @@ -76,6 +76,7 @@ module.exports = { 'test.{js,jsx}', // repos with a single test file 'test-*.{js,jsx}', // repos with multiple top-level test files '**/*.{test,spec}.{js,jsx}', // tests where the extension denotes that it is a test + '**/jest.config.js', // jest config '**/webpack.config.js', // webpack config '**/webpack.config.*.js', // webpack config '**/rollup.config.js', // rollup config From 344c25d83a91c7a9c456e6fc9d5b40d1b924f8d3 Mon Sep 17 00:00:00 2001 From: Wooram Jun Date: Thu, 17 Aug 2017 15:35:14 +0900 Subject: [PATCH 065/554] Fix a wrong link --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 562eebc955..65309ed421 100644 --- a/README.md +++ b/README.md @@ -2658,7 +2658,7 @@ Other Style Guides })()); ``` - [Read more](https://stackoverflow.com/questions/7365172/semicolon-before-self-invoking-function/7365214%237365214). + [Read more](https://stackoverflow.com/questions/7365172/semicolon-before-self-invoking-function/7365214#7365214). **[⬆ back to top](#table-of-contents)** From 855426b3db99b07469962b4d1515757d8284dda0 Mon Sep 17 00:00:00 2001 From: Anton Vasyunin Date: Fri, 18 Aug 2017 00:05:21 +0700 Subject: [PATCH 066/554] Update section on naming conventions for acronyms - Fix array name starting with a capital - Add alternative good example --- README.md | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 65309ed421..69ff656e32 100644 --- a/README.md +++ b/README.md @@ -2928,11 +2928,16 @@ Other Style Guides // ... ]; + // also good + const httpRequests = [ + // ... + ]; + // best import TextMessageContainer from './containers/TextMessageContainer'; // best - const Requests = [ + const requests = [ // ... ]; ``` From 09988e34b4d580af8f6988b438ce492686ad2759 Mon Sep 17 00:00:00 2001 From: Max Kaplan Date: Sun, 20 Aug 2017 09:24:03 -0400 Subject: [PATCH 067/554] [inthewild] adding kaplan komputing --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 69ff656e32..b9887ff20a 100644 --- a/README.md +++ b/README.md @@ -3313,6 +3313,7 @@ Other Style Guides - **Jam3**: [Jam3/Javascript-Code-Conventions](https://github.com/Jam3/Javascript-Code-Conventions) - **JeopardyBot**: [kesne/jeopardy-bot](https://github.com/kesne/jeopardy-bot/blob/master/STYLEGUIDE.md) - **JSSolutions**: [JSSolutions/javascript](https://github.com/JSSolutions/javascript) + - **Kaplan Komputing**: [kaplankomputing/javascript](https://github.com/kaplankomputing/javascript) - **KickorStick**: [kickorstick/javascript](https://github.com/kickorstick/javascript) - **Kinetica Solutions**: [kinetica/javascript](https://github.com/kinetica/Javascript-style-guide) - **LEINWAND**: [LEINWAND/javascript](https://github.com/LEINWAND/javascript) From a79237b02090df922f54b1082515139a59f04874 Mon Sep 17 00:00:00 2001 From: Dhruvdutt Jadhav Date: Thu, 17 Aug 2017 22:54:31 +0530 Subject: [PATCH 068/554] =?UTF-8?q?[guide]=20[react]=20add=20another=20?= =?UTF-8?q?=E2=80=9Cgood=E2=80=9D=20example?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- react/README.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/react/README.md b/react/README.md index b86f743f23..b1ba2ac7a7 100644 --- a/react/README.md +++ b/react/README.md @@ -269,6 +269,9 @@