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 001/343] 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 002/343] [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 003/343] [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 004/343] [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 005/343] 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 006/343] [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 007/343] [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 008/343] 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 009/343] [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 010/343] [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 011/343] [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 012/343] [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 013/343] [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 014/343] [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 015/343] [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 016/343] [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 && +