From 5fd7c6f08c0650ed67297fc83c8a0590c9a92cc8 Mon Sep 17 00:00:00 2001 From: Estelle Date: Mon, 23 Mar 2015 18:48:19 -0700 Subject: [PATCH 001/534] 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/534] [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/534] [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/534] [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/534] [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 4380284b05337f6e48798ff4fd76ab606d5adf94 Mon Sep 17 00:00:00 2001 From: Jason Ellis Date: Tue, 20 Jun 2017 09:37:19 -0500 Subject: [PATCH 006/534] [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 007/534] [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 008/534] 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 009/534] [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 010/534] [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 011/534] [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 012/534] [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 013/534] [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 014/534] [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 015/534] [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 016/534] [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 017/534] [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 018/534] [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 019/534] [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 020/534] [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 021/534] 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 022/534] [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 023/534] [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 024/534] [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 025/534] [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 026/534] [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 027/534] [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 028/534] [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 029/534] [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 030/534] [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 031/534] [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 032/534] [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 033/534] [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 034/534] 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 035/534] 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 036/534] 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 037/534] [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 038/534] 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 039/534] [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 040/534] 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 041/534] 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 042/534] [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 043/534] [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 044/534] 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 045/534] 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 046/534] [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 047/534] =?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 @@