From c068d7cbf1bfb2f263bc928ca7fd895a6a6add7f Mon Sep 17 00:00:00 2001 From: Brett Date: Sat, 26 May 2018 13:38:45 -0700 Subject: [PATCH 001/352] Fix link for Temporal Dead Zone --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 969c65c0e4..0a3a1f88f3 100644 --- a/README.md +++ b/README.md @@ -1748,7 +1748,7 @@ Other Style Guides ## Hoisting - - [14.1](#hoisting--about) `var` declarations get hoisted to the top of their closest enclosing function scope, their assignment does not. `const` and `let` declarations are blessed with a new concept called [Temporal Dead Zones (TDZ)](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/let#Temporal_Dead_Zone_and_errors_with_let). It’s important to know why [typeof is no longer safe](http://es-discourse.com/t/why-typeof-is-no-longer-safe/15). + - [14.1](#hoisting--about) `var` declarations get hoisted to the top of their closest enclosing function scope, their assignment does not. `const` and `let` declarations are blessed with a new concept called [Temporal Dead Zones (TDZ)](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/let#Temporal_Dead_Zone). It’s important to know why [typeof is no longer safe](http://es-discourse.com/t/why-typeof-is-no-longer-safe/15). ```javascript // we know this wouldn’t work (assuming there From 04ab225858b75b9fb1180075b92845700849ea5b Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Sun, 27 May 2018 08:47:29 -0700 Subject: [PATCH 002/352] [eslint config] [*] [deps] update `eslint-plugin-import`, `eslint-find-rules`, `eslint-plugin-react` --- packages/eslint-config-airbnb-base/package.json | 6 +++--- packages/eslint-config-airbnb-base/rules/imports.js | 9 ++++++++- packages/eslint-config-airbnb/package.json | 10 +++++----- 3 files changed, 16 insertions(+), 9 deletions(-) diff --git a/packages/eslint-config-airbnb-base/package.json b/packages/eslint-config-airbnb-base/package.json index 7739f54005..a4b83cda9c 100644 --- a/packages/eslint-config-airbnb-base/package.json +++ b/packages/eslint-config-airbnb-base/package.json @@ -53,15 +53,15 @@ "babel-tape-runner": "^2.0.1", "editorconfig-tools": "^0.1.1", "eslint": "^4.19.1", - "eslint-find-rules": "^3.2.2", - "eslint-plugin-import": "^2.11.0", + "eslint-find-rules": "^3.2.3", + "eslint-plugin-import": "^2.12.0", "in-publish": "^2.0.0", "safe-publish-latest": "^1.1.1", "tape": "^4.9.0" }, "peerDependencies": { "eslint": "^4.19.1", - "eslint-plugin-import": "^2.11.0" + "eslint-plugin-import": "^2.12.0" }, "engines": { "node": ">= 4" diff --git a/packages/eslint-config-airbnb-base/rules/imports.js b/packages/eslint-config-airbnb-base/rules/imports.js index 46c6135093..a8502d554a 100644 --- a/packages/eslint-config-airbnb-base/rules/imports.js +++ b/packages/eslint-config-airbnb-base/rules/imports.js @@ -232,7 +232,14 @@ module.exports = { 'import/no-cycle': ['error', { maxDepth: Infinity }], // Ensures that there are no useless path segments - // https://github.com/benmosher/eslint-plugin-import/issues/1032 + // https://github.com/benmosher/eslint-plugin-import/blob/ebafcbf59ec9f653b2ac2a0156ca3bcba0a7cf57/docs/rules/no-useless-path-segments.md 'import/no-useless-path-segments': 'error', + + // dynamic imports require a leading comment with a webpackChunkName + // https://github.com/benmosher/eslint-plugin-import/blob/ebafcbf59ec9f653b2ac2a0156ca3bcba0a7cf57/docs/rules/dynamic-import-chunkname.md + 'import/dynamic-import-chunkname': ['off', { + importFunctions: [], + webpackChunknameFormat: '[0-9a-zA-Z-_/.]+', + }], }, }; diff --git a/packages/eslint-config-airbnb/package.json b/packages/eslint-config-airbnb/package.json index bc80fdd060..d3fc6d8df1 100644 --- a/packages/eslint-config-airbnb/package.json +++ b/packages/eslint-config-airbnb/package.json @@ -58,10 +58,10 @@ "babel-tape-runner": "^2.0.1", "editorconfig-tools": "^0.1.1", "eslint": "^4.19.1", - "eslint-find-rules": "^3.2.2", - "eslint-plugin-import": "^2.11.0", + "eslint-find-rules": "^3.2.3", + "eslint-plugin-import": "^2.12.0", "eslint-plugin-jsx-a11y": "^6.0.3", - "eslint-plugin-react": "^7.7.0", + "eslint-plugin-react": "^7.8.2", "in-publish": "^2.0.0", "react": ">= 0.13.0", "safe-publish-latest": "^1.1.1", @@ -69,9 +69,9 @@ }, "peerDependencies": { "eslint": "^4.19.1", - "eslint-plugin-import": "^2.11.0", + "eslint-plugin-import": "^2.12.0", "eslint-plugin-jsx-a11y": "^6.0.3", - "eslint-plugin-react": "^7.7.0" + "eslint-plugin-react": "^7.8.2" }, "engines": { "node": ">= 4" From ae82d7678303bd08242299a4a9e2c47717bf9c6b Mon Sep 17 00:00:00 2001 From: Alexandre Syenchuk Date: Wed, 30 May 2018 09:06:14 +0200 Subject: [PATCH 003/352] Update README.md --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 0a3a1f88f3..3b00f8c274 100644 --- a/README.md +++ b/README.md @@ -3719,6 +3719,7 @@ Other Style Guides - **Orion Health**: [orionhealth/javascript](https://github.com/orionhealth/javascript) - **OutBoxSoft**: [OutBoxSoft/javascript](https://github.com/OutBoxSoft/javascript) - **Peerby**: [Peerby/javascript](https://github.com/Peerby/javascript) + - **Qotto**: [Qotto/javascript-style-guide](https://github.com/Qotto/javascript-style-guide) - **Razorfish**: [razorfish/javascript-style-guide](https://github.com/razorfish/javascript-style-guide) - **reddit**: [reddit/styleguide/javascript](https://github.com/reddit/styleguide/tree/master/javascript) - **React**: [facebook.github.io/react/contributing/how-to-contribute.html#style-guide](https://facebook.github.io/react/contributing/how-to-contribute.html#style-guide) From dfc9da71d9ac8669d074cbe0f918b504c8a68be8 Mon Sep 17 00:00:00 2001 From: Andrew Macpherson Date: Thu, 31 May 2018 18:34:17 +0100 Subject: [PATCH 004/352] Add Drupal to In The Wild section. --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 3b00f8c274..d6e1c5e0ab 100644 --- a/README.md +++ b/README.md @@ -3677,6 +3677,7 @@ Other Style Guides - **DailyMotion**: [dailymotion/javascript](https://github.com/dailymotion/javascript) - **DoSomething**: [DoSomething/eslint-config](https://github.com/DoSomething/eslint-config) - **Digitpaint** [digitpaint/javascript](https://github.com/digitpaint/javascript) + - **Drupal**: [www.drupal.org](https://www.drupal.org/project/drupal) - **Ecosia**: [ecosia/javascript](https://github.com/ecosia/javascript) - **Evernote**: [evernote/javascript-style-guide](https://github.com/evernote/javascript-style-guide) - **Evolution Gaming**: [evolution-gaming/javascript](https://github.com/evolution-gaming/javascript) From 8a244801196924797878186d744249c78fa4ed37 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alejandro=20Garc=C3=ADa=20Salas?= Date: Sun, 3 Jun 2018 10:48:10 -0700 Subject: [PATCH 005/352] Fix broken aria roles link in React style guide README --- react/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/react/README.md b/react/README.md index 1af23d4d1f..c4fcf76d56 100644 --- a/react/README.md +++ b/react/README.md @@ -307,7 +307,7 @@ This style guide is mostly based on the standards that are currently prevalent i Me waving hello ``` - - Use only valid, non-abstract [ARIA roles](https://www.w3.org/TR/wai-aria/roles#role_definitions). eslint: [`jsx-a11y/aria-role`](https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/aria-role.md) + - Use only valid, non-abstract [ARIA roles](https://www.w3.org/TR/wai-aria/#usage_intro). eslint: [`jsx-a11y/aria-role`](https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/aria-role.md) ```jsx // bad - not an ARIA role From 5e260928b65f48c895b21d49ea0aa752df2e4d80 Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Sun, 3 Jun 2018 22:19:41 -0700 Subject: [PATCH 006/352] [eslint config] [react] update `eslint-plugin-react` --- packages/eslint-config-airbnb/package.json | 4 ++-- packages/eslint-config-airbnb/rules/react.js | 8 ++++++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/packages/eslint-config-airbnb/package.json b/packages/eslint-config-airbnb/package.json index d3fc6d8df1..faee46ec90 100644 --- a/packages/eslint-config-airbnb/package.json +++ b/packages/eslint-config-airbnb/package.json @@ -61,7 +61,7 @@ "eslint-find-rules": "^3.2.3", "eslint-plugin-import": "^2.12.0", "eslint-plugin-jsx-a11y": "^6.0.3", - "eslint-plugin-react": "^7.8.2", + "eslint-plugin-react": "^7.9.1", "in-publish": "^2.0.0", "react": ">= 0.13.0", "safe-publish-latest": "^1.1.1", @@ -71,7 +71,7 @@ "eslint": "^4.19.1", "eslint-plugin-import": "^2.12.0", "eslint-plugin-jsx-a11y": "^6.0.3", - "eslint-plugin-react": "^7.8.2" + "eslint-plugin-react": "^7.9.1" }, "engines": { "node": ">= 4" diff --git a/packages/eslint-config-airbnb/rules/react.js b/packages/eslint-config-airbnb/rules/react.js index 7d8145a17a..f5a807faac 100644 --- a/packages/eslint-config-airbnb/rules/react.js +++ b/packages/eslint-config-airbnb/rules/react.js @@ -290,8 +290,8 @@ module.exports = { 'react/jsx-indent': ['error', 2], // Disallow target="_blank" on links - // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-no-target-blank.md - 'react/jsx-no-target-blank': 'error', + // https://github.com/yannickcr/eslint-plugin-react/blob/ac102885765be5ff37847a871f239c6703e1c7cc/docs/rules/jsx-no-target-blank.md + 'react/jsx-no-target-blank': ['error', { enforceDynamicLinks: 'always' }], // only .jsx files may have JSX // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-filename-extension.md @@ -436,6 +436,10 @@ module.exports = { // Validate JSX maximum depth // https://github.com/yannickcr/eslint-plugin-react/blob/abe8381c0d6748047224c430ce47f02e40160ed0/docs/rules/jsx-max-depth.md 'react/jsx-max-depth': 'off', + + // Disallow multiple spaces between inline JSX props + // https://github.com/yannickcr/eslint-plugin-react/blob/ac102885765be5ff37847a871f239c6703e1c7cc/docs/rules/jsx-props-no-multi-spaces.md + 'react/jsx-props-no-multi-spaces': 'error', }, settings: { From 74fb34f08d4f1961169e9c37c9036a5b42aa7bf1 Mon Sep 17 00:00:00 2001 From: Daniel McNally Date: Fri, 8 Jun 2018 01:38:03 -0400 Subject: [PATCH 007/352] Add no-unused-vars to README This documents the enforced but currently undocumented `no-unused-vars` rule with a brief description, examples, and noting the `"ignoreRestSiblings": true` option. --- README.md | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/README.md b/README.md index d6e1c5e0ab..b807154d99 100644 --- a/README.md +++ b/README.md @@ -1743,6 +1743,45 @@ Other Style Guides const foo = 'superLongLongLongLongLongLongLongLongString'; ``` + - [13.8](#variables--no-unused-vars) Disallow unused variables. eslint: [`no-unused-vars`](https://eslint.org/docs/rules/no-unused-vars) + + > Why? Variables that are declared and not used anywhere in the code are most likely an error due to incomplete refactoring. Such variables take up space in the code and can lead to confusion by readers. + + ```javascript + // bad + + var some_unused_var = 42; + + // Write-only variables are not considered as used. + var y = 10; + y = 5; + + // A read for a modification of itself is not considered as used. + var z = 0; + z = z + 1; + + // Unused function arguments. + function getX(x, y) { + return x; + } + + // good + + function getXPlusY(x, y) { + return x + y; + } + + var x = 1; + var y = a + 2; + + alert(getXPlusY(x, y)); + + // 'type' is ignored even if unused because it has a rest property sibling. + // This is a form of extracting an object that omits the specified keys. + var { type, ...coords } = data; + // 'coords' is now the 'data' object without its 'type' property. + ``` + **[⬆ back to top](#table-of-contents)** ## Hoisting From 103f5e2a5901392878889ec1f1ad4e59c8d65dc3 Mon Sep 17 00:00:00 2001 From: Vse Mozhet Byt Date: Fri, 8 Jun 2018 19:49:37 +0300 Subject: [PATCH 008/352] doc: add missing anchor in README.md --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index b807154d99..e486ae170e 100644 --- a/README.md +++ b/README.md @@ -1743,6 +1743,7 @@ Other Style Guides const foo = 'superLongLongLongLongLongLongLongLongString'; ``` + - [13.8](#variables--no-unused-vars) Disallow unused variables. eslint: [`no-unused-vars`](https://eslint.org/docs/rules/no-unused-vars) > Why? Variables that are declared and not used anywhere in the code are most likely an error due to incomplete refactoring. Such variables take up space in the code and can lead to confusion by readers. From d270031fc07bd26df9d53106704e04abc37d8256 Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Thu, 21 Jun 2018 13:28:22 -0700 Subject: [PATCH 009/352] [eslint config] [*] [dev deps] update `babel-preset-airbnb`, `tape` --- packages/eslint-config-airbnb-base/package.json | 4 ++-- packages/eslint-config-airbnb/package.json | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/eslint-config-airbnb-base/package.json b/packages/eslint-config-airbnb-base/package.json index a4b83cda9c..9327414f6c 100644 --- a/packages/eslint-config-airbnb-base/package.json +++ b/packages/eslint-config-airbnb-base/package.json @@ -49,7 +49,7 @@ }, "homepage": "https://github.com/airbnb/javascript", "devDependencies": { - "babel-preset-airbnb": "^2.4.0", + "babel-preset-airbnb": "^2.5.1", "babel-tape-runner": "^2.0.1", "editorconfig-tools": "^0.1.1", "eslint": "^4.19.1", @@ -57,7 +57,7 @@ "eslint-plugin-import": "^2.12.0", "in-publish": "^2.0.0", "safe-publish-latest": "^1.1.1", - "tape": "^4.9.0" + "tape": "^4.9.1" }, "peerDependencies": { "eslint": "^4.19.1", diff --git a/packages/eslint-config-airbnb/package.json b/packages/eslint-config-airbnb/package.json index faee46ec90..95cc0adcf8 100644 --- a/packages/eslint-config-airbnb/package.json +++ b/packages/eslint-config-airbnb/package.json @@ -54,7 +54,7 @@ "object.entries": "^1.0.4" }, "devDependencies": { - "babel-preset-airbnb": "^2.4.0", + "babel-preset-airbnb": "^2.5.1", "babel-tape-runner": "^2.0.1", "editorconfig-tools": "^0.1.1", "eslint": "^4.19.1", @@ -65,7 +65,7 @@ "in-publish": "^2.0.0", "react": ">= 0.13.0", "safe-publish-latest": "^1.1.1", - "tape": "^4.9.0" + "tape": "^4.9.1" }, "peerDependencies": { "eslint": "^4.19.1", From 2668495fee10b4b70f72ba623b4f319ad539700a Mon Sep 17 00:00:00 2001 From: minimooooz Date: Thu, 12 Oct 2017 11:17:22 +0700 Subject: [PATCH 010/352] add ES2015-2018 in npm package keywords --- package.json | 3 +++ packages/eslint-config-airbnb-base/package.json | 6 +++++- packages/eslint-config-airbnb/package.json | 6 +++++- 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index b50dd7a121..d907751ccc 100644 --- a/package.json +++ b/package.json @@ -26,6 +26,9 @@ "airbnb", "es6", "es2015", + "es2016", + "es2017", + "es2018", "react", "jsx" ], diff --git a/packages/eslint-config-airbnb-base/package.json b/packages/eslint-config-airbnb-base/package.json index 9327414f6c..bd2ef922c3 100644 --- a/packages/eslint-config-airbnb-base/package.json +++ b/packages/eslint-config-airbnb-base/package.json @@ -25,7 +25,11 @@ "config", "airbnb", "javascript", - "styleguide" + "styleguide", + "es2015", + "es2016", + "es2017", + "es2018" ], "author": "Jake Teton-Landis (https://twitter.com/@jitl)", "contributors": [ diff --git a/packages/eslint-config-airbnb/package.json b/packages/eslint-config-airbnb/package.json index 95cc0adcf8..97e1579393 100644 --- a/packages/eslint-config-airbnb/package.json +++ b/packages/eslint-config-airbnb/package.json @@ -25,7 +25,11 @@ "config", "airbnb", "javascript", - "styleguide" + "styleguide", + "es2015", + "es2016", + "es2017", + "es2018" ], "author": "Jake Teton-Landis (https://twitter.com/@jitl)", "contributors": [ From b3bbd1ccbc2495762ed3b2ec47e776135e532d76 Mon Sep 17 00:00:00 2001 From: Josh Wells Date: Wed, 11 Apr 2018 13:46:34 +0100 Subject: [PATCH 011/352] [eslint config] [base] [breaking] order of import statements is ignored for unassigned imports --- packages/eslint-config-airbnb-base/rules/imports.js | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/packages/eslint-config-airbnb-base/rules/imports.js b/packages/eslint-config-airbnb-base/rules/imports.js index a8502d554a..c48959e14f 100644 --- a/packages/eslint-config-airbnb-base/rules/imports.js +++ b/packages/eslint-config-airbnb-base/rules/imports.js @@ -115,7 +115,7 @@ module.exports = { // disallow non-import statements appearing before import statements // https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/first.md - 'import/first': ['error', 'absolute-first'], + 'import/first': 'error', // disallow non-import statements appearing before import statements // https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/imports-first.md @@ -139,13 +139,10 @@ module.exports = { jsx: 'never', }], - // Enforce a convention in module import order + // ensure absolute imports are above relative imports and that unassigned imports are ignored // https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/order.md - // TODO: enable? - 'import/order': ['off', { - groups: ['builtin', 'external', 'internal', 'parent', 'sibling', 'index'], - 'newlines-between': 'never', - }], + // TODO: enforce a stricter convention in module import order? + 'import/order': ['error', { groups: [['builtin', 'external', 'internal']] }], // Require a newline after the last import/require in a group // https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/newline-after-import.md From 068d6b69bf70c83d16eba25c9c517a4859c96ea4 Mon Sep 17 00:00:00 2001 From: Moritz Kneilmann Date: Tue, 15 May 2018 23:54:09 +0200 Subject: [PATCH 012/352] [eslint config] [base] [patch] Adjust imports for vue-cli Allows the vue-cli config file `vue.config.js` to import `devDependencies` by altering the rule `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 c48959e14f..91d82df1cb 100644 --- a/packages/eslint-config-airbnb-base/rules/imports.js +++ b/packages/eslint-config-airbnb-base/rules/imports.js @@ -79,6 +79,7 @@ module.exports = { 'test-*.{js,jsx}', // repos with multiple top-level test files '**/*{.,_}{test,spec}.{js,jsx}', // tests where the extension or filename suffix denotes that it is a test '**/jest.config.js', // jest config + '**/vue.config.js', // vue-cli config '**/webpack.config.js', // webpack config '**/webpack.config.*.js', // webpack config '**/rollup.config.js', // rollup config From 25e711cedd78e3329e8a8508d723996080d8336f Mon Sep 17 00:00:00 2001 From: Gaurav Paliwal Date: Wed, 20 Jun 2018 17:31:00 +0530 Subject: [PATCH 013/352] [eslint config] [patch] Add new methods introduced in react@16.3 --- packages/eslint-config-airbnb/rules/react.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/packages/eslint-config-airbnb/rules/react.js b/packages/eslint-config-airbnb/rules/react.js index f5a807faac..a2a21c141f 100644 --- a/packages/eslint-config-airbnb/rules/react.js +++ b/packages/eslint-config-airbnb/rules/react.js @@ -23,13 +23,17 @@ module.exports = { 'getDefaultProps', 'getChildContext', 'componentWillMount', + 'UNSAFE_componentWillMount', 'componentDidMount', 'componentWillReceiveProps', + 'UNSAFE_componentWillReceiveProps', 'shouldComponentUpdate', 'componentWillUpdate', + 'UNSAFE_componentWillUpdate', 'componentDidUpdate', 'componentWillUnmount', 'componentDidCatch', + 'getSnapshotBeforeUpdate' ], }], From 951825c6d216ef2b3017472ae66e9b3360b089ae Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Thu, 21 Jun 2018 14:22:54 -0700 Subject: [PATCH 014/352] [eslint config] set `forbid-foreign-prop-types` to "warn" --- packages/eslint-config-airbnb/rules/react.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/packages/eslint-config-airbnb/rules/react.js b/packages/eslint-config-airbnb/rules/react.js index a2a21c141f..20971d1622 100644 --- a/packages/eslint-config-airbnb/rules/react.js +++ b/packages/eslint-config-airbnb/rules/react.js @@ -375,8 +375,9 @@ module.exports = { // Forbids using non-exported propTypes // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/forbid-foreign-prop-types.md - // TODO: enable? - 'react/forbid-foreign-prop-types': ['off', { allowInPropTypes: true }], + // this is intentionally set to "warn". it would be "error", but it's only critical if you're using + // a babel transform to strip propTypes in production. + 'react/forbid-foreign-prop-types': ['warn', { allowInPropTypes: true }], // Prevent void DOM elements from receiving children // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/void-dom-elements-no-children.md From fdb998b38adda8777022fe33b86b2f8092ac83a0 Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Thu, 21 Jun 2018 14:39:07 -0700 Subject: [PATCH 015/352] [eslint config] [base] fix tests --- packages/eslint-config-airbnb-base/whitespace.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/eslint-config-airbnb-base/whitespace.js b/packages/eslint-config-airbnb-base/whitespace.js index 66a05e52b9..d215d4ae6a 100644 --- a/packages/eslint-config-airbnb-base/whitespace.js +++ b/packages/eslint-config-airbnb-base/whitespace.js @@ -1,8 +1,9 @@ -const baseConfig = require('.'); const assign = require('object.assign'); const entries = require('object.entries'); const CLIEngine = require('eslint').CLIEngine; +const baseConfig = require('.'); + function onlyErrorOnRules(rulesToError, config) { const errorsOnly = assign({}, config); const cli = new CLIEngine({ baseConfig: config, useEslintrc: false }); From 8be089eb1138c6e5dbdc27146248525c0633ba47 Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Thu, 21 Jun 2018 14:46:24 -0700 Subject: [PATCH 016/352] [eslint config] fix tests --- packages/eslint-config-airbnb/rules/react.js | 4 ++-- packages/eslint-config-airbnb/whitespace.js | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/packages/eslint-config-airbnb/rules/react.js b/packages/eslint-config-airbnb/rules/react.js index 20971d1622..62675c1cf0 100644 --- a/packages/eslint-config-airbnb/rules/react.js +++ b/packages/eslint-config-airbnb/rules/react.js @@ -375,8 +375,8 @@ module.exports = { // Forbids using non-exported propTypes // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/forbid-foreign-prop-types.md - // this is intentionally set to "warn". it would be "error", but it's only critical if you're using - // a babel transform to strip propTypes in production. + // this is intentionally set to "warn". it would be "error", + // but it's only critical if you're stripping propTypes in production. 'react/forbid-foreign-prop-types': ['warn', { allowInPropTypes: true }], // Prevent void DOM elements from receiving children diff --git a/packages/eslint-config-airbnb/whitespace.js b/packages/eslint-config-airbnb/whitespace.js index ba36569a99..414f9c37a1 100644 --- a/packages/eslint-config-airbnb/whitespace.js +++ b/packages/eslint-config-airbnb/whitespace.js @@ -1,8 +1,9 @@ -const baseConfig = require('.'); const assign = require('object.assign'); const entries = require('object.entries'); const CLIEngine = require('eslint').CLIEngine; +const baseConfig = require('.'); + function onlyErrorOnRules(rulesToError, config) { const errorsOnly = assign({}, config); const cli = new CLIEngine({ baseConfig: config, useEslintrc: false }); From afe340773f082b262955abf243efbd60e2d87ee4 Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Thu, 21 Jun 2018 14:46:43 -0700 Subject: [PATCH 017/352] [eslint config] [base] v13.0.0 --- .../eslint-config-airbnb-base/CHANGELOG.md | 34 +++++++++++++++++++ .../eslint-config-airbnb-base/package.json | 2 +- 2 files changed, 35 insertions(+), 1 deletion(-) diff --git a/packages/eslint-config-airbnb-base/CHANGELOG.md b/packages/eslint-config-airbnb-base/CHANGELOG.md index 6dd34427fc..daff7f51a7 100644 --- a/packages/eslint-config-airbnb-base/CHANGELOG.md +++ b/packages/eslint-config-airbnb-base/CHANGELOG.md @@ -1,3 +1,37 @@ +13.0.0 / 2018-06-21 +================== + - [breaking] order of import statements is ignored for unassigned imports (#1782) + - [breaking] enable `import/no-cycle`: warn on cyclical dependencies (#1779) + - [breaking] Change import/no-self-import from "off" to "error" (#1770) + - [breaking] Update `object-curly-newline` to match eslint 4.18.0 (#1761) + - [breaking] enable `no-useless-path-segments` (#1743) + - [breaking] Prevent line breaks before and after `=` (#1710) + - [breaking] Add .mjs extension support (#1634) + - [breaking] enable `implicit-arrow-linebreak` + - [breaking] Enables `nonblock-statement-body-position` rule and adds link to guide (#1618) + - [breaking] `no-mixed-operators`: only warn on `**` and `%` mixed with arithmetic operators; removes violation against mixing common math operators. (#1611) + - [breaking] `import/named`: enable + - [breaking] `lines-between-class-members`: set to “always” + - [breaking] `no-else-return`: disallow else-if (#1595) + - [breaking] Enables eslint rule for operator-linebreak + - [new] Adds config entry point with only whitespace rules enabled (#1749, #1751) + - [minor] only allow one newline at the end (#1794) + - [patch] Adjust imports for vue-cli (#1809) + - [patch] Allow devDependencies for `foo_spec.js` naming style (#1732) + - [patch] `function-paren-newline`: change to "consistent" + - [patch] avoid `__mocks__` `no-extraneous-dependencies` check (#1772) + - [patch] Include 'accumulator' exception for `no-param-reassign` (#1768) + - [patch] Set import/extensions to ignorePackages (#1652) + - [patch] properly ignore indentation on jsx + - [patch] `array-callback-return`: enable `allowImplicit` option (#1668) + - [deps] update `eslint`, `eslint-plugin-import` + - [dev deps] update `babel-preset-airbnb`, `tape`, `eslint-find-rules` + - [meta] add ES2015-2018 in npm package keywords (#1587) + - [meta] Add licenses to sub packages (#1746) + - [docs] add `npx` shortcut (#1694) + - [docs] Use HTTPS for links to ESLint documentation (#1628) + - [tests] ensure all entry points parse + 12.1.0 / 2017-10-16 ================== - [deps] update `eslint` to `v4.9` diff --git a/packages/eslint-config-airbnb-base/package.json b/packages/eslint-config-airbnb-base/package.json index bd2ef922c3..bd072bf850 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": "12.1.0", + "version": "13.0.0", "description": "Airbnb's base JS ESLint config, following our styleguide", "main": "index.js", "scripts": { From d14ed5daa7625eab6e03fb290b0a18ed11b229fc Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Thu, 21 Jun 2018 15:16:52 -0700 Subject: [PATCH 018/352] [eslint config] [breaking] update `eslint-config-airbnb-base` --- packages/eslint-config-airbnb/package.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/eslint-config-airbnb/package.json b/packages/eslint-config-airbnb/package.json index 97e1579393..313e61a3bb 100644 --- a/packages/eslint-config-airbnb/package.json +++ b/packages/eslint-config-airbnb/package.json @@ -26,7 +26,7 @@ "airbnb", "javascript", "styleguide", - "es2015", + "es2015", "es2016", "es2017", "es2018" @@ -53,7 +53,7 @@ }, "homepage": "https://github.com/airbnb/javascript", "dependencies": { - "eslint-config-airbnb-base": "^12.1.0", + "eslint-config-airbnb-base": "^13.0.0", "object.assign": "^4.1.0", "object.entries": "^1.0.4" }, From cae920fc308325b40f49c5e8f76bbeb5d8663fc5 Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Thu, 21 Jun 2018 15:22:10 -0700 Subject: [PATCH 019/352] [eslint config] v17.0.0 --- packages/eslint-config-airbnb/CHANGELOG.md | 19 +++++++++++++++++++ packages/eslint-config-airbnb/package.json | 2 +- 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/packages/eslint-config-airbnb/CHANGELOG.md b/packages/eslint-config-airbnb/CHANGELOG.md index d19acfc7f2..14f9e6748a 100644 --- a/packages/eslint-config-airbnb/CHANGELOG.md +++ b/packages/eslint-config-airbnb/CHANGELOG.md @@ -1,3 +1,22 @@ +17.0.0 / 2018-06-21 +================== +- [breaking] update `eslint-config-airbnb-base` to v13 +- [breaking] enable `no-useless-path-segments` (#1743) +- [breaking] update `eslint-plugin-react` to `v7.6`; update rule configs (#1737) +- [breaking] bump react pragma to v16; update `class-methods-use-this`'s `exceptMethods` to include `componentDidCatch` (#1704) +- [new] Adds config entry point with only whitespace rules enabled (#1749, #1751) +- [patch] set `forbid-foreign-prop-types` to "warn" +- [patch] Add new methods introduced in react@16.3 (#1831) +- [patch] `label-has-for`: Remove redundant component (#1802) +- [patch] Add 'to' as a specialLink to the 'anchor-is-valid' a11y rule (#1648) +- [patch] disable `no-did-mount-set-state`, since it’s necessary for server-rendering. +- [deps] update `eslint`, `eslint-plugin-react`, `eslint-plugin-import`, +- [dev deps] update `babel-preset-airbnb`, `tape`, `eslint-find-rules` +- [meta] add ES2015-2018 in npm package keywords (#1587) +- [meta] Add licenses to sub packages (#1746) +- [docs] add `npx` shortcut (#1694) +- [docs] Use HTTPS for links to ESLint documentation (#1628) + 16.1.0 / 2017-10-16 ================== - [deps] update `eslint-config-airbnb-base`, `eslint` to v4.9 diff --git a/packages/eslint-config-airbnb/package.json b/packages/eslint-config-airbnb/package.json index 313e61a3bb..160a44b823 100644 --- a/packages/eslint-config-airbnb/package.json +++ b/packages/eslint-config-airbnb/package.json @@ -1,6 +1,6 @@ { "name": "eslint-config-airbnb", - "version": "16.1.0", + "version": "17.0.0", "description": "Airbnb's ESLint config, following our styleguide", "main": "index.js", "scripts": { From 2161ddf8d6b608fbb91466e741f68b6a50608d26 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=96=9B=E5=AE=9A=E8=B0=94=E7=9A=84=E7=8C=AB?= Date: Mon, 25 Jun 2018 02:08:15 +0800 Subject: [PATCH 020/352] Build: add node 10 --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index bc8324b755..0f4ecc3fb1 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,5 +1,6 @@ language: node_js node_js: + - "10" - "9" - "8" - "7" From 8de558b7500c91e8e77e4c2446e9888844bcba77 Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Sun, 24 Jun 2018 19:41:27 -0700 Subject: [PATCH 021/352] [eslint config] [*] [deps] update `eslint-plugin-import` --- packages/eslint-config-airbnb-base/package.json | 4 ++-- packages/eslint-config-airbnb-base/rules/imports.js | 4 ++++ packages/eslint-config-airbnb/package.json | 4 ++-- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/packages/eslint-config-airbnb-base/package.json b/packages/eslint-config-airbnb-base/package.json index bd072bf850..4fced65b6d 100644 --- a/packages/eslint-config-airbnb-base/package.json +++ b/packages/eslint-config-airbnb-base/package.json @@ -58,14 +58,14 @@ "editorconfig-tools": "^0.1.1", "eslint": "^4.19.1", "eslint-find-rules": "^3.2.3", - "eslint-plugin-import": "^2.12.0", + "eslint-plugin-import": "^2.13.0", "in-publish": "^2.0.0", "safe-publish-latest": "^1.1.1", "tape": "^4.9.1" }, "peerDependencies": { "eslint": "^4.19.1", - "eslint-plugin-import": "^2.12.0" + "eslint-plugin-import": "^2.13.0" }, "engines": { "node": ">= 4" diff --git a/packages/eslint-config-airbnb-base/rules/imports.js b/packages/eslint-config-airbnb-base/rules/imports.js index 91d82df1cb..fbeca8dc83 100644 --- a/packages/eslint-config-airbnb-base/rules/imports.js +++ b/packages/eslint-config-airbnb-base/rules/imports.js @@ -239,5 +239,9 @@ module.exports = { importFunctions: [], webpackChunknameFormat: '[0-9a-zA-Z-_/.]+', }], + + // Use this rule to prevent imports to folders in relative parent paths. + // https://github.com/benmosher/eslint-plugin-import/blob/c34f14f67f077acd5a61b3da9c0b0de298d20059/docs/rules/no-relative-parent-imports.md + 'import/no-relative-parent-imports': 'off', }, }; diff --git a/packages/eslint-config-airbnb/package.json b/packages/eslint-config-airbnb/package.json index 160a44b823..f0f16ccc02 100644 --- a/packages/eslint-config-airbnb/package.json +++ b/packages/eslint-config-airbnb/package.json @@ -63,7 +63,7 @@ "editorconfig-tools": "^0.1.1", "eslint": "^4.19.1", "eslint-find-rules": "^3.2.3", - "eslint-plugin-import": "^2.12.0", + "eslint-plugin-import": "^2.13.0", "eslint-plugin-jsx-a11y": "^6.0.3", "eslint-plugin-react": "^7.9.1", "in-publish": "^2.0.0", @@ -73,7 +73,7 @@ }, "peerDependencies": { "eslint": "^4.19.1", - "eslint-plugin-import": "^2.12.0", + "eslint-plugin-import": "^2.13.0", "eslint-plugin-jsx-a11y": "^6.0.3", "eslint-plugin-react": "^7.9.1" }, From 6a593069e1055a082d3891cc50579a6d586bf3eb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=96=9B=E5=AE=9A=E8=B0=94=E7=9A=84=E7=8C=AB?= Date: Mon, 25 Jun 2018 02:09:32 +0800 Subject: [PATCH 022/352] [dev deps] update `markdownlint-cli` --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index d907751ccc..1fdcd7be15 100644 --- a/package.json +++ b/package.json @@ -39,6 +39,6 @@ }, "homepage": "https://github.com/airbnb/javascript", "devDependencies": { - "markdownlint-cli": "^0.3.1" + "markdownlint-cli": "^0.10.0" } } From 363bb077658906ccc809419b1ce3cb2f75b29e90 Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Sun, 24 Jun 2018 22:57:06 -0700 Subject: [PATCH 023/352] [eslint config] [deps] update `eslint-plugin-react` --- packages/eslint-config-airbnb/package.json | 4 ++-- packages/eslint-config-airbnb/rules/react.js | 4 ++++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/packages/eslint-config-airbnb/package.json b/packages/eslint-config-airbnb/package.json index f0f16ccc02..9e3deaa716 100644 --- a/packages/eslint-config-airbnb/package.json +++ b/packages/eslint-config-airbnb/package.json @@ -65,7 +65,7 @@ "eslint-find-rules": "^3.2.3", "eslint-plugin-import": "^2.13.0", "eslint-plugin-jsx-a11y": "^6.0.3", - "eslint-plugin-react": "^7.9.1", + "eslint-plugin-react": "^7.10.0", "in-publish": "^2.0.0", "react": ">= 0.13.0", "safe-publish-latest": "^1.1.1", @@ -75,7 +75,7 @@ "eslint": "^4.19.1", "eslint-plugin-import": "^2.13.0", "eslint-plugin-jsx-a11y": "^6.0.3", - "eslint-plugin-react": "^7.9.1" + "eslint-plugin-react": "^7.10.0" }, "engines": { "node": ">= 4" diff --git a/packages/eslint-config-airbnb/rules/react.js b/packages/eslint-config-airbnb/rules/react.js index 62675c1cf0..dcd3ac95be 100644 --- a/packages/eslint-config-airbnb/rules/react.js +++ b/packages/eslint-config-airbnb/rules/react.js @@ -445,6 +445,10 @@ module.exports = { // Disallow multiple spaces between inline JSX props // https://github.com/yannickcr/eslint-plugin-react/blob/ac102885765be5ff37847a871f239c6703e1c7cc/docs/rules/jsx-props-no-multi-spaces.md 'react/jsx-props-no-multi-spaces': 'error', + + // Prevent usage of UNSAFE_ methods + // https://github.com/yannickcr/eslint-plugin-react/blob/157cc932be2cfaa56b3f5b45df6f6d4322a2f660/docs/rules/no-unsafe.md + 'react/no-unsafe': 'off', }, settings: { From 47021150388d1cea54c529463fe20299f1de9bb5 Mon Sep 17 00:00:00 2001 From: liyuhang Date: Mon, 25 Jun 2018 16:08:50 +0800 Subject: [PATCH 024/352] Fix: Typo --- linters/.markdownlint.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/linters/.markdownlint.json b/linters/.markdownlint.json index e7a019fed8..8731243cf7 100644 --- a/linters/.markdownlint.json +++ b/linters/.markdownlint.json @@ -31,7 +31,7 @@ "comment": "MD009: Disallow trailing spaces", "no-trailing-spaces": { - "br-spaces": 0, + "br_spaces": 0, "comment": "Empty lines inside list items should not be indented", "list_item_empty_lines": false }, From d951220399c75099838fc79577033b00530b2b90 Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Mon, 25 Jun 2018 13:40:38 -0700 Subject: [PATCH 025/352] [eslint config] [*] [dev deps] update `eslint-find-rules` --- packages/eslint-config-airbnb-base/package.json | 2 +- packages/eslint-config-airbnb/package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/eslint-config-airbnb-base/package.json b/packages/eslint-config-airbnb-base/package.json index 4fced65b6d..cb9efcf519 100644 --- a/packages/eslint-config-airbnb-base/package.json +++ b/packages/eslint-config-airbnb-base/package.json @@ -57,7 +57,7 @@ "babel-tape-runner": "^2.0.1", "editorconfig-tools": "^0.1.1", "eslint": "^4.19.1", - "eslint-find-rules": "^3.2.3", + "eslint-find-rules": "^3.3.1", "eslint-plugin-import": "^2.13.0", "in-publish": "^2.0.0", "safe-publish-latest": "^1.1.1", diff --git a/packages/eslint-config-airbnb/package.json b/packages/eslint-config-airbnb/package.json index 9e3deaa716..81f50cbed4 100644 --- a/packages/eslint-config-airbnb/package.json +++ b/packages/eslint-config-airbnb/package.json @@ -62,7 +62,7 @@ "babel-tape-runner": "^2.0.1", "editorconfig-tools": "^0.1.1", "eslint": "^4.19.1", - "eslint-find-rules": "^3.2.3", + "eslint-find-rules": "^3.3.1", "eslint-plugin-import": "^2.13.0", "eslint-plugin-jsx-a11y": "^6.0.3", "eslint-plugin-react": "^7.10.0", From 27e5e20b70a042945a63c37ac1d9ad834fc3acd0 Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Mon, 25 Jun 2018 14:14:01 -0700 Subject: [PATCH 026/352] [eslint config] [base] [new] update base ecmaVersion to 2018; remove deprecated experimentalObjectRestSpread option --- packages/eslint-config-airbnb-base/index.js | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/packages/eslint-config-airbnb-base/index.js b/packages/eslint-config-airbnb-base/index.js index 4de657b075..16b423f35d 100644 --- a/packages/eslint-config-airbnb-base/index.js +++ b/packages/eslint-config-airbnb-base/index.js @@ -9,11 +9,8 @@ module.exports = { './rules/imports', ].map(require.resolve), parserOptions: { - ecmaVersion: 2017, + ecmaVersion: 2018, sourceType: 'module', - ecmaFeatures: { - experimentalObjectRestSpread: true, - }, }, rules: { strict: 'error', From 77fdae6a74a718d1ec32455088dbb5f964f5d271 Mon Sep 17 00:00:00 2001 From: Noah Benham Date: Mon, 2 Jul 2018 09:17:21 -0500 Subject: [PATCH 027/352] Add Cerner to In The Wild [Cerner](https://github.com/cerner/) uses Airbnb for our JS projects. --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index e486ae170e..7912c73cfc 100644 --- a/README.md +++ b/README.md @@ -3711,6 +3711,7 @@ Other Style Guides - **Bonhomme**: [bonhommeparis/javascript](https://github.com/bonhommeparis/javascript) - **Brainshark**: [brainshark/javascript](https://github.com/brainshark/javascript) - **CaseNine**: [CaseNine/javascript](https://github.com/CaseNine/javascript) + - **Cerner**: [Cerner](https://github.com/cerner/) - **Chartboost**: [ChartBoost/javascript-style-guide](https://github.com/ChartBoost/javascript-style-guide) - **ComparaOnline**: [comparaonline/javascript](https://github.com/comparaonline/javascript-style-guide) - **Compass Learning**: [compasslearning/javascript-style-guide](https://github.com/compasslearning/javascript-style-guide) From fe8de599774bf8d312b2b94e93172e873c36df8f Mon Sep 17 00:00:00 2001 From: Ahmed Tarek Date: Tue, 3 Jul 2018 21:18:11 +0200 Subject: [PATCH 028/352] [eslint-config] [*] [docs] :pencil2: fix typo in Readme --- 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 fa0152eb04..3c1a9ce914 100644 --- a/packages/eslint-config-airbnb-base/README.md +++ b/packages/eslint-config-airbnb-base/README.md @@ -86,7 +86,7 @@ See [Airbnb's overarching ESLint config](https://npmjs.com/eslint-config-airbnb) ### eslint-config-airbnb-base/whitespace -This entry point that only warns on whitespace rules and sets all other rules to warnings. View the list of whitespace rules [here](https://github.com/airbnb/javascript/blob/master/packages/eslint-config-airbnb-base/whitespace.js). +This entry point only warns on whitespace rules and sets all other rules to warnings. View the list of whitespace rules [here](https://github.com/airbnb/javascript/blob/master/packages/eslint-config-airbnb-base/whitespace.js). ## Improving this config diff --git a/packages/eslint-config-airbnb/README.md b/packages/eslint-config-airbnb/README.md index 2f341ec187..f679682936 100644 --- a/packages/eslint-config-airbnb/README.md +++ b/packages/eslint-config-airbnb/README.md @@ -57,7 +57,7 @@ If you use yarn, run `npm info "eslint-config-airbnb@latest" peerDependencies` t ### eslint-config-airbnb/whitespace -This entry point that only warns on whitespace rules and sets all other rules to warnings. View the list of whitespace rules [here](https://github.com/airbnb/javascript/blob/master/packages/eslint-config-airbnb/whitespace.js). +This entry point only warns on whitespace rules and sets all other rules to warnings. View the list of whitespace rules [here](https://github.com/airbnb/javascript/blob/master/packages/eslint-config-airbnb/whitespace.js). ### eslint-config-airbnb/base From 5d1f4b9a49ee7def65343f5efccfcce7723b9b4b Mon Sep 17 00:00:00 2001 From: Mauro Zenoni <25953912+maurozenoni@users.noreply.github.com> Date: Tue, 3 Jul 2018 11:51:37 +0200 Subject: [PATCH 029/352] [guide] Updated Arrays Section - corrected paragraph 4.4 (conversion from iterable to array) - added paragraph 4.5 (conversion from array-like to array) --- README.md | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 7912c73cfc..54cb2c0d4c 100644 --- a/README.md +++ b/README.md @@ -369,8 +369,9 @@ Other Style Guides const itemsCopy = [...items]; ``` - - - [4.4](#arrays--from) To convert an array-like object to an array, use spreads `...` instead of [`Array.from`](https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/Array/from). + + + - [4.4](#arrays--from-iterable) To convert an iterable object to an array, use spreads `...` instead of [`Array.from`](https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/Array/from). ```javascript const foo = document.querySelectorAll('.foo'); @@ -382,8 +383,21 @@ Other Style Guides const nodes = [...foo]; ``` + + - [4.5](#arrays--from-array-like) Use [`Array.from`](https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/Array/from) for converting an array-like object to an array. + + ```javascript + const arrLike = { 0: 'foo', 1: 'bar', 2: 'baz', length: 3 }; + + // bad + const arr = Array.prototype.slice.call(arrLike); + + // good + const arr = Array.from(arrLike); + ``` + - - [4.5](#arrays--mapping) Use [Array.from](https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/Array/from) instead of spread `...` for mapping over iterables, because it avoids creating an intermediate array. + - [4.6](#arrays--mapping) Use [`Array.from`](https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/Array/from) instead of spread `...` for mapping over iterables, because it avoids creating an intermediate array. ```javascript // bad @@ -394,7 +408,7 @@ Other Style Guides ``` - - [4.6](#arrays--callback-return) Use return statements in array method callbacks. It’s ok to omit the return if the function body consists of a single statement returning an expression without side effects, following [8.2](#arrows--implicit-return). eslint: [`array-callback-return`](https://eslint.org/docs/rules/array-callback-return) + - [4.7](#arrays--callback-return) Use return statements in array method callbacks. It’s ok to omit the return if the function body consists of a single statement returning an expression without side effects, following [8.2](#arrows--implicit-return). eslint: [`array-callback-return`](https://eslint.org/docs/rules/array-callback-return) ```javascript // good @@ -441,7 +455,7 @@ Other Style Guides ``` - - [4.7](#arrays--bracket-newline) Use line breaks after open and before close array brackets if an array has multiple lines + - [4.8](#arrays--bracket-newline) Use line breaks after open and before close array brackets if an array has multiple lines ```javascript // bad From 7dda84a335f5903d72c9423dc17f33f2c9813d2a Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Wed, 4 Jul 2018 22:33:27 -0700 Subject: [PATCH 030/352] [eslint config] [deps] [minor] update `jsx-a11y` plugin; enable `label-has-associated-control` rule This is semver-minor, because the `label-has-associated-control` rule is the same as the `label-has-for` rule, theoretically. Both remain enabled, but `label-has-for` will be disabled in the future if this rule proves out. --- packages/eslint-config-airbnb/package.json | 4 ++-- packages/eslint-config-airbnb/rules/react-a11y.js | 10 ++++++++++ 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/packages/eslint-config-airbnb/package.json b/packages/eslint-config-airbnb/package.json index 81f50cbed4..53079d4a07 100644 --- a/packages/eslint-config-airbnb/package.json +++ b/packages/eslint-config-airbnb/package.json @@ -64,7 +64,7 @@ "eslint": "^4.19.1", "eslint-find-rules": "^3.3.1", "eslint-plugin-import": "^2.13.0", - "eslint-plugin-jsx-a11y": "^6.0.3", + "eslint-plugin-jsx-a11y": "^6.1.0", "eslint-plugin-react": "^7.10.0", "in-publish": "^2.0.0", "react": ">= 0.13.0", @@ -74,7 +74,7 @@ "peerDependencies": { "eslint": "^4.19.1", "eslint-plugin-import": "^2.13.0", - "eslint-plugin-jsx-a11y": "^6.0.3", + "eslint-plugin-jsx-a11y": "^6.1.0", "eslint-plugin-react": "^7.10.0" }, "engines": { diff --git a/packages/eslint-config-airbnb/rules/react-a11y.js b/packages/eslint-config-airbnb/rules/react-a11y.js index f53b3d22f6..dbb073fa67 100644 --- a/packages/eslint-config-airbnb/rules/react-a11y.js +++ b/packages/eslint-config-airbnb/rules/react-a11y.js @@ -56,6 +56,16 @@ module.exports = { allowChildren: false, }], + // Enforce that a label tag has a text label and an associated control. + // https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/b800f40a2a69ad48015ae9226fbe879f946757ed/docs/rules/label-has-associated-control.md + 'jsx-a11y/label-has-associated-control': ['error', { + labelComponents: [], + labelAttributes: [], + controlComponents: [], + assert: 'both', + depth: 25 + }], + // require that mouseover/out come with focus/blur, for keyboard-only users // 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': 'error', From 2037fd82b9260db71758aedc513e86b7df23c01e Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Mon, 25 Jun 2018 15:48:07 -0700 Subject: [PATCH 031/352] [Tests] link eslint from the base config as well --- packages/eslint-config-airbnb/package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/packages/eslint-config-airbnb/package.json b/packages/eslint-config-airbnb/package.json index 53079d4a07..fd25457d7b 100644 --- a/packages/eslint-config-airbnb/package.json +++ b/packages/eslint-config-airbnb/package.json @@ -11,9 +11,10 @@ "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", - "pretravis": "cd ../eslint-config-airbnb-base && npm install && npm link && cd - && npm link --no-save eslint-config-airbnb-base", + "link:eslint": "cd node_modules/eslint && npm link && cd -", + "pretravis": "npm run link:eslint && cd ../eslint-config-airbnb-base && npm link eslint && npm install && npm link && cd - && npm link --no-save eslint-config-airbnb-base", "travis": "npm run --silent test", - "posttravis": "npm unlink --no-save eslint-config-airbnb-base >/dev/null &" + "posttravis": "npm unlink --no-save eslint-config-airbnb-base eslint >/dev/null &" }, "repository": { "type": "git", From a510095acf20e3d96a94e6d0d0b26cfac71d2c7f Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Mon, 25 Jun 2018 15:06:18 -0700 Subject: [PATCH 032/352] [eslint config] [*] [new] add eslint v5 support --- .travis.yml | 23 ++++++++++++++++--- .../eslint-config-airbnb-base/package.json | 4 ++-- .../rules/best-practices.js | 10 +++++++- .../eslint-config-airbnb-base/rules/style.js | 16 +++++++++++++ packages/eslint-config-airbnb/package.json | 4 ++-- 5 files changed, 49 insertions(+), 8 deletions(-) diff --git a/.travis.yml b/.travis.yml index 0f4ecc3fb1..2fcc94de67 100644 --- a/.travis.yml +++ b/.travis.yml @@ -18,20 +18,37 @@ script: sudo: false env: matrix: - - 'TEST=true ESLINT=4 PACKAGE=eslint-config-airbnb' + - 'TEST=true ESLINT=5 PACKAGE=eslint-config-airbnb-base' + - 'TEST=true ESLINT=5 PACKAGE=eslint-config-airbnb' - 'TEST=true ESLINT=4 PACKAGE=eslint-config-airbnb-base' + - 'TEST=true ESLINT=4 PACKAGE=eslint-config-airbnb' matrix: fast_finish: true include: - node_js: "lts/*" - env: PREPUBLISH=true ESLINT=4 PACKAGE=eslint-config-airbnb + env: PREPUBLISH=true ESLINT=5 PACKAGE=eslint-config-airbnb-base + - node_js: "lts/*" + env: PREPUBLISH=true ESLINT=5 PACKAGE=eslint-config-airbnb - node_js: "lts/*" env: PREPUBLISH=true ESLINT=4 PACKAGE=eslint-config-airbnb-base + - node_js: "lts/*" + env: PREPUBLISH=true ESLINT=4 PACKAGE=eslint-config-airbnb - node_js: "lts/*" env: LINT=true + exclude: + - node_js: "5" + env: TEST=true ESLINT=5 PACKAGE=eslint-config-airbnb-base + - node_js: "5" + env: TEST=true ESLINT=5 PACKAGE=eslint-config-airbnb + - node_js: "4" + env: TEST=true ESLINT=5 PACKAGE=eslint-config-airbnb-base + - node_js: "4" + env: TEST=true ESLINT=5 PACKAGE=eslint-config-airbnb allow_failures: - node_js: "9" - node_js: "7" - node_js: "5" - - env: PREPUBLISH=true ESLINT=4 PACKAGE=eslint-config-airbnb + - env: PREPUBLISH=true ESLINT=5 PACKAGE=eslint-config-airbnb-base + - env: PREPUBLISH=true ESLINT=5 PACKAGE=eslint-config-airbnb - env: PREPUBLISH=true ESLINT=4 PACKAGE=eslint-config-airbnb-base + - env: PREPUBLISH=true ESLINT=4 PACKAGE=eslint-config-airbnb diff --git a/packages/eslint-config-airbnb-base/package.json b/packages/eslint-config-airbnb-base/package.json index cb9efcf519..1bdfc3b2ff 100644 --- a/packages/eslint-config-airbnb-base/package.json +++ b/packages/eslint-config-airbnb-base/package.json @@ -56,7 +56,7 @@ "babel-preset-airbnb": "^2.5.1", "babel-tape-runner": "^2.0.1", "editorconfig-tools": "^0.1.1", - "eslint": "^4.19.1", + "eslint": "^4.19.1 || ^5.0.1", "eslint-find-rules": "^3.3.1", "eslint-plugin-import": "^2.13.0", "in-publish": "^2.0.0", @@ -64,7 +64,7 @@ "tape": "^4.9.1" }, "peerDependencies": { - "eslint": "^4.19.1", + "eslint": "^4.19.1 || ^5.0.1", "eslint-plugin-import": "^2.13.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 b5712d00b2..421b591488 100644 --- a/packages/eslint-config-airbnb-base/rules/best-practices.js +++ b/packages/eslint-config-airbnb-base/rules/best-practices.js @@ -42,6 +42,11 @@ module.exports = { // make sure for-in loops have an if statement 'guard-for-in': 'error', + // enforce a maximum number of classes per file + // https://eslint.org/docs/rules/max-classes-per-file + // TODO: semver-major (eslint 5): enable + 'max-classes-per-file': ['off', 1], + // disallow the use of alert, confirm, and prompt 'no-alert': 'warn', @@ -243,7 +248,10 @@ module.exports = { // disallow self assignment // https://eslint.org/docs/rules/no-self-assign - 'no-self-assign': 'error', + // TODO: semver-major: props -> true + 'no-self-assign': ['error', { + props: false, + }], // disallow comparisons where both sides are exactly the same 'no-self-compare': 'error', diff --git a/packages/eslint-config-airbnb-base/rules/style.js b/packages/eslint-config-airbnb-base/rules/style.js index ca8fc07ae6..ee5408f81c 100644 --- a/packages/eslint-config-airbnb-base/rules/style.js +++ b/packages/eslint-config-airbnb-base/rules/style.js @@ -21,6 +21,7 @@ module.exports = { 'brace-style': ['error', '1tbs', { allowSingleLine: true }], // require camel case names + // TODO: semver-major (eslint 5): add ignoreDestructuring: false option camelcase: ['error', { properties: 'never' }], // enforce or disallow capitalization of the first letter of a comment @@ -83,6 +84,7 @@ module.exports = { // requires function names to match the name of the variable or property to which they are // assigned // https://eslint.org/docs/rules/func-name-matching + // TODO: semver-major (eslint 5): add considerPropertyDescriptor: true 'func-name-matching': ['off', 'always', { includeCommonJSModuleExports: false }], @@ -208,6 +210,15 @@ module.exports = { skipComments: true }], + // enforce a maximum function length + // https://eslint.org/docs/rules/max-lines-per-function + 'max-lines-per-function': ['off', { + max: 50, + skipBlankLines: true, + skipComments: true, + IIFEs: true, + }], + // specify the maximum depth callbacks can be nested 'max-nested-callbacks': 'off', @@ -416,6 +427,11 @@ module.exports = { // https://eslint.org/docs/rules/padding-line-between-statements 'padding-line-between-statements': 'off', + // Prefer use of an object spread over Object.assign + // https://eslint.org/docs/rules/prefer-object-spread + // TODO: semver-major (eslint 5): enable + 'prefer-object-spread': 'off', + // require quotes around object literal property names // https://eslint.org/docs/rules/quote-props.html 'quote-props': ['error', 'as-needed', { keywords: false, unnecessary: true, numbers: false }], diff --git a/packages/eslint-config-airbnb/package.json b/packages/eslint-config-airbnb/package.json index fd25457d7b..63dbe709eb 100644 --- a/packages/eslint-config-airbnb/package.json +++ b/packages/eslint-config-airbnb/package.json @@ -62,7 +62,7 @@ "babel-preset-airbnb": "^2.5.1", "babel-tape-runner": "^2.0.1", "editorconfig-tools": "^0.1.1", - "eslint": "^4.19.1", + "eslint": "^4.19.1 || ^5.0.1", "eslint-find-rules": "^3.3.1", "eslint-plugin-import": "^2.13.0", "eslint-plugin-jsx-a11y": "^6.1.0", @@ -73,7 +73,7 @@ "tape": "^4.9.1" }, "peerDependencies": { - "eslint": "^4.19.1", + "eslint": "^4.19.1 || ^5.0.1", "eslint-plugin-import": "^2.13.0", "eslint-plugin-jsx-a11y": "^6.1.0", "eslint-plugin-react": "^7.10.0" From 96317f8c79d6c5a6e9478a49eb89770863c4e6e1 Mon Sep 17 00:00:00 2001 From: Vse Mozhet Byt Date: Thu, 5 Jul 2018 16:48:26 +0300 Subject: [PATCH 033/352] [guide] fix anchor tag in README.md Currently, this anchor with missing end tag breaks rendering: https://github.com/airbnb/javascript/blob/5d1f4b9a49ee7def65343f5efccfcce7723b9b4b/README.md#arrays--from-iterable --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 54cb2c0d4c..ae13bca33a 100644 --- a/README.md +++ b/README.md @@ -369,7 +369,7 @@ Other Style Guides const itemsCopy = [...items]; ``` - + - [4.4](#arrays--from-iterable) To convert an iterable object to an array, use spreads `...` instead of [`Array.from`](https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/Array/from). From b6a268f780177e03b573a4f0df95ecc0d2e8783e Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Mon, 9 Jul 2018 23:16:25 -0700 Subject: [PATCH 034/352] [eslint config] [react] disable two buggy rules, temporarily --- packages/eslint-config-airbnb/rules/react.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/packages/eslint-config-airbnb/rules/react.js b/packages/eslint-config-airbnb/rules/react.js index dcd3ac95be..7d82df1302 100644 --- a/packages/eslint-config-airbnb/rules/react.js +++ b/packages/eslint-config-airbnb/rules/react.js @@ -413,11 +413,13 @@ module.exports = { // One JSX Element Per Line // https://github.com/yannickcr/eslint-plugin-react/blob/843d71a432baf0f01f598d7cf1eea75ad6896e4b/docs/rules/jsx-one-expression-per-line.md - 'react/jsx-one-expression-per-line': 'error', + // TODO: re-enable when an option for text children is available + 'react/jsx-one-expression-per-line': 'off', // Enforce consistent usage of destructuring assignment of props, state, and context // https://github.com/yannickcr/eslint-plugin-react/blob/843d71a432baf0f01f598d7cf1eea75ad6896e4b/docs/rules/destructuring-assignment.md - 'react/destructuring-assignment': ['error', 'always'], + // TODO: re-enable when component detection is fixed + 'react/destructuring-assignment': ['off', 'always'], // Prevent using this.state within a this.setState // https://github.com/yannickcr/eslint-plugin-react/blob/843d71a432baf0f01f598d7cf1eea75ad6896e4b/docs/rules/no-access-state-in-setstate.md From a12dec90d173464a3fc4e4536b8c6f639fb93236 Mon Sep 17 00:00:00 2001 From: Andrew Scheuermann Date: Wed, 11 Jul 2018 16:26:22 -0700 Subject: [PATCH 035/352] [guide] [react] boolean in jsx alignment --- react/README.md | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/react/README.md b/react/README.md index c4fcf76d56..340e780c01 100644 --- a/react/README.md +++ b/react/README.md @@ -193,6 +193,25 @@ This style guide is mostly based on the standards that are currently prevalent i > + + // bad + {showButton && +