From 5fd7c6f08c0650ed67297fc83c8a0590c9a92cc8 Mon Sep 17 00:00:00 2001 From: Estelle Date: Mon, 23 Mar 2015 18:48:19 -0700 Subject: [PATCH 001/480] 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 d493a04d7f79b2439c68f854f934513d77ebdcff Mon Sep 17 00:00:00 2001 From: Lance Li Date: Sat, 26 Aug 2017 14:49:14 +0800 Subject: [PATCH 002/480] Change Simplified Chinese translation link Currently the Simplified Chinese translation is for ES5, it's out of date, use another one instead of it. --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index b9887ff20a..1d671247e0 100644 --- a/README.md +++ b/README.md @@ -3367,7 +3367,7 @@ Other Style Guides - ![br](https://raw.githubusercontent.com/gosquared/flags/master/flags/flags/shiny/24/Brazil.png) **Brazilian Portuguese**: [armoucar/javascript-style-guide](https://github.com/armoucar/javascript-style-guide) - ![bg](https://raw.githubusercontent.com/gosquared/flags/master/flags/flags/shiny/24/Bulgaria.png) **Bulgarian**: [borislavvv/javascript](https://github.com/borislavvv/javascript) - ![ca](https://raw.githubusercontent.com/fpmweb/javascript-style-guide/master/img/catala.png) **Catalan**: [fpmweb/javascript-style-guide](https://github.com/fpmweb/javascript-style-guide) - - ![cn](https://raw.githubusercontent.com/gosquared/flags/master/flags/flags/shiny/24/China.png) **Chinese (Simplified)**: [sivan/javascript-style-guide](https://github.com/sivan/javascript-style-guide) + - ![cn](https://raw.githubusercontent.com/gosquared/flags/master/flags/flags/shiny/24/China.png) **Chinese (Simplified)**: [yuche/javascript](https://github.com/yuche/javascript) - ![tw](https://raw.githubusercontent.com/gosquared/flags/master/flags/flags/shiny/24/Taiwan.png) **Chinese (Traditional)**: [jigsawye/javascript](https://github.com/jigsawye/javascript) - ![fr](https://raw.githubusercontent.com/gosquared/flags/master/flags/flags/shiny/24/France.png) **French**: [nmussy/javascript-style-guide](https://github.com/nmussy/javascript-style-guide) - ![de](https://raw.githubusercontent.com/gosquared/flags/master/flags/flags/shiny/24/Germany.png) **German**: [timofurrer/javascript-style-guide](https://github.com/timofurrer/javascript-style-guide) From 138aafd2a0afe9054df904bbe1dbe72b3784e4ea Mon Sep 17 00:00:00 2001 From: Vitaly Makarevich Date: Thu, 7 Sep 2017 17:26:11 +0300 Subject: [PATCH 003/480] Update CHANGELOG.md Typo: prefer-restructuring => prefer-destructuring --- packages/eslint-config-airbnb-base/CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/eslint-config-airbnb-base/CHANGELOG.md b/packages/eslint-config-airbnb-base/CHANGELOG.md index 5e268d704b..99bfab9d7b 100644 --- a/packages/eslint-config-airbnb-base/CHANGELOG.md +++ b/packages/eslint-config-airbnb-base/CHANGELOG.md @@ -1,7 +1,7 @@ 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` + - 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-destructuring` - 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) From 5b338e1937725758e03ed21d589177e61ad5d1a9 Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Sat, 2 Sep 2017 11:33:45 -0700 Subject: [PATCH 004/480] [Tests] lint our markdown --- .travis.yml | 6 ++++-- README.md | 4 ++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/.travis.yml b/.travis.yml index c083bda347..aa05d1d238 100644 --- a/.travis.yml +++ b/.travis.yml @@ -9,11 +9,11 @@ before_install: - '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 [ -n "${PACKAGE-}" ]; then cd "packages/${PACKAGE}"; fi' - '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' + - 'if [ -n "${PREPUBLISH-}" ]; then npm run pretravis && npm run prepublish && npm run posttravis; elif [ -n "${LINT-}" ]; then npm run lint; else npm run travis; fi' sudo: false env: matrix: @@ -26,6 +26,8 @@ matrix: env: PREPUBLISH=true ESLINT=4 PACKAGE=eslint-config-airbnb - node_js: "node" env: PREPUBLISH=true ESLINT=4 PACKAGE=eslint-config-airbnb-base + - node_js: "node" + env: LINT=true allow_failures: - node_js: "7" - node_js: "5" diff --git a/README.md b/README.md index 8b5aa0ae6d..adf57fc96b 100644 --- a/README.md +++ b/README.md @@ -3169,7 +3169,7 @@ Other Style Guides 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. + > If this behavior is desired, make it explicit. ```javascript // bad @@ -3186,7 +3186,7 @@ Other Style Guides 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. + > If this behavior is desired, make it explicit. ```javascript // bad From 0aab14c3648511e555da3137e2971201a2f6e338 Mon Sep 17 00:00:00 2001 From: Carlos Soria Date: Thu, 14 Sep 2017 16:09:30 -0500 Subject: [PATCH 005/480] Add Grupo Abraxas to In The Wild section --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index adf57fc96b..e03261ebab 100644 --- a/README.md +++ b/README.md @@ -3355,6 +3355,7 @@ Other Style Guides - **Generation Tux**: [GenerationTux/javascript](https://github.com/generationtux/styleguide) - **GoodData**: [gooddata/gdc-js-style](https://github.com/gooddata/gdc-js-style) - **Grooveshark**: [grooveshark/javascript](https://github.com/grooveshark/javascript) + - **Grupo-Abraxas**: [Grupo-Abraxas/javascript](https://github.com/Grupo-Abraxas/javascript) - **Honey**: [honeyscience/javascript](https://github.com/honeyscience/javascript) - **How About We**: [howaboutwe/javascript](https://github.com/howaboutwe/javascript-style-guide) - **Huballin**: [huballin/javascript](https://github.com/huballin/javascript) From e16b03b841b20e510a203cf7d213d4d75d9d21df Mon Sep 17 00:00:00 2001 From: Nikita Lebedev Date: Sat, 9 Sep 2017 06:07:29 +0500 Subject: [PATCH 006/480] [guide] require array spread operator or `Array.from` Fixes #1084. --- README.md | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index e03261ebab..c9c412e86a 100644 --- a/README.md +++ b/README.md @@ -364,15 +364,31 @@ Other Style Guides ``` - - [4.4](#arrays--from) To convert an array-like object to an array, use [Array.from](https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/Array/from). + - [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). ```javascript const foo = document.querySelectorAll('.foo'); + + // good const nodes = Array.from(foo); + + // best + const nodes = [...foo]; + ``` + + + - [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. + + ```javascript + // bad + const bar = [...foo].map(bar); + + // good + const bar = Array.from(foo, bar); ``` - - [4.5](#arrays--callback-return) Use return statements in array method callbacks. It’s ok to omit the return if the function body consists of a single statement returning an expression without side effects, following [8.2](#arrows--implicit-return). eslint: [`array-callback-return`](http://eslint.org/docs/rules/array-callback-return) + - [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`](http://eslint.org/docs/rules/array-callback-return) ```javascript // good @@ -420,8 +436,8 @@ Other Style Guides }); ``` - - - [4.6](#arrays--bracket-newline) Use line breaks after open and before close array brackets if an array has multiple lines + + - [4.7](#arrays--bracket-newline) Use line breaks after open and before close array brackets if an array has multiple lines ```javascript // bad @@ -2511,7 +2527,7 @@ Other Style Guides ## Commas - + - [20.1](#commas--leading-trailing) Leading commas: **Nope.** eslint: [`comma-style`](http://eslint.org/docs/rules/comma-style.html) jscs: [`requireCommaBeforeLineBreak`](http://jscs.info/rule/requireCommaBeforeLineBreak) ```javascript From 3ad1ad1a6a130377cffdda2c1d00c0ded940e2b3 Mon Sep 17 00:00:00 2001 From: Vladimir Kovpak Date: Thu, 21 Sep 2017 02:11:14 +0300 Subject: [PATCH 007/480] [guide] Updated example in ternaries. --- README.md | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index c9c412e86a..ffa841039b 100644 --- a/README.md +++ b/README.md @@ -1914,16 +1914,15 @@ Other Style Guides ? "bar" : value1 > value2 ? "baz" : null; - // better + // split into 2 separated ternary expressions const maybeNull = value1 > value2 ? 'baz' : null; + // better const foo = maybe1 > maybe2 ? 'bar' : maybeNull; // best - const maybeNull = value1 > value2 ? 'baz' : null; - const foo = maybe1 > maybe2 ? 'bar' : maybeNull; ``` From 2380c0ddb849c61d61db92331cc0255f2c68c02b Mon Sep 17 00:00:00 2001 From: Josh Date: Wed, 27 Sep 2017 12:51:40 -0700 Subject: [PATCH 008/480] [guide] Improve severity of warning comment --- README.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index ffa841039b..f0186becac 100644 --- a/README.md +++ b/README.md @@ -381,10 +381,10 @@ Other Style Guides ```javascript // bad - const bar = [...foo].map(bar); + const baz = [...foo].map(bar); // good - const bar = Array.from(foo, bar); + const baz = Array.from(foo, bar); ``` @@ -400,18 +400,18 @@ Other Style Guides // good [1, 2, 3].map(x => x + 1); - // bad + // bad - no returned value means `memo` becomes undefined after the first iteration const flat = {}; [[0, 1], [2, 3], [4, 5]].reduce((memo, item, index) => { const flatten = memo.concat(item); - flat[index] = flatten; + memo[index] = flatten; }); // good const flat = {}; [[0, 1], [2, 3], [4, 5]].reduce((memo, item, index) => { const flatten = memo.concat(item); - flat[index] = flatten; + memo[index] = flatten; return flatten; }); From 8e29a161f91cb0e190ebe3f955073f3c16894d9f Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Wed, 27 Sep 2017 16:33:51 -0400 Subject: [PATCH 009/480] [eslint config] [base] [fix] ensure all JSX elements are ignored by `indent` Fixes #1569. --- packages/eslint-config-airbnb-base/rules/style.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/eslint-config-airbnb-base/rules/style.js b/packages/eslint-config-airbnb-base/rules/style.js index 4aa35aeafe..328468dd38 100644 --- a/packages/eslint-config-airbnb-base/rules/style.js +++ b/packages/eslint-config-airbnb-base/rules/style.js @@ -119,7 +119,7 @@ module.exports = { ObjectExpression: 1, ImportDeclaration: 1, flatTernaryExpressions: false, - ignoredNodes: ['JSXElement *'] + ignoredNodes: ['JSXElement', 'JSXElement *'] }], // specify whether double or single quotes should be used in JSX attributes From b7ff33e79c886581a92dccfc51011f6a9f7cc704 Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Wed, 27 Sep 2017 16:37:54 -0400 Subject: [PATCH 010/480] [eslint config] [base] [deps] update `eslint` --- packages/eslint-config-airbnb-base/package.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/eslint-config-airbnb-base/package.json b/packages/eslint-config-airbnb-base/package.json index 6c18415998..f5a447f4fb 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.6.0", + "eslint": "^4.7.2", "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": "^4.6.0", + "eslint": "^4.7.2", "eslint-plugin-import": "^2.7.0" }, "engines": { From cd038fb89bf4f5cc6596a9c4cb58302e11cf7125 Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Wed, 27 Sep 2017 16:38:49 -0400 Subject: [PATCH 011/480] v12.0.1 --- packages/eslint-config-airbnb-base/CHANGELOG.md | 5 +++++ packages/eslint-config-airbnb-base/package.json | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/packages/eslint-config-airbnb-base/CHANGELOG.md b/packages/eslint-config-airbnb-base/CHANGELOG.md index 99bfab9d7b..4296651735 100644 --- a/packages/eslint-config-airbnb-base/CHANGELOG.md +++ b/packages/eslint-config-airbnb-base/CHANGELOG.md @@ -1,3 +1,8 @@ +12.0.1 / 2017-09-27 +================== + - [fix] ensure all JSX elements are ignored by `indent` (#1569) + - [deps] update `eslint` + 12.0.0 / 2017-09-02 ================== - [deps] [breaking] require `eslint` v4 diff --git a/packages/eslint-config-airbnb-base/package.json b/packages/eslint-config-airbnb-base/package.json index f5a447f4fb..cd7037ff75 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.0.0", + "version": "12.0.1", "description": "Airbnb's base JS ESLint config, following our styleguide", "main": "index.js", "scripts": { From faedb670429755a2a3f082f610177571db329307 Mon Sep 17 00:00:00 2001 From: Leonid Lebedev Date: Sun, 1 Oct 2017 17:36:45 +0300 Subject: [PATCH 012/480] Add Amendments --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index f0186becac..fdfcca7a59 100644 --- a/README.md +++ b/README.md @@ -56,6 +56,7 @@ Other Style Guides 1. [Chat With Us About JavaScript](#chat-with-us-about-javascript) 1. [Contributors](#contributors) 1. [License](#license) + 1. [Amendments](#amendments) ## Types From a8155091ff4ecffc55848d3f79db376ecf8bdb24 Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Thu, 5 Oct 2017 00:02:31 -0700 Subject: [PATCH 013/480] [eslint config] [base] [deps] update `eslint` --- packages/eslint-config-airbnb-base/package.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/eslint-config-airbnb-base/package.json b/packages/eslint-config-airbnb-base/package.json index cd7037ff75..e4c349948f 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.7.2", + "eslint": "^4.8.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": "^4.7.2", + "eslint": "^4.8.0", "eslint-plugin-import": "^2.7.0" }, "engines": { From ad3746672e5bd79f77159c4e2612077651e9af17 Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Thu, 5 Oct 2017 00:03:21 -0700 Subject: [PATCH 014/480] [eslint config] [base] v12.0.2 --- 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 4296651735..68275e325d 100644 --- a/packages/eslint-config-airbnb-base/CHANGELOG.md +++ b/packages/eslint-config-airbnb-base/CHANGELOG.md @@ -1,3 +1,7 @@ +12.0.2 / 2017-10-05 +================== + - [deps] update `eslint` + 12.0.1 / 2017-09-27 ================== - [fix] ensure all JSX elements are ignored by `indent` (#1569) diff --git a/packages/eslint-config-airbnb-base/package.json b/packages/eslint-config-airbnb-base/package.json index e4c349948f..81c1011774 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.0.1", + "version": "12.0.2", "description": "Airbnb's base JS ESLint config, following our styleguide", "main": "index.js", "scripts": { From 2c228825a808b6c782e4b79c80db3c28cfceae4d Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Thu, 5 Oct 2017 00:55:14 -0700 Subject: [PATCH 015/480] [eslint config] [deps] update `eslint`, `eslint-config-airbnb-base`, `eslint-plugin-react` --- packages/eslint-config-airbnb/package.json | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/packages/eslint-config-airbnb/package.json b/packages/eslint-config-airbnb/package.json index 5edc1665fe..1723a6934e 100644 --- a/packages/eslint-config-airbnb/package.json +++ b/packages/eslint-config-airbnb/package.json @@ -48,27 +48,27 @@ }, "homepage": "https://github.com/airbnb/javascript", "dependencies": { - "eslint-config-airbnb-base": "^12.0.0" + "eslint-config-airbnb-base": "^12.0.2" }, "devDependencies": { "babel-preset-airbnb": "^2.4.0", "babel-tape-runner": "^2.0.1", "editorconfig-tools": "^0.1.1", - "eslint": "^4.6.0", + "eslint": "^4.8.0", "eslint-find-rules": "^3.1.1", "eslint-plugin-import": "^2.7.0", "eslint-plugin-jsx-a11y": "^6.0.2", - "eslint-plugin-react": "^7.3.0", + "eslint-plugin-react": "^7.4.0", "in-publish": "^2.0.0", "react": ">= 0.13.0", "safe-publish-latest": "^1.1.1", "tape": "^4.8.0" }, "peerDependencies": { - "eslint": "^4.6.0", + "eslint": "^4.8.0", "eslint-plugin-jsx-a11y": "^6.0.2", "eslint-plugin-import": "^2.7.0", - "eslint-plugin-react": "^7.3.0" + "eslint-plugin-react": "^7.4.0" }, "engines": { "node": ">= 4" From e5b5aeeb6bfc2402969360e9537c40ba42b1d137 Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Thu, 5 Oct 2017 01:01:01 -0700 Subject: [PATCH 016/480] [eslint config] [breaking] enable/add react rules: - `react/jsx-curly-brace-presence` - `react/no-typos` - `react/no-unused-state` - `react/no-redundant-should-component-update` - `react/default-props-match-prop-types` --- packages/eslint-config-airbnb/rules/react.js | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/packages/eslint-config-airbnb/rules/react.js b/packages/eslint-config-airbnb/rules/react.js index 15324c8608..f6e3528079 100644 --- a/packages/eslint-config-airbnb/rules/react.js +++ b/packages/eslint-config-airbnb/rules/react.js @@ -328,18 +328,15 @@ module.exports = { // 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 }], + 'react/default-props-match-prop-types': ['error', { 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', + 'react/no-redundant-should-component-update': 'error', // Prevent unused state values - // https://github.com/yannickcr/eslint-plugin-react/pull/1103/files - // TODO: enable? semver-major - 'react/no-unused-state': 'off', + // https://github.com/yannickcr/eslint-plugin-react/pull/1103/ + 'react/no-unused-state': 'error', // Enforces consistent naming for boolean props // https://github.com/yannickcr/eslint-plugin-react/blob/73abadb697034b5ccb514d79fb4689836fe61f91/docs/rules/boolean-prop-naming.md @@ -350,8 +347,11 @@ module.exports = { // 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', + 'react/no-typos': 'error', + + // Enforce curly braces or disallow unnecessary curly braces in JSX props and/or children + // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-curly-brace-presence.md + 'react/jsx-curly-brace-presence': ['error', { props: 'never', children: 'never' }] }, settings: { From dfbeaaea4bf09be28463eea15979dd8c862fc10a Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Fri, 6 Oct 2017 10:40:05 -0700 Subject: [PATCH 017/480] [eslint config] v16.0.0 --- packages/eslint-config-airbnb/CHANGELOG.md | 10 ++++++++++ packages/eslint-config-airbnb/package.json | 2 +- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/packages/eslint-config-airbnb/CHANGELOG.md b/packages/eslint-config-airbnb/CHANGELOG.md index a1c3b5d188..8bba950e66 100644 --- a/packages/eslint-config-airbnb/CHANGELOG.md +++ b/packages/eslint-config-airbnb/CHANGELOG.md @@ -1,3 +1,13 @@ +16.0.0 / 2017-10-06 +================== +- [breaking] [deps] require `eslint` `v4`, update `eslint-config-airbnb-base` +- [breaking] [deps] Upgrade `eslint-plugin-jsx-a11y` to `v6`; enable more a11y rules (#1482) +- [breaking] enable/add react rules: `react/jsx-curly-brace-presence`, `react/no-typos`, `react/no-unused-state`, `react/no-redundant-should-component-update`, `react/default-props-match-prop-types` +- [new] add `propWrapperFunctions` default settings for `eslint-plugin-react` +- [new] Enable `react/jsx-closing-tag-location` (#1533) +- [deps] update `eslint` v4, `eslint-plugin-react`, `tape` +- [docs] Specify yarn-specific install instructions (#1511) + 15.1.0 / 2017-07-24 ================== - [deps] allow eslint v3 or v4 (#1447) diff --git a/packages/eslint-config-airbnb/package.json b/packages/eslint-config-airbnb/package.json index 1723a6934e..e9b1550511 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.1.0", + "version": "16.0.0", "description": "Airbnb's ESLint config, following our styleguide", "main": "index.js", "scripts": { From ac2ed5a749ea9649105dc52f1bdefead46f2c73d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20K=C3=BCnnen?= <7766565+DavidKuennen@users.noreply.github.com> Date: Thu, 12 Oct 2017 13:30:18 +0200 Subject: [PATCH 018/480] Added our company to "In The Wild" --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index fdfcca7a59..adc3fae08c 100644 --- a/README.md +++ b/README.md @@ -3336,6 +3336,7 @@ Other Style Guides This is a list of organizations that are using this style guide. Send us a pull request and we'll add you to the list. + - **123erfasst**: [123erfasst/javascript](https://github.com/123erfasst/javascript) - **3blades**: [3Blades/javascript](https://github.com/3blades/javascript) - **4Catalyzer**: [4Catalyzer/javascript](https://github.com/4Catalyzer/javascript) - **Aan Zee**: [AanZee/javascript](https://github.com/AanZee/javascript) From 62d8d66049b04d35a87e86a8bcd2425a2fc0243c Mon Sep 17 00:00:00 2001 From: Pirasis Leelatanon <1pete@users.noreply.github.com> Date: Fri, 13 Oct 2017 10:33:59 +0700 Subject: [PATCH 019/480] [eslint config] sort peerDependencies in alphabetical order --- packages/eslint-config-airbnb/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/eslint-config-airbnb/package.json b/packages/eslint-config-airbnb/package.json index e9b1550511..041464a23c 100644 --- a/packages/eslint-config-airbnb/package.json +++ b/packages/eslint-config-airbnb/package.json @@ -66,8 +66,8 @@ }, "peerDependencies": { "eslint": "^4.8.0", - "eslint-plugin-jsx-a11y": "^6.0.2", "eslint-plugin-import": "^2.7.0", + "eslint-plugin-jsx-a11y": "^6.0.2", "eslint-plugin-react": "^7.4.0" }, "engines": { From 3581bac32fdeeefca4dee4ceabbf879ae585462b Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Mon, 16 Oct 2017 11:42:13 -0700 Subject: [PATCH 020/480] [eslint config] [base] [deps] update `eslint` to `v4.9` --- packages/eslint-config-airbnb-base/package.json | 6 +++--- .../eslint-config-airbnb-base/rules/best-practices.js | 4 +++- packages/eslint-config-airbnb-base/rules/style.js | 11 ++++++++++- 3 files changed, 16 insertions(+), 5 deletions(-) diff --git a/packages/eslint-config-airbnb-base/package.json b/packages/eslint-config-airbnb-base/package.json index 81c1011774..6fc7d259b7 100644 --- a/packages/eslint-config-airbnb-base/package.json +++ b/packages/eslint-config-airbnb-base/package.json @@ -5,7 +5,7 @@ "main": "index.js", "scripts": { "prelint": "editorconfig-tools check * rules/* test/*", - "lint": "eslint .", + "lint": "eslint --report-unused-disable-directives .", "tests-only": "babel-tape-runner ./test/test-*.js", "prepublish": "(in-install || eslint-find-rules --unused) && (not-in-publish || npm test) && safe-publish-latest", "pretest": "npm run --silent lint", @@ -51,7 +51,7 @@ "babel-preset-airbnb": "^2.4.0", "babel-tape-runner": "^2.0.1", "editorconfig-tools": "^0.1.1", - "eslint": "^4.8.0", + "eslint": "^4.9.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": "^4.8.0", + "eslint": "^4.9.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 83808bb879..d712e8a9a4 100644 --- a/packages/eslint-config-airbnb-base/rules/best-practices.js +++ b/packages/eslint-config-airbnb-base/rules/best-practices.js @@ -57,7 +57,9 @@ module.exports = { 'no-div-regex': 'off', // disallow else after a return in an if - 'no-else-return': 'error', + // https://eslint.org/docs/rules/no-else-return + // TODO: semver-major, set allowElseIf to false + 'no-else-return': ['error', { allowElseIf: true }], // disallow empty functions, except for standalone funcs/arrows // http://eslint.org/docs/rules/no-empty-function diff --git a/packages/eslint-config-airbnb-base/rules/style.js b/packages/eslint-config-airbnb-base/rules/style.js index 328468dd38..88f4210dba 100644 --- a/packages/eslint-config-airbnb-base/rules/style.js +++ b/packages/eslint-config-airbnb-base/rules/style.js @@ -3,7 +3,7 @@ module.exports = { // 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 }], + 'array-bracket-newline': ['off', 'consistent'], // object option alternative: { multiline: true, minItems: 3 } // enforce line breaks between array elements // http://eslint.org/docs/rules/array-element-newline @@ -153,6 +153,11 @@ module.exports = { // http://eslint.org/docs/rules/linebreak-style 'linebreak-style': ['error', 'unix'], + // require or disallow an empty line between class members + // https://eslint.org/docs/rules/lines-between-class-members + // TODO: semver-major: enable + 'lines-between-class-members': ['off', 'always', { exceptAfterSingleLine: false }], + // enforces empty lines around comments 'lines-around-comment': 'off', @@ -197,6 +202,10 @@ module.exports = { // http://eslint.org/docs/rules/max-statements-per-line 'max-statements-per-line': ['off', { max: 1 }], + // enforce a particular style for multiline comments + // https://eslint.org/docs/rules/multiline-comment-style + 'multiline-comment-style': ['off', 'starred-block'], + // require multiline ternary // http://eslint.org/docs/rules/multiline-ternary // TODO: enable? From 9025c52a73dd5dfc1f4fc4f490d453830ff735f4 Mon Sep 17 00:00:00 2001 From: Pirasis Leelatanon <1pete@users.noreply.github.com> Date: Mon, 16 Oct 2017 21:18:48 +0700 Subject: [PATCH 021/480] [doc] add eslint rule reference for `prefer-destructuring` --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index adc3fae08c..3391bdcffe 100644 --- a/README.md +++ b/README.md @@ -479,7 +479,7 @@ Other Style Guides ## Destructuring - - [5.1](#destructuring--object) Use object destructuring when accessing and using multiple properties of an object. jscs: [`requireObjectDestructuring`](http://jscs.info/rule/requireObjectDestructuring) + - [5.1](#destructuring--object) Use object destructuring when accessing and using multiple properties of an object. eslint: [`prefer-destructuring`](https://eslint.org/docs/rules/prefer-destructuring) jscs: [`requireObjectDestructuring`](http://jscs.info/rule/requireObjectDestructuring) > Why? Destructuring saves you from creating temporary references for those properties. @@ -505,7 +505,7 @@ Other Style Guides ``` - - [5.2](#destructuring--array) Use array destructuring. jscs: [`requireArrayDestructuring`](http://jscs.info/rule/requireArrayDestructuring) + - [5.2](#destructuring--array) Use array destructuring. eslint: [`prefer-destructuring`](https://eslint.org/docs/rules/prefer-destructuring) jscs: [`requireArrayDestructuring`](http://jscs.info/rule/requireArrayDestructuring) ```javascript const arr = [1, 2, 3, 4]; From 7f61af685c928d5e1b5e7a9bb6bbdb5cd781a861 Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Mon, 16 Oct 2017 11:50:50 -0700 Subject: [PATCH 022/480] [eslint config] [base] v12.1.0 --- 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 68275e325d..6dd34427fc 100644 --- a/packages/eslint-config-airbnb-base/CHANGELOG.md +++ b/packages/eslint-config-airbnb-base/CHANGELOG.md @@ -1,3 +1,7 @@ +12.1.0 / 2017-10-16 +================== + - [deps] update `eslint` to `v4.9` + 12.0.2 / 2017-10-05 ================== - [deps] update `eslint` diff --git a/packages/eslint-config-airbnb-base/package.json b/packages/eslint-config-airbnb-base/package.json index 6fc7d259b7..cf83b916ae 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.0.2", + "version": "12.1.0", "description": "Airbnb's base JS ESLint config, following our styleguide", "main": "index.js", "scripts": { From ec4b9b109a6e5b2fa836be2c2ec7c1d581e9743d Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Mon, 16 Oct 2017 12:00:49 -0700 Subject: [PATCH 023/480] [eslint config] [deps] update `eslint-config-airbnb-base`, `eslint` to v4.9 --- 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 041464a23c..f48b81931d 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": "^12.0.2" + "eslint-config-airbnb-base": "^12.1.0" }, "devDependencies": { "babel-preset-airbnb": "^2.4.0", "babel-tape-runner": "^2.0.1", "editorconfig-tools": "^0.1.1", - "eslint": "^4.8.0", + "eslint": "^4.9.0", "eslint-find-rules": "^3.1.1", "eslint-plugin-import": "^2.7.0", "eslint-plugin-jsx-a11y": "^6.0.2", @@ -65,7 +65,7 @@ "tape": "^4.8.0" }, "peerDependencies": { - "eslint": "^4.8.0", + "eslint": "^4.9.0", "eslint-plugin-import": "^2.7.0", "eslint-plugin-jsx-a11y": "^6.0.2", "eslint-plugin-react": "^7.4.0" From cf9e17efee72121b17507b030c04f9b11c521a9b Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Mon, 16 Oct 2017 12:01:21 -0700 Subject: [PATCH 024/480] [eslint config] v16.1.0 --- packages/eslint-config-airbnb/CHANGELOG.md | 4 ++++ packages/eslint-config-airbnb/package.json | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/packages/eslint-config-airbnb/CHANGELOG.md b/packages/eslint-config-airbnb/CHANGELOG.md index 8bba950e66..ae38f3c048 100644 --- a/packages/eslint-config-airbnb/CHANGELOG.md +++ b/packages/eslint-config-airbnb/CHANGELOG.md @@ -1,3 +1,7 @@ +16.1.0 / 2017-10-16 +================== +- [deps] update `eslint-config-airbnb-base`, `eslint` to v4.9 + 16.0.0 / 2017-10-06 ================== - [breaking] [deps] require `eslint` `v4`, update `eslint-config-airbnb-base` diff --git a/packages/eslint-config-airbnb/package.json b/packages/eslint-config-airbnb/package.json index f48b81931d..14746226d7 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.0.0", + "version": "16.1.0", "description": "Airbnb's ESLint config, following our styleguide", "main": "index.js", "scripts": { From 6e1f11185d95432ba90a647efc027bd32983f17d Mon Sep 17 00:00:00 2001 From: Sharmila Date: Wed, 18 Oct 2017 11:42:26 -0700 Subject: [PATCH 025/480] [eslint config] [base] Enables eslint rule for operator-linebreak Requiring operators at the beginning of the line makes code more readable. When operators are on the left hand side they mirror the syntax of method chaining and it is easy to see the build of logic in a statement. --- packages/eslint-config-airbnb-base/rules/style.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/packages/eslint-config-airbnb-base/rules/style.js b/packages/eslint-config-airbnb-base/rules/style.js index 88f4210dba..3195e875ae 100644 --- a/packages/eslint-config-airbnb-base/rules/style.js +++ b/packages/eslint-config-airbnb-base/rules/style.js @@ -374,8 +374,9 @@ module.exports = { // http://eslint.org/docs/rules/operator-assignment 'operator-assignment': ['error', 'always'], - // enforce operators to be placed before or after line breaks - 'operator-linebreak': 'off', + // Requires operator at the beginning of the line in multiline statements + // https://eslint.org/docs/rules/operator-linebreak + 'operator-linebreak': ['error', 'before'], // disallow padding within blocks 'padded-blocks': ['error', { blocks: 'never', classes: 'never', switches: 'never' }], From 2ab0e618582f5b64e406fe81fb5c9540b3be9824 Mon Sep 17 00:00:00 2001 From: Sharmila Date: Wed, 18 Oct 2017 11:56:06 -0700 Subject: [PATCH 026/480] Updates Control Statements section to reflect eslint config change --- README.md | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index 3391bdcffe..50212d6d8b 100644 --- a/README.md +++ b/README.md @@ -1998,7 +1998,9 @@ Other Style Guides ## Control Statements - - [17.1](#control-statements) In case your control statement (`if`, `while` etc.) gets too long or exceeds the maximum line length, each (grouped) condition could be put into a new line. It’s up to you whether the logical operator should begin or end the line. + - [17.1](#control-statements) In case your control statement (`if`, `while` etc.) gets too long or exceeds the maximum line length, each (grouped) condition could be put into a new line. The logical operator should begin the line. + + > Why? This ensures readability. ```javascript // bad @@ -2018,33 +2020,33 @@ Other Style Guides thing1(); } - // good + // bad if ( - (foo === 123 || bar === "abc") && - doesItLookGoodWhenItBecomesThatLong() && - isThisReallyHappening() + foo === 123 && + bar === 'abc' ) { thing1(); } // good - if (foo === 123 && bar === 'abc') { + if ( + foo === 123 + && bar === 'abc' + ) { thing1(); } // good if ( - foo === 123 && - bar === 'abc' + (foo === 123 || bar === "abc") + && doesItLookGoodWhenItBecomesThatLong() + && isThisReallyHappening() ) { thing1(); } // good - if ( - foo === 123 - && bar === 'abc' - ) { + if (foo === 123 && bar === 'abc') { thing1(); } ``` From 6fbc47256ef0671be7f11cb3016489f6a9afa16a Mon Sep 17 00:00:00 2001 From: Sharmila Date: Wed, 18 Oct 2017 13:34:15 -0700 Subject: [PATCH 027/480] Fixes test syles --- packages/eslint-config-airbnb-base/test/test-base.js | 4 ++-- packages/eslint-config-airbnb/test/test-base.js | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/eslint-config-airbnb-base/test/test-base.js b/packages/eslint-config-airbnb-base/test/test-base.js index 6936e0eb24..01b5dd12d3 100644 --- a/packages/eslint-config-airbnb-base/test/test-base.js +++ b/packages/eslint-config-airbnb-base/test/test-base.js @@ -20,8 +20,8 @@ Object.keys(files).forEach(( // eslint-disable-line function-paren-newline t.plan(2); // scan plugins for react and fail if it is found - const hasReactPlugin = Object.prototype.hasOwnProperty.call(config, 'plugins') && - config.plugins.indexOf('react') !== -1; + const hasReactPlugin = Object.prototype.hasOwnProperty.call(config, 'plugins') + && config.plugins.indexOf('react') !== -1; t.notOk(hasReactPlugin, 'there is no react plugin'); // scan rules for react/ and fail if any exist diff --git a/packages/eslint-config-airbnb/test/test-base.js b/packages/eslint-config-airbnb/test/test-base.js index 2b946a462c..807191dfe3 100644 --- a/packages/eslint-config-airbnb/test/test-base.js +++ b/packages/eslint-config-airbnb/test/test-base.js @@ -22,8 +22,8 @@ Object.keys(files).forEach((name) => { t.plan(2); // scan plugins for react and fail if it is found - const hasReactPlugin = Object.prototype.hasOwnProperty.call(config, 'plugins') && - config.plugins.indexOf('react') !== -1; + const hasReactPlugin = Object.prototype.hasOwnProperty.call(config, 'plugins') + && config.plugins.indexOf('react') !== -1; t.notOk(hasReactPlugin, 'there is no react plugin'); // scan rules for react/ and fail if any exist From f2a65c689831185975c97abc9558d96e4e8bbc46 Mon Sep 17 00:00:00 2001 From: Sharmila Date: Wed, 18 Oct 2017 13:41:24 -0700 Subject: [PATCH 028/480] Improves 'Why?' message --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 50212d6d8b..f0607fa1e8 100644 --- a/README.md +++ b/README.md @@ -2000,7 +2000,7 @@ Other Style Guides - [17.1](#control-statements) In case your control statement (`if`, `while` etc.) gets too long or exceeds the maximum line length, each (grouped) condition could be put into a new line. The logical operator should begin the line. - > Why? This ensures readability. + > Why? Having operators at the beginning of the line keeps the operators aligned and follows a pattern similar to method chaining. This also improves readability by making it easier to visually follow complex logic. ```javascript // bad From 01e72b9963bd8ff6567001d6be1612701a79383d Mon Sep 17 00:00:00 2001 From: Thomas Grainger Date: Mon, 16 Oct 2017 21:12:47 +0100 Subject: [PATCH 029/480] [eslint config] [base] [breaking] `no-else-return`: disallow else-if --- packages/eslint-config-airbnb-base/rules/best-practices.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/packages/eslint-config-airbnb-base/rules/best-practices.js b/packages/eslint-config-airbnb-base/rules/best-practices.js index d712e8a9a4..559338074a 100644 --- a/packages/eslint-config-airbnb-base/rules/best-practices.js +++ b/packages/eslint-config-airbnb-base/rules/best-practices.js @@ -58,8 +58,7 @@ module.exports = { // disallow else after a return in an if // https://eslint.org/docs/rules/no-else-return - // TODO: semver-major, set allowElseIf to false - 'no-else-return': ['error', { allowElseIf: true }], + 'no-else-return': ['error', { allowElseIf: false }], // disallow empty functions, except for standalone funcs/arrows // http://eslint.org/docs/rules/no-empty-function From cd4ec29ed33fde4f81184f81eeddbda0b561dcd2 Mon Sep 17 00:00:00 2001 From: Sharmila Date: Wed, 18 Oct 2017 11:42:26 -0700 Subject: [PATCH 030/480] [eslint config] [base] Enables eslint rule for operator-linebreak Requiring operators at the beginning of the line makes code more readable. When operators are on the left hand side they mirror the syntax of method chaining and it is easy to see the build of logic in a statement. This also updates the readme and fixes a style violation as a result of adding this rule in eslint-config-airbnb/test/test-base.js and eslint-config-airbnb-base/test/test-base.js. --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index f0607fa1e8..360d445742 100644 --- a/README.md +++ b/README.md @@ -2000,7 +2000,7 @@ Other Style Guides - [17.1](#control-statements) In case your control statement (`if`, `while` etc.) gets too long or exceeds the maximum line length, each (grouped) condition could be put into a new line. The logical operator should begin the line. - > Why? Having operators at the beginning of the line keeps the operators aligned and follows a pattern similar to method chaining. This also improves readability by making it easier to visually follow complex logic. + > Why? Requiring operators at the beginning of the line keeps the operators aligned and follows a pattern similar to method chaining. This also improves readability by making it easier to visually follow complex logic. ```javascript // bad From 2b3c86d8124729eb2207e596512222dd3f5f82fe Mon Sep 17 00:00:00 2001 From: Sharmila Date: Wed, 18 Oct 2017 14:50:58 -0700 Subject: [PATCH 031/480] Fixes indentation --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 360d445742..6cbacc3b25 100644 --- a/README.md +++ b/README.md @@ -2000,7 +2000,7 @@ Other Style Guides - [17.1](#control-statements) In case your control statement (`if`, `while` etc.) gets too long or exceeds the maximum line length, each (grouped) condition could be put into a new line. The logical operator should begin the line. - > Why? Requiring operators at the beginning of the line keeps the operators aligned and follows a pattern similar to method chaining. This also improves readability by making it easier to visually follow complex logic. + > Why? Requiring operators at the beginning of the line keeps the operators aligned and follows a pattern similar to method chaining. This also improves readability by making it easier to visually follow complex logic. ```javascript // bad From b66d6e42f3224cc4f8a138ecce34bf704e7a320c Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Wed, 18 Oct 2017 14:27:41 -0700 Subject: [PATCH 032/480] =?UTF-8?q?[eslint=20config]=20[base]=20[breaking]?= =?UTF-8?q?=20`lines-between-class-members`:=20set=20to=20=E2=80=9Calways?= =?UTF-8?q?=E2=80=9D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/eslint-config-airbnb-base/rules/style.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/packages/eslint-config-airbnb-base/rules/style.js b/packages/eslint-config-airbnb-base/rules/style.js index 3195e875ae..2ce7582a03 100644 --- a/packages/eslint-config-airbnb-base/rules/style.js +++ b/packages/eslint-config-airbnb-base/rules/style.js @@ -155,8 +155,7 @@ module.exports = { // require or disallow an empty line between class members // https://eslint.org/docs/rules/lines-between-class-members - // TODO: semver-major: enable - 'lines-between-class-members': ['off', 'always', { exceptAfterSingleLine: false }], + 'lines-between-class-members': ['error', 'always', { exceptAfterSingleLine: false }], // enforces empty lines around comments 'lines-around-comment': 'off', From 6f2395a3f146863f4cba86cbf2433618828fa9f3 Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Wed, 18 Oct 2017 14:28:58 -0700 Subject: [PATCH 033/480] [eslint config] [base] [breaking] `import/named`: enable --- 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 81b845a871..6636d771ce 100644 --- a/packages/eslint-config-airbnb-base/rules/imports.js +++ b/packages/eslint-config-airbnb-base/rules/imports.js @@ -37,7 +37,7 @@ module.exports = { // ensure named imports coupled with named exports // https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/named.md#when-not-to-use-it - 'import/named': 'off', + 'import/named': 'error', // ensure default import coupled with default export // https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/default.md#when-not-to-use-it From 8cfc97eee9e18efcca308115b21c075cff687b7c Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Wed, 18 Oct 2017 21:28:52 -0700 Subject: [PATCH 034/480] [Tests] fix linting tests --- packages/eslint-config-airbnb/package.json | 2 +- packages/eslint-config-airbnb/test/test-react-order.js | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/packages/eslint-config-airbnb/package.json b/packages/eslint-config-airbnb/package.json index 14746226d7..b35110c18b 100644 --- a/packages/eslint-config-airbnb/package.json +++ b/packages/eslint-config-airbnb/package.json @@ -12,7 +12,7 @@ "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", "travis": "npm run --silent test", - "posttravis": "npm unlink eslint-config-airbnb-base >/dev/null &" + "posttravis": "npm unlink --no-save eslint-config-airbnb-base >/dev/null &" }, "repository": { "type": "git", diff --git a/packages/eslint-config-airbnb/test/test-react-order.js b/packages/eslint-config-airbnb/test/test-react-order.js index 0e7fd9e6ec..e8fa989dbd 100644 --- a/packages/eslint-config-airbnb/test/test-react-order.js +++ b/packages/eslint-config-airbnb/test/test-react-order.js @@ -11,6 +11,8 @@ const cli = new CLIEngine({ rules: { // It is okay to import devDependencies in tests. 'import/no-extraneous-dependencies': [2, { devDependencies: true }], + // this doesn't matter for tests + 'lines-between-class-members': 0, }, }); From 67e34433e441779d18957b22329284b6d61d5920 Mon Sep 17 00:00:00 2001 From: Sharmila Date: Wed, 18 Oct 2017 21:16:01 -0700 Subject: [PATCH 035/480] Adds guide section for no-return-else --- README.md | 65 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 65 insertions(+) diff --git a/README.md b/README.md index 6cbacc3b25..f1fbeb6e01 100644 --- a/README.md +++ b/README.md @@ -1993,6 +1993,71 @@ Other Style Guides } ``` + + - [16.3](#blocks--no-else-return) If an `if` block always executes a `return` statement, the subsequent `else` block is unnecessary. A `return` in an `else if` block following an `if` block that contains a `return` can be separated into multiple `if` blocks. eslint: [`no-else-return`](https://eslint.org/docs/rules/no-else-return) + + ```javascript + // bad + function foo() { + if (x) { + return x; + } else { + return y; + } + } + + // bad + function cats() { + if (x) { + return x; + } else if (y) { + return y; + } + } + + // bad + function dogs() { + if (x) { + return x; + } else { + if (y) { + return y; + } + } + } + + // good + function foo() { + if (x) { + return x; + } + + return y; + } + + // good + function cats() { + if (x) { + return x; + } + + if (y) { + return y; + } + } + + //good + function dogs(x) { + if (x) { + if (z) { + return y; + } + } else { + return z; + } + } + ``` + **[⬆ back to top](#table-of-contents)** ## Control Statements From 39cf84f43b5abc921a339ef453669be4f7c69544 Mon Sep 17 00:00:00 2001 From: jabacchetta Date: Thu, 19 Oct 2017 18:59:41 -0500 Subject: [PATCH 036/480] [guide] Add clarification to arrow functions MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Clarify and correct explanation — to be consistent with section 7.1 (use named function expressions). --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index f1fbeb6e01..f7d8a77e1b 100644 --- a/README.md +++ b/README.md @@ -912,11 +912,11 @@ Other Style Guides ## Arrow Functions - - [8.1](#arrows--use-them) When you must use function expressions (as when passing an anonymous function), use arrow function notation. eslint: [`prefer-arrow-callback`](http://eslint.org/docs/rules/prefer-arrow-callback.html), [`arrow-spacing`](http://eslint.org/docs/rules/arrow-spacing.html) jscs: [`requireArrowFunctions`](http://jscs.info/rule/requireArrowFunctions) + - [8.1](#arrows--use-them) When you must use an anonymous function (as when passing an inline callback), use arrow function notation. eslint: [`prefer-arrow-callback`](http://eslint.org/docs/rules/prefer-arrow-callback.html), [`arrow-spacing`](http://eslint.org/docs/rules/arrow-spacing.html) jscs: [`requireArrowFunctions`](http://jscs.info/rule/requireArrowFunctions) > Why? It creates a version of the function that executes in the context of `this`, which is usually what you want, and is a more concise syntax. - > Why not? If you have a fairly complicated function, you might move that logic out into its own function declaration. + > Why not? If you have a fairly complicated function, you might move that logic out into its own named function expression. ```javascript // bad From 3c6d40ccca6c436b7628c6fd3d2fe6a7eb9aae1a Mon Sep 17 00:00:00 2001 From: jabacchetta Date: Thu, 19 Oct 2017 19:46:28 -0500 Subject: [PATCH 037/480] [docs] Clarify reasoning for named function expressions For convenience, added brief explanations that are given in the linked discussion (mostly eliminating the need to scroll through the comments). --- README.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index f7d8a77e1b..f2fe1dc135 100644 --- a/README.md +++ b/README.md @@ -633,7 +633,7 @@ Other Style Guides - [7.1](#functions--declarations) Use named function expressions instead of function declarations. eslint: [`func-style`](http://eslint.org/docs/rules/func-style) jscs: [`disallowFunctionDeclarations`](http://jscs.info/rule/disallowFunctionDeclarations) - > Why? Function declarations are hoisted, which means that it’s easy - too easy - to reference the function before it is defined in the file. This harms readability and maintainability. If you find that a function’s definition is large or complex enough that it is interfering with understanding the rest of the file, then perhaps it’s time to extract it to its own module! Don’t forget to name the expression - anonymous functions can make it harder to locate the problem in an Error’s call stack. ([Discussion](https://github.com/airbnb/javascript/issues/794)) + > Why? Function declarations are hoisted, which means that it’s easy - too easy - to reference the function before it is defined in the file. This harms readability and maintainability. If you find that a function’s definition is large or complex enough that it is interfering with understanding the rest of the file, then perhaps it’s time to extract it to its own module! Don’t forget to explicitly name the expression, regardless of whether or not the name is inferred from the containing variable (which is often the case in modern browsers or when using compilers such as Babel). This eliminates any assumptions made about the Error's call stack. ([Discussion](https://github.com/airbnb/javascript/issues/794)) ```javascript // bad @@ -647,7 +647,8 @@ Other Style Guides }; // good - const foo = function bar() { + // lexical name distinguished from the variable-referenced invocation(s) + const foo = function uniqueMoreDescriptiveLexicalFoo() { // ... }; ``` From 94c47734e8ee11f720ddd1df28b9fa9d481a4941 Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Fri, 20 Oct 2017 15:48:09 -0700 Subject: [PATCH 038/480] [eslint config] [*] [deps] update `eslint-plugin-import` --- packages/eslint-config-airbnb-base/package.json | 4 ++-- packages/eslint-config-airbnb-base/rules/imports.js | 5 +++++ packages/eslint-config-airbnb/package.json | 4 ++-- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/packages/eslint-config-airbnb-base/package.json b/packages/eslint-config-airbnb-base/package.json index cf83b916ae..2066ad1ab0 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.9.0", "eslint-find-rules": "^3.1.1", - "eslint-plugin-import": "^2.7.0", + "eslint-plugin-import": "^2.8.0", "in-publish": "^2.0.0", "safe-publish-latest": "^1.1.1", "tape": "^4.8.0" }, "peerDependencies": { "eslint": "^4.9.0", - "eslint-plugin-import": "^2.7.0" + "eslint-plugin-import": "^2.8.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 6636d771ce..54e158f57f 100644 --- a/packages/eslint-config-airbnb-base/rules/imports.js +++ b/packages/eslint-config-airbnb-base/rules/imports.js @@ -204,5 +204,10 @@ module.exports = { allowLiteral: false, allowObject: false, }], + + // This rule enforces that all exports are declared at the bottom of the file. + // https://github.com/benmosher/eslint-plugin-import/blob/98acd6afd04dcb6920b81330114e146dc8532ea4/docs/rules/exports-last.md + // TODO: enable? + 'import/exports-last': 'off', }, }; diff --git a/packages/eslint-config-airbnb/package.json b/packages/eslint-config-airbnb/package.json index b35110c18b..bdf9700026 100644 --- a/packages/eslint-config-airbnb/package.json +++ b/packages/eslint-config-airbnb/package.json @@ -56,7 +56,7 @@ "editorconfig-tools": "^0.1.1", "eslint": "^4.9.0", "eslint-find-rules": "^3.1.1", - "eslint-plugin-import": "^2.7.0", + "eslint-plugin-import": "^2.8.0", "eslint-plugin-jsx-a11y": "^6.0.2", "eslint-plugin-react": "^7.4.0", "in-publish": "^2.0.0", @@ -66,7 +66,7 @@ }, "peerDependencies": { "eslint": "^4.9.0", - "eslint-plugin-import": "^2.7.0", + "eslint-plugin-import": "^2.8.0", "eslint-plugin-jsx-a11y": "^6.0.2", "eslint-plugin-react": "^7.4.0" }, From 232b719fc5192075c03dd1fc07445982df718486 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=88=98=E5=86=B2?= Date: Sat, 21 Oct 2017 22:11:18 +0800 Subject: [PATCH 039/480] To Clarify the func-style description As "foo" is still meaningless, but with "short", we can see that, we are intend to use a short alias name to make our coding happily. --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index f2fe1dc135..2af76733c7 100644 --- a/README.md +++ b/README.md @@ -648,7 +648,7 @@ Other Style Guides // good // lexical name distinguished from the variable-referenced invocation(s) - const foo = function uniqueMoreDescriptiveLexicalFoo() { +    const short = function longUniqueMoreDescriptiveLexicalFoo() { // ... }; ``` From 97a68836215914c0ece2f221d1896a2e01f56a22 Mon Sep 17 00:00:00 2001 From: Liu Chong Date: Sun, 22 Oct 2017 14:10:35 +0800 Subject: [PATCH 040/480] Fix markdown style breaking It came from the special characters "M-BM-": ``` diff README.md README.md.new | cat -A 651c651$ < const foo = function uniqueMoreDescriptiveLexicalFoo() {$ ---$ > M-BM- M-BM- const short = function longUniqueMoreDescriptiveLexicalFoo() {$ ``` --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 2af76733c7..134abe9e3c 100644 --- a/README.md +++ b/README.md @@ -647,8 +647,8 @@ Other Style Guides }; // good - // lexical name distinguished from the variable-referenced invocation(s) -    const short = function longUniqueMoreDescriptiveLexicalFoo() { + // lexical name distinguished from the variable-referenced invocation(s) + const short = function longUniqueMoreDescriptiveLexicalFoo() { // ... }; ``` From 8161f32f1ff7afb1d382a304db2690cee4d6a3e7 Mon Sep 17 00:00:00 2001 From: Sharmila Date: Fri, 20 Oct 2017 16:09:16 -0700 Subject: [PATCH 041/480] [eslint config] [base] [breaking] `no-mixed-operators`: only warn on `**` and `%` mixed with arithmetic operators; removes violation against mixing common math operators. Fixes #1071. --- README.md | 32 +++++++++++++++++++ .../eslint-config-airbnb-base/rules/style.js | 12 ++++++- 2 files changed, 43 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 134abe9e3c..4c304fcf4f 100644 --- a/README.md +++ b/README.md @@ -1943,6 +1943,38 @@ Other Style Guides const baz = !c; ``` + + - [15.7](#comparison--no-mixed-operators) Enclose operators in parentheses when they are mixed in a statement. When mixing arithmetic operators, do not mix `**` and `%` with themselves or with `+`, `-`, `*`, & `/`. eslint: [`no-mixed-operators`](http://eslint.org/docs/rules/no-mixed-operators.html) + + > Why? This improves readability and clarifies the developer’s intention. + + ```javascript + // bad + const foo = a && b < 0 || c > 0 || d + 1 === 0; + + // bad + const bar = a ** b - 5 % d; + + // bad + if (a || b && c) { + return d; + } + + // good + const foo = (a && b < 0) || c > 0 || (d + 1 === 0); + + // good + const bar = (a ** b) - (5 % d); + + // good + if ((a || b) && c) { + return d; + } + + // good + const bar = a + b / c * d; + ``` + **[⬆ back to top](#table-of-contents)** ## Blocks diff --git a/packages/eslint-config-airbnb-base/rules/style.js b/packages/eslint-config-airbnb-base/rules/style.js index 2ce7582a03..fe621239fd 100644 --- a/packages/eslint-config-airbnb-base/rules/style.js +++ b/packages/eslint-config-airbnb-base/rules/style.js @@ -254,8 +254,18 @@ module.exports = { // disallow un-paren'd mixes of different operators // http://eslint.org/docs/rules/no-mixed-operators 'no-mixed-operators': ['error', { + // the list of arthmetic groups disallows mixing `%` and `**` + // with other arithmetic operators. groups: [ - ['+', '-', '*', '/', '%', '**'], + ['%', '**'], + ['%', '+'], + ['%', '-'], + ['%', '*'], + ['%', '/'], + ['**', '+'], + ['**', '-'], + ['**', '*'], + ['**', '/'], ['&', '|', '^', '~', '<<', '>>', '>>>'], ['==', '!=', '===', '!==', '>', '>=', '<', '<='], ['&&', '||'], From dbd69346bde8b7edebfed3c2b092148bf3f449e1 Mon Sep 17 00:00:00 2001 From: Vse Mozhet Byt Date: Tue, 24 Oct 2017 00:07:05 +0300 Subject: [PATCH 042/480] [guide] Fix a numeration typo in README.md - also remove legacy numbered link --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 4c304fcf4f..677948fa09 100644 --- a/README.md +++ b/README.md @@ -1943,8 +1943,8 @@ Other Style Guides const baz = !c; ``` - - - [15.7](#comparison--no-mixed-operators) Enclose operators in parentheses when they are mixed in a statement. When mixing arithmetic operators, do not mix `**` and `%` with themselves or with `+`, `-`, `*`, & `/`. eslint: [`no-mixed-operators`](http://eslint.org/docs/rules/no-mixed-operators.html) + + - [15.8](#comparison--no-mixed-operators) Enclose operators in parentheses when they are mixed in a statement. When mixing arithmetic operators, do not mix `**` and `%` with themselves or with `+`, `-`, `*`, & `/`. eslint: [`no-mixed-operators`](http://eslint.org/docs/rules/no-mixed-operators.html) > Why? This improves readability and clarifies the developer’s intention. From bd3ba6edfe0f0fb907008a90c83846ced21a5c4d Mon Sep 17 00:00:00 2001 From: Arnav Date: Mon, 23 Oct 2017 15:04:58 -0700 Subject: [PATCH 043/480] Add symbol as a primitive type - Also add note that symbols cannot by polyfilled and should not be used in environments that don't support them --- README.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/README.md b/README.md index 677948fa09..282bd173f9 100644 --- a/README.md +++ b/README.md @@ -68,6 +68,7 @@ Other Style Guides - `boolean` - `null` - `undefined` + - `symbol` ```javascript const foo = 1; @@ -78,6 +79,8 @@ Other Style Guides console.log(foo, bar); // => 1, 9 ``` + - Symbols cannot be faithfully polyfilled, so they should not be used when targeting browsers/environments that don't support them natively. + - [1.2](#types--complex) **Complex**: When you access a complex type you work on a reference to its value. From ecf8e077a7d97695d17fab9f58f0948869a4672c Mon Sep 17 00:00:00 2001 From: Leonid Lebedev Date: Tue, 24 Oct 2017 14:33:47 +0300 Subject: [PATCH 044/480] Remove unnecessary variables --- README.md | 2 -- 1 file changed, 2 deletions(-) diff --git a/README.md b/README.md index 282bd173f9..116e6a5762 100644 --- a/README.md +++ b/README.md @@ -405,14 +405,12 @@ Other Style Guides [1, 2, 3].map(x => x + 1); // bad - no returned value means `memo` becomes undefined after the first iteration - const flat = {}; [[0, 1], [2, 3], [4, 5]].reduce((memo, item, index) => { const flatten = memo.concat(item); memo[index] = flatten; }); // good - const flat = {}; [[0, 1], [2, 3], [4, 5]].reduce((memo, item, index) => { const flatten = memo.concat(item); memo[index] = flatten; From 2676cbfb2f9cae832f02f0ea43a9df3f024a24f9 Mon Sep 17 00:00:00 2001 From: Sharmila Date: Tue, 24 Oct 2017 17:36:18 -0700 Subject: [PATCH 045/480] [eslint config] [base] [breaking] Enables `nonblock-statement-body-position` rule and adds link to guide --- README.md | 2 +- packages/eslint-config-airbnb-base/rules/style.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 116e6a5762..c5f79a6f48 100644 --- a/README.md +++ b/README.md @@ -1981,7 +1981,7 @@ Other Style Guides ## Blocks - - [16.1](#blocks--braces) Use braces with all multi-line blocks. + - [16.1](#blocks--braces) Use braces with all multi-line blocks. eslint: [`nonblock-statement-body-position`](https://eslint.org/docs/rules/nonblock-statement-body-position) ```javascript // bad diff --git a/packages/eslint-config-airbnb-base/rules/style.js b/packages/eslint-config-airbnb-base/rules/style.js index fe621239fd..e358e2a417 100644 --- a/packages/eslint-config-airbnb-base/rules/style.js +++ b/packages/eslint-config-airbnb-base/rules/style.js @@ -354,7 +354,7 @@ module.exports = { // enforce the location of single-line statements // http://eslint.org/docs/rules/nonblock-statement-body-position - 'nonblock-statement-body-position': 'off', + 'nonblock-statement-body-position': ['error', 'beside', { overrides: {} }], // require padding inside curly braces 'object-curly-spacing': ['error', 'always'], From 999fe3b83ac9cb41bb7f1514baeb68c007a369a3 Mon Sep 17 00:00:00 2001 From: Piotr Lasota Date: Wed, 25 Oct 2017 20:03:56 +0200 Subject: [PATCH 046/480] Change className to variant in examples --- react/README.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/react/README.md b/react/README.md index 6ade245c42..d172990bf6 100644 --- a/react/README.md +++ b/react/README.md @@ -400,7 +400,7 @@ ```jsx // bad render() { - return + return ; } @@ -408,7 +408,7 @@ // good render() { return ( - + ); @@ -427,10 +427,10 @@ ```jsx // bad - + // good - + ``` - If your component has multi-line properties, close its tag on a new line. eslint: [`react/jsx-closing-bracket-location`](https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-closing-bracket-location.md) From 9d3e7e0a2c47dedf6032d77418a531e8abfd7762 Mon Sep 17 00:00:00 2001 From: Piotr Lasota Date: Wed, 25 Oct 2017 20:05:40 +0200 Subject: [PATCH 047/480] Add component with className as anti-pattern example --- react/README.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/react/README.md b/react/README.md index d172990bf6..ee440e9b11 100644 --- a/react/README.md +++ b/react/README.md @@ -143,6 +143,9 @@ // bad + // bad + + // good ``` From 327795bf3c9bb8e4777d7b36387d01304dd7f46d Mon Sep 17 00:00:00 2001 From: Pirasis Leelatanon <1pete@users.noreply.github.com> Date: Thu, 26 Oct 2017 02:36:13 +0700 Subject: [PATCH 048/480] [doc] add eslint rule reference for `no-new-wrappers` --- README.md | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index c5f79a6f48..dd9e33241d 100644 --- a/README.md +++ b/README.md @@ -2796,11 +2796,14 @@ Other Style Guides - [22.1](#coercion--explicit) Perform type coercion at the beginning of the statement. - - [22.2](#coercion--strings) Strings: + - [22.2](#coercion--strings) Strings: eslint: [`no-new-wrappers`](https://eslint.org/docs/rules/no-new-wrappers) ```javascript // => this.reviewScore = 9; + // bad + const totalScore = new String(this.reviewScore); // typeof totalScore is "object" not "string" + // bad const totalScore = this.reviewScore + ''; // invokes this.reviewScore.valueOf() @@ -2812,7 +2815,7 @@ Other Style Guides ``` - - [22.3](#coercion--numbers) Numbers: Use `Number` for type casting and `parseInt` always with a radix for parsing strings. eslint: [`radix`](http://eslint.org/docs/rules/radix) + - [22.3](#coercion--numbers) Numbers: Use `Number` for type casting and `parseInt` always with a radix for parsing strings. eslint: [`radix`](http://eslint.org/docs/rules/radix) [`no-new-wrappers`](https://eslint.org/docs/rules/no-new-wrappers) ```javascript const inputValue = '4'; @@ -2859,7 +2862,7 @@ Other Style Guides ``` - - [22.6](#coercion--booleans) Booleans: + - [22.6](#coercion--booleans) Booleans: eslint: [`no-new-wrappers`](https://eslint.org/docs/rules/no-new-wrappers) ```javascript const age = 0; From dbdf8ea0ef966903968230d7ee11de6fa084ea9c Mon Sep 17 00:00:00 2001 From: Pirasis Leelatanon <1pete@users.noreply.github.com> Date: Thu, 26 Oct 2017 02:21:23 +0700 Subject: [PATCH 049/480] [doc] add eslint rule reference for `no-multi-assign` --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index dd9e33241d..feac6b354f 100644 --- a/README.md +++ b/README.md @@ -1633,7 +1633,7 @@ Other Style Guides } ``` - - [13.5](#variables--no-chain-assignment) Don’t chain variable assignments. + - [13.5](#variables--no-chain-assignment) Don’t chain variable assignments. eslint: [`no-multi-assign`](https://eslint.org/docs/rules/no-multi-assign) > Why? Chaining variable assignments creates implicit global variables. From c40d0d1f8444ba838e7550622334ad4418abf991 Mon Sep 17 00:00:00 2001 From: Vse Mozhet Byt Date: Sat, 28 Oct 2017 03:41:29 +0300 Subject: [PATCH 050/480] [guide] Fix a link, add an anchor --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index feac6b354f..e23c729b0b 100644 --- a/README.md +++ b/README.md @@ -1704,7 +1704,7 @@ Other Style Guides ## Hoisting - - [14.1](#hoisting--about) `var` declarations get hoisted to the top of their scope, their assignment does not. `const` and `let` declarations are blessed with a new concept called [Temporal Dead Zones (TDZ)](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/let#Temporal_dead_zone_and_errors_with_let). It’s important to know why [typeof is no longer safe](http://es-discourse.com/t/why-typeof-is-no-longer-safe/15). + - [14.1](#hoisting--about) `var` declarations get hoisted to the top of their scope, their assignment does not. `const` and `let` declarations are blessed with a new concept called [Temporal Dead Zones (TDZ)](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/let#Temporal_Dead_Zone_and_errors_with_let). It’s important to know why [typeof is no longer safe](http://es-discourse.com/t/why-typeof-is-no-longer-safe/15). ```javascript // we know this wouldn’t work (assuming there @@ -2223,6 +2223,7 @@ Other Style Guides } ``` + - [18.3](#comments--spaces) Start all comments with a space to make it easier to read. eslint: [`spaced-comment`](http://eslint.org/docs/rules/spaced-comment) ```javascript From 2d4343acd19bd7700a69b514d01889c7041d65fb Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Fri, 27 Oct 2017 22:10:32 -0700 Subject: [PATCH 051/480] [guide] remove/update outdated links. Fixes #1626. --- README.md | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/README.md b/README.md index e23c729b0b..d26d1824be 100644 --- a/README.md +++ b/README.md @@ -670,7 +670,7 @@ Other Style Guides - [7.3](#functions--in-blocks) Never declare a function in a non-function block (`if`, `while`, etc). Assign the function to a variable instead. Browsers will allow you to do it, but they all interpret it differently, which is bad news bears. eslint: [`no-loop-func`](http://eslint.org/docs/rules/no-loop-func.html) - - [7.4](#functions--note-on-blocks) **Note:** ECMA-262 defines a `block` as a list of statements. A function declaration is not a statement. [Read ECMA-262’s note on this issue](http://www.ecma-international.org/publications/files/ECMA-ST/Ecma-262.pdf#page=97). + - [7.4](#functions--note-on-blocks) **Note:** ECMA-262 defines a `block` as a list of statements. A function declaration is not a statement. ```javascript // bad @@ -3358,9 +3358,9 @@ Other Style Guides ## Resources -**Learning ES6** +**Learning ES6+** - - [Draft ECMA 2015 (ES6) Spec](https://people.mozilla.org/~jorendorff/es6-draft.html) + - [Latest ECMA spec](https://tc39.github.io/ecma262/) - [ExploringJS](http://exploringjs.com/) - [ES6 Compatibility Table](https://kangax.github.io/compat-table/es6/) - [Comprehensive Overview of ES6 Features](http://es6-features.org/) @@ -3427,7 +3427,6 @@ Other Style Guides - [Perfection Kills](http://perfectionkills.com/) - [Ben Alman](http://benalman.com/) - [Dmitry Baranovskiy](http://dmitry.baranovskiy.com/) - - [Dustin Diaz](http://dustindiaz.com/) - [nettuts](http://code.tutsplus.com/?s=javascript) **Podcasts** @@ -3442,7 +3441,7 @@ Other Style Guides This is a list of organizations that are using this style guide. Send us a pull request and we'll add you to the list. - **123erfasst**: [123erfasst/javascript](https://github.com/123erfasst/javascript) - - **3blades**: [3Blades/javascript](https://github.com/3blades/javascript) + - **3blades**: [3Blades](https://github.com/3blades) - **4Catalyzer**: [4Catalyzer/javascript](https://github.com/4Catalyzer/javascript) - **Aan Zee**: [AanZee/javascript](https://github.com/AanZee/javascript) - **Adult Swim**: [adult-swim/javascript](https://github.com/adult-swim/javascript) @@ -3455,7 +3454,7 @@ Other Style Guides - **Axept**: [axept/javascript](https://github.com/axept/javascript) - **BashPros**: [BashPros/javascript](https://github.com/BashPros/javascript) - **Billabong**: [billabong/javascript](https://github.com/billabong/javascript) - - **Bisk**: [bisk/javascript](https://github.com/Bisk/javascript/) + - **Bisk**: [bisk](https://github.com/Bisk/) - **Bonhomme**: [bonhommeparis/javascript](https://github.com/bonhommeparis/javascript) - **Brainshark**: [brainshark/javascript](https://github.com/brainshark/javascript) - **CaseNine**: [CaseNine/javascript](https://github.com/CaseNine/javascript) @@ -3472,7 +3471,7 @@ Other Style Guides - **ExactTarget**: [ExactTarget/javascript](https://github.com/ExactTarget/javascript) - **Expensify** [Expensify/Style-Guide](https://github.com/Expensify/Style-Guide/blob/master/javascript.md) - **Flexberry**: [Flexberry/javascript-style-guide](https://github.com/Flexberry/javascript-style-guide) - - **Gawker Media**: [gawkermedia/javascript](https://github.com/gawkermedia/javascript) + - **Gawker Media**: [gawkermedia](https://github.com/gawkermedia/) - **General Electric**: [GeneralElectric/javascript](https://github.com/GeneralElectric/javascript) - **Generation Tux**: [GenerationTux/javascript](https://github.com/generationtux/styleguide) - **GoodData**: [gooddata/gdc-js-style](https://github.com/gooddata/gdc-js-style) @@ -3480,7 +3479,7 @@ Other Style Guides - **Grupo-Abraxas**: [Grupo-Abraxas/javascript](https://github.com/Grupo-Abraxas/javascript) - **Honey**: [honeyscience/javascript](https://github.com/honeyscience/javascript) - **How About We**: [howaboutwe/javascript](https://github.com/howaboutwe/javascript-style-guide) - - **Huballin**: [huballin/javascript](https://github.com/huballin/javascript) + - **Huballin**: [huballin](https://github.com/huballin/) - **HubSpot**: [HubSpot/javascript](https://github.com/HubSpot/javascript) - **Hyper**: [hyperoslo/javascript-playbook](https://github.com/hyperoslo/javascript-playbook/blob/master/style.md) - **InterCity Group**: [intercitygroup/javascript-style-guide](https://github.com/intercitygroup/javascript-style-guide) @@ -3488,7 +3487,7 @@ Other Style Guides - **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) + - **KickorStick**: [kickorstick](https://github.com/kickorstick/) - **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) @@ -3498,8 +3497,8 @@ Other Style Guides - **MitocGroup**: [MitocGroup/javascript](https://github.com/MitocGroup/javascript) - **ModCloth**: [modcloth/javascript](https://github.com/modcloth/javascript) - **Money Advice Service**: [moneyadviceservice/javascript](https://github.com/moneyadviceservice/javascript) - - **Muber**: [muber/javascript](https://github.com/muber/javascript) - - **National Geographic**: [natgeo/javascript](https://github.com/natgeo/javascript) + - **Muber**: [muber](https://github.com/muber/) + - **National Geographic**: [natgeo](https://github.com/natgeo/) - **Nimbl3**: [nimbl3/javascript](https://github.com/nimbl3/javascript) - **Nulogy**: [nulogy/javascript](https://github.com/nulogy/javascript) - **Orange Hill Development**: [orangehill/javascript](https://github.com/orangehill/javascript) @@ -3509,13 +3508,13 @@ Other Style Guides - **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) - - **REI**: [reidev/js-style-guide](https://github.com/rei/code-style-guides/blob/master/docs/javascript.md) + - **REI**: [reidev/js-style-guide](https://github.com/rei/code-style-guides/) - **Ripple**: [ripple/javascript-style-guide](https://github.com/ripple/javascript-style-guide) - **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) - - **Springload**: [springload/javascript](https://github.com/springload/javascript) + - **Springload**: [springload](https://github.com/springload/) - **StratoDem Analytics**: [stratodem/javascript](https://github.com/stratodem/javascript) - **SteelKiwi Development**: [steelkiwi/javascript](https://github.com/steelkiwi/javascript) - **StudentSphere**: [studentsphere/javascript](https://github.com/studentsphere/guide-javascript) From 7ff6303513b46e8b7dd0bc03327b138a6db7b3b4 Mon Sep 17 00:00:00 2001 From: Ed Morley <501702+edmorley@users.noreply.github.com> Date: Mon, 30 Oct 2017 13:10:30 +0000 Subject: [PATCH 052/480] [guide] Use HTTPS for links to ESLint documentation The result of a `s_http://eslint\.org_https://eslint\.org_g`. Avoids the HTTP 302s of the non-HTTPs URLs. --- README.md | 126 +++++++++--------- packages/eslint-config-airbnb-base/README.md | 2 +- .../rules/best-practices.js | 50 +++---- .../eslint-config-airbnb-base/rules/errors.js | 26 ++-- .../eslint-config-airbnb-base/rules/es6.js | 54 ++++---- .../eslint-config-airbnb-base/rules/node.js | 6 +- .../eslint-config-airbnb-base/rules/style.js | 92 ++++++------- .../rules/variables.js | 4 +- packages/eslint-config-airbnb/CHANGELOG.md | 60 ++++----- packages/eslint-config-airbnb/README.md | 2 +- packages/eslint-config-airbnb/rules/react.js | 2 +- .../test/test-react-order.js | 4 +- react/README.md | 4 +- 13 files changed, 216 insertions(+), 216 deletions(-) diff --git a/README.md b/README.md index d26d1824be..52b5ed4a8f 100644 --- a/README.md +++ b/README.md @@ -102,7 +102,7 @@ Other Style Guides ## References - - [2.1](#references--prefer-const) Use `const` for all of your references; avoid using `var`. eslint: [`prefer-const`](http://eslint.org/docs/rules/prefer-const.html), [`no-const-assign`](http://eslint.org/docs/rules/no-const-assign.html) + - [2.1](#references--prefer-const) Use `const` for all of your references; avoid using `var`. eslint: [`prefer-const`](https://eslint.org/docs/rules/prefer-const.html), [`no-const-assign`](https://eslint.org/docs/rules/no-const-assign.html) > Why? This ensures that you can’t reassign your references, which can lead to bugs and difficult to comprehend code. @@ -117,7 +117,7 @@ Other Style Guides ``` - - [2.2](#references--disallow-var) If you must reassign references, use `let` instead of `var`. eslint: [`no-var`](http://eslint.org/docs/rules/no-var.html) jscs: [`disallowVar`](http://jscs.info/rule/disallowVar) + - [2.2](#references--disallow-var) If you must reassign references, use `let` instead of `var`. eslint: [`no-var`](https://eslint.org/docs/rules/no-var.html) jscs: [`disallowVar`](http://jscs.info/rule/disallowVar) > Why? `let` is block-scoped rather than function-scoped like `var`. @@ -153,7 +153,7 @@ Other Style Guides ## Objects - - [3.1](#objects--no-new) Use the literal syntax for object creation. eslint: [`no-new-object`](http://eslint.org/docs/rules/no-new-object.html) + - [3.1](#objects--no-new) Use the literal syntax for object creation. eslint: [`no-new-object`](https://eslint.org/docs/rules/no-new-object.html) ```javascript // bad @@ -190,7 +190,7 @@ Other Style Guides ``` - - [3.3](#es6-object-shorthand) Use object method shorthand. eslint: [`object-shorthand`](http://eslint.org/docs/rules/object-shorthand.html) jscs: [`requireEnhancedObjectLiterals`](http://jscs.info/rule/requireEnhancedObjectLiterals) + - [3.3](#es6-object-shorthand) Use object method shorthand. eslint: [`object-shorthand`](https://eslint.org/docs/rules/object-shorthand.html) jscs: [`requireEnhancedObjectLiterals`](http://jscs.info/rule/requireEnhancedObjectLiterals) ```javascript // bad @@ -213,7 +213,7 @@ Other Style Guides ``` - - [3.4](#es6-object-concise) Use property value shorthand. eslint: [`object-shorthand`](http://eslint.org/docs/rules/object-shorthand.html) jscs: [`requireEnhancedObjectLiterals`](http://jscs.info/rule/requireEnhancedObjectLiterals) + - [3.4](#es6-object-concise) Use property value shorthand. eslint: [`object-shorthand`](https://eslint.org/docs/rules/object-shorthand.html) jscs: [`requireEnhancedObjectLiterals`](http://jscs.info/rule/requireEnhancedObjectLiterals) > Why? It is shorter to write and descriptive. @@ -262,7 +262,7 @@ Other Style Guides ``` - - [3.6](#objects--quoted-props) Only quote properties that are invalid identifiers. eslint: [`quote-props`](http://eslint.org/docs/rules/quote-props.html) jscs: [`disallowQuotedKeysInObjects`](http://jscs.info/rule/disallowQuotedKeysInObjects) + - [3.6](#objects--quoted-props) Only quote properties that are invalid identifiers. eslint: [`quote-props`](https://eslint.org/docs/rules/quote-props.html) jscs: [`disallowQuotedKeysInObjects`](http://jscs.info/rule/disallowQuotedKeysInObjects) > Why? In general we consider it subjectively easier to read. It improves syntax highlighting, and is also more easily optimized by many JS engines. @@ -327,7 +327,7 @@ Other Style Guides ## Arrays - - [4.1](#arrays--literals) Use the literal syntax for array creation. eslint: [`no-array-constructor`](http://eslint.org/docs/rules/no-array-constructor.html) + - [4.1](#arrays--literals) Use the literal syntax for array creation. eslint: [`no-array-constructor`](https://eslint.org/docs/rules/no-array-constructor.html) ```javascript // bad @@ -392,7 +392,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`](http://eslint.org/docs/rules/array-callback-return) + - [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) ```javascript // good @@ -549,7 +549,7 @@ Other Style Guides ## Strings - - [6.1](#strings--quotes) Use single quotes `''` for strings. eslint: [`quotes`](http://eslint.org/docs/rules/quotes.html) jscs: [`validateQuoteMarks`](http://jscs.info/rule/validateQuoteMarks) + - [6.1](#strings--quotes) Use single quotes `''` for strings. eslint: [`quotes`](https://eslint.org/docs/rules/quotes.html) jscs: [`validateQuoteMarks`](http://jscs.info/rule/validateQuoteMarks) ```javascript // bad @@ -584,7 +584,7 @@ Other Style Guides ``` - - [6.3](#es6-template-literals) When programmatically building up strings, use template strings instead of concatenation. eslint: [`prefer-template`](http://eslint.org/docs/rules/prefer-template.html) [`template-curly-spacing`](http://eslint.org/docs/rules/template-curly-spacing) jscs: [`requireTemplateStrings`](http://jscs.info/rule/requireTemplateStrings) + - [6.3](#es6-template-literals) When programmatically building up strings, use template strings instead of concatenation. eslint: [`prefer-template`](https://eslint.org/docs/rules/prefer-template.html) [`template-curly-spacing`](https://eslint.org/docs/rules/template-curly-spacing) jscs: [`requireTemplateStrings`](http://jscs.info/rule/requireTemplateStrings) > Why? Template strings give you a readable, concise syntax with proper newlines and string interpolation features. @@ -611,10 +611,10 @@ Other Style Guides ``` - - [6.4](#strings--eval) Never use `eval()` on a string, it opens too many vulnerabilities. eslint: [`no-eval`](http://eslint.org/docs/rules/no-eval) + - [6.4](#strings--eval) Never use `eval()` on a string, it opens too many vulnerabilities. eslint: [`no-eval`](https://eslint.org/docs/rules/no-eval) - - [6.5](#strings--escaping) Do not unnecessarily escape characters in strings. eslint: [`no-useless-escape`](http://eslint.org/docs/rules/no-useless-escape) + - [6.5](#strings--escaping) Do not unnecessarily escape characters in strings. eslint: [`no-useless-escape`](https://eslint.org/docs/rules/no-useless-escape) > Why? Backslashes harm readability, thus they should only be present when necessary. @@ -632,7 +632,7 @@ Other Style Guides ## Functions - - [7.1](#functions--declarations) Use named function expressions instead of function declarations. eslint: [`func-style`](http://eslint.org/docs/rules/func-style) jscs: [`disallowFunctionDeclarations`](http://jscs.info/rule/disallowFunctionDeclarations) + - [7.1](#functions--declarations) Use named function expressions instead of function declarations. eslint: [`func-style`](https://eslint.org/docs/rules/func-style) jscs: [`disallowFunctionDeclarations`](http://jscs.info/rule/disallowFunctionDeclarations) > Why? Function declarations are hoisted, which means that it’s easy - too easy - to reference the function before it is defined in the file. This harms readability and maintainability. If you find that a function’s definition is large or complex enough that it is interfering with understanding the rest of the file, then perhaps it’s time to extract it to its own module! Don’t forget to explicitly name the expression, regardless of whether or not the name is inferred from the containing variable (which is often the case in modern browsers or when using compilers such as Babel). This eliminates any assumptions made about the Error's call stack. ([Discussion](https://github.com/airbnb/javascript/issues/794)) @@ -655,7 +655,7 @@ Other Style Guides ``` - - [7.2](#functions--iife) Wrap immediately invoked function expressions in parentheses. eslint: [`wrap-iife`](http://eslint.org/docs/rules/wrap-iife.html) jscs: [`requireParenthesesAroundIIFE`](http://jscs.info/rule/requireParenthesesAroundIIFE) + - [7.2](#functions--iife) Wrap immediately invoked function expressions in parentheses. eslint: [`wrap-iife`](https://eslint.org/docs/rules/wrap-iife.html) jscs: [`requireParenthesesAroundIIFE`](http://jscs.info/rule/requireParenthesesAroundIIFE) > Why? An immediately invoked function expression is a single unit - wrapping both it, and its invocation parens, in parens, cleanly expresses this. Note that in a world with modules everywhere, you almost never need an IIFE. @@ -667,7 +667,7 @@ Other Style Guides ``` - - [7.3](#functions--in-blocks) Never declare a function in a non-function block (`if`, `while`, etc). Assign the function to a variable instead. Browsers will allow you to do it, but they all interpret it differently, which is bad news bears. eslint: [`no-loop-func`](http://eslint.org/docs/rules/no-loop-func.html) + - [7.3](#functions--in-blocks) Never declare a function in a non-function block (`if`, `while`, etc). Assign the function to a variable instead. Browsers will allow you to do it, but they all interpret it differently, which is bad news bears. eslint: [`no-loop-func`](https://eslint.org/docs/rules/no-loop-func.html) - [7.4](#functions--note-on-blocks) **Note:** ECMA-262 defines a `block` as a list of statements. A function declaration is not a statement. @@ -705,7 +705,7 @@ Other Style Guides ``` - - [7.6](#es6-rest) Never use `arguments`, opt to use rest syntax `...` instead. eslint: [`prefer-rest-params`](http://eslint.org/docs/rules/prefer-rest-params) + - [7.6](#es6-rest) Never use `arguments`, opt to use rest syntax `...` instead. eslint: [`prefer-rest-params`](https://eslint.org/docs/rules/prefer-rest-params) > Why? `...` is explicit about which arguments you want pulled. Plus, rest arguments are a real Array, and not merely Array-like like `arguments`. @@ -782,7 +782,7 @@ Other Style Guides ``` - - [7.10](#functions--constructor) Never use the Function constructor to create a new function. eslint: [`no-new-func`](http://eslint.org/docs/rules/no-new-func) + - [7.10](#functions--constructor) Never use the Function constructor to create a new function. eslint: [`no-new-func`](https://eslint.org/docs/rules/no-new-func) > Why? Creating a function in this way evaluates a string similarly to eval(), which opens vulnerabilities. @@ -795,7 +795,7 @@ Other Style Guides ``` - - [7.11](#functions--signature-spacing) Spacing in a function signature. eslint: [`space-before-function-paren`](http://eslint.org/docs/rules/space-before-function-paren) [`space-before-blocks`](http://eslint.org/docs/rules/space-before-blocks) + - [7.11](#functions--signature-spacing) Spacing in a function signature. eslint: [`space-before-function-paren`](https://eslint.org/docs/rules/space-before-function-paren) [`space-before-blocks`](https://eslint.org/docs/rules/space-before-blocks) > Why? Consistency is good, and you shouldn’t have to add or remove a space when adding or removing a name. @@ -811,7 +811,7 @@ Other Style Guides ``` - - [7.12](#functions--mutate-params) Never mutate parameters. eslint: [`no-param-reassign`](http://eslint.org/docs/rules/no-param-reassign.html) + - [7.12](#functions--mutate-params) Never mutate parameters. eslint: [`no-param-reassign`](https://eslint.org/docs/rules/no-param-reassign.html) > Why? Manipulating objects passed in as parameters can cause unwanted variable side effects in the original caller. @@ -828,7 +828,7 @@ Other Style Guides ``` - - [7.13](#functions--reassign-params) Never reassign parameters. eslint: [`no-param-reassign`](http://eslint.org/docs/rules/no-param-reassign.html) + - [7.13](#functions--reassign-params) Never reassign parameters. eslint: [`no-param-reassign`](https://eslint.org/docs/rules/no-param-reassign.html) > Why? Reassigning parameters can lead to unexpected behavior, especially when accessing the `arguments` object. It can also cause optimization issues, especially in V8. @@ -856,7 +856,7 @@ Other Style Guides ``` - - [7.14](#functions--spread-vs-apply) Prefer the use of the spread operator `...` to call variadic functions. eslint: [`prefer-spread`](http://eslint.org/docs/rules/prefer-spread) + - [7.14](#functions--spread-vs-apply) Prefer the use of the spread operator `...` to call variadic functions. eslint: [`prefer-spread`](https://eslint.org/docs/rules/prefer-spread) > Why? It’s cleaner, you don’t need to supply a context, and you can not easily compose `new` with `apply`. @@ -914,7 +914,7 @@ Other Style Guides ## Arrow Functions - - [8.1](#arrows--use-them) When you must use an anonymous function (as when passing an inline callback), use arrow function notation. eslint: [`prefer-arrow-callback`](http://eslint.org/docs/rules/prefer-arrow-callback.html), [`arrow-spacing`](http://eslint.org/docs/rules/arrow-spacing.html) jscs: [`requireArrowFunctions`](http://jscs.info/rule/requireArrowFunctions) + - [8.1](#arrows--use-them) When you must use an anonymous function (as when passing an inline callback), use arrow function notation. eslint: [`prefer-arrow-callback`](https://eslint.org/docs/rules/prefer-arrow-callback.html), [`arrow-spacing`](https://eslint.org/docs/rules/arrow-spacing.html) jscs: [`requireArrowFunctions`](http://jscs.info/rule/requireArrowFunctions) > Why? It creates a version of the function that executes in the context of `this`, which is usually what you want, and is a more concise syntax. @@ -935,7 +935,7 @@ Other Style Guides ``` - - [8.2](#arrows--implicit-return) If the function body consists of a single statement returning an [expression](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Expressions_and_Operators#Expressions) without side effects, omit the braces and use the implicit return. Otherwise, keep the braces and use a `return` statement. eslint: [`arrow-parens`](http://eslint.org/docs/rules/arrow-parens.html), [`arrow-body-style`](http://eslint.org/docs/rules/arrow-body-style.html) jscs: [`disallowParenthesesAroundArrowParam`](http://jscs.info/rule/disallowParenthesesAroundArrowParam), [`requireShorthandArrowFunctions`](http://jscs.info/rule/requireShorthandArrowFunctions) + - [8.2](#arrows--implicit-return) If the function body consists of a single statement returning an [expression](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Expressions_and_Operators#Expressions) without side effects, omit the braces and use the implicit return. Otherwise, keep the braces and use a `return` statement. eslint: [`arrow-parens`](https://eslint.org/docs/rules/arrow-parens.html), [`arrow-body-style`](https://eslint.org/docs/rules/arrow-body-style.html) jscs: [`disallowParenthesesAroundArrowParam`](http://jscs.info/rule/disallowParenthesesAroundArrowParam), [`requireShorthandArrowFunctions`](http://jscs.info/rule/requireShorthandArrowFunctions) > Why? Syntactic sugar. It reads well when multiple functions are chained together. @@ -1002,7 +1002,7 @@ Other Style Guides ``` - - [8.4](#arrows--one-arg-parens) If your function takes a single argument and doesn’t use braces, omit the parentheses. Otherwise, always include parentheses around arguments for clarity and consistency. Note: it is also acceptable to always use parentheses, in which case use the [“always” option](http://eslint.org/docs/rules/arrow-parens#always) for eslint or do not include [`disallowParenthesesAroundArrowParam`](http://jscs.info/rule/disallowParenthesesAroundArrowParam) for jscs. eslint: [`arrow-parens`](http://eslint.org/docs/rules/arrow-parens.html) jscs: [`disallowParenthesesAroundArrowParam`](http://jscs.info/rule/disallowParenthesesAroundArrowParam) + - [8.4](#arrows--one-arg-parens) If your function takes a single argument and doesn’t use braces, omit the parentheses. Otherwise, always include parentheses around arguments for clarity and consistency. Note: it is also acceptable to always use parentheses, in which case use the [“always” option](https://eslint.org/docs/rules/arrow-parens#always) for eslint or do not include [`disallowParenthesesAroundArrowParam`](http://jscs.info/rule/disallowParenthesesAroundArrowParam) for jscs. eslint: [`arrow-parens`](https://eslint.org/docs/rules/arrow-parens.html) jscs: [`disallowParenthesesAroundArrowParam`](http://jscs.info/rule/disallowParenthesesAroundArrowParam) > Why? Less visual clutter. @@ -1032,7 +1032,7 @@ Other Style Guides ``` - - [8.5](#arrows--confusing) Avoid confusing arrow function syntax (`=>`) with comparison operators (`<=`, `>=`). eslint: [`no-confusing-arrow`](http://eslint.org/docs/rules/no-confusing-arrow) + - [8.5](#arrows--confusing) Avoid confusing arrow function syntax (`=>`) with comparison operators (`<=`, `>=`). eslint: [`no-confusing-arrow`](https://eslint.org/docs/rules/no-confusing-arrow) ```javascript // bad @@ -1165,7 +1165,7 @@ Other Style Guides ``` - - [9.5](#constructors--no-useless) Classes have a default constructor if one is not specified. An empty constructor function or one that just delegates to a parent class is unnecessary. eslint: [`no-useless-constructor`](http://eslint.org/docs/rules/no-useless-constructor) + - [9.5](#constructors--no-useless) Classes have a default constructor if one is not specified. An empty constructor function or one that just delegates to a parent class is unnecessary. eslint: [`no-useless-constructor`](https://eslint.org/docs/rules/no-useless-constructor) ```javascript // bad @@ -1194,7 +1194,7 @@ Other Style Guides ``` - - [9.6](#classes--no-duplicate-members) Avoid duplicate class members. eslint: [`no-dupe-class-members`](http://eslint.org/docs/rules/no-dupe-class-members) + - [9.6](#classes--no-duplicate-members) Avoid duplicate class members. eslint: [`no-dupe-class-members`](https://eslint.org/docs/rules/no-dupe-class-members) > Why? Duplicate class member declarations will silently prefer the last one - having duplicates is almost certainly a bug. @@ -1270,7 +1270,7 @@ Other Style Guides - [10.4](#modules--no-duplicate-imports) Only import from a path in one place. - eslint: [`no-duplicate-imports`](http://eslint.org/docs/rules/no-duplicate-imports) + eslint: [`no-duplicate-imports`](https://eslint.org/docs/rules/no-duplicate-imports) > Why? Having multiple lines that import from the same path can make code harder to maintain. ```javascript @@ -1375,7 +1375,7 @@ Other Style Guides ## Iterators and Generators - - [11.1](#iterators--nope) Don’t use iterators. Prefer JavaScript’s higher-order functions instead of loops like `for-in` or `for-of`. eslint: [`no-iterator`](http://eslint.org/docs/rules/no-iterator.html) [`no-restricted-syntax`](http://eslint.org/docs/rules/no-restricted-syntax) + - [11.1](#iterators--nope) Don’t use iterators. Prefer JavaScript’s higher-order functions instead of loops like `for-in` or `for-of`. eslint: [`no-iterator`](https://eslint.org/docs/rules/no-iterator.html) [`no-restricted-syntax`](https://eslint.org/docs/rules/no-restricted-syntax) > Why? This enforces our immutable rule. Dealing with pure functions that return values is easier to reason about than side effects. @@ -1424,7 +1424,7 @@ Other Style Guides > Why? They don’t transpile well to ES5. - - [11.3](#generators--spacing) If you must use generators, or if you disregard [our advice](#generators--nope), make sure their function signature is spaced properly. eslint: [`generator-star-spacing`](http://eslint.org/docs/rules/generator-star-spacing) + - [11.3](#generators--spacing) If you must use generators, or if you disregard [our advice](#generators--nope), make sure their function signature is spaced properly. eslint: [`generator-star-spacing`](https://eslint.org/docs/rules/generator-star-spacing) > Why? `function` and `*` are part of the same conceptual keyword - `*` is not a modifier for `function`, `function*` is a unique construct, different from `function`. @@ -1489,7 +1489,7 @@ Other Style Guides ## Properties - - [12.1](#properties--dot) Use dot notation when accessing properties. eslint: [`dot-notation`](http://eslint.org/docs/rules/dot-notation.html) jscs: [`requireDotNotation`](http://jscs.info/rule/requireDotNotation) + - [12.1](#properties--dot) Use dot notation when accessing properties. eslint: [`dot-notation`](https://eslint.org/docs/rules/dot-notation.html) jscs: [`requireDotNotation`](http://jscs.info/rule/requireDotNotation) ```javascript const luke = { @@ -1520,7 +1520,7 @@ 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). + - [12.3](#es2016-properties--exponentiation-operator) Use exponentiation operator `**` when calculating exponentiations. eslint: [`no-restricted-properties`](https://eslint.org/docs/rules/no-restricted-properties). ```javascript // bad @@ -1535,7 +1535,7 @@ Other Style Guides ## Variables - - [13.1](#variables--const) Always use `const` or `let` to declare variables. Not doing so will result in global variables. We want to avoid polluting the global namespace. Captain Planet warned us of that. eslint: [`no-undef`](http://eslint.org/docs/rules/no-undef) [`prefer-const`](http://eslint.org/docs/rules/prefer-const) + - [13.1](#variables--const) Always use `const` or `let` to declare variables. Not doing so will result in global variables. We want to avoid polluting the global namespace. Captain Planet warned us of that. eslint: [`no-undef`](https://eslint.org/docs/rules/no-undef) [`prefer-const`](https://eslint.org/docs/rules/prefer-const) ```javascript // bad @@ -1546,7 +1546,7 @@ Other Style Guides ``` - - [13.2](#variables--one-const) Use one `const` or `let` declaration per variable. eslint: [`one-var`](http://eslint.org/docs/rules/one-var.html) jscs: [`disallowMultipleVarDecl`](http://jscs.info/rule/disallowMultipleVarDecl) + - [13.2](#variables--one-const) Use one `const` or `let` declaration per variable. eslint: [`one-var`](https://eslint.org/docs/rules/one-var.html) jscs: [`disallowMultipleVarDecl`](http://jscs.info/rule/disallowMultipleVarDecl) > Why? It’s easier to add new variable declarations this way, and you never have to worry about swapping out a `;` for a `,` or introducing punctuation-only diffs. You can also step through each declaration with the debugger, instead of jumping through all of them at once. @@ -1666,7 +1666,7 @@ Other Style Guides ``` - - [13.6](#variables--unary-increment-decrement) Avoid using unary increments and decrements (++, --). eslint [`no-plusplus`](http://eslint.org/docs/rules/no-plusplus) + - [13.6](#variables--unary-increment-decrement) Avoid using unary increments and decrements (++, --). eslint [`no-plusplus`](https://eslint.org/docs/rules/no-plusplus) > Why? Per the eslint documentation, unary increment and decrement statements are subject to automatic semicolon insertion and can cause silent errors with incrementing or decrementing values within an application. It is also more expressive to mutate your values with statements like `num += 1` instead of `num++` or `num ++`. Disallowing unary increment and decrement statements also prevents you from pre-incrementing/pre-decrementing values unintentionally which can also cause unexpected behavior in your programs. @@ -1803,7 +1803,7 @@ Other Style Guides ## Comparison Operators & Equality - - [15.1](#comparison--eqeqeq) Use `===` and `!==` over `==` and `!=`. eslint: [`eqeqeq`](http://eslint.org/docs/rules/eqeqeq.html) + - [15.1](#comparison--eqeqeq) Use `===` and `!==` over `==` and `!=`. eslint: [`eqeqeq`](https://eslint.org/docs/rules/eqeqeq.html) - [15.2](#comparison--if) Conditional statements such as the `if` statement evaluate their expression using coercion with the `ToBoolean` abstract method and always follow these simple rules: @@ -1861,7 +1861,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: [`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`](https://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. @@ -1909,7 +1909,7 @@ Other Style Guides ``` - - [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) + - [15.6](#comparison--nested-ternaries) Ternaries should not be nested and generally be single line expressions. eslint: [`no-nested-ternary`](https://eslint.org/docs/rules/no-nested-ternary.html) ```javascript // bad @@ -1930,7 +1930,7 @@ Other Style Guides ``` - - [15.7](#comparison--unneeded-ternary) Avoid unneeded ternary statements. eslint: [`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`](https://eslint.org/docs/rules/no-unneeded-ternary.html) ```javascript // bad @@ -1945,7 +1945,7 @@ Other Style Guides ``` - - [15.8](#comparison--no-mixed-operators) Enclose operators in parentheses when they are mixed in a statement. When mixing arithmetic operators, do not mix `**` and `%` with themselves or with `+`, `-`, `*`, & `/`. eslint: [`no-mixed-operators`](http://eslint.org/docs/rules/no-mixed-operators.html) + - [15.8](#comparison--no-mixed-operators) Enclose operators in parentheses when they are mixed in a statement. When mixing arithmetic operators, do not mix `**` and `%` with themselves or with `+`, `-`, `*`, & `/`. eslint: [`no-mixed-operators`](https://eslint.org/docs/rules/no-mixed-operators.html) > Why? This improves readability and clarifies the developer’s intention. @@ -2006,7 +2006,7 @@ Other Style Guides ``` - - [16.2](#blocks--cuddled-elses) If you're using multi-line blocks with `if` and `else`, put `else` on the same line as your `if` block’s closing brace. eslint: [`brace-style`](http://eslint.org/docs/rules/brace-style.html) jscs: [`disallowNewlineBeforeBlockStatements`](http://jscs.info/rule/disallowNewlineBeforeBlockStatements) + - [16.2](#blocks--cuddled-elses) If you're using multi-line blocks with `if` and `else`, put `else` on the same line as your `if` block’s closing brace. eslint: [`brace-style`](https://eslint.org/docs/rules/brace-style.html) jscs: [`disallowNewlineBeforeBlockStatements`](http://jscs.info/rule/disallowNewlineBeforeBlockStatements) ```javascript // bad @@ -2224,7 +2224,7 @@ Other Style Guides ``` - - [18.3](#comments--spaces) Start all comments with a space to make it easier to read. eslint: [`spaced-comment`](http://eslint.org/docs/rules/spaced-comment) + - [18.3](#comments--spaces) Start all comments with a space to make it easier to read. eslint: [`spaced-comment`](https://eslint.org/docs/rules/spaced-comment) ```javascript // bad @@ -2296,7 +2296,7 @@ Other Style Guides ## Whitespace - - [19.1](#whitespace--spaces) Use soft tabs (space character) set to 2 spaces. eslint: [`indent`](http://eslint.org/docs/rules/indent.html) jscs: [`validateIndentation`](http://jscs.info/rule/validateIndentation) + - [19.1](#whitespace--spaces) Use soft tabs (space character) set to 2 spaces. eslint: [`indent`](https://eslint.org/docs/rules/indent.html) jscs: [`validateIndentation`](http://jscs.info/rule/validateIndentation) ```javascript // bad @@ -2316,7 +2316,7 @@ Other Style Guides ``` - - [19.2](#whitespace--before-blocks) Place 1 space before the leading brace. eslint: [`space-before-blocks`](http://eslint.org/docs/rules/space-before-blocks.html) jscs: [`requireSpaceBeforeBlockStatements`](http://jscs.info/rule/requireSpaceBeforeBlockStatements) + - [19.2](#whitespace--before-blocks) Place 1 space before the leading brace. eslint: [`space-before-blocks`](https://eslint.org/docs/rules/space-before-blocks.html) jscs: [`requireSpaceBeforeBlockStatements`](http://jscs.info/rule/requireSpaceBeforeBlockStatements) ```javascript // bad @@ -2343,7 +2343,7 @@ Other Style Guides ``` - - [19.3](#whitespace--around-keywords) Place 1 space before the opening parenthesis in control statements (`if`, `while` etc.). Place no space between the argument list and the function name in function calls and declarations. eslint: [`keyword-spacing`](http://eslint.org/docs/rules/keyword-spacing.html) jscs: [`requireSpaceAfterKeywords`](http://jscs.info/rule/requireSpaceAfterKeywords) + - [19.3](#whitespace--around-keywords) Place 1 space before the opening parenthesis in control statements (`if`, `while` etc.). Place no space between the argument list and the function name in function calls and declarations. eslint: [`keyword-spacing`](https://eslint.org/docs/rules/keyword-spacing.html) jscs: [`requireSpaceAfterKeywords`](http://jscs.info/rule/requireSpaceAfterKeywords) ```javascript // bad @@ -2368,7 +2368,7 @@ Other Style Guides ``` - - [19.4](#whitespace--infix-ops) Set off operators with spaces. eslint: [`space-infix-ops`](http://eslint.org/docs/rules/space-infix-ops.html) jscs: [`requireSpaceBeforeBinaryOperators`](http://jscs.info/rule/requireSpaceBeforeBinaryOperators), [`requireSpaceAfterBinaryOperators`](http://jscs.info/rule/requireSpaceAfterBinaryOperators) + - [19.4](#whitespace--infix-ops) Set off operators with spaces. eslint: [`space-infix-ops`](https://eslint.org/docs/rules/space-infix-ops.html) jscs: [`requireSpaceBeforeBinaryOperators`](http://jscs.info/rule/requireSpaceBeforeBinaryOperators), [`requireSpaceAfterBinaryOperators`](http://jscs.info/rule/requireSpaceAfterBinaryOperators) ```javascript // bad @@ -2405,7 +2405,7 @@ Other Style Guides - [19.6](#whitespace--chains) Use indentation when making long method chains (more than 2 method chains). Use a leading dot, which - emphasizes that the line is a method call, not a new statement. eslint: [`newline-per-chained-call`](http://eslint.org/docs/rules/newline-per-chained-call) [`no-whitespace-before-property`](http://eslint.org/docs/rules/no-whitespace-before-property) + emphasizes that the line is a method call, not a new statement. eslint: [`newline-per-chained-call`](https://eslint.org/docs/rules/newline-per-chained-call) [`no-whitespace-before-property`](https://eslint.org/docs/rules/no-whitespace-before-property) ```javascript // bad @@ -2506,7 +2506,7 @@ Other Style Guides ``` - - [19.8](#whitespace--padded-blocks) Do not pad your blocks with blank lines. eslint: [`padded-blocks`](http://eslint.org/docs/rules/padded-blocks.html) jscs: [`disallowPaddingNewlinesInBlocks`](http://jscs.info/rule/disallowPaddingNewlinesInBlocks) + - [19.8](#whitespace--padded-blocks) Do not pad your blocks with blank lines. eslint: [`padded-blocks`](https://eslint.org/docs/rules/padded-blocks.html) jscs: [`disallowPaddingNewlinesInBlocks`](http://jscs.info/rule/disallowPaddingNewlinesInBlocks) ```javascript // bad @@ -2547,7 +2547,7 @@ Other Style Guides ``` - - [19.9](#whitespace--in-parens) Do not add spaces inside parentheses. eslint: [`space-in-parens`](http://eslint.org/docs/rules/space-in-parens.html) jscs: [`disallowSpacesInsideParentheses`](http://jscs.info/rule/disallowSpacesInsideParentheses) + - [19.9](#whitespace--in-parens) Do not add spaces inside parentheses. eslint: [`space-in-parens`](https://eslint.org/docs/rules/space-in-parens.html) jscs: [`disallowSpacesInsideParentheses`](http://jscs.info/rule/disallowSpacesInsideParentheses) ```javascript // bad @@ -2572,7 +2572,7 @@ Other Style Guides ``` - - [19.10](#whitespace--in-brackets) Do not add spaces inside brackets. eslint: [`array-bracket-spacing`](http://eslint.org/docs/rules/array-bracket-spacing.html) jscs: [`disallowSpacesInsideArrayBrackets`](http://jscs.info/rule/disallowSpacesInsideArrayBrackets) + - [19.10](#whitespace--in-brackets) Do not add spaces inside brackets. eslint: [`array-bracket-spacing`](https://eslint.org/docs/rules/array-bracket-spacing.html) jscs: [`disallowSpacesInsideArrayBrackets`](http://jscs.info/rule/disallowSpacesInsideArrayBrackets) ```javascript // bad @@ -2585,7 +2585,7 @@ Other Style Guides ``` - - [19.11](#whitespace--in-braces) Add spaces inside curly braces. eslint: [`object-curly-spacing`](http://eslint.org/docs/rules/object-curly-spacing.html) jscs: [`requireSpacesInsideObjectBrackets`](http://jscs.info/rule/requireSpacesInsideObjectBrackets) + - [19.11](#whitespace--in-braces) Add spaces inside curly braces. eslint: [`object-curly-spacing`](https://eslint.org/docs/rules/object-curly-spacing.html) jscs: [`requireSpacesInsideObjectBrackets`](http://jscs.info/rule/requireSpacesInsideObjectBrackets) ```javascript // bad @@ -2596,7 +2596,7 @@ Other Style Guides ``` - - [19.12](#whitespace--max-len) Avoid having lines of code that are longer than 100 characters (including whitespace). Note: per [above](#strings--line-length), long strings are exempt from this rule, and should not be broken up. eslint: [`max-len`](http://eslint.org/docs/rules/max-len.html) jscs: [`maximumLineLength`](http://jscs.info/rule/maximumLineLength) + - [19.12](#whitespace--max-len) Avoid having lines of code that are longer than 100 characters (including whitespace). Note: per [above](#strings--line-length), long strings are exempt from this rule, and should not be broken up. eslint: [`max-len`](https://eslint.org/docs/rules/max-len.html) jscs: [`maximumLineLength`](http://jscs.info/rule/maximumLineLength) > Why? This ensures readability and maintainability. @@ -2630,7 +2630,7 @@ Other Style Guides ## Commas - - [20.1](#commas--leading-trailing) Leading commas: **Nope.** eslint: [`comma-style`](http://eslint.org/docs/rules/comma-style.html) jscs: [`requireCommaBeforeLineBreak`](http://jscs.info/rule/requireCommaBeforeLineBreak) + - [20.1](#commas--leading-trailing) Leading commas: **Nope.** eslint: [`comma-style`](https://eslint.org/docs/rules/comma-style.html) jscs: [`requireCommaBeforeLineBreak`](http://jscs.info/rule/requireCommaBeforeLineBreak) ```javascript // bad @@ -2665,7 +2665,7 @@ Other Style Guides ``` - - [20.2](#commas--dangling) Additional trailing comma: **Yup.** eslint: [`comma-dangle`](http://eslint.org/docs/rules/comma-dangle.html) jscs: [`requireTrailingComma`](http://jscs.info/rule/requireTrailingComma) + - [20.2](#commas--dangling) Additional trailing comma: **Yup.** eslint: [`comma-dangle`](https://eslint.org/docs/rules/comma-dangle.html) jscs: [`requireTrailingComma`](http://jscs.info/rule/requireTrailingComma) > Why? This leads to cleaner git diffs. Also, transpilers like Babel will remove the additional trailing comma in the transpiled code which means you don’t have to worry about the [trailing comma problem](https://github.com/airbnb/javascript/blob/es5-deprecated/es5/README.md#commas) in legacy browsers. @@ -2765,7 +2765,7 @@ Other Style Guides ## Semicolons - - [21.1](#semicolons--required) **Yup.** eslint: [`semi`](http://eslint.org/docs/rules/semi.html) jscs: [`requireSemicolons`](http://jscs.info/rule/requireSemicolons) + - [21.1](#semicolons--required) **Yup.** eslint: [`semi`](https://eslint.org/docs/rules/semi.html) jscs: [`requireSemicolons`](http://jscs.info/rule/requireSemicolons) ```javascript // bad @@ -2816,7 +2816,7 @@ Other Style Guides ``` - - [22.3](#coercion--numbers) Numbers: Use `Number` for type casting and `parseInt` always with a radix for parsing strings. eslint: [`radix`](http://eslint.org/docs/rules/radix) [`no-new-wrappers`](https://eslint.org/docs/rules/no-new-wrappers) + - [22.3](#coercion--numbers) Numbers: Use `Number` for type casting and `parseInt` always with a radix for parsing strings. eslint: [`radix`](https://eslint.org/docs/rules/radix) [`no-new-wrappers`](https://eslint.org/docs/rules/no-new-wrappers) ```javascript const inputValue = '4'; @@ -2883,7 +2883,7 @@ Other Style Guides ## Naming Conventions - - [23.1](#naming--descriptive) Avoid single letter names. Be descriptive with your naming. eslint: [`id-length`](http://eslint.org/docs/rules/id-length) + - [23.1](#naming--descriptive) Avoid single letter names. Be descriptive with your naming. eslint: [`id-length`](https://eslint.org/docs/rules/id-length) ```javascript // bad @@ -2898,7 +2898,7 @@ Other Style Guides ``` - - [23.2](#naming--camelCase) Use camelCase when naming objects, functions, and instances. eslint: [`camelcase`](http://eslint.org/docs/rules/camelcase.html) jscs: [`requireCamelCaseOrUpperCaseIdentifiers`](http://jscs.info/rule/requireCamelCaseOrUpperCaseIdentifiers) + - [23.2](#naming--camelCase) Use camelCase when naming objects, functions, and instances. eslint: [`camelcase`](https://eslint.org/docs/rules/camelcase.html) jscs: [`requireCamelCaseOrUpperCaseIdentifiers`](http://jscs.info/rule/requireCamelCaseOrUpperCaseIdentifiers) ```javascript // bad @@ -2912,7 +2912,7 @@ Other Style Guides ``` - - [23.3](#naming--PascalCase) Use PascalCase only when naming constructors or classes. eslint: [`new-cap`](http://eslint.org/docs/rules/new-cap.html) jscs: [`requireCapitalizedConstructors`](http://jscs.info/rule/requireCapitalizedConstructors) + - [23.3](#naming--PascalCase) Use PascalCase only when naming constructors or classes. eslint: [`new-cap`](https://eslint.org/docs/rules/new-cap.html) jscs: [`requireCapitalizedConstructors`](http://jscs.info/rule/requireCapitalizedConstructors) ```javascript // bad @@ -2937,7 +2937,7 @@ Other Style Guides ``` - - [23.4](#naming--leading-underscore) Do not use trailing or leading underscores. eslint: [`no-underscore-dangle`](http://eslint.org/docs/rules/no-underscore-dangle.html) jscs: [`disallowDanglingUnderscores`](http://jscs.info/rule/disallowDanglingUnderscores) + - [23.4](#naming--leading-underscore) Do not use trailing or leading underscores. eslint: [`no-underscore-dangle`](https://eslint.org/docs/rules/no-underscore-dangle.html) jscs: [`disallowDanglingUnderscores`](http://jscs.info/rule/disallowDanglingUnderscores) > Why? JavaScript does not have the concept of privacy in terms of properties or methods. Although a leading underscore is a common convention to mean “private”, in fact, these properties are fully public, and as such, are part of your public API contract. This convention might lead developers to wrongly think that a change won’t count as breaking, or that tests aren’t needed. tl;dr: if you want something to be “private”, it must not be observably present. @@ -3287,7 +3287,7 @@ Other Style Guides - [29.1](#standard-library--isnan) Use `Number.isNaN` instead of global `isNaN`. - eslint: [`no-restricted-globals`](http://eslint.org/docs/rules/no-restricted-globals) + eslint: [`no-restricted-globals`](https://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. @@ -3304,7 +3304,7 @@ Other Style Guides - [29.2](#standard-library--isfinite) Use `Number.isFinite` instead of global `isFinite`. - eslint: [`no-restricted-globals`](http://eslint.org/docs/rules/no-restricted-globals) + eslint: [`no-restricted-globals`](https://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. @@ -3372,7 +3372,7 @@ Other Style Guides **Tools** - Code Style Linters - - [ESlint](http://eslint.org/) - [Airbnb Style .eslintrc](https://github.com/airbnb/javascript/blob/master/linters/.eslintrc) + - [ESlint](https://eslint.org/) - [Airbnb Style .eslintrc](https://github.com/airbnb/javascript/blob/master/linters/.eslintrc) - [JSHint](http://jshint.com/) - [Airbnb Style .jshintrc](https://github.com/airbnb/javascript/blob/master/linters/.jshintrc) - [JSCS](https://github.com/jscs-dev/node-jscs) - [Airbnb Style Preset](https://github.com/jscs-dev/node-jscs/blob/master/presets/airbnb.json) (Deprecated, please use [ESlint](https://github.com/airbnb/javascript/tree/master/packages/eslint-config-airbnb-base)) - Neutrino preset - [neutrino-preset-airbnb-base](https://neutrino.js.org/presets/neutrino-preset-airbnb-base/) diff --git a/packages/eslint-config-airbnb-base/README.md b/packages/eslint-config-airbnb-base/README.md index 881b86b2db..a28a40a302 100644 --- a/packages/eslint-config-airbnb-base/README.md +++ b/packages/eslint-config-airbnb-base/README.md @@ -75,7 +75,7 @@ Lints ES5 and below. Requires `eslint` and `eslint-plugin-import`. 2. Add `"extends": "airbnb-base/legacy"` to your .eslintrc -See [Airbnb's overarching ESLint config](https://npmjs.com/eslint-config-airbnb), [Airbnb's Javascript styleguide](https://github.com/airbnb/javascript), and the [ESlint config docs](http://eslint.org/docs/user-guide/configuring#extending-configuration-files) for more information. +See [Airbnb's overarching ESLint config](https://npmjs.com/eslint-config-airbnb), [Airbnb's Javascript styleguide](https://github.com/airbnb/javascript), and the [ESlint config docs](https://eslint.org/docs/user-guide/configuring#extending-configuration-files) for more information. ## Improving this config diff --git a/packages/eslint-config-airbnb-base/rules/best-practices.js b/packages/eslint-config-airbnb-base/rules/best-practices.js index 559338074a..3fd0ff105d 100644 --- a/packages/eslint-config-airbnb-base/rules/best-practices.js +++ b/packages/eslint-config-airbnb-base/rules/best-practices.js @@ -4,7 +4,7 @@ module.exports = { 'accessor-pairs': 'off', // enforces return statements in callbacks of array's methods - // http://eslint.org/docs/rules/array-callback-return + // https://eslint.org/docs/rules/array-callback-return 'array-callback-return': 'error', // treat var statements as if they were block scoped @@ -14,7 +14,7 @@ module.exports = { complexity: ['off', 11], // enforce that class methods use "this" - // http://eslint.org/docs/rules/class-methods-use-this + // https://eslint.org/docs/rules/class-methods-use-this 'class-methods-use-this': ['error', { exceptMethods: [], }], @@ -32,11 +32,11 @@ module.exports = { 'dot-notation': ['error', { allowKeywords: true }], // enforces consistent newlines before or after dots - // http://eslint.org/docs/rules/dot-location + // https://eslint.org/docs/rules/dot-location 'dot-location': ['error', 'property'], // require the use of === and !== - // http://eslint.org/docs/rules/eqeqeq + // https://eslint.org/docs/rules/eqeqeq eqeqeq: ['error', 'always', { null: 'ignore' }], // make sure for-in loops have an if statement @@ -49,11 +49,11 @@ module.exports = { 'no-caller': 'error', // disallow lexical declarations in case/default clauses - // http://eslint.org/docs/rules/no-case-declarations.html + // https://eslint.org/docs/rules/no-case-declarations.html 'no-case-declarations': 'error', // disallow division operators explicitly at beginning of regular expression - // http://eslint.org/docs/rules/no-div-regex + // https://eslint.org/docs/rules/no-div-regex 'no-div-regex': 'off', // disallow else after a return in an if @@ -61,7 +61,7 @@ module.exports = { 'no-else-return': ['error', { allowElseIf: false }], // disallow empty functions, except for standalone funcs/arrows - // http://eslint.org/docs/rules/no-empty-function + // https://eslint.org/docs/rules/no-empty-function 'no-empty-function': ['error', { allow: [ 'arrowFunctions', @@ -71,7 +71,7 @@ module.exports = { }], // disallow empty destructuring patterns - // http://eslint.org/docs/rules/no-empty-pattern + // https://eslint.org/docs/rules/no-empty-pattern 'no-empty-pattern': 'error', // disallow comparisons to null without a type-checking operator @@ -87,7 +87,7 @@ module.exports = { 'no-extra-bind': 'error', // disallow Unnecessary Labels - // http://eslint.org/docs/rules/no-extra-label + // https://eslint.org/docs/rules/no-extra-label 'no-extra-label': 'error', // disallow fallthrough of case statements @@ -97,13 +97,13 @@ module.exports = { 'no-floating-decimal': 'error', // disallow reassignments of native objects or read-only globals - // http://eslint.org/docs/rules/no-global-assign + // https://eslint.org/docs/rules/no-global-assign 'no-global-assign': ['error', { exceptions: [] }], // deprecated in favor of no-global-assign 'no-native-reassign': 'off', // disallow implicit type conversions - // http://eslint.org/docs/rules/no-implicit-coercion + // https://eslint.org/docs/rules/no-implicit-coercion 'no-implicit-coercion': ['off', { boolean: false, number: true, @@ -112,7 +112,7 @@ module.exports = { }], // disallow var and named functions in global scope - // http://eslint.org/docs/rules/no-implicit-globals + // https://eslint.org/docs/rules/no-implicit-globals 'no-implicit-globals': 'off', // disallow use of eval()-like methods @@ -134,7 +134,7 @@ module.exports = { 'no-loop-func': 'error', // disallow magic numbers - // http://eslint.org/docs/rules/no-magic-numbers + // https://eslint.org/docs/rules/no-magic-numbers 'no-magic-numbers': ['off', { ignore: [], ignoreArrayIndexes: true, @@ -168,7 +168,7 @@ module.exports = { // disallow reassignment of function parameters // disallow parameter object manipulation except for specific exclusions - // rule: http://eslint.org/docs/rules/no-param-reassign.html + // rule: https://eslint.org/docs/rules/no-param-reassign.html 'no-param-reassign': ['error', { props: true, ignorePropertyModificationsFor: [ @@ -190,7 +190,7 @@ module.exports = { 'no-redeclare': 'error', // disallow certain object properties - // http://eslint.org/docs/rules/no-restricted-properties + // https://eslint.org/docs/rules/no-restricted-properties 'no-restricted-properties': ['error', { object: 'arguments', property: 'callee', @@ -241,7 +241,7 @@ module.exports = { 'no-script-url': 'error', // disallow self assignment - // http://eslint.org/docs/rules/no-self-assign + // https://eslint.org/docs/rules/no-self-assign 'no-self-assign': 'error', // disallow comparisons where both sides are exactly the same @@ -254,7 +254,7 @@ module.exports = { 'no-throw-literal': 'error', // disallow unmodified conditions of loops - // http://eslint.org/docs/rules/no-unmodified-loop-condition + // https://eslint.org/docs/rules/no-unmodified-loop-condition 'no-unmodified-loop-condition': 'off', // disallow usage of expressions in statement position @@ -265,26 +265,26 @@ module.exports = { }], // disallow unused labels - // http://eslint.org/docs/rules/no-unused-labels + // https://eslint.org/docs/rules/no-unused-labels 'no-unused-labels': 'error', // disallow unnecessary .call() and .apply() 'no-useless-call': 'off', // disallow useless string concatenation - // http://eslint.org/docs/rules/no-useless-concat + // https://eslint.org/docs/rules/no-useless-concat 'no-useless-concat': 'error', // disallow unnecessary string escaping - // http://eslint.org/docs/rules/no-useless-escape + // https://eslint.org/docs/rules/no-useless-escape 'no-useless-escape': 'error', // disallow redundant return; keywords - // http://eslint.org/docs/rules/no-useless-return + // https://eslint.org/docs/rules/no-useless-return 'no-useless-return': 'error', // disallow use of void operator - // http://eslint.org/docs/rules/no-void + // https://eslint.org/docs/rules/no-void 'no-void': 'error', // disallow usage of configurable warning terms in comments: e.g. todo @@ -294,21 +294,21 @@ module.exports = { 'no-with': 'error', // require using Error objects as Promise rejection reasons - // http://eslint.org/docs/rules/prefer-promise-reject-errors + // https://eslint.org/docs/rules/prefer-promise-reject-errors 'prefer-promise-reject-errors': ['error', { allowEmptyReject: true }], // require use of the second argument for parseInt() radix: 'error', // require `await` in `async function` (note: this is a horrible rule that should never be used) - // http://eslint.org/docs/rules/require-await + // https://eslint.org/docs/rules/require-await 'require-await': 'off', // requires to declare all vars on top of their containing scope 'vars-on-top': 'error', // require immediate function invocation to be wrapped in parentheses - // http://eslint.org/docs/rules/wrap-iife.html + // https://eslint.org/docs/rules/wrap-iife.html 'wrap-iife': ['error', 'outside', { functionPrototypeMethods: false }], // require or disallow Yoda conditions diff --git a/packages/eslint-config-airbnb-base/rules/errors.js b/packages/eslint-config-airbnb-base/rules/errors.js index 19b815a09b..8cae2b525e 100644 --- a/packages/eslint-config-airbnb-base/rules/errors.js +++ b/packages/eslint-config-airbnb-base/rules/errors.js @@ -1,19 +1,19 @@ module.exports = { rules: { // Enforce “for” loop update clause moving the counter in the right direction - // http://eslint.org/docs/rules/for-direction + // https://eslint.org/docs/rules/for-direction 'for-direction': 'error', // Enforces that a return statement is present in property getters - // http://eslint.org/docs/rules/getter-return + // https://eslint.org/docs/rules/getter-return 'getter-return': ['error', { allowImplicit: true }], // Disallow await inside of loops - // http://eslint.org/docs/rules/no-await-in-loop + // https://eslint.org/docs/rules/no-await-in-loop 'no-await-in-loop': 'error', // Disallow comparisons to negative zero - // http://eslint.org/docs/rules/no-compare-neg-zero + // https://eslint.org/docs/rules/no-compare-neg-zero 'no-compare-neg-zero': 'error', // disallow assignment in conditional expressions @@ -50,11 +50,11 @@ module.exports = { 'no-ex-assign': 'error', // disallow double-negation boolean casts in a boolean context - // http://eslint.org/docs/rules/no-extra-boolean-cast + // https://eslint.org/docs/rules/no-extra-boolean-cast 'no-extra-boolean-cast': 'error', // disallow unnecessary parentheses - // http://eslint.org/docs/rules/no-extra-parens + // https://eslint.org/docs/rules/no-extra-parens 'no-extra-parens': ['off', 'all', { conditionalAssign: true, nestedBinaryExpressions: false, @@ -82,7 +82,7 @@ module.exports = { 'no-obj-calls': 'error', // disallow use of Object.prototypes builtins directly - // http://eslint.org/docs/rules/no-prototype-builtins + // https://eslint.org/docs/rules/no-prototype-builtins 'no-prototype-builtins': 'error', // disallow multiple spaces in a regular expression literal @@ -92,22 +92,22 @@ module.exports = { 'no-sparse-arrays': 'error', // Disallow template literal placeholder syntax in regular strings - // http://eslint.org/docs/rules/no-template-curly-in-string + // https://eslint.org/docs/rules/no-template-curly-in-string 'no-template-curly-in-string': 'error', // Avoid code that looks like two expressions but is actually one - // http://eslint.org/docs/rules/no-unexpected-multiline + // https://eslint.org/docs/rules/no-unexpected-multiline 'no-unexpected-multiline': 'error', // disallow unreachable statements after a return, throw, continue, or break statement 'no-unreachable': 'error', // disallow return/throw/break/continue inside finally blocks - // http://eslint.org/docs/rules/no-unsafe-finally + // https://eslint.org/docs/rules/no-unsafe-finally 'no-unsafe-finally': 'error', // disallow negating the left operand of relational operators - // http://eslint.org/docs/rules/no-unsafe-negation + // https://eslint.org/docs/rules/no-unsafe-negation 'no-unsafe-negation': 'error', // disallow negation of the left operand of an in expression // deprecated in favor of no-unsafe-negation @@ -117,11 +117,11 @@ module.exports = { 'use-isnan': 'error', // ensure JSDoc comments are valid - // http://eslint.org/docs/rules/valid-jsdoc + // https://eslint.org/docs/rules/valid-jsdoc 'valid-jsdoc': 'off', // ensure that the results of typeof are compared against a valid string - // http://eslint.org/docs/rules/valid-typeof + // https://eslint.org/docs/rules/valid-typeof 'valid-typeof': ['error', { requireStringLiterals: true }], } }; diff --git a/packages/eslint-config-airbnb-base/rules/es6.js b/packages/eslint-config-airbnb-base/rules/es6.js index f53814d1e7..cf81d198d9 100644 --- a/packages/eslint-config-airbnb-base/rules/es6.js +++ b/packages/eslint-config-airbnb-base/rules/es6.js @@ -13,35 +13,35 @@ module.exports = { rules: { // enforces no braces where they can be omitted - // http://eslint.org/docs/rules/arrow-body-style + // https://eslint.org/docs/rules/arrow-body-style // TODO: enable requireReturnForObjectLiteral? 'arrow-body-style': ['error', 'as-needed', { requireReturnForObjectLiteral: false, }], // require parens in arrow function arguments - // http://eslint.org/docs/rules/arrow-parens + // https://eslint.org/docs/rules/arrow-parens 'arrow-parens': ['error', 'as-needed', { requireForBlockBody: true, }], // require space before/after arrow function's arrow - // http://eslint.org/docs/rules/arrow-spacing + // https://eslint.org/docs/rules/arrow-spacing 'arrow-spacing': ['error', { before: true, after: true }], // verify super() callings in constructors 'constructor-super': 'error', // enforce the spacing around the * in generator functions - // http://eslint.org/docs/rules/generator-star-spacing + // https://eslint.org/docs/rules/generator-star-spacing 'generator-star-spacing': ['error', { before: false, after: true }], // disallow modifying variables of class declarations - // http://eslint.org/docs/rules/no-class-assign + // https://eslint.org/docs/rules/no-class-assign 'no-class-assign': 'error', // disallow arrow functions where they could be confused with comparisons - // http://eslint.org/docs/rules/no-confusing-arrow + // https://eslint.org/docs/rules/no-confusing-arrow 'no-confusing-arrow': ['error', { allowParens: true, }], @@ -50,36 +50,36 @@ module.exports = { 'no-const-assign': 'error', // disallow duplicate class members - // http://eslint.org/docs/rules/no-dupe-class-members + // https://eslint.org/docs/rules/no-dupe-class-members 'no-dupe-class-members': 'error', // disallow importing from the same path more than once - // http://eslint.org/docs/rules/no-duplicate-imports + // https://eslint.org/docs/rules/no-duplicate-imports // replaced by https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/no-duplicates.md 'no-duplicate-imports': 'off', // disallow symbol constructor - // http://eslint.org/docs/rules/no-new-symbol + // https://eslint.org/docs/rules/no-new-symbol 'no-new-symbol': 'error', // disallow specific imports - // http://eslint.org/docs/rules/no-restricted-imports + // https://eslint.org/docs/rules/no-restricted-imports 'no-restricted-imports': 'off', // disallow to use this/super before super() calling in constructors. - // http://eslint.org/docs/rules/no-this-before-super + // https://eslint.org/docs/rules/no-this-before-super 'no-this-before-super': 'error', // disallow useless computed property keys - // http://eslint.org/docs/rules/no-useless-computed-key + // https://eslint.org/docs/rules/no-useless-computed-key 'no-useless-computed-key': 'error', // disallow unnecessary constructor - // http://eslint.org/docs/rules/no-useless-constructor + // https://eslint.org/docs/rules/no-useless-constructor 'no-useless-constructor': 'error', // disallow renaming import, export, and destructured assignments to the same name - // http://eslint.org/docs/rules/no-useless-rename + // https://eslint.org/docs/rules/no-useless-rename 'no-useless-rename': ['error', { ignoreDestructuring: false, ignoreImport: false, @@ -90,7 +90,7 @@ module.exports = { 'no-var': 'error', // require method and property shorthand syntax for object literals - // http://eslint.org/docs/rules/object-shorthand + // https://eslint.org/docs/rules/object-shorthand 'object-shorthand': ['error', 'always', { ignoreConstructors: false, avoidQuotes: true, @@ -109,7 +109,7 @@ module.exports = { }], // Prefer destructuring from arrays and objects - // http://eslint.org/docs/rules/prefer-destructuring + // https://eslint.org/docs/rules/prefer-destructuring 'prefer-destructuring': ['error', { VariableDeclarator: { array: false, @@ -124,35 +124,35 @@ module.exports = { }], // disallow parseInt() in favor of binary, octal, and hexadecimal literals - // http://eslint.org/docs/rules/prefer-numeric-literals + // https://eslint.org/docs/rules/prefer-numeric-literals 'prefer-numeric-literals': 'error', // suggest using Reflect methods where applicable - // http://eslint.org/docs/rules/prefer-reflect + // https://eslint.org/docs/rules/prefer-reflect 'prefer-reflect': 'off', // use rest parameters instead of arguments - // http://eslint.org/docs/rules/prefer-rest-params + // https://eslint.org/docs/rules/prefer-rest-params 'prefer-rest-params': 'error', // suggest using the spread operator instead of .apply() - // http://eslint.org/docs/rules/prefer-spread + // https://eslint.org/docs/rules/prefer-spread 'prefer-spread': 'error', // suggest using template literals instead of string concatenation - // http://eslint.org/docs/rules/prefer-template + // https://eslint.org/docs/rules/prefer-template 'prefer-template': 'error', // disallow generator functions that do not have yield - // http://eslint.org/docs/rules/require-yield + // https://eslint.org/docs/rules/require-yield 'require-yield': 'error', // enforce spacing between object rest-spread - // http://eslint.org/docs/rules/rest-spread-spacing + // https://eslint.org/docs/rules/rest-spread-spacing 'rest-spread-spacing': ['error', 'never'], // import sorting - // http://eslint.org/docs/rules/sort-imports + // https://eslint.org/docs/rules/sort-imports 'sort-imports': ['off', { ignoreCase: false, ignoreMemberSort: false, @@ -160,15 +160,15 @@ module.exports = { }], // require a Symbol description - // http://eslint.org/docs/rules/symbol-description + // https://eslint.org/docs/rules/symbol-description 'symbol-description': 'error', // enforce usage of spacing in template strings - // http://eslint.org/docs/rules/template-curly-spacing + // https://eslint.org/docs/rules/template-curly-spacing 'template-curly-spacing': 'error', // enforce spacing around the * in yield* expressions - // http://eslint.org/docs/rules/yield-star-spacing + // https://eslint.org/docs/rules/yield-star-spacing 'yield-star-spacing': ['error', 'after'] } }; diff --git a/packages/eslint-config-airbnb-base/rules/node.js b/packages/eslint-config-airbnb-base/rules/node.js index 9413b5483a..b178d7f909 100644 --- a/packages/eslint-config-airbnb-base/rules/node.js +++ b/packages/eslint-config-airbnb-base/rules/node.js @@ -8,14 +8,14 @@ module.exports = { 'callback-return': 'off', // require all requires be top-level - // http://eslint.org/docs/rules/global-require + // https://eslint.org/docs/rules/global-require 'global-require': 'error', // 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 + // https://eslint.org/docs/rules/no-buffer-constructor 'no-buffer-constructor': 'error', // disallow mixing regular variable and require declarations @@ -25,7 +25,7 @@ module.exports = { 'no-new-require': 'error', // disallow string concatenation with __dirname and __filename - // http://eslint.org/docs/rules/no-path-concat + // https://eslint.org/docs/rules/no-path-concat 'no-path-concat': 'error', // disallow use of process.env diff --git a/packages/eslint-config-airbnb-base/rules/style.js b/packages/eslint-config-airbnb-base/rules/style.js index e358e2a417..26b9f784d0 100644 --- a/packages/eslint-config-airbnb-base/rules/style.js +++ b/packages/eslint-config-airbnb-base/rules/style.js @@ -1,12 +1,12 @@ module.exports = { rules: { // enforce line breaks after opening and before closing array brackets - // http://eslint.org/docs/rules/array-bracket-newline + // https://eslint.org/docs/rules/array-bracket-newline // TODO: enable? semver-major 'array-bracket-newline': ['off', 'consistent'], // object option alternative: { multiline: true, minItems: 3 } // enforce line breaks between array elements - // http://eslint.org/docs/rules/array-element-newline + // https://eslint.org/docs/rules/array-element-newline // TODO: enable? semver-major 'array-element-newline': ['off', { multiline: true, minItems: 3 }], @@ -14,7 +14,7 @@ module.exports = { 'array-bracket-spacing': ['error', 'never'], // enforce spacing inside single-line blocks - // http://eslint.org/docs/rules/block-spacing + // https://eslint.org/docs/rules/block-spacing 'block-spacing': ['error', 'always'], // enforce one true brace style @@ -24,7 +24,7 @@ module.exports = { camelcase: ['error', { properties: 'never' }], // enforce or disallow capitalization of the first letter of a comment - // http://eslint.org/docs/rules/capitalized-comments + // https://eslint.org/docs/rules/capitalized-comments 'capitalized-comments': ['off', 'never', { line: { ignorePattern: '.*', @@ -63,22 +63,22 @@ module.exports = { 'eol-last': ['error', 'always'], // enforce spacing between functions and their invocations - // http://eslint.org/docs/rules/func-call-spacing + // https://eslint.org/docs/rules/func-call-spacing 'func-call-spacing': ['error', 'never'], // requires function names to match the name of the variable or property to which they are // assigned - // http://eslint.org/docs/rules/func-name-matching + // https://eslint.org/docs/rules/func-name-matching 'func-name-matching': ['off', 'always', { includeCommonJSModuleExports: false }], // require function expressions to have a name - // http://eslint.org/docs/rules/func-names + // https://eslint.org/docs/rules/func-names 'func-names': 'warn', // enforces use of function declarations or expressions - // http://eslint.org/docs/rules/func-style + // https://eslint.org/docs/rules/func-style // TODO: enable 'func-style': ['off', 'expression'], @@ -87,7 +87,7 @@ module.exports = { 'function-paren-newline': ['error', 'multiline'], // Blacklist certain identifiers to prevent them being used - // http://eslint.org/docs/rules/id-blacklist + // https://eslint.org/docs/rules/id-blacklist 'id-blacklist': 'off', // this option enforces minimum and maximum identifier lengths @@ -98,7 +98,7 @@ module.exports = { 'id-match': 'off', // this option sets a specific tab width for your code - // http://eslint.org/docs/rules/indent + // https://eslint.org/docs/rules/indent indent: ['error', 2, { SwitchCase: 1, VariableDeclarator: 1, @@ -123,7 +123,7 @@ module.exports = { }], // specify whether double or single quotes should be used in JSX attributes - // http://eslint.org/docs/rules/jsx-quotes + // https://eslint.org/docs/rules/jsx-quotes 'jsx-quotes': ['off', 'prefer-double'], // enforces spacing between keys and values in object literal properties @@ -141,7 +141,7 @@ module.exports = { }], // enforce position of line comments - // http://eslint.org/docs/rules/line-comment-position + // https://eslint.org/docs/rules/line-comment-position // TODO: enable? 'line-comment-position': ['off', { position: 'above', @@ -150,7 +150,7 @@ module.exports = { }], // disallow mixed 'LF' and 'CRLF' as linebreaks - // http://eslint.org/docs/rules/linebreak-style + // https://eslint.org/docs/rules/linebreak-style 'linebreak-style': ['error', 'unix'], // require or disallow an empty line between class members @@ -161,7 +161,7 @@ module.exports = { 'lines-around-comment': 'off', // require or disallow newlines around directives - // http://eslint.org/docs/rules/lines-around-directive + // https://eslint.org/docs/rules/lines-around-directive 'lines-around-directive': ['error', { before: 'always', after: 'always', @@ -171,7 +171,7 @@ module.exports = { 'max-depth': ['off', 4], // specify the maximum length of a line in your program - // http://eslint.org/docs/rules/max-len + // https://eslint.org/docs/rules/max-len 'max-len': ['error', 100, 2, { ignoreUrls: true, ignoreComments: false, @@ -181,7 +181,7 @@ module.exports = { }], // specify the max number of lines in a file - // http://eslint.org/docs/rules/max-lines + // https://eslint.org/docs/rules/max-lines 'max-lines': ['off', { max: 300, skipBlankLines: true, @@ -198,7 +198,7 @@ module.exports = { 'max-statements': ['off', 10], // restrict the number of statements per line - // http://eslint.org/docs/rules/max-statements-per-line + // https://eslint.org/docs/rules/max-statements-per-line 'max-statements-per-line': ['off', { max: 1 }], // enforce a particular style for multiline comments @@ -206,7 +206,7 @@ module.exports = { 'multiline-comment-style': ['off', 'starred-block'], // require multiline ternary - // http://eslint.org/docs/rules/multiline-ternary + // https://eslint.org/docs/rules/multiline-ternary // TODO: enable? 'multiline-ternary': ['off', 'never'], @@ -219,40 +219,40 @@ module.exports = { }], // disallow the omission of parentheses when invoking a constructor with no arguments - // http://eslint.org/docs/rules/new-parens + // https://eslint.org/docs/rules/new-parens 'new-parens': 'error', // allow/disallow an empty newline after var statement 'newline-after-var': 'off', - // http://eslint.org/docs/rules/newline-before-return + // https://eslint.org/docs/rules/newline-before-return 'newline-before-return': 'off', // enforces new line after each method call in the chain to make it // more readable and easy to maintain - // http://eslint.org/docs/rules/newline-per-chained-call + // https://eslint.org/docs/rules/newline-per-chained-call 'newline-per-chained-call': ['error', { ignoreChainWithDepth: 4 }], // disallow use of the Array constructor 'no-array-constructor': 'error', // disallow use of bitwise operators - // http://eslint.org/docs/rules/no-bitwise + // https://eslint.org/docs/rules/no-bitwise 'no-bitwise': 'error', // disallow use of the continue statement - // http://eslint.org/docs/rules/no-continue + // https://eslint.org/docs/rules/no-continue 'no-continue': 'error', // disallow comments inline after code 'no-inline-comments': 'off', // disallow if as the only statement in an else block - // http://eslint.org/docs/rules/no-lonely-if + // https://eslint.org/docs/rules/no-lonely-if 'no-lonely-if': 'error', // disallow un-paren'd mixes of different operators - // http://eslint.org/docs/rules/no-mixed-operators + // https://eslint.org/docs/rules/no-mixed-operators 'no-mixed-operators': ['error', { // the list of arthmetic groups disallows mixing `%` and `**` // with other arithmetic operators. @@ -278,14 +278,14 @@ module.exports = { 'no-mixed-spaces-and-tabs': 'error', // disallow use of chained assignment expressions - // http://eslint.org/docs/rules/no-multi-assign + // https://eslint.org/docs/rules/no-multi-assign 'no-multi-assign': ['error'], // disallow multiple empty lines and only one newline at the end 'no-multiple-empty-lines': ['error', { max: 2, maxEOF: 1 }], // disallow negated conditions - // http://eslint.org/docs/rules/no-negated-condition + // https://eslint.org/docs/rules/no-negated-condition 'no-negated-condition': 'off', // disallow nested ternary expressions @@ -295,11 +295,11 @@ module.exports = { 'no-new-object': 'error', // disallow use of unary operators, ++ and -- - // http://eslint.org/docs/rules/no-plusplus + // https://eslint.org/docs/rules/no-plusplus 'no-plusplus': 'error', // disallow certain syntax forms - // http://eslint.org/docs/rules/no-restricted-syntax + // https://eslint.org/docs/rules/no-restricted-syntax 'no-restricted-syntax': [ 'error', { @@ -345,29 +345,29 @@ module.exports = { // disallow the use of Boolean literals in conditional expressions // also, prefer `a || b` over `a ? a : b` - // http://eslint.org/docs/rules/no-unneeded-ternary + // https://eslint.org/docs/rules/no-unneeded-ternary 'no-unneeded-ternary': ['error', { defaultAssignment: false }], // disallow whitespace before properties - // http://eslint.org/docs/rules/no-whitespace-before-property + // https://eslint.org/docs/rules/no-whitespace-before-property 'no-whitespace-before-property': 'error', // enforce the location of single-line statements - // http://eslint.org/docs/rules/nonblock-statement-body-position + // https://eslint.org/docs/rules/nonblock-statement-body-position 'nonblock-statement-body-position': ['error', 'beside', { overrides: {} }], // require padding inside curly braces 'object-curly-spacing': ['error', 'always'], // enforce line breaks between braces - // http://eslint.org/docs/rules/object-curly-newline + // https://eslint.org/docs/rules/object-curly-newline 'object-curly-newline': ['error', { ObjectExpression: { minProperties: 4, multiline: true, consistent: true }, ObjectPattern: { minProperties: 4, multiline: true, consistent: true } }], // enforce "same line" or "multiple line" on object properties. - // http://eslint.org/docs/rules/object-property-newline + // https://eslint.org/docs/rules/object-property-newline 'object-property-newline': ['error', { allowMultiplePropertiesPerLine: true, }], @@ -376,11 +376,11 @@ module.exports = { 'one-var': ['error', 'never'], // require a newline around variable declaration - // http://eslint.org/docs/rules/one-var-declaration-per-line + // https://eslint.org/docs/rules/one-var-declaration-per-line 'one-var-declaration-per-line': ['error', 'always'], // require assignment operator shorthand where possible or prohibit it entirely - // http://eslint.org/docs/rules/operator-assignment + // https://eslint.org/docs/rules/operator-assignment 'operator-assignment': ['error', 'always'], // Requires operator at the beginning of the line in multiline statements @@ -391,18 +391,18 @@ module.exports = { '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 + // https://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 + // https://eslint.org/docs/rules/quote-props.html 'quote-props': ['error', 'as-needed', { keywords: false, unnecessary: true, numbers: false }], // specify whether double or single quotes should be used quotes: ['error', 'single', { avoidEscape: true }], // do not require jsdoc - // http://eslint.org/docs/rules/require-jsdoc + // https://eslint.org/docs/rules/require-jsdoc 'require-jsdoc': 'off', // require or disallow use of semicolons instead of ASI @@ -412,7 +412,7 @@ module.exports = { 'semi-spacing': ['error', { before: false, after: true }], // Enforce location of semicolons - // http://eslint.org/docs/rules/semi-style + // https://eslint.org/docs/rules/semi-style 'semi-style': ['error', 'last'], // requires object keys to be sorted @@ -425,7 +425,7 @@ module.exports = { 'space-before-blocks': 'error', // require or disallow space before function opening parenthesis - // http://eslint.org/docs/rules/space-before-function-paren + // https://eslint.org/docs/rules/space-before-function-paren 'space-before-function-paren': ['error', { anonymous: 'always', named: 'never', @@ -439,7 +439,7 @@ module.exports = { 'space-infix-ops': 'error', // Require or disallow spaces before/after unary operators - // http://eslint.org/docs/rules/space-unary-ops + // https://eslint.org/docs/rules/space-unary-ops 'space-unary-ops': ['error', { words: true, nonwords: false, @@ -448,7 +448,7 @@ module.exports = { }], // require or disallow a space immediately following the // or /* in a comment - // http://eslint.org/docs/rules/spaced-comment + // https://eslint.org/docs/rules/spaced-comment 'spaced-comment': ['error', 'always', { line: { exceptions: ['-', '+'], @@ -462,15 +462,15 @@ module.exports = { }], // Enforce spacing around colons of switch statements - // http://eslint.org/docs/rules/switch-colon-spacing + // https://eslint.org/docs/rules/switch-colon-spacing '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 + // https://eslint.org/docs/rules/template-tag-spacing 'template-tag-spacing': ['error', 'never'], // require or disallow the Unicode Byte Order Mark - // http://eslint.org/docs/rules/unicode-bom + // https://eslint.org/docs/rules/unicode-bom 'unicode-bom': ['error', 'never'], // require regex literals to be wrapped in parentheses diff --git a/packages/eslint-config-airbnb-base/rules/variables.js b/packages/eslint-config-airbnb-base/rules/variables.js index 805563a51a..aeab992320 100644 --- a/packages/eslint-config-airbnb-base/rules/variables.js +++ b/packages/eslint-config-airbnb-base/rules/variables.js @@ -12,7 +12,7 @@ module.exports = { 'no-delete-var': 'error', // disallow labels that share a name with a variable - // http://eslint.org/docs/rules/no-label-var + // https://eslint.org/docs/rules/no-label-var 'no-label-var': 'error', // disallow specific globals @@ -31,7 +31,7 @@ module.exports = { 'no-undef-init': 'error', // disallow use of undefined variable - // http://eslint.org/docs/rules/no-undefined + // https://eslint.org/docs/rules/no-undefined // TODO: enable? 'no-undefined': 'off', diff --git a/packages/eslint-config-airbnb/CHANGELOG.md b/packages/eslint-config-airbnb/CHANGELOG.md index ae38f3c048..d19acfc7f2 100644 --- a/packages/eslint-config-airbnb/CHANGELOG.md +++ b/packages/eslint-config-airbnb/CHANGELOG.md @@ -308,36 +308,36 @@ [pr-modular]: https://github.com/airbnb/javascript/pull/526 [pr-legacy]: https://github.com/airbnb/javascript/pull/527 -[array-bracket-spacing]: http://eslint.org/docs/rules/array-bracket-spacing -[array-callback-return]: http://eslint.org/docs/rules/array-callback-return -[arrow-body-style]: http://eslint.org/docs/rules/arrow-body-style -[arrow-spacing]: http://eslint.org/docs/rules/arrow-spacing -[computed-property-spacing]: http://eslint.org/docs/rules/computed-property-spacing -[id-length]: http://eslint.org/docs/rules/id-length -[indent]: http://eslint.org/docs/rules/indent -[max-len]: http://eslint.org/docs/rules/max-len -[newline-per-chained-call]: http://eslint.org/docs/rules/newline-per-chained-call -[no-confusing-arrow]: http://eslint.org/docs/rules/no-confusing-arrow -[no-const-assign]: http://eslint.org/docs/rules/no-const-assign -[no-mixed-spaces-and-tabs]: http://eslint.org/docs/rules/no-mixed-spaces-and-tabs -[no-multiple-empty-lines]: http://eslint.org/docs/rules/no-multiple-empty-lines -[no-new-symbol]: http://eslint.org/docs/rules/no-new-symbol -[no-restricted-imports]: http://eslint.org/docs/rules/no-restricted-imports -[no-self-assign]: http://eslint.org/docs/rules/no-self-assign -[no-undef]: http://eslint.org/docs/rules/no-undef -[no-useless-constructor]: http://eslint.org/docs/rules/no-useless-constructor -[no-whitespace-before-property]: http://eslint.org/docs/rules/no-whitespace-before-property -[object-curly-spacing]: http://eslint.org/docs/rules/object-curly-spacing -[object-shorthand]: http://eslint.org/docs/rules/object-shorthand -[one-var-declaration-per-line]: http://eslint.org/docs/rules/one-var-declaration-per-line -[prefer-arrow-callback]: http://eslint.org/docs/rules/prefer-arrow-callback -[prefer-rest-params]: http://eslint.org/docs/rules/prefer-rest-params -[prefer-template]: http://eslint.org/docs/rules/prefer-template -[quote-props]: http://eslint.org/docs/rules/quote-props -[space-before-function-paren]: http://eslint.org/docs/rules/space-before-function-paren -[space-before-keywords]: http://eslint.org/docs/rules/space-before-keywords -[space-in-parens]: http://eslint.org/docs/rules/space-in-parens -[template-curly-spacing]: http://eslint.org/docs/rules/template-curly-spacing +[array-bracket-spacing]: https://eslint.org/docs/rules/array-bracket-spacing +[array-callback-return]: https://eslint.org/docs/rules/array-callback-return +[arrow-body-style]: https://eslint.org/docs/rules/arrow-body-style +[arrow-spacing]: https://eslint.org/docs/rules/arrow-spacing +[computed-property-spacing]: https://eslint.org/docs/rules/computed-property-spacing +[id-length]: https://eslint.org/docs/rules/id-length +[indent]: https://eslint.org/docs/rules/indent +[max-len]: https://eslint.org/docs/rules/max-len +[newline-per-chained-call]: https://eslint.org/docs/rules/newline-per-chained-call +[no-confusing-arrow]: https://eslint.org/docs/rules/no-confusing-arrow +[no-const-assign]: https://eslint.org/docs/rules/no-const-assign +[no-mixed-spaces-and-tabs]: https://eslint.org/docs/rules/no-mixed-spaces-and-tabs +[no-multiple-empty-lines]: https://eslint.org/docs/rules/no-multiple-empty-lines +[no-new-symbol]: https://eslint.org/docs/rules/no-new-symbol +[no-restricted-imports]: https://eslint.org/docs/rules/no-restricted-imports +[no-self-assign]: https://eslint.org/docs/rules/no-self-assign +[no-undef]: https://eslint.org/docs/rules/no-undef +[no-useless-constructor]: https://eslint.org/docs/rules/no-useless-constructor +[no-whitespace-before-property]: https://eslint.org/docs/rules/no-whitespace-before-property +[object-curly-spacing]: https://eslint.org/docs/rules/object-curly-spacing +[object-shorthand]: https://eslint.org/docs/rules/object-shorthand +[one-var-declaration-per-line]: https://eslint.org/docs/rules/one-var-declaration-per-line +[prefer-arrow-callback]: https://eslint.org/docs/rules/prefer-arrow-callback +[prefer-rest-params]: https://eslint.org/docs/rules/prefer-rest-params +[prefer-template]: https://eslint.org/docs/rules/prefer-template +[quote-props]: https://eslint.org/docs/rules/quote-props +[space-before-function-paren]: https://eslint.org/docs/rules/space-before-function-paren +[space-before-keywords]: https://eslint.org/docs/rules/space-before-keywords +[space-in-parens]: https://eslint.org/docs/rules/space-in-parens +[template-curly-spacing]: https://eslint.org/docs/rules/template-curly-spacing [react/jsx-space-before-closing]: https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-space-before-closing.md [react/sort-comp]: https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/sort-comp.md diff --git a/packages/eslint-config-airbnb/README.md b/packages/eslint-config-airbnb/README.md index 567c929a31..853588d4d3 100644 --- a/packages/eslint-config-airbnb/README.md +++ b/packages/eslint-config-airbnb/README.md @@ -59,7 +59,7 @@ This entry point is deprecated. See [eslint-config-airbnb-base](https://npmjs.co This entry point is deprecated. See [eslint-config-airbnb-base](https://npmjs.com/eslint-config-airbnb-base). See [Airbnb's Javascript styleguide](https://github.com/airbnb/javascript) and -the [ESlint config docs](http://eslint.org/docs/user-guide/configuring#extending-configuration-files) +the [ESlint config docs](https://eslint.org/docs/user-guide/configuring#extending-configuration-files) for more information. ## Improving this config diff --git a/packages/eslint-config-airbnb/rules/react.js b/packages/eslint-config-airbnb/rules/react.js index f6e3528079..d0f4ed54d3 100644 --- a/packages/eslint-config-airbnb/rules/react.js +++ b/packages/eslint-config-airbnb/rules/react.js @@ -13,7 +13,7 @@ module.exports = { // https://github.com/yannickcr/eslint-plugin-react#list-of-supported-rules rules: { // Specify whether double or single quotes should be used in JSX attributes - // http://eslint.org/docs/rules/jsx-quotes + // https://eslint.org/docs/rules/jsx-quotes 'jsx-quotes': ['error', 'prefer-double'], 'class-methods-use-this': ['error', { diff --git a/packages/eslint-config-airbnb/test/test-react-order.js b/packages/eslint-config-airbnb/test/test-react-order.js index e8fa989dbd..b28792a6d5 100644 --- a/packages/eslint-config-airbnb/test/test-react-order.js +++ b/packages/eslint-config-airbnb/test/test-react-order.js @@ -17,8 +17,8 @@ const cli = new CLIEngine({ }); function lint(text) { - // @see http://eslint.org/docs/developer-guide/nodejs-api.html#executeonfiles - // @see http://eslint.org/docs/developer-guide/nodejs-api.html#executeontext + // @see https://eslint.org/docs/developer-guide/nodejs-api.html#executeonfiles + // @see https://eslint.org/docs/developer-guide/nodejs-api.html#executeontext const linter = cli.executeOnText(text); return linter.results[0]; } diff --git a/react/README.md b/react/README.md index ee440e9b11..304e6cbcbb 100644 --- a/react/README.md +++ b/react/README.md @@ -195,7 +195,7 @@ ## Quotes - - Always use double quotes (`"`) for JSX attributes, but single quotes (`'`) for all other JS. eslint: [`jsx-quotes`](http://eslint.org/docs/rules/jsx-quotes) + - Always use double quotes (`"`) for JSX attributes, but single quotes (`'`) for all other JS. eslint: [`jsx-quotes`](https://eslint.org/docs/rules/jsx-quotes) > Why? Regular HTML attributes also typically use double quotes instead of single, so JSX attributes mirror this convention. @@ -215,7 +215,7 @@ ## Spacing - - Always include a single space in your self-closing tag. eslint: [`no-multi-spaces`](http://eslint.org/docs/rules/no-multi-spaces), [`react/jsx-tag-spacing`](https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-tag-spacing.md) + - Always include a single space in your self-closing tag. eslint: [`no-multi-spaces`](https://eslint.org/docs/rules/no-multi-spaces), [`react/jsx-tag-spacing`](https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-tag-spacing.md) ```jsx // bad From 1948c302fd21d7bedd7d6e1a1e83c2e51efcb18e Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Wed, 1 Nov 2017 08:01:50 -0700 Subject: [PATCH 053/480] =?UTF-8?q?[Tests]=20on=20`node`=20`v9`;=20use=20`?= =?UTF-8?q?nvm=20install-latest-npm`=20so=20new=20npm=20doesn=E2=80=99t=20?= =?UTF-8?q?break=20old=20node;=20pin=20included=20builds=20to=20LTS.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .travis.yml | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/.travis.yml b/.travis.yml index aa05d1d238..bc8324b755 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,16 +1,16 @@ language: node_js node_js: + - "9" - "8" - "7" - "6" - "5" - "4" before_install: - - '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' + - 'nvm install-latest-npm' install: - 'if [ -n "${PACKAGE-}" ]; then cd "packages/${PACKAGE}"; fi' - - '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 [ "${TRAVIS_NODE_VERSION}" = "0.6" ] || [ "${TRAVIS_NODE_VERSION}" = "0.9" ]; then nvm install --latest-npm 0.8 && 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; elif [ -n "${LINT-}" ]; then npm run lint; else npm run travis; fi' @@ -22,13 +22,14 @@ env: matrix: fast_finish: true include: - - node_js: "node" + - node_js: "lts/*" env: PREPUBLISH=true ESLINT=4 PACKAGE=eslint-config-airbnb - - node_js: "node" + - node_js: "lts/*" env: PREPUBLISH=true ESLINT=4 PACKAGE=eslint-config-airbnb-base - - node_js: "node" + - node_js: "lts/*" env: LINT=true allow_failures: + - node_js: "9" - node_js: "7" - node_js: "5" - env: PREPUBLISH=true ESLINT=4 PACKAGE=eslint-config-airbnb From 5682155e9a2bd5391fe8579a25d6abd482d78123 Mon Sep 17 00:00:00 2001 From: Maggie Love Date: Sun, 29 Oct 2017 17:28:25 -0400 Subject: [PATCH 054/480] Adds section about spreading props --- react/README.md | 52 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) diff --git a/react/README.md b/react/README.md index 304e6cbcbb..e1133c3754 100644 --- a/react/README.md +++ b/react/README.md @@ -380,6 +380,58 @@ }; ``` + - Use spread props sparingly. + > Why? Otherwise you're more likely to pass unnecessary props down to components. And for React v15.6.1 and older, you could [pass invalid HTML attributes to the DOM](https://reactjs.org/blog/2017/09/08/dom-attributes-in-react-16.html). + + Exceptions: + + - HOCs that proxy down props and hoist propTypes + + ```jsx + function HOC(WrappedComponent) { + return class Proxy extends React.Component { + Proxy.propTypes = { + text: PropTypes.string, + isLoading: PropTypes.bool + }; + + render() { + return + } + } + } + ``` + + - Spreading objects with known, explicit props. This can be particularly useful when testing React components with Mocha's beforeEach construct. + + ```jsx + export default function Foo { + const props = { + text: '', + isPublished: false + } + + return (
); + } + ``` + + Notes for use: + Filter out unnecessary props when possible. Also, use [prop-types-exact](https://www.npmjs.com/package/prop-types-exact) to help prevent bugs. + + ```jsx + //good + render() { + const { irrelevantProp, ...relevantProps } = this.props; + return + } + + //bad + render() { + const { irrelevantProp, ...relevantProps } = this.props; + return + } + ``` + ## Refs - Always use ref callbacks. eslint: [`react/no-string-refs`](https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/no-string-refs.md) From 44dbd0bdc41d08eb5de8ad698099ae44240f4b0d Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Sat, 4 Nov 2017 01:02:09 -0700 Subject: [PATCH 055/480] =?UTF-8?q?[eslint=20config]=20[patch]=20disable?= =?UTF-8?q?=20`no-did-mount-set-state`,=20since=20it=E2=80=99s=20necessary?= =?UTF-8?q?=20for=20server-rendering.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixes #684. --- packages/eslint-config-airbnb/rules/react.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/eslint-config-airbnb/rules/react.js b/packages/eslint-config-airbnb/rules/react.js index d0f4ed54d3..8bf726bed6 100644 --- a/packages/eslint-config-airbnb/rules/react.js +++ b/packages/eslint-config-airbnb/rules/react.js @@ -142,7 +142,8 @@ module.exports = { // Prevent usage of setState in componentDidMount // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/no-did-mount-set-state.md - 'react/no-did-mount-set-state': 'error', + // this is necessary for server-rendering + 'react/no-did-mount-set-state': 'off', // Prevent usage of setState in componentDidUpdate // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/no-did-update-set-state.md From 8cf2c70a4164ba2dad9a79e7ac9021d32a406487 Mon Sep 17 00:00:00 2001 From: Josh Bourgeois Date: Wed, 4 Oct 2017 13:38:13 -0700 Subject: [PATCH 056/480] [guide] Add explanation for semicolon enforcement rule Also update code samples to highlight ways in which ES6 currently mishandles code when relying on Automatic Semicolon Insertion Revise hyperlink and example - Use more up-to-date TC39 reference page on github.io - wrap returnless function with side-effects in curly braces also, clean up punctuation on a long comment line Always use single-quoted strings Except for when the string needs to be double-quoted because the string contains apostrophes Update second example to incorporate IIFE An IIFE is a more realistic example of code that developers may encounter which would raise an exception when relying completely upon ASI --- README.md | 47 ++++++++++++++++++++++++++++++++++------------- 1 file changed, 34 insertions(+), 13 deletions(-) diff --git a/README.md b/README.md index 52b5ed4a8f..05d6257897 100644 --- a/README.md +++ b/README.md @@ -2767,24 +2767,45 @@ Other Style Guides - [21.1](#semicolons--required) **Yup.** eslint: [`semi`](https://eslint.org/docs/rules/semi.html) jscs: [`requireSemicolons`](http://jscs.info/rule/requireSemicolons) + > Why? When JavaScript encounters a line break without a semicolon, it uses a set of rules called [Automatic Semicolon Insertion](https://tc39.github.io/ecma262/#sec-automatic-semicolon-insertion) to determine whether or not it should regard that line break as the end of a statement, and (as the name implies) place a semicolon into your code before the line break if it thinks so. ASI contains a few eccentric behaviors, though, and your code will break if JavaScript misinterprets your line break. These rules will become more complicated as new features become a part of JavaScript. Explicitly terminating your statements and configuring your linter to catch missing semicolons will help prevent you from encountering issues. + ```javascript - // bad - (function () { - const name = 'Skywalker' - return name - })() + // bad - raises exception + const luke = {} + const leia = {} + [luke, leia].forEach(jedi => jedi.father = 'vader') + + // bad - raises exception + const reaction = "No! That's impossible!" + (async function meanwhileOnTheFalcon(){ + // handle `leia`, `lando`, `chewie`, `r2`, `c3p0` + // ... + }()) + + // bad - returns `undefined` instead of the value on the next line - always happens when `return` is on a line by itself because of ASI! + function foo() { + return + 'search your feelings, you know it to be foo' + } // good - (function () { - const name = 'Skywalker'; - return name; + const luke = {}; + const leia = {}; + [luke, leia].forEach((jedi) => { + jedi.father = 'vader'; + }); + + // good + const reaction = "No! That's impossible!"; + (async function meanwhileOnTheFalcon(){ + // handle `leia`, `lando`, `chewie`, `r2`, `c3p0` + // ... }()); - // good, but legacy (guards against the function becoming an argument when two files with IIFEs are concatenated) - ;((() => { - const name = 'Skywalker'; - return name; - })()); + // good + function foo() { + return 'search your feelings, you know it to be foo'; + } ``` [Read more](https://stackoverflow.com/questions/7365172/semicolon-before-self-invoking-function/7365214#7365214). From 1d9d25d278423525d098b353c0e2654c8ae2665a Mon Sep 17 00:00:00 2001 From: Matias Olivera Date: Sun, 5 Nov 2017 13:21:48 -0300 Subject: [PATCH 057/480] Add .mjs to the list of supported extensions --- packages/eslint-config-airbnb-base/rules/imports.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/eslint-config-airbnb-base/rules/imports.js b/packages/eslint-config-airbnb-base/rules/imports.js index 54e158f57f..ecfcc8e6c8 100644 --- a/packages/eslint-config-airbnb-base/rules/imports.js +++ b/packages/eslint-config-airbnb-base/rules/imports.js @@ -13,11 +13,12 @@ module.exports = { settings: { 'import/resolver': { node: { - extensions: ['.js', '.json'] + extensions: ['.mjs', '.js', '.json'] } }, 'import/extensions': [ '.js', + '.mjs', '.jsx', ], 'import/core-modules': [ From eb50272401bf0a02ff385f65fc3ec845cd159d0a Mon Sep 17 00:00:00 2001 From: Matias Olivera Date: Sun, 5 Nov 2017 13:23:21 -0300 Subject: [PATCH 058/480] Forbid .mjs extension from being specified --- 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 ecfcc8e6c8..9536e9b4a4 100644 --- a/packages/eslint-config-airbnb-base/rules/imports.js +++ b/packages/eslint-config-airbnb-base/rules/imports.js @@ -134,6 +134,7 @@ module.exports = { // https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/extensions.md 'import/extensions': ['error', 'always', { js: 'never', + mjs: 'never', jsx: 'never', }], From 2087a42b51a8977308a05fe7096c27849b5cacdb Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Wed, 29 Nov 2017 23:43:55 -0800 Subject: [PATCH 059/480] [eslint config] [base] [deps] update `eslint` --- packages/eslint-config-airbnb-base/package.json | 4 ++-- packages/eslint-config-airbnb-base/rules/es6.js | 5 ++++- packages/eslint-config-airbnb-base/rules/style.js | 5 +++++ 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/packages/eslint-config-airbnb-base/package.json b/packages/eslint-config-airbnb-base/package.json index 2066ad1ab0..e0b7ebc01d 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.9.0", + "eslint": "^4.12.1", "eslint-find-rules": "^3.1.1", "eslint-plugin-import": "^2.8.0", "in-publish": "^2.0.0", @@ -59,7 +59,7 @@ "tape": "^4.8.0" }, "peerDependencies": { - "eslint": "^4.9.0", + "eslint": "^4.12.1", "eslint-plugin-import": "^2.8.0" }, "engines": { diff --git a/packages/eslint-config-airbnb-base/rules/es6.js b/packages/eslint-config-airbnb-base/rules/es6.js index cf81d198d9..f9e5198c96 100644 --- a/packages/eslint-config-airbnb-base/rules/es6.js +++ b/packages/eslint-config-airbnb-base/rules/es6.js @@ -64,7 +64,10 @@ module.exports = { // disallow specific imports // https://eslint.org/docs/rules/no-restricted-imports - 'no-restricted-imports': 'off', + 'no-restricted-imports': ['off', { + paths: [], + patterns: [] + }], // disallow to use this/super before super() calling in constructors. // https://eslint.org/docs/rules/no-this-before-super diff --git a/packages/eslint-config-airbnb-base/rules/style.js b/packages/eslint-config-airbnb-base/rules/style.js index 26b9f784d0..6ae51af7eb 100644 --- a/packages/eslint-config-airbnb-base/rules/style.js +++ b/packages/eslint-config-airbnb-base/rules/style.js @@ -97,6 +97,11 @@ module.exports = { // require identifiers to match the provided regular expression 'id-match': 'off', + // Enforce the location of arrow function bodies with implicit returns + // https://eslint.org/docs/rules/implicit-arrow-linebreak + // TODO: enable, semver-major + 'implicit-arrow-linebreak': ['off', 'beside'], + // this option sets a specific tab width for your code // https://eslint.org/docs/rules/indent indent: ['error', 2, { From b7090234944eaff912b54faa3f86ca4eee4d017a Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Wed, 29 Nov 2017 23:52:45 -0800 Subject: [PATCH 060/480] [eslint config] [base] [breaking] enable `implicit-arrow-linebreak` --- packages/eslint-config-airbnb-base/rules/style.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/packages/eslint-config-airbnb-base/rules/style.js b/packages/eslint-config-airbnb-base/rules/style.js index 6ae51af7eb..d32b5935eb 100644 --- a/packages/eslint-config-airbnb-base/rules/style.js +++ b/packages/eslint-config-airbnb-base/rules/style.js @@ -99,8 +99,7 @@ module.exports = { // Enforce the location of arrow function bodies with implicit returns // https://eslint.org/docs/rules/implicit-arrow-linebreak - // TODO: enable, semver-major - 'implicit-arrow-linebreak': ['off', 'beside'], + 'implicit-arrow-linebreak': ['error', 'beside'], // this option sets a specific tab width for your code // https://eslint.org/docs/rules/indent From 4817a6b75cd44fe8b28a16b06d33a5c65603a74c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Krist=C3=B3f=20Poduszl=C3=B3?= Date: Tue, 28 Nov 2017 19:47:00 +0100 Subject: [PATCH 061/480] [eslint config] [patch] Add 'to' as a specialLink to the 'anchor-is-valid' a11y rule Support React Router's `` attribute out of the box. --- packages/eslint-config-airbnb/rules/react-a11y.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/eslint-config-airbnb/rules/react-a11y.js b/packages/eslint-config-airbnb/rules/react-a11y.js index 6e1c395656..3e7f5c970c 100644 --- a/packages/eslint-config-airbnb/rules/react-a11y.js +++ b/packages/eslint-config-airbnb/rules/react-a11y.js @@ -187,7 +187,7 @@ module.exports = { // https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/0745af376cdc8686d85a361ce36952b1fb1ccf6e/docs/rules/anchor-is-valid.md 'jsx-a11y/anchor-is-valid': ['error', { components: ['Link'], - specialLink: [], + specialLink: ['to'], aspects: ['noHref', 'invalidHref', 'preferButton'], }], }, From 255b0f369ad6579ac74f808c000f2daa4e03d74f Mon Sep 17 00:00:00 2001 From: Ilici Date: Thu, 14 Dec 2017 23:14:27 +0100 Subject: [PATCH 062/480] Fix third example in Enclosed operators section --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 05d6257897..71979c2b22 100644 --- a/README.md +++ b/README.md @@ -1957,6 +1957,7 @@ Other Style Guides const bar = a ** b - 5 % d; // bad + // one may be confused into thinking (a || b) && c if (a || b && c) { return d; } @@ -1968,7 +1969,7 @@ Other Style Guides const bar = (a ** b) - (5 % d); // good - if ((a || b) && c) { + if (a || (b && c)) { return d; } From 8a12ffed193ab985d438bed2a20aedb8b5faea1e Mon Sep 17 00:00:00 2001 From: Thomas Broadley Date: Fri, 15 Dec 2017 20:31:09 -0500 Subject: [PATCH 063/480] [guide] Fix spelling error in link (preserve old link for back-compat) --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 71979c2b22..43d36eb0a5 100644 --- a/README.md +++ b/README.md @@ -1754,8 +1754,8 @@ Other Style Guides } ``` - - - [14.3](#hoisting--named-expresions) Named function expressions hoist the variable name, not the function name or the function body. + + - [14.3](#hoisting--named-expressions) Named function expressions hoist the variable name, not the function name or the function body. ```javascript function example() { @@ -1957,7 +1957,7 @@ Other Style Guides const bar = a ** b - 5 % d; // bad - // one may be confused into thinking (a || b) && c + // one may be confused into thinking (a || b) && c if (a || b && c) { return d; } From 9061044af05cce24cc322ce123b7d5c2f826d0e5 Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Sat, 23 Dec 2017 20:25:29 -0800 Subject: [PATCH 064/480] [eslint config] [*] [deps] update `eslint`, `eslint-plugin-jsx-a11y` --- packages/eslint-config-airbnb-base/package.json | 4 ++-- packages/eslint-config-airbnb/package.json | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/packages/eslint-config-airbnb-base/package.json b/packages/eslint-config-airbnb-base/package.json index e0b7ebc01d..194b1123e2 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.12.1", + "eslint": "^4.14.0", "eslint-find-rules": "^3.1.1", "eslint-plugin-import": "^2.8.0", "in-publish": "^2.0.0", @@ -59,7 +59,7 @@ "tape": "^4.8.0" }, "peerDependencies": { - "eslint": "^4.12.1", + "eslint": "^4.14.0", "eslint-plugin-import": "^2.8.0" }, "engines": { diff --git a/packages/eslint-config-airbnb/package.json b/packages/eslint-config-airbnb/package.json index bdf9700026..ba820e47ba 100644 --- a/packages/eslint-config-airbnb/package.json +++ b/packages/eslint-config-airbnb/package.json @@ -54,10 +54,10 @@ "babel-preset-airbnb": "^2.4.0", "babel-tape-runner": "^2.0.1", "editorconfig-tools": "^0.1.1", - "eslint": "^4.9.0", + "eslint": "^4.14.0", "eslint-find-rules": "^3.1.1", "eslint-plugin-import": "^2.8.0", - "eslint-plugin-jsx-a11y": "^6.0.2", + "eslint-plugin-jsx-a11y": "^6.0.3", "eslint-plugin-react": "^7.4.0", "in-publish": "^2.0.0", "react": ">= 0.13.0", @@ -65,7 +65,7 @@ "tape": "^4.8.0" }, "peerDependencies": { - "eslint": "^4.9.0", + "eslint": "^4.14.0", "eslint-plugin-import": "^2.8.0", "eslint-plugin-jsx-a11y": "^6.0.2", "eslint-plugin-react": "^7.4.0" From 90235cab7c060d69430001cf17aa28ff74da86b4 Mon Sep 17 00:00:00 2001 From: Pirasis <1pete@users.noreply.github.com> Date: Sun, 24 Dec 2017 10:06:09 +0700 Subject: [PATCH 065/480] [eslint config] [base] [patch] `array-callback-return`: enable `allowImplicit` option --- packages/eslint-config-airbnb-base/rules/best-practices.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/eslint-config-airbnb-base/rules/best-practices.js b/packages/eslint-config-airbnb-base/rules/best-practices.js index 3fd0ff105d..978cafc698 100644 --- a/packages/eslint-config-airbnb-base/rules/best-practices.js +++ b/packages/eslint-config-airbnb-base/rules/best-practices.js @@ -5,7 +5,7 @@ module.exports = { // enforces return statements in callbacks of array's methods // https://eslint.org/docs/rules/array-callback-return - 'array-callback-return': 'error', + 'array-callback-return': ['error', { allowImplicit: true }], // treat var statements as if they were block scoped 'block-scoped-var': 'error', From fc34709d195b0ec9787c7b9905d3d5d72fd305b5 Mon Sep 17 00:00:00 2001 From: Ronald Eddy Jr Date: Sun, 24 Dec 2017 13:20:12 -0800 Subject: [PATCH 066/480] Docs: HTTP -> HTTPS URL was updated to use HTTPS protocol --- css-in-javascript/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/css-in-javascript/README.md b/css-in-javascript/README.md index 13099410a9..2b4d5e489b 100644 --- a/css-in-javascript/README.md +++ b/css-in-javascript/README.md @@ -429,4 +429,4 @@ --- -CSS puns adapted from [Saijo George](http://saijogeorge.com/css-puns/). +CSS puns adapted from [Saijo George](https://saijogeorge.com/css-puns/). From 1b6bcd0e0fd4ed95eec2ff0a23b24b961af77e30 Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Mon, 25 Dec 2017 10:24:54 -0800 Subject: [PATCH 067/480] [guide] more precisely refer to an "object literal" instead of just a "hash" Fixes #1680. --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 43d36eb0a5..4d39ff9cfa 100644 --- a/README.md +++ b/README.md @@ -3170,7 +3170,7 @@ Other Style Guides ## Events - - [25.1](#events--hash) When attaching data payloads to events (whether DOM events or something more proprietary like Backbone events), pass a hash instead of a raw value. This allows a subsequent contributor to add more data to the event payload without finding and updating every handler for the event. For example, instead of: + - [25.1](#events--hash) When attaching data payloads to events (whether DOM events or something more proprietary like Backbone events), pass an object literal (also known as a "hash") instead of a raw value. This allows a subsequent contributor to add more data to the event payload without finding and updating every handler for the event. For example, instead of: ```javascript // bad From 0991476c9f803f47abaf68b47434c5d1e58c49d7 Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Mon, 25 Dec 2017 10:27:33 -0800 Subject: [PATCH 068/480] [guide] Clarify that vars are hoisted to function scope, not block scope Fixes #1675. --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 4d39ff9cfa..d80964a362 100644 --- a/README.md +++ b/README.md @@ -1704,7 +1704,7 @@ Other Style Guides ## Hoisting - - [14.1](#hoisting--about) `var` declarations get hoisted to the top of their scope, their assignment does not. `const` and `let` declarations are blessed with a new concept called [Temporal Dead Zones (TDZ)](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/let#Temporal_Dead_Zone_and_errors_with_let). It’s important to know why [typeof is no longer safe](http://es-discourse.com/t/why-typeof-is-no-longer-safe/15). + - [14.1](#hoisting--about) `var` declarations get hoisted to the top of their 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). ```javascript // we know this wouldn’t work (assuming there From f9fcb37af15391f6f75ae3e8d5e09f5f2ae064b8 Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Mon, 25 Dec 2017 10:37:36 -0800 Subject: [PATCH 069/480] [guide] Add link to "has" package Fixes #1670. --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index d80964a362..3b173dd385 100644 --- a/README.md +++ b/README.md @@ -297,7 +297,7 @@ Other Style Guides // best const has = Object.prototype.hasOwnProperty; // cache the lookup once, in module scope. /* or */ - import has from 'has'; + import has from 'has'; // https://www.npmjs.com/package/has // ... console.log(has.call(object, key)); ``` From cb9482c04efac0a5278373b4506a29849753f67f Mon Sep 17 00:00:00 2001 From: Miguel Piedrafita Date: Mon, 1 Jan 2018 00:50:59 +0100 Subject: [PATCH 070/480] [guide] Update license year --- LICENSE.md | 2 +- README.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/LICENSE.md b/LICENSE.md index 2867dece2b..69d80c0252 100644 --- a/LICENSE.md +++ b/LICENSE.md @@ -1,6 +1,6 @@ MIT License -Copyright (c) 2017 Airbnb +Copyright (c) 2012 Airbnb Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/README.md b/README.md index 3b173dd385..e00d988f60 100644 --- a/README.md +++ b/README.md @@ -3591,7 +3591,7 @@ Other Style Guides (The MIT License) -Copyright (c) 2014-2017 Airbnb +Copyright (c) 2012 Airbnb Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the From fe3a2de6b511f6373bab5f00d81e699ff6e81a56 Mon Sep 17 00:00:00 2001 From: Sharmila Date: Mon, 8 Jan 2018 14:36:08 -0800 Subject: [PATCH 071/480] [fixes: #1678] Improves wording of no-mixed-operators recommendation. --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index e00d988f60..20ac163402 100644 --- a/README.md +++ b/README.md @@ -1945,7 +1945,7 @@ Other Style Guides ``` - - [15.8](#comparison--no-mixed-operators) Enclose operators in parentheses when they are mixed in a statement. When mixing arithmetic operators, do not mix `**` and `%` with themselves or with `+`, `-`, `*`, & `/`. eslint: [`no-mixed-operators`](https://eslint.org/docs/rules/no-mixed-operators.html) + - [15.8](#comparison--no-mixed-operators) When mixing operators, enclose them in parentheses. The only exception is the standard arithmetic operators (`+`, `-`, `*`, & `/`) since their precedence is broadly understood. eslint: [`no-mixed-operators`](https://eslint.org/docs/rules/no-mixed-operators.html) > Why? This improves readability and clarifies the developer’s intention. From 7b18d7c2155f52937b1d48a3c6b905943fc1e5b7 Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Mon, 8 Jan 2018 00:35:15 -0800 Subject: [PATCH 072/480] [eslint config] [*] [deps] update `eslint` --- packages/eslint-config-airbnb-base/package.json | 4 ++-- packages/eslint-config-airbnb-base/rules/style.js | 3 ++- packages/eslint-config-airbnb/package.json | 4 ++-- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/packages/eslint-config-airbnb-base/package.json b/packages/eslint-config-airbnb-base/package.json index 194b1123e2..83565bbac0 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.14.0", + "eslint": "^4.15.0", "eslint-find-rules": "^3.1.1", "eslint-plugin-import": "^2.8.0", "in-publish": "^2.0.0", @@ -59,7 +59,7 @@ "tape": "^4.8.0" }, "peerDependencies": { - "eslint": "^4.14.0", + "eslint": "^4.15.0", "eslint-plugin-import": "^2.8.0" }, "engines": { diff --git a/packages/eslint-config-airbnb-base/rules/style.js b/packages/eslint-config-airbnb-base/rules/style.js index d32b5935eb..024c901781 100644 --- a/packages/eslint-config-airbnb-base/rules/style.js +++ b/packages/eslint-config-airbnb-base/rules/style.js @@ -123,7 +123,8 @@ module.exports = { ObjectExpression: 1, ImportDeclaration: 1, flatTernaryExpressions: false, - ignoredNodes: ['JSXElement', 'JSXElement *'] + ignoredNodes: ['JSXElement', 'JSXElement *'], + ignoreComments: false }], // specify whether double or single quotes should be used in JSX attributes diff --git a/packages/eslint-config-airbnb/package.json b/packages/eslint-config-airbnb/package.json index ba820e47ba..17664483ac 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": "^4.14.0", + "eslint": "^4.15.0", "eslint-find-rules": "^3.1.1", "eslint-plugin-import": "^2.8.0", "eslint-plugin-jsx-a11y": "^6.0.3", @@ -65,7 +65,7 @@ "tape": "^4.8.0" }, "peerDependencies": { - "eslint": "^4.14.0", + "eslint": "^4.15.0", "eslint-plugin-import": "^2.8.0", "eslint-plugin-jsx-a11y": "^6.0.2", "eslint-plugin-react": "^7.4.0" From 69a3554100935b79b9c444102504f98103834079 Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Mon, 8 Jan 2018 00:52:17 -0800 Subject: [PATCH 073/480] [eslint config] [base] [patch] properly ignore indentation on jsx Fixes #1658. --- packages/eslint-config-airbnb-base/rules/style.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/eslint-config-airbnb-base/rules/style.js b/packages/eslint-config-airbnb-base/rules/style.js index 024c901781..5566ce7076 100644 --- a/packages/eslint-config-airbnb-base/rules/style.js +++ b/packages/eslint-config-airbnb-base/rules/style.js @@ -123,7 +123,8 @@ module.exports = { ObjectExpression: 1, ImportDeclaration: 1, flatTernaryExpressions: false, - ignoredNodes: ['JSXElement', 'JSXElement *'], + // list derived from https://github.com/benjamn/ast-types/blob/HEAD/def/jsx.js + ignoredNodes: ['JSXElement', 'JSXElement > *', 'JSXAttribute', 'JSXIdentifier', 'JSXNamespacedName', 'JSXMemberExpression', 'JSXSpreadAttribute', 'JSXExpressionContainer', 'JSXOpeningElement', 'JSXClosingElement', 'JSXText', 'JSXEmptyExpression', 'JSXSpreadChild'], ignoreComments: false }], From a08afd77d5d4fe6fdaae1ac9045de957ac433367 Mon Sep 17 00:00:00 2001 From: Aditya Agarwal Date: Wed, 10 Jan 2018 20:04:25 +0530 Subject: [PATCH 074/480] [eslint-config] [*] [docs] add `npx` shortcut --- packages/eslint-config-airbnb-base/README.md | 11 +++++++++-- packages/eslint-config-airbnb/README.md | 11 ++++++++--- 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/packages/eslint-config-airbnb-base/README.md b/packages/eslint-config-airbnb-base/README.md index a28a40a302..686ccb06e8 100644 --- a/packages/eslint-config-airbnb-base/README.md +++ b/packages/eslint-config-airbnb-base/README.md @@ -20,7 +20,14 @@ If you use yarn, run `npm info "eslint-config-airbnb-base@latest" peerDependenci npm info "eslint-config-airbnb-base@latest" peerDependencies ``` - Linux/OSX users can run + If using **npm 5+**, use this shortcut + + ```sh + npx install-peerdeps --dev eslint-config-airbnb-base + ``` + + If using **npm < 5**, Linux/OSX users can run + ```sh ( export PKG=eslint-config-airbnb-base; @@ -34,7 +41,7 @@ If you use yarn, run `npm info "eslint-config-airbnb-base@latest" peerDependenci npm install --save-dev eslint-config-airbnb-base eslint@^#.#.# eslint-plugin-import@^#.#.# ``` - Windows users can either install all the peer dependencies manually, or use the [install-peerdeps](https://github.com/nathanhleung/install-peerdeps) cli tool. + If using **npm < 5**, Windows users can either install all the peer dependencies manually, or use the [install-peerdeps](https://github.com/nathanhleung/install-peerdeps) cli tool. ```sh npm install -g install-peerdeps diff --git a/packages/eslint-config-airbnb/README.md b/packages/eslint-config-airbnb/README.md index 853588d4d3..88e6c80d23 100644 --- a/packages/eslint-config-airbnb/README.md +++ b/packages/eslint-config-airbnb/README.md @@ -20,7 +20,13 @@ If you use yarn, run `npm info "eslint-config-airbnb@latest" peerDependencies` t npm info "eslint-config-airbnb@latest" peerDependencies ``` - Linux/OSX users can run + If using **npm 5+**, use this shortcut + + ```sh + npx install-peerdeps --dev eslint-config-airbnb + ``` + + If using **npm < 5**, Linux/OSX users can run ```sh ( @@ -35,13 +41,12 @@ If you use yarn, run `npm info "eslint-config-airbnb@latest" peerDependencies` t npm install --save-dev eslint-config-airbnb eslint@^#.#.# eslint-plugin-jsx-a11y@^#.#.# eslint-plugin-import@^#.#.# eslint-plugin-react@^#.#.# ``` - Windows users can either install all the peer dependencies manually, or use the [install-peerdeps](https://github.com/nathanhleung/install-peerdeps) cli tool. + If using **npm < 5**, Windows users can either install all the peer dependencies manually, or use the [install-peerdeps](https://github.com/nathanhleung/install-peerdeps) cli tool. ```sh npm install -g install-peerdeps install-peerdeps --dev eslint-config-airbnb ``` - The cli will produce and run a command like: ```sh From 262b07b106bdb83f476c77923340aa9c679da9a2 Mon Sep 17 00:00:00 2001 From: Ben Fortner Date: Tue, 16 Jan 2018 09:55:54 -0500 Subject: [PATCH 075/480] fix example to meet standard listingId v listingID fixed code example to meet the standard. `listingId` changed to `listingID` See - Naming Conventions: Acronyms and initialisms should always be all capitalized, or all lowercased. --- README.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index ae1aaf8a3b..d6f4836fa5 100644 --- a/README.md +++ b/README.md @@ -3178,8 +3178,8 @@ Other Style Guides // ... - $(this).on('listingUpdated', (e, listingId) => { - // do something with listingId + $(this).on('listingUpdated', (e, listingID) => { + // do something with listingID }); ``` @@ -3187,12 +3187,12 @@ Other Style Guides ```javascript // good - $(this).trigger('listingUpdated', { listingId: listing.id }); + $(this).trigger('listingUpdated', { listingID: listing.id }); // ... $(this).on('listingUpdated', (e, data) => { - // do something with data.listingId + // do something with data.listingID }); ``` From 7b1ced2bf79cfe119ab1b7becd096b88b9250ee7 Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Sat, 20 Jan 2018 23:35:21 -0800 Subject: [PATCH 076/480] [eslint config] [base] [deps] update `eslint` --- .../eslint-config-airbnb-base/package.json | 4 ++-- .../eslint-config-airbnb-base/rules/style.js | 18 ++++++++++++++++-- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/packages/eslint-config-airbnb-base/package.json b/packages/eslint-config-airbnb-base/package.json index 83565bbac0..5d4cd5ccc5 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.15.0", + "eslint": "^4.16.0", "eslint-find-rules": "^3.1.1", "eslint-plugin-import": "^2.8.0", "in-publish": "^2.0.0", @@ -59,7 +59,7 @@ "tape": "^4.8.0" }, "peerDependencies": { - "eslint": "^4.15.0", + "eslint": "^4.16.0", "eslint-plugin-import": "^2.8.0" }, "engines": { diff --git a/packages/eslint-config-airbnb-base/rules/style.js b/packages/eslint-config-airbnb-base/rules/style.js index 5566ce7076..81ee87a4fc 100644 --- a/packages/eslint-config-airbnb-base/rules/style.js +++ b/packages/eslint-config-airbnb-base/rules/style.js @@ -51,7 +51,21 @@ module.exports = { 'comma-spacing': ['error', { before: false, after: true }], // enforce one true comma style - 'comma-style': ['error', 'last'], + 'comma-style': ['error', 'last', { + exceptions: { + ArrayExpression: false, + ArrayPattern: false, + ArrowFunctionExpression: false, + CallExpression: false, + FunctionDeclaration: false, + FunctionExpression: false, + ImportDeclaration: false, + ObjectExpression: false, + ObjectPattern: false, + VariableDeclaration: false, + NewExpression: false, + } + }], // disallow padding inside computed properties 'computed-property-spacing': ['error', 'never'], @@ -375,7 +389,7 @@ module.exports = { // enforce "same line" or "multiple line" on object properties. // https://eslint.org/docs/rules/object-property-newline 'object-property-newline': ['error', { - allowMultiplePropertiesPerLine: true, + allowAllPropertiesOnSameLine: true, }], // allow just one var statement per function From 7dab8371c9302cb4c228e652d376a6c2d66db4a3 Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Sat, 20 Jan 2018 23:36:32 -0800 Subject: [PATCH 077/480] [eslint config] [deps] update `eslint` --- 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 17664483ac..7fd3a288fc 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": "^4.15.0", + "eslint": "^4.16.0", "eslint-find-rules": "^3.1.1", "eslint-plugin-import": "^2.8.0", "eslint-plugin-jsx-a11y": "^6.0.3", @@ -65,9 +65,9 @@ "tape": "^4.8.0" }, "peerDependencies": { - "eslint": "^4.15.0", + "eslint": "^4.16.0", "eslint-plugin-import": "^2.8.0", - "eslint-plugin-jsx-a11y": "^6.0.2", + "eslint-plugin-jsx-a11y": "^6.0.3", "eslint-plugin-react": "^7.4.0" }, "engines": { From c4dcfd93a732c950004c500b8696a50412d8ad82 Mon Sep 17 00:00:00 2001 From: zwei Date: Tue, 16 Jan 2018 16:20:46 +0800 Subject: [PATCH 078/480] [guide] fix indentation in section 4.7 --- README.md | 62 +++++++++++++++++++++++++++---------------------------- 1 file changed, 31 insertions(+), 31 deletions(-) diff --git a/README.md b/README.md index d6f4836fa5..7e5a491ba5 100644 --- a/README.md +++ b/README.md @@ -441,39 +441,39 @@ Other Style Guides - [4.7](#arrays--bracket-newline) Use line breaks after open and before close array brackets if an array has multiple lines - ```javascript - // bad - const arr = [ - [0, 1], [2, 3], [4, 5], - ]; - - const objectInArray = [{ - id: 1, - }, { - id: 2, - }]; - - const numberInArray = [ - 1, 2, - ]; - - // good - const arr = [[0, 1], [2, 3], [4, 5]]; - - const objectInArray = [ - { + ```javascript + // bad + const arr = [ + [0, 1], [2, 3], [4, 5], + ]; + + const objectInArray = [{ id: 1, - }, - { + }, { id: 2, - }, - ]; - - const numberInArray = [ - 1, - 2, - ]; - ``` + }]; + + const numberInArray = [ + 1, 2, + ]; + + // good + const arr = [[0, 1], [2, 3], [4, 5]]; + + const objectInArray = [ + { + id: 1, + }, + { + id: 2, + }, + ]; + + const numberInArray = [ + 1, + 2, + ]; + ``` **[⬆ back to top](#table-of-contents)** From 53b2d7d245ba4abefc0429bfda4a46f099b9ace5 Mon Sep 17 00:00:00 2001 From: Alex Baulch Date: Mon, 22 Jan 2018 10:42:28 +0000 Subject: [PATCH 079/480] [eslint config] [breaking] bump react pragma to v16; update `class-methods-use-this`'s `exceptMethods` to include `componentDidCatch` --- packages/eslint-config-airbnb/rules/react.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/eslint-config-airbnb/rules/react.js b/packages/eslint-config-airbnb/rules/react.js index 8bf726bed6..999d3a1cbb 100644 --- a/packages/eslint-config-airbnb/rules/react.js +++ b/packages/eslint-config-airbnb/rules/react.js @@ -29,6 +29,7 @@ module.exports = { 'componentWillUpdate', 'componentDidUpdate', 'componentWillUnmount', + 'componentDidCatch', ], }], @@ -363,7 +364,7 @@ module.exports = { }, react: { pragma: 'React', - version: '15.0' + version: '16.0' }, propWrapperFunctions: [ 'forbidExtraProps', // https://www.npmjs.com/package/airbnb-prop-types From e9fff7adbf6dd4e3723c12849c407aafd429cf0f Mon Sep 17 00:00:00 2001 From: Sharmila Date: Fri, 26 Jan 2018 10:57:21 -0800 Subject: [PATCH 080/480] [eslint config] [base] [breaking] Prevent line breaks before and after `=` --- README.md | 22 +++++++++++++++++++ .../eslint-config-airbnb-base/rules/style.js | 2 +- 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 7e5a491ba5..e3410a172e 100644 --- a/README.md +++ b/README.md @@ -1699,6 +1699,28 @@ Other Style Guides const truthyCount = array.filter(Boolean).length; ``` + - [13.7](#variables--linebreak) Avoid linebreaks before or after `=` in an assignment. If your assignment violates [`max-len`](https://eslint.org/docs/rules/max-len.html), surround the value in parens. eslint [`operator-linebreak`](https://eslint.org/docs/rules/operator-linebreak.html). + + > Why? Linebreaks surrounding `=` can obfuscate the value of an assignment. + + ```javascript + // bad + const foo = + superLongLongLongLongLongLongLongLongFunctionName(); + + // bad + const foo + = 'superLongLongLongLongLongLongLongLongString'; + + // good + const foo = ( + superLongLongLongLongLongLongLongLongFunctionName() + ); + + // good + const foo = 'superLongLongLongLongLongLongLongLongString'; + ``` + **[⬆ back to top](#table-of-contents)** ## Hoisting diff --git a/packages/eslint-config-airbnb-base/rules/style.js b/packages/eslint-config-airbnb-base/rules/style.js index 81ee87a4fc..bc5e032e4a 100644 --- a/packages/eslint-config-airbnb-base/rules/style.js +++ b/packages/eslint-config-airbnb-base/rules/style.js @@ -405,7 +405,7 @@ module.exports = { // Requires operator at the beginning of the line in multiline statements // https://eslint.org/docs/rules/operator-linebreak - 'operator-linebreak': ['error', 'before'], + 'operator-linebreak': ['error', 'before', { overrides: { '=': 'none' } }], // disallow padding within blocks 'padded-blocks': ['error', { blocks: 'never', classes: 'never', switches: 'never' }], From fc99aefc4c4ca7b66ef665b35a898a0c83ae2b5d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9mie=20Astori?= Date: Fri, 26 Jan 2018 13:16:39 -0500 Subject: [PATCH 081/480] [guide] Use `acc` as `reduce` accumulator instead of `memo` to make it valid In [this part of the `no-param-reassign` configuration](https://github.com/airbnb/javascript/blob/53b2d7d245ba4abefc0429bfda4a46f099b9ace5/packages/eslint-config-airbnb-base/rules/best-practices.js#L174-L175), `acc` is allowed to be mutated (rule [7.12](https://github.com/airbnb/javascript#functions--mutate-params), but `memo` is not. This causes the [rule 4.6 example](https://github.com/airbnb/javascript#arrays--callback-return) in the README to actually be invalid. --- README.md | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index e3410a172e..609c43f201 100644 --- a/README.md +++ b/README.md @@ -404,16 +404,16 @@ Other Style Guides // good [1, 2, 3].map(x => x + 1); - // bad - no returned value means `memo` becomes undefined after the first iteration - [[0, 1], [2, 3], [4, 5]].reduce((memo, item, index) => { - const flatten = memo.concat(item); - memo[index] = flatten; + // bad - no returned value means `acc` becomes undefined after the first iteration + [[0, 1], [2, 3], [4, 5]].reduce((acc, item, index) => { + const flatten = acc.concat(item); + acc[index] = flatten; }); // good - [[0, 1], [2, 3], [4, 5]].reduce((memo, item, index) => { - const flatten = memo.concat(item); - memo[index] = flatten; + [[0, 1], [2, 3], [4, 5]].reduce((acc, item, index) => { + const flatten = acc.concat(item); + acc[index] = flatten; return flatten; }); From 1eefaed4fbb8ff469a864de5dfb652bb04607253 Mon Sep 17 00:00:00 2001 From: Antonio Erdeljac Date: Wed, 10 Jan 2018 09:08:21 +0100 Subject: [PATCH 082/480] [guide] [css] Fixed Italic subtitle in css-in-js README.md --- css-in-javascript/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/css-in-javascript/README.md b/css-in-javascript/README.md index 2b4d5e489b..d6162df55d 100644 --- a/css-in-javascript/README.md +++ b/css-in-javascript/README.md @@ -1,6 +1,6 @@ # Airbnb CSS-in-JavaScript Style Guide -*A mostly reasonable approach to CSS-in-JavaScript +*A mostly reasonable approach to CSS-in-JavaScript* ## Table of Contents From 17b6491ae2ec5da4f8c3a8d6352840dfa0facc17 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ali=20O=C4=9Fuzhan=20Y=C4=B1ld=C4=B1z?= Date: Mon, 4 Sep 2017 00:00:04 +0300 Subject: [PATCH 083/480] add Turkish translation --- react/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/react/README.md b/react/README.md index e1133c3754..bf3ed2666c 100644 --- a/react/README.md +++ b/react/README.md @@ -689,6 +689,7 @@ - ![Br](https://raw.githubusercontent.com/gosquared/flags/master/flags/flags/shiny/24/Brazil.png) **Portuguese**: [ronal2do/javascript](https://github.com/ronal2do/airbnb-react-styleguide) - ![ru](https://raw.githubusercontent.com/gosquared/flags/master/flags/flags/shiny/24/Russia.png) **Russian**: [leonidlebedev/javascript-airbnb](https://github.com/leonidlebedev/javascript-airbnb/tree/master/react) - ![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/tree/master/react) + - ![tr](https://raw.githubusercontent.com/gosquared/flags/master/flags/flags/shiny/24/Turkey.png) **Turkish**: [alioguzhan/react-style-guide](https://github.com/alioguzhan/react-style-guide) - ![ua](https://raw.githubusercontent.com/gosquared/flags/master/flags/flags/shiny/24/Ukraine.png) **Ukrainian**: [ivanzusko/javascript](https://github.com/ivanzusko/javascript/tree/master/react) **[⬆ back to top](#table-of-contents)** From 9a3e6356cf67b9c6bb6002041d854f1483a4a510 Mon Sep 17 00:00:00 2001 From: David Clark Date: Sun, 28 Jan 2018 00:38:48 -0700 Subject: [PATCH 084/480] Added GreenChef organization to README --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 609c43f201..a304b078db 100644 --- a/README.md +++ b/README.md @@ -3519,6 +3519,7 @@ Other Style Guides - **General Electric**: [GeneralElectric/javascript](https://github.com/GeneralElectric/javascript) - **Generation Tux**: [GenerationTux/javascript](https://github.com/generationtux/styleguide) - **GoodData**: [gooddata/gdc-js-style](https://github.com/gooddata/gdc-js-style) + - **GreenChef**: [greenchef/javascript](https://github.com/greenchef/javascript) - **Grooveshark**: [grooveshark/javascript](https://github.com/grooveshark/javascript) - **Grupo-Abraxas**: [Grupo-Abraxas/javascript](https://github.com/Grupo-Abraxas/javascript) - **Honey**: [honeyscience/javascript](https://github.com/honeyscience/javascript) From aefff97bd10e8e17963749bd1013a6927d90fe29 Mon Sep 17 00:00:00 2001 From: ParkSB Date: Tue, 30 Jan 2018 11:49:24 +0900 Subject: [PATCH 085/480] Update Korean translation link --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index a304b078db..5a6d678f98 100644 --- a/README.md +++ b/README.md @@ -3591,7 +3591,7 @@ Other Style Guides - ![de](https://raw.githubusercontent.com/gosquared/flags/master/flags/flags/shiny/24/Germany.png) **German**: [timofurrer/javascript-style-guide](https://github.com/timofurrer/javascript-style-guide) - ![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) + - ![kr](https://raw.githubusercontent.com/gosquared/flags/master/flags/flags/shiny/24/South-Korea.png) **Korean**: [ParkSB/javascript-style-guide](https://github.com/ParkSB/javascript-style-guide) - ![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 c5411a42d2385762ec879d900dcfdcfc60f54f62 Mon Sep 17 00:00:00 2001 From: Teddy Katz Date: Sun, 4 Feb 2018 17:11:01 -0500 Subject: [PATCH 086/480] Suggest using WeakMaps when hidden properties are needed This updates the "trailing or leading underscores" guideline to suggest an better way to make properties hidden, as an alternative to just removing the underscore and making the property public. --- README.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/README.md b/README.md index 5a6d678f98..d070347150 100644 --- a/README.md +++ b/README.md @@ -2993,6 +2993,11 @@ Other Style Guides // good this.firstName = 'Panda'; + + // good, in environments where WeakMaps are available + // see https://kangax.github.io/compat-table/es6/#test-WeakMap + const firstNames = new WeakMap(); + firstNames.set(this, 'Panda'); ``` From 16190d8cb5cb9b8257aec53a04ef3efc25ad9dff Mon Sep 17 00:00:00 2001 From: Ajay Poshak Date: Sun, 4 Feb 2018 18:52:51 +0530 Subject: [PATCH 087/480] Note added for translation --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index d070347150..ee02c0e97c 100644 --- a/README.md +++ b/README.md @@ -8,6 +8,8 @@ [![Downloads](https://img.shields.io/npm/dm/eslint-config-airbnb-base.svg)](https://www.npmjs.com/package/eslint-config-airbnb-base) [![Gitter](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/airbnb/javascript?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge) +This guide is available in other languages too. See [Translation](#translation) + Other Style Guides - [ES5 (Deprecated)](https://github.com/airbnb/javascript/tree/es5-deprecated/es5) From c8b1164105064b7786b24258f53f6237fb4bdd15 Mon Sep 17 00:00:00 2001 From: Gil Birman Date: Thu, 8 Feb 2018 13:07:34 -0800 Subject: [PATCH 088/480] control-statement--value-selection 2 --- README.md | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/README.md b/README.md index ee02c0e97c..556e874c17 100644 --- a/README.md +++ b/README.md @@ -2175,6 +2175,20 @@ Other Style Guides } ``` + + - [17.2](#control-statements--value-selection) Don't use selection operators in place of control statements. + + + ```javascript + // bad + !isRunning && startRunning(); + + // good + if (!isRunning) { + startRunning(); + } + ``` + **[⬆ back to top](#table-of-contents)** ## Comments From 4c870cbd4090016fa36d15f8b2673324c83aabcc Mon Sep 17 00:00:00 2001 From: Kevin Ji Date: Thu, 8 Feb 2018 11:29:44 -0800 Subject: [PATCH 089/480] [guide] Fix function signature spacing --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 556e874c17..ead4903bdb 100644 --- a/README.md +++ b/README.md @@ -2816,7 +2816,7 @@ Other Style Guides // bad - raises exception const reaction = "No! That's impossible!" - (async function meanwhileOnTheFalcon(){ + (async function meanwhileOnTheFalcon() { // handle `leia`, `lando`, `chewie`, `r2`, `c3p0` // ... }()) @@ -2836,7 +2836,7 @@ Other Style Guides // good const reaction = "No! That's impossible!"; - (async function meanwhileOnTheFalcon(){ + (async function meanwhileOnTheFalcon() { // handle `leia`, `lando`, `chewie`, `r2`, `c3p0` // ... }()); From cfe10c17d3f1df7325f8d40a4fcb2486254892f1 Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Thu, 8 Feb 2018 21:45:09 -0800 Subject: [PATCH 090/480] fix linting error in guide --- README.md | 1 - 1 file changed, 1 deletion(-) diff --git a/README.md b/README.md index ead4903bdb..c2840b0b6f 100644 --- a/README.md +++ b/README.md @@ -2178,7 +2178,6 @@ Other Style Guides - [17.2](#control-statements--value-selection) Don't use selection operators in place of control statements. - ```javascript // bad !isRunning && startRunning(); From 901fd85b7cd9386f20a86530f56ec4661b4f18e7 Mon Sep 17 00:00:00 2001 From: Rauno Freiberg Date: Mon, 19 Feb 2018 14:58:24 +0200 Subject: [PATCH 091/480] Use single quotes for consistency --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index c2840b0b6f..b299c9be10 100644 --- a/README.md +++ b/README.md @@ -2162,7 +2162,7 @@ Other Style Guides // good if ( - (foo === 123 || bar === "abc") + (foo === 123 || bar === 'abc') && doesItLookGoodWhenItBecomesThatLong() && isThisReallyHappening() ) { From ff1c12178e268d4ee33321b4aab39571739af49d Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Fri, 26 Jan 2018 23:31:30 -0800 Subject: [PATCH 092/480] [eslint config] [breaking] update `eslint-plugin-react` to `v7.6`; update rule configs --- packages/eslint-config-airbnb/package.json | 4 +- packages/eslint-config-airbnb/rules/react.js | 109 ++++++++++++++++--- 2 files changed, 95 insertions(+), 18 deletions(-) diff --git a/packages/eslint-config-airbnb/package.json b/packages/eslint-config-airbnb/package.json index 7fd3a288fc..0e52b0e0ea 100644 --- a/packages/eslint-config-airbnb/package.json +++ b/packages/eslint-config-airbnb/package.json @@ -58,7 +58,7 @@ "eslint-find-rules": "^3.1.1", "eslint-plugin-import": "^2.8.0", "eslint-plugin-jsx-a11y": "^6.0.3", - "eslint-plugin-react": "^7.4.0", + "eslint-plugin-react": "^7.6.1", "in-publish": "^2.0.0", "react": ">= 0.13.0", "safe-publish-latest": "^1.1.1", @@ -68,7 +68,7 @@ "eslint": "^4.16.0", "eslint-plugin-import": "^2.8.0", "eslint-plugin-jsx-a11y": "^6.0.3", - "eslint-plugin-react": "^7.4.0" + "eslint-plugin-react": "^7.6.1" }, "engines": { "node": ">= 4" diff --git a/packages/eslint-config-airbnb/rules/react.js b/packages/eslint-config-airbnb/rules/react.js index 999d3a1cbb..6332546b26 100644 --- a/packages/eslint-config-airbnb/rules/react.js +++ b/packages/eslint-config-airbnb/rules/react.js @@ -38,8 +38,16 @@ module.exports = { 'react/display-name': ['off', { ignoreTranspilerName: false }], // Forbid certain propTypes (any, array, object) - // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/forbid-prop-types.md - 'react/forbid-prop-types': ['error', { forbid: ['any', 'array', 'object'] }], + // https://github.com/yannickcr/eslint-plugin-react/blob/843d71a432baf0f01f598d7cf1eea75ad6896e4b/docs/rules/forbid-prop-types.md + 'react/forbid-prop-types': ['error', { + forbid: ['any', 'array', 'object'], + checkContextTypes: true, + checkChildContextTypes: true, + }], + + // Forbid certain props on DOM Nodes + // https://github.com/yannickcr/eslint-plugin-react/blob/843d71a432baf0f01f598d7cf1eea75ad6896e4b/docs/rules/forbid-dom-props.md + 'react/forbid-dom-props': ['off', { forbid: [] }], // Enforce boolean attributes notation in JSX // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-boolean-value.md @@ -109,6 +117,7 @@ module.exports = { ignoreCase: true, callbacksLast: false, requiredFirst: false, + sortShapeProp: true, }], // Deprecated in favor of react/jsx-sort-props @@ -125,6 +134,12 @@ module.exports = { reservedFirst: true, }], + // Enforce defaultProps declarations alphabetical sorting + // https://github.com/yannickcr/eslint-plugin-react/blob/843d71a432baf0f01f598d7cf1eea75ad6896e4b/docs/rules/jsx-sort-default-props.md + 'react/jsx-sort-default-props': ['off', { + ignoreCase: true, + }], + // Prevent React to be incorrectly marked as unused // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-uses-react.md 'react/jsx-uses-react': ['error'], @@ -207,28 +222,59 @@ module.exports = { 'react/self-closing-comp': 'error', // Enforce component methods order - // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/sort-comp.md + // https://github.com/yannickcr/eslint-plugin-react/blob/843d71a432baf0f01f598d7cf1eea75ad6896e4b/docs/rules/sort-comp.md 'react/sort-comp': ['error', { order: [ 'static-methods', + 'instance-variables', 'lifecycle', '/^on.+$/', 'getters', 'setters', '/^(get|set)(?!(InitialState$|DefaultProps$|ChildContext$)).+$/', + 'instance-methods', 'everything-else', - '/^render.+$/', - 'render' + 'rendering', ], + groups: { + lifecycle: [ + 'displayName', + 'propTypes', + 'contextTypes', + 'childContextTypes', + 'mixins', + 'statics', + 'defaultProps', + 'constructor', + 'getDefaultProps', + 'getInitialState', + 'state', + 'getChildContext', + 'componentWillMount', + 'componentDidMount', + 'componentWillReceiveProps', + 'shouldComponentUpdate', + 'componentWillUpdate', + 'componentDidUpdate', + 'componentWillUnmount', + ], + rendering: [ + '/^render.+$/', + 'render' + ], + }, }], // Prevent missing parentheses around multilines JSX - // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-wrap-multilines.md + // https://github.com/yannickcr/eslint-plugin-react/blob/843d71a432baf0f01f598d7cf1eea75ad6896e4b/docs/rules/jsx-wrap-multilines.md 'react/jsx-wrap-multilines': ['error', { - declaration: true, - assignment: true, - return: true, - arrow: true, + declaration: 'parens-new-line', + assignment: 'parens-new-line', + return: 'parens-new-line', + arrow: 'parens-new-line', + condition: 'parens-new-line', + logical: 'parens-new-line', + prop: 'parens-new-line', }], // Require that the first prop in a JSX element be on a new line when the element is multiline @@ -300,11 +346,12 @@ module.exports = { 'react/no-children-prop': 'error', // Validate whitespace in and around the JSX opening and closing brackets - // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-tag-spacing.md + // https://github.com/yannickcr/eslint-plugin-react/blob/843d71a432baf0f01f598d7cf1eea75ad6896e4b/docs/rules/jsx-tag-spacing.md 'react/jsx-tag-spacing': ['error', { closingSlash: 'never', beforeSelfClosing: 'always', - afterOpening: 'never' + afterOpening: 'never', + beforeClosing: 'never', }], // Enforce spaces before the closing bracket of self-closing JSX elements @@ -317,8 +364,10 @@ module.exports = { 'react/no-array-index-key': 'error', // Enforce a defaultProps definition for every prop that is not a required prop - // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/require-default-props.md - 'react/require-default-props': 'error', + // https://github.com/yannickcr/eslint-plugin-react/blob/843d71a432baf0f01f598d7cf1eea75ad6896e4b/docs/rules/require-default-props.md + 'react/require-default-props': ['error', { + forbidDefaultForRequired: true, + }], // Forbids using non-exported propTypes // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/forbid-foreign-prop-types.md @@ -341,10 +390,11 @@ module.exports = { 'react/no-unused-state': 'error', // Enforces consistent naming for boolean props - // https://github.com/yannickcr/eslint-plugin-react/blob/73abadb697034b5ccb514d79fb4689836fe61f91/docs/rules/boolean-prop-naming.md + // https://github.com/yannickcr/eslint-plugin-react/blob/843d71a432baf0f01f598d7cf1eea75ad6896e4b/docs/rules/boolean-prop-naming.md 'react/boolean-prop-naming': ['off', { propTypeNames: ['bool', 'mutuallyExclusiveTrueProps'], rule: '^(is|has)[A-Z]([A-Za-z0-9]?)+', + message: '', }], // Prevents common casing typos @@ -353,7 +403,34 @@ module.exports = { // Enforce curly braces or disallow unnecessary curly braces in JSX props and/or children // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-curly-brace-presence.md - 'react/jsx-curly-brace-presence': ['error', { props: 'never', children: 'never' }] + 'react/jsx-curly-brace-presence': ['error', { props: 'never', children: 'never' }], + + // 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', + + // 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'], + + // 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 + 'react/no-access-state-in-setstate': 'error', + + // Prevent usage of button elements without an explicit type attribute + // https://github.com/yannickcr/eslint-plugin-react/blob/843d71a432baf0f01f598d7cf1eea75ad6896e4b/docs/rules/button-has-type.md + 'react/button-has-type': ['error', { + button: true, + submit: true, + reset: false, + }], + + // Ensures inline tags are not rendered without spaces between them + 'react/jsx-child-element-spacing': 'off', + + // Prevent this from being used in stateless functional components + // https://github.com/yannickcr/eslint-plugin-react/blob/843d71a432baf0f01f598d7cf1eea75ad6896e4b/docs/rules/no-this-in-sfc.md + 'react/no-this-in-sfc': 'error', }, settings: { From 3c3074e502dc9ebc7dbdad372df474e49f52d512 Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Tue, 20 Feb 2018 00:10:46 -0800 Subject: [PATCH 093/480] [eslint config] [*] [deps] update `eslint`, `eslint-find-rules`, `eslint-plugin-react`, `tape` --- packages/eslint-config-airbnb-base/package.json | 6 +++--- packages/eslint-config-airbnb/package.json | 12 ++++++------ packages/eslint-config-airbnb/rules/react.js | 7 ++++++- 3 files changed, 15 insertions(+), 10 deletions(-) diff --git a/packages/eslint-config-airbnb-base/package.json b/packages/eslint-config-airbnb-base/package.json index 5d4cd5ccc5..a3d13d59f0 100644 --- a/packages/eslint-config-airbnb-base/package.json +++ b/packages/eslint-config-airbnb-base/package.json @@ -51,12 +51,12 @@ "babel-preset-airbnb": "^2.4.0", "babel-tape-runner": "^2.0.1", "editorconfig-tools": "^0.1.1", - "eslint": "^4.16.0", - "eslint-find-rules": "^3.1.1", + "eslint": "^4.18.0", + "eslint-find-rules": "^3.2.0", "eslint-plugin-import": "^2.8.0", "in-publish": "^2.0.0", "safe-publish-latest": "^1.1.1", - "tape": "^4.8.0" + "tape": "^4.9.0" }, "peerDependencies": { "eslint": "^4.16.0", diff --git a/packages/eslint-config-airbnb/package.json b/packages/eslint-config-airbnb/package.json index 0e52b0e0ea..66c0b8294c 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": "^4.16.0", - "eslint-find-rules": "^3.1.1", + "eslint": "^4.18.0", + "eslint-find-rules": "^3.2.0", "eslint-plugin-import": "^2.8.0", "eslint-plugin-jsx-a11y": "^6.0.3", - "eslint-plugin-react": "^7.6.1", + "eslint-plugin-react": "^7.7.0", "in-publish": "^2.0.0", "react": ">= 0.13.0", "safe-publish-latest": "^1.1.1", - "tape": "^4.8.0" + "tape": "^4.9.0" }, "peerDependencies": { - "eslint": "^4.16.0", + "eslint": "^4.18.0", "eslint-plugin-import": "^2.8.0", "eslint-plugin-jsx-a11y": "^6.0.3", - "eslint-plugin-react": "^7.6.1" + "eslint-plugin-react": "^7.7.0" }, "engines": { "node": ">= 4" diff --git a/packages/eslint-config-airbnb/rules/react.js b/packages/eslint-config-airbnb/rules/react.js index 6332546b26..7d8145a17a 100644 --- a/packages/eslint-config-airbnb/rules/react.js +++ b/packages/eslint-config-airbnb/rules/react.js @@ -371,7 +371,8 @@ module.exports = { // Forbids using non-exported propTypes // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/forbid-foreign-prop-types.md - 'react/forbid-foreign-prop-types': 'off', + // TODO: enable? + 'react/forbid-foreign-prop-types': ['off', { 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 @@ -431,6 +432,10 @@ module.exports = { // Prevent this from being used in stateless functional components // https://github.com/yannickcr/eslint-plugin-react/blob/843d71a432baf0f01f598d7cf1eea75ad6896e4b/docs/rules/no-this-in-sfc.md 'react/no-this-in-sfc': 'error', + + // Validate JSX maximum depth + // https://github.com/yannickcr/eslint-plugin-react/blob/abe8381c0d6748047224c430ce47f02e40160ed0/docs/rules/jsx-max-depth.md + 'react/jsx-max-depth': 'off', }, settings: { From a7a7cab504576b32157edaf92c8d4613fc235c54 Mon Sep 17 00:00:00 2001 From: Song Xie Date: Wed, 21 Feb 2018 14:44:58 -0800 Subject: [PATCH 094/480] [guide] Add an anchor for rule 13.7 --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index b299c9be10..881eb01490 100644 --- a/README.md +++ b/README.md @@ -1701,6 +1701,7 @@ Other Style Guides const truthyCount = array.filter(Boolean).length; ``` + - [13.7](#variables--linebreak) Avoid linebreaks before or after `=` in an assignment. If your assignment violates [`max-len`](https://eslint.org/docs/rules/max-len.html), surround the value in parens. eslint [`operator-linebreak`](https://eslint.org/docs/rules/operator-linebreak.html). > Why? Linebreaks surrounding `=` can obfuscate the value of an assignment. From ea14bda1101abc2971c86b663fa7eed6bd4e6be8 Mon Sep 17 00:00:00 2001 From: Honza Javorek Date: Thu, 22 Feb 2018 15:48:50 +0100 Subject: [PATCH 095/480] Add licenses to sub packages --- packages/eslint-config-airbnb-base/LICENSE.md | 21 +++++++++++++++++++ packages/eslint-config-airbnb/LICENSE.md | 21 +++++++++++++++++++ 2 files changed, 42 insertions(+) create mode 100644 packages/eslint-config-airbnb-base/LICENSE.md create mode 100644 packages/eslint-config-airbnb/LICENSE.md diff --git a/packages/eslint-config-airbnb-base/LICENSE.md b/packages/eslint-config-airbnb-base/LICENSE.md new file mode 100644 index 0000000000..69d80c0252 --- /dev/null +++ b/packages/eslint-config-airbnb-base/LICENSE.md @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2012 Airbnb + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/packages/eslint-config-airbnb/LICENSE.md b/packages/eslint-config-airbnb/LICENSE.md new file mode 100644 index 0000000000..69d80c0252 --- /dev/null +++ b/packages/eslint-config-airbnb/LICENSE.md @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2012 Airbnb + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. From fd68fdbd2270021eaf0fcc6e4a4f66c261b5b0da Mon Sep 17 00:00:00 2001 From: Rauno Freiberg Date: Tue, 20 Feb 2018 19:28:52 +0200 Subject: [PATCH 096/480] [guide] [react] add comment about what JS standards are followed Seen a few pull requests for the React style guide that try to introduce features that aren't yet in stage >= 3 (static class fields for i.e), so I've decided to add a comment to the beginning of the guide. Not sure if this is the right place to put it, but here it is. This disclaimer might help: 1) give the community an idea what standards this guide is based on 2) prevent redundant pull requests --- react/README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/react/README.md b/react/README.md index bf3ed2666c..0db1fa8d3d 100644 --- a/react/README.md +++ b/react/README.md @@ -2,6 +2,8 @@ *A mostly reasonable approach to React and JSX* +This style guide is mostly based on the standards that are currently prevalent in JavaScript, although some conventions (i.e async/await or static class fields) may still be included or prohibited on a case-by-case basis. Currently, anything prior to stage 3 is not included nor recommended in this guide. + ## Table of Contents 1. [Basic Rules](#basic-rules) From 1fbeabd0c4b5d6ece9b7b966aa594854c6da9930 Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Thu, 22 Feb 2018 13:51:02 -0800 Subject: [PATCH 097/480] [eslint config] [*] [breaking] [deps] update `eslint`, `eslint-plugin-import` --- .../eslint-config-airbnb-base/package.json | 8 ++++---- .../rules/imports.js | 20 +++++++++++++++++++ packages/eslint-config-airbnb/package.json | 8 ++++---- 3 files changed, 28 insertions(+), 8 deletions(-) diff --git a/packages/eslint-config-airbnb-base/package.json b/packages/eslint-config-airbnb-base/package.json index a3d13d59f0..f74a57d8e2 100644 --- a/packages/eslint-config-airbnb-base/package.json +++ b/packages/eslint-config-airbnb-base/package.json @@ -51,16 +51,16 @@ "babel-preset-airbnb": "^2.4.0", "babel-tape-runner": "^2.0.1", "editorconfig-tools": "^0.1.1", - "eslint": "^4.18.0", + "eslint": "^4.18.1", "eslint-find-rules": "^3.2.0", - "eslint-plugin-import": "^2.8.0", + "eslint-plugin-import": "^2.9.0", "in-publish": "^2.0.0", "safe-publish-latest": "^1.1.1", "tape": "^4.9.0" }, "peerDependencies": { - "eslint": "^4.16.0", - "eslint-plugin-import": "^2.8.0" + "eslint": "^4.18.1", + "eslint-plugin-import": "^2.9.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 9536e9b4a4..88f704a996 100644 --- a/packages/eslint-config-airbnb-base/rules/imports.js +++ b/packages/eslint-config-airbnb-base/rules/imports.js @@ -211,5 +211,25 @@ module.exports = { // https://github.com/benmosher/eslint-plugin-import/blob/98acd6afd04dcb6920b81330114e146dc8532ea4/docs/rules/exports-last.md // TODO: enable? 'import/exports-last': 'off', + + // Reports when named exports are not grouped together in a single export declaration + // or when multiple assignments to CommonJS module.exports or exports object are present + // in a single file. + // https://github.com/benmosher/eslint-plugin-import/blob/44a038c06487964394b1e15b64f3bd34e5d40cde/docs/rules/group-exports.md + 'import/group-exports': 'off', + + // forbid default exports. this is a terrible rule, do not use it. + // https://github.com/benmosher/eslint-plugin-import/blob/44a038c06487964394b1e15b64f3bd34e5d40cde/docs/rules/no-default-export.md + 'import/no-default-export': 'off', + + // Forbid a module from importing itself + // https://github.com/benmosher/eslint-plugin-import/blob/44a038c06487964394b1e15b64f3bd34e5d40cde/docs/rules/no-self-import.md + // TODO: enable + 'import/no-self-import': 'off', + + // Ensures that there are no useless path segments + // https://github.com/benmosher/eslint-plugin-import/issues/1032 + // TODO: enable + 'import/no-useless-path-segments': 'off', }, }; diff --git a/packages/eslint-config-airbnb/package.json b/packages/eslint-config-airbnb/package.json index 66c0b8294c..b67dd57cdb 100644 --- a/packages/eslint-config-airbnb/package.json +++ b/packages/eslint-config-airbnb/package.json @@ -54,9 +54,9 @@ "babel-preset-airbnb": "^2.4.0", "babel-tape-runner": "^2.0.1", "editorconfig-tools": "^0.1.1", - "eslint": "^4.18.0", + "eslint": "^4.18.1", "eslint-find-rules": "^3.2.0", - "eslint-plugin-import": "^2.8.0", + "eslint-plugin-import": "^2.9.0", "eslint-plugin-jsx-a11y": "^6.0.3", "eslint-plugin-react": "^7.7.0", "in-publish": "^2.0.0", @@ -65,8 +65,8 @@ "tape": "^4.9.0" }, "peerDependencies": { - "eslint": "^4.18.0", - "eslint-plugin-import": "^2.8.0", + "eslint": "^4.18.1", + "eslint-plugin-import": "^2.9.0", "eslint-plugin-jsx-a11y": "^6.0.3", "eslint-plugin-react": "^7.7.0" }, From c82500d7fa65e199d3df0ce52783a058fb6f4683 Mon Sep 17 00:00:00 2001 From: Thomas Grainger Date: Thu, 22 Feb 2018 01:07:09 +0000 Subject: [PATCH 098/480] [eslint config] [base] [breaking] enable `no-useless-path-segments` --- packages/eslint-config-airbnb-base/rules/imports.js | 3 +-- packages/eslint-config-airbnb-base/test/test-base.js | 2 +- packages/eslint-config-airbnb/test/test-react-order.js | 2 +- 3 files changed, 3 insertions(+), 4 deletions(-) diff --git a/packages/eslint-config-airbnb-base/rules/imports.js b/packages/eslint-config-airbnb-base/rules/imports.js index 88f704a996..005656e6f8 100644 --- a/packages/eslint-config-airbnb-base/rules/imports.js +++ b/packages/eslint-config-airbnb-base/rules/imports.js @@ -229,7 +229,6 @@ module.exports = { // Ensures that there are no useless path segments // https://github.com/benmosher/eslint-plugin-import/issues/1032 - // TODO: enable - 'import/no-useless-path-segments': 'off', + 'import/no-useless-path-segments': 'error', }, }; diff --git a/packages/eslint-config-airbnb-base/test/test-base.js b/packages/eslint-config-airbnb-base/test/test-base.js index 01b5dd12d3..f907581502 100644 --- a/packages/eslint-config-airbnb-base/test/test-base.js +++ b/packages/eslint-config-airbnb-base/test/test-base.js @@ -2,7 +2,7 @@ import fs from 'fs'; import path from 'path'; import test from 'tape'; -import index from '../'; +import index from '..'; const files = { ...{ index } }; // object spread is to test parsing diff --git a/packages/eslint-config-airbnb/test/test-react-order.js b/packages/eslint-config-airbnb/test/test-react-order.js index b28792a6d5..2527f04e19 100644 --- a/packages/eslint-config-airbnb/test/test-react-order.js +++ b/packages/eslint-config-airbnb/test/test-react-order.js @@ -1,6 +1,6 @@ import test from 'tape'; import { CLIEngine } from 'eslint'; -import eslintrc from '../'; +import eslintrc from '..'; import reactRules from '../rules/react'; import reactA11yRules from '../rules/react-a11y'; From 6373dab9901a29105712ec040006f2352a318dd6 Mon Sep 17 00:00:00 2001 From: Sharmila Date: Wed, 21 Feb 2018 20:18:56 -0800 Subject: [PATCH 099/480] Adds config entry point with only whitespace rules enabled Adds a change to eslint-config-airbnb and eslint-config-airbnb-base to pull a list of rules from the project root and return a config with all rules turned off except the whitespace rules explicitly listed in the array. Also adds entry point data to readme. --- packages/eslint-config-airbnb-base/README.md | 4 + .../eslint-config-airbnb-base/package.json | 3 +- .../eslint-config-airbnb-base/whitespace.js | 73 ++++++++++++++++ packages/eslint-config-airbnb/README.md | 4 + packages/eslint-config-airbnb/package.json | 3 +- packages/eslint-config-airbnb/whitespace.js | 87 +++++++++++++++++++ 6 files changed, 172 insertions(+), 2 deletions(-) create mode 100644 packages/eslint-config-airbnb-base/whitespace.js create mode 100644 packages/eslint-config-airbnb/whitespace.js diff --git a/packages/eslint-config-airbnb-base/README.md b/packages/eslint-config-airbnb-base/README.md index 686ccb06e8..fa0152eb04 100644 --- a/packages/eslint-config-airbnb-base/README.md +++ b/packages/eslint-config-airbnb-base/README.md @@ -84,6 +84,10 @@ Lints ES5 and below. Requires `eslint` and `eslint-plugin-import`. See [Airbnb's overarching ESLint config](https://npmjs.com/eslint-config-airbnb), [Airbnb's Javascript styleguide](https://github.com/airbnb/javascript), and the [ESlint config docs](https://eslint.org/docs/user-guide/configuring#extending-configuration-files) for more information. +### 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). + ## Improving this config Consider adding test cases if you're making complicated rules changes, like anything involving regexes. Perhaps in a distant future, we could use literate programming to structure our README as test cases for our .eslintrc? diff --git a/packages/eslint-config-airbnb-base/package.json b/packages/eslint-config-airbnb-base/package.json index f74a57d8e2..6dd7461c8e 100644 --- a/packages/eslint-config-airbnb-base/package.json +++ b/packages/eslint-config-airbnb-base/package.json @@ -66,6 +66,7 @@ "node": ">= 4" }, "dependencies": { - "eslint-restricted-globals": "^0.1.1" + "eslint-restricted-globals": "^0.1.1", + "object.entries": "^1.0.4" } } diff --git a/packages/eslint-config-airbnb-base/whitespace.js b/packages/eslint-config-airbnb-base/whitespace.js new file mode 100644 index 0000000000..408c0b72b6 --- /dev/null +++ b/packages/eslint-config-airbnb-base/whitespace.js @@ -0,0 +1,73 @@ +const baseConfig = require('.'); +const entries = require('object.entries'); +const { CLIEngine } = require('eslint'); + +function onlyErrorOnRules(rulesToError, config) { + const errorsOnly = { ...config }; + const cli = new CLIEngine({ baseConfig: config, useEslintrc: false }); + const baseRules = cli.getConfigForFile('./').rules; + + entries(baseRules).forEach(([key, value]) => { + if (rulesToError.indexOf(key) === -1) { + if (Array.isArray(value)) { + errorsOnly.rules[key] = ['warn'].concat(value.slice(1)); + } else if (typeof value === 'number') { + errorsOnly.rules[key] = 1; + } else { + errorsOnly.rules[key] = 'warn'; + } + } + }); + + return errorsOnly; +} + +module.exports = onlyErrorOnRules([ + 'array-bracket-newline', + 'array-bracket-spacing', + 'array-element-newline', + 'arrow-spacing', + 'block-spacing', + 'comma-spacing', + 'computed-property-spacing', + 'dot-location', + 'eol-last', + 'func-call-spacing', + 'function-paren-newline', + 'generator-star-spacing', + 'implicit-arrow-linebreak', + 'indent', + 'key-spacing', + 'keyword-spacing', + 'line-comment-position', + 'linebreak-style', + 'multiline-ternary', + 'newline-per-chained-call', + 'no-irregular-whitespace', + 'no-mixed-spaces-and-tabs', + 'no-multi-spaces', + 'no-regex-spaces', + 'no-spaced-func', + 'no-trailing-spaces', + 'no-whitespace-before-property', + 'nonblock-statement-body-position', + 'object-curly-newline', + 'object-curly-spacing', + 'object-property-newline', + 'one-var-declaration-per-line', + 'operator-linebreak', + 'padded-blocks', + 'padding-line-between-statements', + 'rest-spread-spacing', + 'semi-spacing', + 'semi-style', + 'space-before-blocks', + 'space-before-function-paren', + 'space-in-parens', + 'space-infix-ops', + 'space-unary-ops', + 'spaced-comment', + 'switch-colon-spacing', + 'template-tag-spacing', + 'import/newline-after-import', +], baseConfig); diff --git a/packages/eslint-config-airbnb/README.md b/packages/eslint-config-airbnb/README.md index 88e6c80d23..2f341ec187 100644 --- a/packages/eslint-config-airbnb/README.md +++ b/packages/eslint-config-airbnb/README.md @@ -55,6 +55,10 @@ If you use yarn, run `npm info "eslint-config-airbnb@latest" peerDependencies` t 2. Add `"extends": "airbnb"` to your .eslintrc +### 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). + ### eslint-config-airbnb/base This entry point is deprecated. See [eslint-config-airbnb-base](https://npmjs.com/eslint-config-airbnb-base). diff --git a/packages/eslint-config-airbnb/package.json b/packages/eslint-config-airbnb/package.json index b67dd57cdb..9dc6c92a45 100644 --- a/packages/eslint-config-airbnb/package.json +++ b/packages/eslint-config-airbnb/package.json @@ -48,7 +48,8 @@ }, "homepage": "https://github.com/airbnb/javascript", "dependencies": { - "eslint-config-airbnb-base": "^12.1.0" + "eslint-config-airbnb-base": "^12.1.0", + "object.entries": "^1.0.4" }, "devDependencies": { "babel-preset-airbnb": "^2.4.0", diff --git a/packages/eslint-config-airbnb/whitespace.js b/packages/eslint-config-airbnb/whitespace.js new file mode 100644 index 0000000000..f533385e80 --- /dev/null +++ b/packages/eslint-config-airbnb/whitespace.js @@ -0,0 +1,87 @@ +const baseConfig = require('.'); +const entries = require('object.entries'); +const { CLIEngine } = require('eslint'); + +function onlyErrorOnRules(rulesToError, config) { + const errorsOnly = { ...config }; + const cli = new CLIEngine({ baseConfig: config, useEslintrc: false }); + const baseRules = cli.getConfigForFile('./').rules; + + entries(baseRules).forEach(([key, value]) => { + if (rulesToError.indexOf(key) === -1) { + if (Array.isArray(value)) { + errorsOnly.rules[key] = ['warn'].concat(value.slice(1)); + } else if (typeof value === 'number') { + errorsOnly.rules[key] = 1; + } else { + errorsOnly.rules[key] = 'warn'; + } + } + }); + + return errorsOnly; +} + +module.exports = onlyErrorOnRules([ + 'array-bracket-newline', + 'array-bracket-spacing', + 'array-element-newline', + 'arrow-spacing', + 'block-spacing', + 'comma-spacing', + 'computed-property-spacing', + 'dot-location', + 'eol-last', + 'func-call-spacing', + 'function-paren-newline', + 'generator-star-spacing', + 'implicit-arrow-linebreak', + 'indent', + 'key-spacing', + 'keyword-spacing', + 'line-comment-position', + 'linebreak-style', + 'multiline-ternary', + 'newline-per-chained-call', + 'no-irregular-whitespace', + 'no-mixed-spaces-and-tabs', + 'no-multi-spaces', + 'no-regex-spaces', + 'no-spaced-func', + 'no-trailing-spaces', + 'no-whitespace-before-property', + 'nonblock-statement-body-position', + 'object-curly-newline', + 'object-curly-spacing', + 'object-property-newline', + 'one-var-declaration-per-line', + 'operator-linebreak', + 'padded-blocks', + 'padding-line-between-statements', + 'rest-spread-spacing', + 'semi-spacing', + 'semi-style', + 'space-before-blocks', + 'space-before-function-paren', + 'space-in-parens', + 'space-infix-ops', + 'space-unary-ops', + 'spaced-comment', + 'switch-colon-spacing', + 'template-tag-spacing', + 'import/newline-after-import', + // eslint-plugin-react rules + 'react/jsx-child-element-spacing', + 'react/jsx-closing-bracket-location', + 'react/jsx-closing-tag-location', + 'react/jsx-curly-spacing', + 'react/jsx-equals-spacing', + 'react/jsx-first-prop-newline', + 'react/jsx-indent', + 'react/jsx-indent-props', + 'react/jsx-max-props-per-line', + 'react/jsx-one-expression-per-line', + 'react/jsx-space-before-closing', + 'react/jsx-tag-spacing', + 'react/jsx-wrap-multilines', +], baseConfig); From 40dbeace170d3cf309e857dd9a9caa092d6aac2c Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Wed, 28 Feb 2018 23:00:19 -0800 Subject: [PATCH 100/480] [Tests] ensure all entry points parse --- packages/eslint-config-airbnb-base/package.json | 1 + .../eslint-config-airbnb-base/test/requires.js | 16 ++++++++++++++++ packages/eslint-config-airbnb/package.json | 1 + packages/eslint-config-airbnb/test/requires.js | 17 +++++++++++++++++ 4 files changed, 35 insertions(+) create mode 100644 packages/eslint-config-airbnb-base/test/requires.js create mode 100644 packages/eslint-config-airbnb/test/requires.js diff --git a/packages/eslint-config-airbnb-base/package.json b/packages/eslint-config-airbnb-base/package.json index 6dd7461c8e..608046874c 100644 --- a/packages/eslint-config-airbnb-base/package.json +++ b/packages/eslint-config-airbnb-base/package.json @@ -6,6 +6,7 @@ "scripts": { "prelint": "editorconfig-tools check * rules/* test/*", "lint": "eslint --report-unused-disable-directives .", + "pretests-only": "node ./test/requires", "tests-only": "babel-tape-runner ./test/test-*.js", "prepublish": "(in-install || eslint-find-rules --unused) && (not-in-publish || npm test) && safe-publish-latest", "pretest": "npm run --silent lint", diff --git a/packages/eslint-config-airbnb-base/test/requires.js b/packages/eslint-config-airbnb-base/test/requires.js new file mode 100644 index 0000000000..180a09bf42 --- /dev/null +++ b/packages/eslint-config-airbnb-base/test/requires.js @@ -0,0 +1,16 @@ +/* eslint + strict: 0, + global-require: 0, + */ + +'use strict'; + +const test = require('tape'); + +test('all entry points parse', (t) => { + t.doesNotThrow(() => require('..'), 'index does not throw'); + t.doesNotThrow(() => require('../legacy'), 'legacy does not throw'); + t.doesNotThrow(() => require('../whitespace'), 'whitespace does not throw'); + + t.end(); +}); diff --git a/packages/eslint-config-airbnb/package.json b/packages/eslint-config-airbnb/package.json index 9dc6c92a45..54e9883cc5 100644 --- a/packages/eslint-config-airbnb/package.json +++ b/packages/eslint-config-airbnb/package.json @@ -6,6 +6,7 @@ "scripts": { "prelint": "editorconfig-tools check * rules/* test/*", "lint": "eslint .", + "pretests-only": "node ./test/requires", "tests-only": "babel-tape-runner ./test/test-*.js", "prepublish": "(in-install || eslint-find-rules --unused) && (not-in-publish || npm test) && safe-publish-latest", "pretest": "npm run --silent lint", diff --git a/packages/eslint-config-airbnb/test/requires.js b/packages/eslint-config-airbnb/test/requires.js new file mode 100644 index 0000000000..0ab4aae58d --- /dev/null +++ b/packages/eslint-config-airbnb/test/requires.js @@ -0,0 +1,17 @@ +/* eslint + strict: 0, + global-require: 0, + */ + +'use strict'; + +const test = require('tape'); + +test('all entry points parse', (t) => { + t.doesNotThrow(() => require('..'), 'index does not throw'); + t.doesNotThrow(() => require('../base'), 'base does not throw'); + t.doesNotThrow(() => require('../legacy'), 'legacy does not throw'); + t.doesNotThrow(() => require('../whitespace'), 'whitespace does not throw'); + + t.end(); +}); From 396166b1d3266c3bd4c9a83a8f3142c7bcc58865 Mon Sep 17 00:00:00 2001 From: Pirasis <1pete@users.noreply.github.com> Date: Thu, 1 Mar 2018 12:15:56 +0700 Subject: [PATCH 101/480] [eslint config] [*] [fix] ensure `whitespace` entry point is compatible with node 4 --- packages/eslint-config-airbnb-base/.eslintrc | 4 +++- .../eslint-config-airbnb-base/package.json | 1 + .../eslint-config-airbnb-base/whitespace.js | 22 +++++++++++-------- packages/eslint-config-airbnb/.eslintrc | 6 +++-- packages/eslint-config-airbnb/package.json | 1 + packages/eslint-config-airbnb/whitespace.js | 22 +++++++++++-------- 6 files changed, 35 insertions(+), 21 deletions(-) diff --git a/packages/eslint-config-airbnb-base/.eslintrc b/packages/eslint-config-airbnb-base/.eslintrc index 224149fda6..f9bd289286 100644 --- a/packages/eslint-config-airbnb-base/.eslintrc +++ b/packages/eslint-config-airbnb-base/.eslintrc @@ -3,6 +3,8 @@ "rules": { // disable requiring trailing commas because it might be nice to revert to // being JSON at some point, and I don't want to make big changes now. - "comma-dangle": 0 + "comma-dangle": 0, + // we support node 4 + "prefer-destructuring": 0, }, } diff --git a/packages/eslint-config-airbnb-base/package.json b/packages/eslint-config-airbnb-base/package.json index 608046874c..e9a6589bd0 100644 --- a/packages/eslint-config-airbnb-base/package.json +++ b/packages/eslint-config-airbnb-base/package.json @@ -68,6 +68,7 @@ }, "dependencies": { "eslint-restricted-globals": "^0.1.1", + "object.assign": "^4.1.0", "object.entries": "^1.0.4" } } diff --git a/packages/eslint-config-airbnb-base/whitespace.js b/packages/eslint-config-airbnb-base/whitespace.js index 408c0b72b6..66a05e52b9 100644 --- a/packages/eslint-config-airbnb-base/whitespace.js +++ b/packages/eslint-config-airbnb-base/whitespace.js @@ -1,20 +1,24 @@ const baseConfig = require('.'); +const assign = require('object.assign'); const entries = require('object.entries'); -const { CLIEngine } = require('eslint'); +const CLIEngine = require('eslint').CLIEngine; function onlyErrorOnRules(rulesToError, config) { - const errorsOnly = { ...config }; + const errorsOnly = assign({}, config); const cli = new CLIEngine({ baseConfig: config, useEslintrc: false }); const baseRules = cli.getConfigForFile('./').rules; - entries(baseRules).forEach(([key, value]) => { - if (rulesToError.indexOf(key) === -1) { - if (Array.isArray(value)) { - errorsOnly.rules[key] = ['warn'].concat(value.slice(1)); - } else if (typeof value === 'number') { - errorsOnly.rules[key] = 1; + entries(baseRules).forEach((rule) => { + const ruleName = rule[0]; + const ruleConfig = rule[1]; + + if (rulesToError.indexOf(ruleName) === -1) { + if (Array.isArray(ruleConfig)) { + errorsOnly.rules[ruleName] = ['warn'].concat(ruleConfig.slice(1)); + } else if (typeof ruleConfig === 'number') { + errorsOnly.rules[ruleName] = 1; } else { - errorsOnly.rules[key] = 'warn'; + errorsOnly.rules[ruleName] = 'warn'; } } }); diff --git a/packages/eslint-config-airbnb/.eslintrc b/packages/eslint-config-airbnb/.eslintrc index 6c8556be3b..f9bd289286 100644 --- a/packages/eslint-config-airbnb/.eslintrc +++ b/packages/eslint-config-airbnb/.eslintrc @@ -3,6 +3,8 @@ "rules": { // disable requiring trailing commas because it might be nice to revert to // being JSON at some point, and I don't want to make big changes now. - "comma-dangle": 0 - } + "comma-dangle": 0, + // we support node 4 + "prefer-destructuring": 0, + }, } diff --git a/packages/eslint-config-airbnb/package.json b/packages/eslint-config-airbnb/package.json index 54e9883cc5..df135d545a 100644 --- a/packages/eslint-config-airbnb/package.json +++ b/packages/eslint-config-airbnb/package.json @@ -50,6 +50,7 @@ "homepage": "https://github.com/airbnb/javascript", "dependencies": { "eslint-config-airbnb-base": "^12.1.0", + "object.assign": "^4.1.0", "object.entries": "^1.0.4" }, "devDependencies": { diff --git a/packages/eslint-config-airbnb/whitespace.js b/packages/eslint-config-airbnb/whitespace.js index f533385e80..ba36569a99 100644 --- a/packages/eslint-config-airbnb/whitespace.js +++ b/packages/eslint-config-airbnb/whitespace.js @@ -1,20 +1,24 @@ const baseConfig = require('.'); +const assign = require('object.assign'); const entries = require('object.entries'); -const { CLIEngine } = require('eslint'); +const CLIEngine = require('eslint').CLIEngine; function onlyErrorOnRules(rulesToError, config) { - const errorsOnly = { ...config }; + const errorsOnly = assign({}, config); const cli = new CLIEngine({ baseConfig: config, useEslintrc: false }); const baseRules = cli.getConfigForFile('./').rules; - entries(baseRules).forEach(([key, value]) => { - if (rulesToError.indexOf(key) === -1) { - if (Array.isArray(value)) { - errorsOnly.rules[key] = ['warn'].concat(value.slice(1)); - } else if (typeof value === 'number') { - errorsOnly.rules[key] = 1; + entries(baseRules).forEach((rule) => { + const ruleName = rule[0]; + const ruleConfig = rule[1]; + + if (rulesToError.indexOf(ruleName) === -1) { + if (Array.isArray(ruleConfig)) { + errorsOnly.rules[ruleName] = ['warn'].concat(ruleConfig.slice(1)); + } else if (typeof ruleConfig === 'number') { + errorsOnly.rules[ruleName] = 1; } else { - errorsOnly.rules[key] = 'warn'; + errorsOnly.rules[ruleName] = 'warn'; } } }); From a9fc9d8a0f8b606d560bd173af4cdcfa18e86261 Mon Sep 17 00:00:00 2001 From: Rauno Date: Mon, 5 Mar 2018 22:24:19 +0200 Subject: [PATCH 102/480] [docs] [js] add function-paren-newline eslint reference link --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 881eb01490..4b9f4f709c 100644 --- a/README.md +++ b/README.md @@ -879,7 +879,7 @@ Other Style Guides ``` - - [7.15](#functions--signature-invocation-indentation) Functions with multiline signatures, or invocations, should be indented just like every other multiline list in this guide: with each item on a line by itself, with a trailing comma on the last item. + - [7.15](#functions--signature-invocation-indentation) Functions with multiline signatures, or invocations, should be indented just like every other multiline list in this guide: with each item on a line by itself, with a trailing comma on the last item. eslint: [`function-paren-newline`](https://eslint.org/docs/rules/function-paren-newline) ```javascript // bad From 55adae99c960be8d4433b8c98b410695f6cea733 Mon Sep 17 00:00:00 2001 From: Michael Altamirano Date: Sat, 10 Mar 2018 17:30:38 -0800 Subject: [PATCH 103/480] [guide] Reflect adoption of jest --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 4b9f4f709c..2c6c5c6c7d 100644 --- a/README.md +++ b/README.md @@ -3401,7 +3401,7 @@ Other Style Guides - Whichever testing framework you use, you should be writing tests! - Strive to write many small pure functions, and minimize where mutations occur. - Be cautious about stubs and mocks - they can make your tests more brittle. - - We primarily use [`mocha`](https://www.npmjs.com/package/mocha) at Airbnb. [`tape`](https://www.npmjs.com/package/tape) is also used occasionally for small, separate modules. + - We primarily use [`mocha`](https://www.npmjs.com/package/mocha) and [`jest`](https://www.npmjs.com/package/jest) at Airbnb. [`tape`](https://www.npmjs.com/package/tape) is also used occasionally for small, separate modules. - 100% test coverage is a good goal to strive for, even if it’s not always practical to reach it. - Whenever you fix a bug, _write a regression test_. A bug fixed without a regression test is almost certainly going to break again in the future. From a100a3957ffb11c841dbd74a649cbb9b5a17a2aa Mon Sep 17 00:00:00 2001 From: Remco Haszing Date: Thu, 1 Mar 2018 14:33:02 +0100 Subject: [PATCH 104/480] [eslint config] [base] [breaking] Update `object-curly-newline` to match eslint 4.18.0 In eslint v4.18.0 separate settings are introduced for imports and exports for the `object-curly-newline` rule. Without this change, there is different behavior when updating eslint to this version. --- packages/eslint-config-airbnb-base/rules/style.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/packages/eslint-config-airbnb-base/rules/style.js b/packages/eslint-config-airbnb-base/rules/style.js index bc5e032e4a..12cd60d509 100644 --- a/packages/eslint-config-airbnb-base/rules/style.js +++ b/packages/eslint-config-airbnb-base/rules/style.js @@ -383,7 +383,9 @@ module.exports = { // https://eslint.org/docs/rules/object-curly-newline 'object-curly-newline': ['error', { ObjectExpression: { minProperties: 4, multiline: true, consistent: true }, - ObjectPattern: { minProperties: 4, multiline: true, consistent: true } + ObjectPattern: { minProperties: 4, multiline: true, consistent: true }, + ImportDeclaration: { minProperties: 4, multiline: true, consistent: true }, + ExportDeclaration: { minProperties: 4, multiline: true, consistent: true }, }], // enforce "same line" or "multiple line" on object properties. From 8247e338a2d689f2e16010b0db225fbce7760f97 Mon Sep 17 00:00:00 2001 From: Remco Haszing Date: Mon, 4 Dec 2017 10:11:35 +0100 Subject: [PATCH 105/480] [eslint config] [base] [patch] Set import/extensions to ignorePackages This allows to import non-JavaScript files through the main export of a dependency's package.json. The following would trigger an error before, but is fine with the new configuration: ```js import 'roboto-fontface'; ``` --- 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 005656e6f8..4a83126e1b 100644 --- a/packages/eslint-config-airbnb-base/rules/imports.js +++ b/packages/eslint-config-airbnb-base/rules/imports.js @@ -132,7 +132,7 @@ module.exports = { // Ensure consistent use of file extension within the import path // https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/extensions.md - 'import/extensions': ['error', 'always', { + 'import/extensions': ['error', 'ignorePackages', { js: 'never', mjs: 'never', jsx: 'never', From a9f5d519fe7356a60843c2c24aae974f716e6d17 Mon Sep 17 00:00:00 2001 From: Shane Mileham Date: Mon, 12 Mar 2018 11:20:34 -0700 Subject: [PATCH 106/480] Added naming--uppercase section from comment --- README.md | 37 ++++++++++++++++++++++++------------- 1 file changed, 24 insertions(+), 13 deletions(-) diff --git a/README.md b/README.md index 1116dcb4ba..49f554e2cf 100644 --- a/README.md +++ b/README.md @@ -3140,32 +3140,43 @@ Other Style Guides ``` - - [23.10](#naming--uppercase) Use UPPERCASE for nested object namespacing, global variables, and constants. + - [23.10](#naming--uppercase) You may optionally uppercase a constant only if it (1) is exported, (2) is a `const` (it can not be reassigned), and (3) the programmer can trust it (and its nested properties) to never change. + > Why? This is an additional tool to assist in situations where the programmer would be unsure if a variable might ever change. UPPERCASE_VARIABLES are letting the programmer know that they can trust the variable (and its properties) not to change. + - What about all `const` variables? - This is unnecessary, so uppercasing should not be used for constants within a file. It should be used for exported constants however. + - What about exported objects? - Uppercase at the top level of export (e.g. `EXPORTED_OBJECT.key`) and maintain that all nested properties do not change. ```javascript // bad - const namespace = namespace || {}; + const PRIVATE_VARIABLE = 'should not be unnecessarily uppercased within a file'; - namespace.util.Widget = { - // ...stuff... - } + // bad + export const THING_TO_BE_CHANGED = 'should obviously not be uppercased'; // bad - const apiKey = '44b345234534t455245njkl523452-vbb9'; + export let REASSIGNABLE_VARIABLE = 'do not use let with uppercase variables'; - // good - const NAMESPACE = NAMESPACE || {}; + // --- - NAMESPACE.util.Widget = { - // ...stuff... - } + // allowed but does not supply semantic value + export const apiKey = 'SOMEKEY'; + + // better in most cases + export const API_KEY = 'SOMEKEY'; + + // --- + + // bad - unnecessarily uppercases key while adding no semantic value + export const MAPPING = { + KEY: 'value' + }; // good - const API_KEY = '44b345234534t455245njkl523452-vbb9'; + export const MAPPING = { + key: 'value' + }; ``` - **[⬆ back to top](#table-of-contents)** ## Accessors From 49dab881da79eb3742e7f1e26c754194a9f26991 Mon Sep 17 00:00:00 2001 From: Joe Lencioni Date: Fri, 23 Mar 2018 08:42:42 -0700 Subject: [PATCH 107/480] Change import/no-self-import from "off" to "error" We recently had an incident where this rule would have prevented infinite loops in Hypernova and in the browser. --- packages/eslint-config-airbnb-base/rules/imports.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/packages/eslint-config-airbnb-base/rules/imports.js b/packages/eslint-config-airbnb-base/rules/imports.js index 4a83126e1b..a34e7f2524 100644 --- a/packages/eslint-config-airbnb-base/rules/imports.js +++ b/packages/eslint-config-airbnb-base/rules/imports.js @@ -224,8 +224,7 @@ module.exports = { // Forbid a module from importing itself // https://github.com/benmosher/eslint-plugin-import/blob/44a038c06487964394b1e15b64f3bd34e5d40cde/docs/rules/no-self-import.md - // TODO: enable - 'import/no-self-import': 'off', + 'import/no-self-import': 'error', // Ensures that there are no useless path segments // https://github.com/benmosher/eslint-plugin-import/issues/1032 From 8ed1d855bbefccbb147fe17d902a18c8f9aa3977 Mon Sep 17 00:00:00 2001 From: Naomi Jacobs Date: Tue, 20 Mar 2018 11:40:04 -0700 Subject: [PATCH 108/480] [eslint config] [base] [patch] Include 'accumulator' exception for `no-param-reassign` --- packages/eslint-config-airbnb-base/rules/best-practices.js | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/eslint-config-airbnb-base/rules/best-practices.js b/packages/eslint-config-airbnb-base/rules/best-practices.js index 978cafc698..b5712d00b2 100644 --- a/packages/eslint-config-airbnb-base/rules/best-practices.js +++ b/packages/eslint-config-airbnb-base/rules/best-practices.js @@ -173,6 +173,7 @@ module.exports = { props: true, ignorePropertyModificationsFor: [ 'acc', // for reduce accumulators + 'accumulator', // for reduce accumulators 'e', // for e.returnvalue 'ctx', // for Koa routing 'req', // for Express requests From 06e28997b239a341bcc196905f710f2c437ed8cf Mon Sep 17 00:00:00 2001 From: Simon Owen Date: Wed, 28 Mar 2018 15:39:14 +0100 Subject: [PATCH 109/480] Minor spacing update --- react/README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/react/README.md b/react/README.md index 0db1fa8d3d..b89bad0710 100644 --- a/react/README.md +++ b/react/README.md @@ -421,13 +421,13 @@ This style guide is mostly based on the standards that are currently prevalent i Filter out unnecessary props when possible. Also, use [prop-types-exact](https://www.npmjs.com/package/prop-types-exact) to help prevent bugs. ```jsx - //good + // good render() { const { irrelevantProp, ...relevantProps } = this.props; return } - //bad + // bad render() { const { irrelevantProp, ...relevantProps } = this.props; return From 31d95fded451b31695d9cc09abc117edcea4969d Mon Sep 17 00:00:00 2001 From: Sharmila Date: Wed, 4 Apr 2018 16:23:02 -0700 Subject: [PATCH 110/480] [eslint config] [*] [deps] update `eslint`, `eslint-plugin-import`, `eslint-find-rules` --- packages/eslint-config-airbnb-base/package.json | 10 +++++----- packages/eslint-config-airbnb-base/rules/imports.js | 5 +++++ packages/eslint-config-airbnb/package.json | 10 +++++----- 3 files changed, 15 insertions(+), 10 deletions(-) diff --git a/packages/eslint-config-airbnb-base/package.json b/packages/eslint-config-airbnb-base/package.json index e9a6589bd0..2c3d49bd21 100644 --- a/packages/eslint-config-airbnb-base/package.json +++ b/packages/eslint-config-airbnb-base/package.json @@ -52,16 +52,16 @@ "babel-preset-airbnb": "^2.4.0", "babel-tape-runner": "^2.0.1", "editorconfig-tools": "^0.1.1", - "eslint": "^4.18.1", - "eslint-find-rules": "^3.2.0", - "eslint-plugin-import": "^2.9.0", + "eslint": "^4.19.1", + "eslint-find-rules": "^3.2.2", + "eslint-plugin-import": "^2.10.0", "in-publish": "^2.0.0", "safe-publish-latest": "^1.1.1", "tape": "^4.9.0" }, "peerDependencies": { - "eslint": "^4.18.1", - "eslint-plugin-import": "^2.9.0" + "eslint": "^4.19.1", + "eslint-plugin-import": "^2.10.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 a34e7f2524..3c76a5aa3d 100644 --- a/packages/eslint-config-airbnb-base/rules/imports.js +++ b/packages/eslint-config-airbnb-base/rules/imports.js @@ -226,6 +226,11 @@ module.exports = { // https://github.com/benmosher/eslint-plugin-import/blob/44a038c06487964394b1e15b64f3bd34e5d40cde/docs/rules/no-self-import.md 'import/no-self-import': 'error', + // Forbid cyclical dependencies between modules + // https://github.com/benmosher/eslint-plugin-import/blob/d81f48a2506182738409805f5272eff4d77c9348/docs/rules/no-cycle.md + // TODO: enable, semver-major + 'import/no-cycle': ['off', { maxDepth: Infinity }], + // Ensures that there are no useless path segments // https://github.com/benmosher/eslint-plugin-import/issues/1032 'import/no-useless-path-segments': 'error', diff --git a/packages/eslint-config-airbnb/package.json b/packages/eslint-config-airbnb/package.json index df135d545a..dfaadad2ad 100644 --- a/packages/eslint-config-airbnb/package.json +++ b/packages/eslint-config-airbnb/package.json @@ -57,9 +57,9 @@ "babel-preset-airbnb": "^2.4.0", "babel-tape-runner": "^2.0.1", "editorconfig-tools": "^0.1.1", - "eslint": "^4.18.1", - "eslint-find-rules": "^3.2.0", - "eslint-plugin-import": "^2.9.0", + "eslint": "^4.19.1", + "eslint-find-rules": "^3.2.2", + "eslint-plugin-import": "^2.10.0", "eslint-plugin-jsx-a11y": "^6.0.3", "eslint-plugin-react": "^7.7.0", "in-publish": "^2.0.0", @@ -68,8 +68,8 @@ "tape": "^4.9.0" }, "peerDependencies": { - "eslint": "^4.18.1", - "eslint-plugin-import": "^2.9.0", + "eslint": "^4.19.1", + "eslint-plugin-import": "^2.10.0", "eslint-plugin-jsx-a11y": "^6.0.3", "eslint-plugin-react": "^7.7.0" }, From c71e8c9231394ef9489cacf6cbf1ea9dd63b1b32 Mon Sep 17 00:00:00 2001 From: Sharmila Date: Wed, 4 Apr 2018 16:15:27 -0700 Subject: [PATCH 111/480] [eslint config] [base] [breaking] enable `import/no-cycle`: warn on cyclical dependencies --- packages/eslint-config-airbnb-base/rules/imports.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/packages/eslint-config-airbnb-base/rules/imports.js b/packages/eslint-config-airbnb-base/rules/imports.js index 3c76a5aa3d..1ea95697c9 100644 --- a/packages/eslint-config-airbnb-base/rules/imports.js +++ b/packages/eslint-config-airbnb-base/rules/imports.js @@ -228,8 +228,7 @@ module.exports = { // Forbid cyclical dependencies between modules // https://github.com/benmosher/eslint-plugin-import/blob/d81f48a2506182738409805f5272eff4d77c9348/docs/rules/no-cycle.md - // TODO: enable, semver-major - 'import/no-cycle': ['off', { maxDepth: Infinity }], + 'import/no-cycle': ['error', { maxDepth: Infinity }], // Ensures that there are no useless path segments // https://github.com/benmosher/eslint-plugin-import/issues/1032 From bd97fca21b99b542d9ef9eebec78198d6bb5fde0 Mon Sep 17 00:00:00 2001 From: Pramod Garg Date: Wed, 4 Apr 2018 22:45:44 +0530 Subject: [PATCH 112/480] [guide] Minor addition of spaces --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 49f554e2cf..b0093efe40 100644 --- a/README.md +++ b/README.md @@ -2106,7 +2106,7 @@ Other Style Guides } } - //good + // good function dogs(x) { if (x) { if (z) { @@ -2267,7 +2267,7 @@ Other Style Guides ```javascript // bad - //is current tab + // is current tab const active = true; // good From 8720f5f90bbe4aaf87e03d81b3b4f607f27ff6c6 Mon Sep 17 00:00:00 2001 From: "C. T. Lin" Date: Wed, 28 Mar 2018 13:05:12 +0800 Subject: [PATCH 113/480] [eslint config] [base] [patch] avoid `__mocks__` `no-extraneous-dependencies` check --- 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 1ea95697c9..04455c97fb 100644 --- a/packages/eslint-config-airbnb-base/rules/imports.js +++ b/packages/eslint-config-airbnb-base/rules/imports.js @@ -74,6 +74,7 @@ module.exports = { 'tests/**', // also common npm pattern 'spec/**', // mocha, rspec-like pattern '**/__tests__/**', // jest pattern + '**/__mocks__/**', // jest pattern '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 From 06998522e1f4935f81f732c458d2cc72dde2cac9 Mon Sep 17 00:00:00 2001 From: Hernaldo Jesus Henriquez Date: Fri, 6 Apr 2018 14:53:46 -0300 Subject: [PATCH 114/480] [guide] fix "bad" comment to be actually bad --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index b0093efe40..6a58c28480 100644 --- a/README.md +++ b/README.md @@ -2267,7 +2267,7 @@ Other Style Guides ```javascript // bad - // is current tab + //is current tab const active = true; // good From 8956338ee95087ab2da99b368d00ff482e77df3b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Eray=20=C3=87etinay?= Date: Sun, 8 Apr 2018 22:51:19 +0300 Subject: [PATCH 115/480] [guide] Turkish Translation Link Added --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 6a58c28480..57ca65ed4e 100644 --- a/README.md +++ b/README.md @@ -3654,6 +3654,7 @@ Other Style Guides - ![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) + - ![tr](https://raw.githubusercontent.com/gosquared/flags/master/flags/flags/shiny/24/Turkey.png) **Turkish**: [eraycetinay/javascript](https://github.com/eraycetinay/javascript) - ![ua](https://raw.githubusercontent.com/gosquared/flags/master/flags/flags/shiny/24/Ukraine.png) **Ukrainian**: [ivanzusko/javascript](https://github.com/ivanzusko/javascript) - ![vn](https://raw.githubusercontent.com/gosquared/flags/master/flags/flags/shiny/24/Vietnam.png) **Vietnam**: [hngiang/javascript-style-guide](https://github.com/hngiang/javascript-style-guide) From 6088a8f5b503c4e383552cbb6ae36d3fa4c6e7b1 Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Thu, 12 Apr 2018 15:46:55 -0700 Subject: [PATCH 116/480] [guide] remove references to jscs --- README.md | 71 +++++++++++++++++++++++++++---------------------------- 1 file changed, 35 insertions(+), 36 deletions(-) diff --git a/README.md b/README.md index 57ca65ed4e..ed54520555 100644 --- a/README.md +++ b/README.md @@ -119,7 +119,7 @@ Other Style Guides ``` - - [2.2](#references--disallow-var) If you must reassign references, use `let` instead of `var`. eslint: [`no-var`](https://eslint.org/docs/rules/no-var.html) jscs: [`disallowVar`](http://jscs.info/rule/disallowVar) + - [2.2](#references--disallow-var) If you must reassign references, use `let` instead of `var`. eslint: [`no-var`](https://eslint.org/docs/rules/no-var.html) > Why? `let` is block-scoped rather than function-scoped like `var`. @@ -192,7 +192,7 @@ Other Style Guides ``` - - [3.3](#es6-object-shorthand) Use object method shorthand. eslint: [`object-shorthand`](https://eslint.org/docs/rules/object-shorthand.html) jscs: [`requireEnhancedObjectLiterals`](http://jscs.info/rule/requireEnhancedObjectLiterals) + - [3.3](#es6-object-shorthand) Use object method shorthand. eslint: [`object-shorthand`](https://eslint.org/docs/rules/object-shorthand.html) ```javascript // bad @@ -215,7 +215,7 @@ Other Style Guides ``` - - [3.4](#es6-object-concise) Use property value shorthand. eslint: [`object-shorthand`](https://eslint.org/docs/rules/object-shorthand.html) jscs: [`requireEnhancedObjectLiterals`](http://jscs.info/rule/requireEnhancedObjectLiterals) + - [3.4](#es6-object-concise) Use property value shorthand. eslint: [`object-shorthand`](https://eslint.org/docs/rules/object-shorthand.html) > Why? It is shorter to write and descriptive. @@ -264,7 +264,7 @@ Other Style Guides ``` - - [3.6](#objects--quoted-props) Only quote properties that are invalid identifiers. eslint: [`quote-props`](https://eslint.org/docs/rules/quote-props.html) jscs: [`disallowQuotedKeysInObjects`](http://jscs.info/rule/disallowQuotedKeysInObjects) + - [3.6](#objects--quoted-props) Only quote properties that are invalid identifiers. eslint: [`quote-props`](https://eslint.org/docs/rules/quote-props.html) > Why? In general we consider it subjectively easier to read. It improves syntax highlighting, and is also more easily optimized by many JS engines. @@ -482,7 +482,7 @@ Other Style Guides ## Destructuring - - [5.1](#destructuring--object) Use object destructuring when accessing and using multiple properties of an object. eslint: [`prefer-destructuring`](https://eslint.org/docs/rules/prefer-destructuring) jscs: [`requireObjectDestructuring`](http://jscs.info/rule/requireObjectDestructuring) + - [5.1](#destructuring--object) Use object destructuring when accessing and using multiple properties of an object. eslint: [`prefer-destructuring`](https://eslint.org/docs/rules/prefer-destructuring) > Why? Destructuring saves you from creating temporary references for those properties. @@ -508,7 +508,7 @@ Other Style Guides ``` - - [5.2](#destructuring--array) Use array destructuring. eslint: [`prefer-destructuring`](https://eslint.org/docs/rules/prefer-destructuring) jscs: [`requireArrayDestructuring`](http://jscs.info/rule/requireArrayDestructuring) + - [5.2](#destructuring--array) Use array destructuring. eslint: [`prefer-destructuring`](https://eslint.org/docs/rules/prefer-destructuring) ```javascript const arr = [1, 2, 3, 4]; @@ -522,7 +522,7 @@ Other Style Guides ``` - - [5.3](#destructuring--object-over-array) Use object destructuring for multiple return values, not array destructuring. jscs: [`disallowArrayDestructuringReturn`](http://jscs.info/rule/disallowArrayDestructuringReturn) + - [5.3](#destructuring--object-over-array) Use object destructuring for multiple return values, not array destructuring. > Why? You can add new properties over time or change the order of things without breaking call sites. @@ -551,7 +551,7 @@ Other Style Guides ## Strings - - [6.1](#strings--quotes) Use single quotes `''` for strings. eslint: [`quotes`](https://eslint.org/docs/rules/quotes.html) jscs: [`validateQuoteMarks`](http://jscs.info/rule/validateQuoteMarks) + - [6.1](#strings--quotes) Use single quotes `''` for strings. eslint: [`quotes`](https://eslint.org/docs/rules/quotes.html) ```javascript // bad @@ -586,7 +586,7 @@ Other Style Guides ``` - - [6.3](#es6-template-literals) When programmatically building up strings, use template strings instead of concatenation. eslint: [`prefer-template`](https://eslint.org/docs/rules/prefer-template.html) [`template-curly-spacing`](https://eslint.org/docs/rules/template-curly-spacing) jscs: [`requireTemplateStrings`](http://jscs.info/rule/requireTemplateStrings) + - [6.3](#es6-template-literals) When programmatically building up strings, use template strings instead of concatenation. eslint: [`prefer-template`](https://eslint.org/docs/rules/prefer-template.html) [`template-curly-spacing`](https://eslint.org/docs/rules/template-curly-spacing) > Why? Template strings give you a readable, concise syntax with proper newlines and string interpolation features. @@ -634,7 +634,7 @@ Other Style Guides ## Functions - - [7.1](#functions--declarations) Use named function expressions instead of function declarations. eslint: [`func-style`](https://eslint.org/docs/rules/func-style) jscs: [`disallowFunctionDeclarations`](http://jscs.info/rule/disallowFunctionDeclarations) + - [7.1](#functions--declarations) Use named function expressions instead of function declarations. eslint: [`func-style`](https://eslint.org/docs/rules/func-style) > Why? Function declarations are hoisted, which means that it’s easy - too easy - to reference the function before it is defined in the file. This harms readability and maintainability. If you find that a function’s definition is large or complex enough that it is interfering with understanding the rest of the file, then perhaps it’s time to extract it to its own module! Don’t forget to explicitly name the expression, regardless of whether or not the name is inferred from the containing variable (which is often the case in modern browsers or when using compilers such as Babel). This eliminates any assumptions made about the Error's call stack. ([Discussion](https://github.com/airbnb/javascript/issues/794)) @@ -657,7 +657,7 @@ Other Style Guides ``` - - [7.2](#functions--iife) Wrap immediately invoked function expressions in parentheses. eslint: [`wrap-iife`](https://eslint.org/docs/rules/wrap-iife.html) jscs: [`requireParenthesesAroundIIFE`](http://jscs.info/rule/requireParenthesesAroundIIFE) + - [7.2](#functions--iife) Wrap immediately invoked function expressions in parentheses. eslint: [`wrap-iife`](https://eslint.org/docs/rules/wrap-iife.html) > Why? An immediately invoked function expression is a single unit - wrapping both it, and its invocation parens, in parens, cleanly expresses this. Note that in a world with modules everywhere, you almost never need an IIFE. @@ -916,7 +916,7 @@ Other Style Guides ## Arrow Functions - - [8.1](#arrows--use-them) When you must use an anonymous function (as when passing an inline callback), use arrow function notation. eslint: [`prefer-arrow-callback`](https://eslint.org/docs/rules/prefer-arrow-callback.html), [`arrow-spacing`](https://eslint.org/docs/rules/arrow-spacing.html) jscs: [`requireArrowFunctions`](http://jscs.info/rule/requireArrowFunctions) + - [8.1](#arrows--use-them) When you must use an anonymous function (as when passing an inline callback), use arrow function notation. eslint: [`prefer-arrow-callback`](https://eslint.org/docs/rules/prefer-arrow-callback.html), [`arrow-spacing`](https://eslint.org/docs/rules/arrow-spacing.html) > Why? It creates a version of the function that executes in the context of `this`, which is usually what you want, and is a more concise syntax. @@ -937,7 +937,7 @@ Other Style Guides ``` - - [8.2](#arrows--implicit-return) If the function body consists of a single statement returning an [expression](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Expressions_and_Operators#Expressions) without side effects, omit the braces and use the implicit return. Otherwise, keep the braces and use a `return` statement. eslint: [`arrow-parens`](https://eslint.org/docs/rules/arrow-parens.html), [`arrow-body-style`](https://eslint.org/docs/rules/arrow-body-style.html) jscs: [`disallowParenthesesAroundArrowParam`](http://jscs.info/rule/disallowParenthesesAroundArrowParam), [`requireShorthandArrowFunctions`](http://jscs.info/rule/requireShorthandArrowFunctions) + - [8.2](#arrows--implicit-return) If the function body consists of a single statement returning an [expression](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Expressions_and_Operators#Expressions) without side effects, omit the braces and use the implicit return. Otherwise, keep the braces and use a `return` statement. eslint: [`arrow-parens`](https://eslint.org/docs/rules/arrow-parens.html), [`arrow-body-style`](https://eslint.org/docs/rules/arrow-body-style.html) > Why? Syntactic sugar. It reads well when multiple functions are chained together. @@ -1004,7 +1004,7 @@ Other Style Guides ``` - - [8.4](#arrows--one-arg-parens) If your function takes a single argument and doesn’t use braces, omit the parentheses. Otherwise, always include parentheses around arguments for clarity and consistency. Note: it is also acceptable to always use parentheses, in which case use the [“always” option](https://eslint.org/docs/rules/arrow-parens#always) for eslint or do not include [`disallowParenthesesAroundArrowParam`](http://jscs.info/rule/disallowParenthesesAroundArrowParam) for jscs. eslint: [`arrow-parens`](https://eslint.org/docs/rules/arrow-parens.html) jscs: [`disallowParenthesesAroundArrowParam`](http://jscs.info/rule/disallowParenthesesAroundArrowParam) + - [8.4](#arrows--one-arg-parens) If your function takes a single argument and doesn’t use braces, omit the parentheses. Otherwise, always include parentheses around arguments for clarity and consistency. Note: it is also acceptable to always use parentheses, in which case use the [“always” option](https://eslint.org/docs/rules/arrow-parens#always) for eslint. eslint: [`arrow-parens`](https://eslint.org/docs/rules/arrow-parens.html) > Why? Less visual clutter. @@ -1491,7 +1491,7 @@ Other Style Guides ## Properties - - [12.1](#properties--dot) Use dot notation when accessing properties. eslint: [`dot-notation`](https://eslint.org/docs/rules/dot-notation.html) jscs: [`requireDotNotation`](http://jscs.info/rule/requireDotNotation) + - [12.1](#properties--dot) Use dot notation when accessing properties. eslint: [`dot-notation`](https://eslint.org/docs/rules/dot-notation.html) ```javascript const luke = { @@ -1548,7 +1548,7 @@ Other Style Guides ``` - - [13.2](#variables--one-const) Use one `const` or `let` declaration per variable. eslint: [`one-var`](https://eslint.org/docs/rules/one-var.html) jscs: [`disallowMultipleVarDecl`](http://jscs.info/rule/disallowMultipleVarDecl) + - [13.2](#variables--one-const) Use one `const` or `let` declaration per variable. eslint: [`one-var`](https://eslint.org/docs/rules/one-var.html) > Why? It’s easier to add new variable declarations this way, and you never have to worry about swapping out a `;` for a `,` or introducing punctuation-only diffs. You can also step through each declaration with the debugger, instead of jumping through all of them at once. @@ -2032,7 +2032,7 @@ Other Style Guides ``` - - [16.2](#blocks--cuddled-elses) If you're using multi-line blocks with `if` and `else`, put `else` on the same line as your `if` block’s closing brace. eslint: [`brace-style`](https://eslint.org/docs/rules/brace-style.html) jscs: [`disallowNewlineBeforeBlockStatements`](http://jscs.info/rule/disallowNewlineBeforeBlockStatements) + - [16.2](#blocks--cuddled-elses) If you're using multi-line blocks with `if` and `else`, put `else` on the same line as your `if` block’s closing brace. eslint: [`brace-style`](https://eslint.org/docs/rules/brace-style.html) ```javascript // bad @@ -2335,7 +2335,7 @@ Other Style Guides ## Whitespace - - [19.1](#whitespace--spaces) Use soft tabs (space character) set to 2 spaces. eslint: [`indent`](https://eslint.org/docs/rules/indent.html) jscs: [`validateIndentation`](http://jscs.info/rule/validateIndentation) + - [19.1](#whitespace--spaces) Use soft tabs (space character) set to 2 spaces. eslint: [`indent`](https://eslint.org/docs/rules/indent.html) ```javascript // bad @@ -2355,7 +2355,7 @@ Other Style Guides ``` - - [19.2](#whitespace--before-blocks) Place 1 space before the leading brace. eslint: [`space-before-blocks`](https://eslint.org/docs/rules/space-before-blocks.html) jscs: [`requireSpaceBeforeBlockStatements`](http://jscs.info/rule/requireSpaceBeforeBlockStatements) + - [19.2](#whitespace--before-blocks) Place 1 space before the leading brace. eslint: [`space-before-blocks`](https://eslint.org/docs/rules/space-before-blocks.html) ```javascript // bad @@ -2382,7 +2382,7 @@ Other Style Guides ``` - - [19.3](#whitespace--around-keywords) Place 1 space before the opening parenthesis in control statements (`if`, `while` etc.). Place no space between the argument list and the function name in function calls and declarations. eslint: [`keyword-spacing`](https://eslint.org/docs/rules/keyword-spacing.html) jscs: [`requireSpaceAfterKeywords`](http://jscs.info/rule/requireSpaceAfterKeywords) + - [19.3](#whitespace--around-keywords) Place 1 space before the opening parenthesis in control statements (`if`, `while` etc.). Place no space between the argument list and the function name in function calls and declarations. eslint: [`keyword-spacing`](https://eslint.org/docs/rules/keyword-spacing.html) ```javascript // bad @@ -2407,7 +2407,7 @@ Other Style Guides ``` - - [19.4](#whitespace--infix-ops) Set off operators with spaces. eslint: [`space-infix-ops`](https://eslint.org/docs/rules/space-infix-ops.html) jscs: [`requireSpaceBeforeBinaryOperators`](http://jscs.info/rule/requireSpaceBeforeBinaryOperators), [`requireSpaceAfterBinaryOperators`](http://jscs.info/rule/requireSpaceAfterBinaryOperators) + - [19.4](#whitespace--infix-ops) Set off operators with spaces. eslint: [`space-infix-ops`](https://eslint.org/docs/rules/space-infix-ops.html) ```javascript // bad @@ -2487,7 +2487,7 @@ Other Style Guides ``` - - [19.7](#whitespace--after-blocks) Leave a blank line after blocks and before the next statement. jscs: [`requirePaddingNewLinesAfterBlocks`](http://jscs.info/rule/requirePaddingNewLinesAfterBlocks) + - [19.7](#whitespace--after-blocks) Leave a blank line after blocks and before the next statement. ```javascript // bad @@ -2545,7 +2545,7 @@ Other Style Guides ``` - - [19.8](#whitespace--padded-blocks) Do not pad your blocks with blank lines. eslint: [`padded-blocks`](https://eslint.org/docs/rules/padded-blocks.html) jscs: [`disallowPaddingNewlinesInBlocks`](http://jscs.info/rule/disallowPaddingNewlinesInBlocks) + - [19.8](#whitespace--padded-blocks) Do not pad your blocks with blank lines. eslint: [`padded-blocks`](https://eslint.org/docs/rules/padded-blocks.html) ```javascript // bad @@ -2586,7 +2586,7 @@ Other Style Guides ``` - - [19.9](#whitespace--in-parens) Do not add spaces inside parentheses. eslint: [`space-in-parens`](https://eslint.org/docs/rules/space-in-parens.html) jscs: [`disallowSpacesInsideParentheses`](http://jscs.info/rule/disallowSpacesInsideParentheses) + - [19.9](#whitespace--in-parens) Do not add spaces inside parentheses. eslint: [`space-in-parens`](https://eslint.org/docs/rules/space-in-parens.html) ```javascript // bad @@ -2611,7 +2611,7 @@ Other Style Guides ``` - - [19.10](#whitespace--in-brackets) Do not add spaces inside brackets. eslint: [`array-bracket-spacing`](https://eslint.org/docs/rules/array-bracket-spacing.html) jscs: [`disallowSpacesInsideArrayBrackets`](http://jscs.info/rule/disallowSpacesInsideArrayBrackets) + - [19.10](#whitespace--in-brackets) Do not add spaces inside brackets. eslint: [`array-bracket-spacing`](https://eslint.org/docs/rules/array-bracket-spacing.html) ```javascript // bad @@ -2624,7 +2624,7 @@ Other Style Guides ``` - - [19.11](#whitespace--in-braces) Add spaces inside curly braces. eslint: [`object-curly-spacing`](https://eslint.org/docs/rules/object-curly-spacing.html) jscs: [`requireSpacesInsideObjectBrackets`](http://jscs.info/rule/requireSpacesInsideObjectBrackets) + - [19.11](#whitespace--in-braces) Add spaces inside curly braces. eslint: [`object-curly-spacing`](https://eslint.org/docs/rules/object-curly-spacing.html) ```javascript // bad @@ -2635,7 +2635,7 @@ Other Style Guides ``` - - [19.12](#whitespace--max-len) Avoid having lines of code that are longer than 100 characters (including whitespace). Note: per [above](#strings--line-length), long strings are exempt from this rule, and should not be broken up. eslint: [`max-len`](https://eslint.org/docs/rules/max-len.html) jscs: [`maximumLineLength`](http://jscs.info/rule/maximumLineLength) + - [19.12](#whitespace--max-len) Avoid having lines of code that are longer than 100 characters (including whitespace). Note: per [above](#strings--line-length), long strings are exempt from this rule, and should not be broken up. eslint: [`max-len`](https://eslint.org/docs/rules/max-len.html) > Why? This ensures readability and maintainability. @@ -2669,7 +2669,7 @@ Other Style Guides ## Commas - - [20.1](#commas--leading-trailing) Leading commas: **Nope.** eslint: [`comma-style`](https://eslint.org/docs/rules/comma-style.html) jscs: [`requireCommaBeforeLineBreak`](http://jscs.info/rule/requireCommaBeforeLineBreak) + - [20.1](#commas--leading-trailing) Leading commas: **Nope.** eslint: [`comma-style`](https://eslint.org/docs/rules/comma-style.html) ```javascript // bad @@ -2704,7 +2704,7 @@ Other Style Guides ``` - - [20.2](#commas--dangling) Additional trailing comma: **Yup.** eslint: [`comma-dangle`](https://eslint.org/docs/rules/comma-dangle.html) jscs: [`requireTrailingComma`](http://jscs.info/rule/requireTrailingComma) + - [20.2](#commas--dangling) Additional trailing comma: **Yup.** eslint: [`comma-dangle`](https://eslint.org/docs/rules/comma-dangle.html) > Why? This leads to cleaner git diffs. Also, transpilers like Babel will remove the additional trailing comma in the transpiled code which means you don’t have to worry about the [trailing comma problem](https://github.com/airbnb/javascript/blob/es5-deprecated/es5/README.md#commas) in legacy browsers. @@ -2804,7 +2804,7 @@ Other Style Guides ## Semicolons - - [21.1](#semicolons--required) **Yup.** eslint: [`semi`](https://eslint.org/docs/rules/semi.html) jscs: [`requireSemicolons`](http://jscs.info/rule/requireSemicolons) + - [21.1](#semicolons--required) **Yup.** eslint: [`semi`](https://eslint.org/docs/rules/semi.html) > Why? When JavaScript encounters a line break without a semicolon, it uses a set of rules called [Automatic Semicolon Insertion](https://tc39.github.io/ecma262/#sec-automatic-semicolon-insertion) to determine whether or not it should regard that line break as the end of a statement, and (as the name implies) place a semicolon into your code before the line break if it thinks so. ASI contains a few eccentric behaviors, though, and your code will break if JavaScript misinterprets your line break. These rules will become more complicated as new features become a part of JavaScript. Explicitly terminating your statements and configuring your linter to catch missing semicolons will help prevent you from encountering issues. @@ -2958,7 +2958,7 @@ Other Style Guides ``` - - [23.2](#naming--camelCase) Use camelCase when naming objects, functions, and instances. eslint: [`camelcase`](https://eslint.org/docs/rules/camelcase.html) jscs: [`requireCamelCaseOrUpperCaseIdentifiers`](http://jscs.info/rule/requireCamelCaseOrUpperCaseIdentifiers) + - [23.2](#naming--camelCase) Use camelCase when naming objects, functions, and instances. eslint: [`camelcase`](https://eslint.org/docs/rules/camelcase.html) ```javascript // bad @@ -2972,7 +2972,7 @@ Other Style Guides ``` - - [23.3](#naming--PascalCase) Use PascalCase only when naming constructors or classes. eslint: [`new-cap`](https://eslint.org/docs/rules/new-cap.html) jscs: [`requireCapitalizedConstructors`](http://jscs.info/rule/requireCapitalizedConstructors) + - [23.3](#naming--PascalCase) Use PascalCase only when naming constructors or classes. eslint: [`new-cap`](https://eslint.org/docs/rules/new-cap.html) ```javascript // bad @@ -2997,7 +2997,7 @@ Other Style Guides ``` - - [23.4](#naming--leading-underscore) Do not use trailing or leading underscores. eslint: [`no-underscore-dangle`](https://eslint.org/docs/rules/no-underscore-dangle.html) jscs: [`disallowDanglingUnderscores`](http://jscs.info/rule/disallowDanglingUnderscores) + - [23.4](#naming--leading-underscore) Do not use trailing or leading underscores. eslint: [`no-underscore-dangle`](https://eslint.org/docs/rules/no-underscore-dangle.html) > Why? JavaScript does not have the concept of privacy in terms of properties or methods. Although a leading underscore is a common convention to mean “private”, in fact, these properties are fully public, and as such, are part of your public API contract. This convention might lead developers to wrongly think that a change won’t count as breaking, or that tests aren’t needed. tl;dr: if you want something to be “private”, it must not be observably present. @@ -3017,7 +3017,7 @@ Other Style Guides ``` - - [23.5](#naming--self-this) Don’t save references to `this`. Use arrow functions or [Function#bind](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/bind). jscs: [`disallowNodeTypes`](http://jscs.info/rule/disallowNodeTypes) + - [23.5](#naming--self-this) Don’t save references to `this`. Use arrow functions or [Function#bind](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/bind). ```javascript // bad @@ -3282,7 +3282,7 @@ Other Style Guides ## jQuery - - [26.1](#jquery--dollar-prefix) Prefix jQuery object variables with a `$`. jscs: [`requireDollarBeforejQueryAssignment`](http://jscs.info/rule/requireDollarBeforejQueryAssignment) + - [26.1](#jquery--dollar-prefix) Prefix jQuery object variables with a `$`. ```javascript // bad @@ -3477,7 +3477,6 @@ Other Style Guides - Code Style Linters - [ESlint](https://eslint.org/) - [Airbnb Style .eslintrc](https://github.com/airbnb/javascript/blob/master/linters/.eslintrc) - [JSHint](http://jshint.com/) - [Airbnb Style .jshintrc](https://github.com/airbnb/javascript/blob/master/linters/.jshintrc) - - [JSCS](https://github.com/jscs-dev/node-jscs) - [Airbnb Style Preset](https://github.com/jscs-dev/node-jscs/blob/master/presets/airbnb.json) (Deprecated, please use [ESlint](https://github.com/airbnb/javascript/tree/master/packages/eslint-config-airbnb-base)) - Neutrino preset - [neutrino-preset-airbnb-base](https://neutrino.js.org/presets/neutrino-preset-airbnb-base/) **Other Style Guides** From 308fb24815a62c98aa4e89aae1bad0744dab3a92 Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Fri, 13 Apr 2018 13:43:43 -0700 Subject: [PATCH 117/480] [eslint config] [*] [deps] update `eslint-plugin-import` --- 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 2c3d49bd21..7739f54005 100644 --- a/packages/eslint-config-airbnb-base/package.json +++ b/packages/eslint-config-airbnb-base/package.json @@ -54,14 +54,14 @@ "editorconfig-tools": "^0.1.1", "eslint": "^4.19.1", "eslint-find-rules": "^3.2.2", - "eslint-plugin-import": "^2.10.0", + "eslint-plugin-import": "^2.11.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.10.0" + "eslint-plugin-import": "^2.11.0" }, "engines": { "node": ">= 4" diff --git a/packages/eslint-config-airbnb/package.json b/packages/eslint-config-airbnb/package.json index dfaadad2ad..bc80fdd060 100644 --- a/packages/eslint-config-airbnb/package.json +++ b/packages/eslint-config-airbnb/package.json @@ -59,7 +59,7 @@ "editorconfig-tools": "^0.1.1", "eslint": "^4.19.1", "eslint-find-rules": "^3.2.2", - "eslint-plugin-import": "^2.10.0", + "eslint-plugin-import": "^2.11.0", "eslint-plugin-jsx-a11y": "^6.0.3", "eslint-plugin-react": "^7.7.0", "in-publish": "^2.0.0", @@ -69,7 +69,7 @@ }, "peerDependencies": { "eslint": "^4.19.1", - "eslint-plugin-import": "^2.10.0", + "eslint-plugin-import": "^2.11.0", "eslint-plugin-jsx-a11y": "^6.0.3", "eslint-plugin-react": "^7.7.0" }, From 87f97e042ddb94d87950be7c483b4aa4e391e2c2 Mon Sep 17 00:00:00 2001 From: Joe Lencioni Date: Wed, 18 Apr 2018 11:28:06 -0700 Subject: [PATCH 118/480] Replace flag images with emoji We can use emoji for most of these flags, which should make them look better on higher resolution displays and improve the loading performance of the style guide a little. The only flag we have here that does not have a good emoji yet is the flag of Catalonia, which I left as-is for now. https://emojipedia.org/flag-for-catalonia-esct/ --- README.md | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/README.md b/README.md index ed54520555..3ca74e2606 100644 --- a/README.md +++ b/README.md @@ -3640,22 +3640,22 @@ Other Style Guides This style guide is also available in other languages: - - ![br](https://raw.githubusercontent.com/gosquared/flags/master/flags/flags/shiny/24/Brazil.png) **Brazilian Portuguese**: [armoucar/javascript-style-guide](https://github.com/armoucar/javascript-style-guide) - - ![bg](https://raw.githubusercontent.com/gosquared/flags/master/flags/flags/shiny/24/Bulgaria.png) **Bulgarian**: [borislavvv/javascript](https://github.com/borislavvv/javascript) + - 🇧🇷 **Brazilian Portuguese**: [armoucar/javascript-style-guide](https://github.com/armoucar/javascript-style-guide) + - 🇧🇬 **Bulgarian**: [borislavvv/javascript](https://github.com/borislavvv/javascript) - ![ca](https://raw.githubusercontent.com/fpmweb/javascript-style-guide/master/img/catala.png) **Catalan**: [fpmweb/javascript-style-guide](https://github.com/fpmweb/javascript-style-guide) - - ![cn](https://raw.githubusercontent.com/gosquared/flags/master/flags/flags/shiny/24/China.png) **Chinese (Simplified)**: [yuche/javascript](https://github.com/yuche/javascript) - - ![tw](https://raw.githubusercontent.com/gosquared/flags/master/flags/flags/shiny/24/Taiwan.png) **Chinese (Traditional)**: [jigsawye/javascript](https://github.com/jigsawye/javascript) - - ![fr](https://raw.githubusercontent.com/gosquared/flags/master/flags/flags/shiny/24/France.png) **French**: [nmussy/javascript-style-guide](https://github.com/nmussy/javascript-style-guide) - - ![de](https://raw.githubusercontent.com/gosquared/flags/master/flags/flags/shiny/24/Germany.png) **German**: [timofurrer/javascript-style-guide](https://github.com/timofurrer/javascript-style-guide) - - ![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**: [ParkSB/javascript-style-guide](https://github.com/ParkSB/javascript-style-guide) - - ![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) - - ![tr](https://raw.githubusercontent.com/gosquared/flags/master/flags/flags/shiny/24/Turkey.png) **Turkish**: [eraycetinay/javascript](https://github.com/eraycetinay/javascript) - - ![ua](https://raw.githubusercontent.com/gosquared/flags/master/flags/flags/shiny/24/Ukraine.png) **Ukrainian**: [ivanzusko/javascript](https://github.com/ivanzusko/javascript) - - ![vn](https://raw.githubusercontent.com/gosquared/flags/master/flags/flags/shiny/24/Vietnam.png) **Vietnam**: [hngiang/javascript-style-guide](https://github.com/hngiang/javascript-style-guide) + - 🇨🇳 **Chinese (Simplified)**: [yuche/javascript](https://github.com/yuche/javascript) + - 🇹🇼 **Chinese (Traditional)**: [jigsawye/javascript](https://github.com/jigsawye/javascript) + - 🇫🇷 **French**: [nmussy/javascript-style-guide](https://github.com/nmussy/javascript-style-guide) + - 🇩🇪 **German**: [timofurrer/javascript-style-guide](https://github.com/timofurrer/javascript-style-guide) + - 🇮🇹 **Italian**: [sinkswim/javascript-style-guide](https://github.com/sinkswim/javascript-style-guide) + - 🇯🇵 **Japanese**: [mitsuruog/javascript-style-guide](https://github.com/mitsuruog/javascript-style-guide) + - 🇰🇷 **Korean**: [ParkSB/javascript-style-guide](https://github.com/ParkSB/javascript-style-guide) + - 🇷🇺 **Russian**: [leonidlebedev/javascript-airbnb](https://github.com/leonidlebedev/javascript-airbnb) + - 🇪🇸 **Spanish**: [paolocarrasco/javascript-style-guide](https://github.com/paolocarrasco/javascript-style-guide) + - 🇹🇭 **Thai**: [lvarayut/javascript-style-guide](https://github.com/lvarayut/javascript-style-guide) + - 🇹🇷 **Turkish**: [eraycetinay/javascript](https://github.com/eraycetinay/javascript) + - 🇺🇦 **Ukrainian**: [ivanzusko/javascript](https://github.com/ivanzusko/javascript) + - 🇻🇳 **Vietnam**: [hngiang/javascript-style-guide](https://github.com/hngiang/javascript-style-guide) ## The JavaScript Style Guide Guide From b56875bee21eb8d87213c787dc105c288066f43e Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Fri, 20 Apr 2018 14:00:50 -0700 Subject: [PATCH 119/480] [eslint config] [base] [patch] `function-paren-newline`: change to "consistent" --- packages/eslint-config-airbnb-base/rules/style.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/eslint-config-airbnb-base/rules/style.js b/packages/eslint-config-airbnb-base/rules/style.js index 12cd60d509..0f58957211 100644 --- a/packages/eslint-config-airbnb-base/rules/style.js +++ b/packages/eslint-config-airbnb-base/rules/style.js @@ -98,7 +98,7 @@ module.exports = { // enforce consistent line breaks inside function parentheses // https://eslint.org/docs/rules/function-paren-newline - 'function-paren-newline': ['error', 'multiline'], + 'function-paren-newline': ['error', 'consistent'], // Blacklist certain identifiers to prevent them being used // https://eslint.org/docs/rules/id-blacklist From fd0834764c8b991a807e6366181c1a3eddba240d Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Fri, 20 Apr 2018 15:19:14 -0700 Subject: [PATCH 120/480] [eslint config] [base] fix tests --- packages/eslint-config-airbnb-base/test/test-base.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/eslint-config-airbnb-base/test/test-base.js b/packages/eslint-config-airbnb-base/test/test-base.js index f907581502..07d17b1027 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(( // eslint-disable-line function-paren-newline +Object.keys(files).forEach(( 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) => { From 5705b8ae6b22305cc9dca048e0a4b14db7ce6934 Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Sun, 22 Apr 2018 14:48:50 -0700 Subject: [PATCH 121/480] Revert "Replace flag images with emoji" This reverts commit 87f97e042ddb94d87950be7c483b4aa4e391e2c2. Closes #1789. --- README.md | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/README.md b/README.md index 3ca74e2606..ed54520555 100644 --- a/README.md +++ b/README.md @@ -3640,22 +3640,22 @@ Other Style Guides This style guide is also available in other languages: - - 🇧🇷 **Brazilian Portuguese**: [armoucar/javascript-style-guide](https://github.com/armoucar/javascript-style-guide) - - 🇧🇬 **Bulgarian**: [borislavvv/javascript](https://github.com/borislavvv/javascript) + - ![br](https://raw.githubusercontent.com/gosquared/flags/master/flags/flags/shiny/24/Brazil.png) **Brazilian Portuguese**: [armoucar/javascript-style-guide](https://github.com/armoucar/javascript-style-guide) + - ![bg](https://raw.githubusercontent.com/gosquared/flags/master/flags/flags/shiny/24/Bulgaria.png) **Bulgarian**: [borislavvv/javascript](https://github.com/borislavvv/javascript) - ![ca](https://raw.githubusercontent.com/fpmweb/javascript-style-guide/master/img/catala.png) **Catalan**: [fpmweb/javascript-style-guide](https://github.com/fpmweb/javascript-style-guide) - - 🇨🇳 **Chinese (Simplified)**: [yuche/javascript](https://github.com/yuche/javascript) - - 🇹🇼 **Chinese (Traditional)**: [jigsawye/javascript](https://github.com/jigsawye/javascript) - - 🇫🇷 **French**: [nmussy/javascript-style-guide](https://github.com/nmussy/javascript-style-guide) - - 🇩🇪 **German**: [timofurrer/javascript-style-guide](https://github.com/timofurrer/javascript-style-guide) - - 🇮🇹 **Italian**: [sinkswim/javascript-style-guide](https://github.com/sinkswim/javascript-style-guide) - - 🇯🇵 **Japanese**: [mitsuruog/javascript-style-guide](https://github.com/mitsuruog/javascript-style-guide) - - 🇰🇷 **Korean**: [ParkSB/javascript-style-guide](https://github.com/ParkSB/javascript-style-guide) - - 🇷🇺 **Russian**: [leonidlebedev/javascript-airbnb](https://github.com/leonidlebedev/javascript-airbnb) - - 🇪🇸 **Spanish**: [paolocarrasco/javascript-style-guide](https://github.com/paolocarrasco/javascript-style-guide) - - 🇹🇭 **Thai**: [lvarayut/javascript-style-guide](https://github.com/lvarayut/javascript-style-guide) - - 🇹🇷 **Turkish**: [eraycetinay/javascript](https://github.com/eraycetinay/javascript) - - 🇺🇦 **Ukrainian**: [ivanzusko/javascript](https://github.com/ivanzusko/javascript) - - 🇻🇳 **Vietnam**: [hngiang/javascript-style-guide](https://github.com/hngiang/javascript-style-guide) + - ![cn](https://raw.githubusercontent.com/gosquared/flags/master/flags/flags/shiny/24/China.png) **Chinese (Simplified)**: [yuche/javascript](https://github.com/yuche/javascript) + - ![tw](https://raw.githubusercontent.com/gosquared/flags/master/flags/flags/shiny/24/Taiwan.png) **Chinese (Traditional)**: [jigsawye/javascript](https://github.com/jigsawye/javascript) + - ![fr](https://raw.githubusercontent.com/gosquared/flags/master/flags/flags/shiny/24/France.png) **French**: [nmussy/javascript-style-guide](https://github.com/nmussy/javascript-style-guide) + - ![de](https://raw.githubusercontent.com/gosquared/flags/master/flags/flags/shiny/24/Germany.png) **German**: [timofurrer/javascript-style-guide](https://github.com/timofurrer/javascript-style-guide) + - ![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**: [ParkSB/javascript-style-guide](https://github.com/ParkSB/javascript-style-guide) + - ![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) + - ![tr](https://raw.githubusercontent.com/gosquared/flags/master/flags/flags/shiny/24/Turkey.png) **Turkish**: [eraycetinay/javascript](https://github.com/eraycetinay/javascript) + - ![ua](https://raw.githubusercontent.com/gosquared/flags/master/flags/flags/shiny/24/Ukraine.png) **Ukrainian**: [ivanzusko/javascript](https://github.com/ivanzusko/javascript) + - ![vn](https://raw.githubusercontent.com/gosquared/flags/master/flags/flags/shiny/24/Vietnam.png) **Vietnam**: [hngiang/javascript-style-guide](https://github.com/hngiang/javascript-style-guide) ## The JavaScript Style Guide Guide From 2653730fee20e46a1fc6e6c9fd512329d8719fb0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nguy=E1=BB=85n=20Ti=E1=BA=BFn=20Minh?= Date: Sat, 21 Apr 2018 13:51:56 +0700 Subject: [PATCH 122/480] [react] add vietnamese --- react/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/react/README.md b/react/README.md index b89bad0710..1af23d4d1f 100644 --- a/react/README.md +++ b/react/README.md @@ -693,5 +693,6 @@ This style guide is mostly based on the standards that are currently prevalent i - ![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/tree/master/react) - ![tr](https://raw.githubusercontent.com/gosquared/flags/master/flags/flags/shiny/24/Turkey.png) **Turkish**: [alioguzhan/react-style-guide](https://github.com/alioguzhan/react-style-guide) - ![ua](https://raw.githubusercontent.com/gosquared/flags/master/flags/flags/shiny/24/Ukraine.png) **Ukrainian**: [ivanzusko/javascript](https://github.com/ivanzusko/javascript/tree/master/react) + - ![vn](https://raw.githubusercontent.com/gosquared/flags/master/flags/flags/shiny/24/Vietnam.png) **Vietnam**: [uetcodecamp/jsx-style-guide](https://github.com/UETCodeCamp/jsx-style-guide) **[⬆ back to top](#table-of-contents)** From 22f01558a08eed9f32ad3b6e963ac71bebd37433 Mon Sep 17 00:00:00 2001 From: Feross Aboukhadijeh Date: Wed, 25 Apr 2018 20:28:41 -0700 Subject: [PATCH 123/480] Add StandardJS to "Other Style Guides" list MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit StandardJS is one of the top style guides, though like the Google and jQuery styles, it's less popular than the airbnb style. 😀 --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index ed54520555..855be914f9 100644 --- a/README.md +++ b/README.md @@ -3484,6 +3484,7 @@ Other Style Guides - [Google JavaScript Style Guide](https://google.github.io/styleguide/javascriptguide.xml) - [jQuery Core Style Guidelines](https://contribute.jquery.org/style-guide/js/) - [Principles of Writing Consistent, Idiomatic JavaScript](https://github.com/rwaldron/idiomatic.js) + - [StandardJS](https://standardjs.com) **Other Styles** From 8c83d03a20d166aba0acefa1358efe6043eacc3e Mon Sep 17 00:00:00 2001 From: Joe Lencioni Date: Thu, 15 Feb 2018 11:58:17 -0800 Subject: [PATCH 124/480] [eslint config] [base] [patch] Allow devDependencies for foo_spec.js naming style Some projects name test files like `foo_spec.js` instead of `foo.spec.js`. --- 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 04455c97fb..46c6135093 100644 --- a/packages/eslint-config-airbnb-base/rules/imports.js +++ b/packages/eslint-config-airbnb-base/rules/imports.js @@ -77,7 +77,7 @@ module.exports = { '**/__mocks__/**', // jest pattern '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 + '**/*{.,_}{test,spec}.{js,jsx}', // tests where the extension or filename suffix denotes that it is a test '**/jest.config.js', // jest config '**/webpack.config.js', // webpack config '**/webpack.config.*.js', // webpack config From 2d9779907f9760472e0318ad11b01f67a9f5dc7e Mon Sep 17 00:00:00 2001 From: Thomas Grainger Date: Mon, 30 Apr 2018 09:30:38 +0100 Subject: [PATCH 125/480] [eslint config] [base] [minor] only allow one newline at the end --- packages/eslint-config-airbnb-base/rules/style.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/eslint-config-airbnb-base/rules/style.js b/packages/eslint-config-airbnb-base/rules/style.js index 0f58957211..ca8fc07ae6 100644 --- a/packages/eslint-config-airbnb-base/rules/style.js +++ b/packages/eslint-config-airbnb-base/rules/style.js @@ -302,7 +302,7 @@ module.exports = { 'no-multi-assign': ['error'], // disallow multiple empty lines and only one newline at the end - 'no-multiple-empty-lines': ['error', { max: 2, maxEOF: 1 }], + 'no-multiple-empty-lines': ['error', { max: 2, maxEOF: 0 }], // disallow negated conditions // https://eslint.org/docs/rules/no-negated-condition From edf942eeb6bee3ae538e1484861ea0721fad4856 Mon Sep 17 00:00:00 2001 From: Daniel McNally Date: Wed, 2 May 2018 01:01:19 -0400 Subject: [PATCH 126/480] [guide] Add descriptions of enforced rules This commit adds brief descriptions and examples of rules enforced by the guide that were not previously mentioned in the README. --- README.md | 102 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 102 insertions(+) diff --git a/README.md b/README.md index 855be914f9..8a2cb4b6fc 100644 --- a/README.md +++ b/README.md @@ -1053,6 +1053,24 @@ Other Style Guides }; ``` + - [8.6](#whitespace--implicit-arrow-linebreak) Enforce the location of arrow function bodies with implicit returns. eslint: [`implicit-arrow-linebreak`](https://eslint.org/docs/rules/implicit-arrow-linebreak) + + ```javascript + // bad + (foo) => + bar; + + (foo) => + (bar); + + // good + (foo) => bar; + (foo) => (bar); + (foo) => ( + bar + ) + ``` + **[⬆ back to top](#table-of-contents)** ## Classes & Constructors @@ -2664,6 +2682,90 @@ Other Style Guides .fail(() => console.log('You have failed this city.')); ``` + - [19.13](#whitespace--block-spacing) Require consistent spacing inside an open block token and the next token on the same line. This rule also enforces consistent spacing inside a close block token and previous token on the same line. eslint: [`block-spacing`](https://eslint.org/docs/rules/block-spacing) + + ```javascript + // bad + function foo() {return true;} + if (foo) { bar = 0;} + + // good + function foo() { return true; } + if (foo) { bar = 0; } + ``` + + - [19.14](#whitespace--comma-spacing) Avoid spaces before commas and require a space after commas. eslint: [`comma-spacing`](https://eslint.org/docs/rules/comma-spacing) + + ```javascript + // bad + var foo = 1,bar = 2; + var arr = [1 , 2]; + + // good + var foo = 1, bar = 2; + var arr = [1, 2]; + ``` + + - [19.15](#whitespace--computed-property-spacing) Avoid spaces before commas and require a space after commas. eslint: [`computed-property-spacing`](https://eslint.org/docs/rules/computed-property-spacing) + + ```javascript + // bad + obj[foo ] + obj[ 'foo'] + var x = {[ b ]: a} + obj[foo[ bar ]] + + // good + obj[foo] + obj['foo'] + var x = { [b]: a } + obj[foo[bar]] + ``` + + - [19.16](#whitespace--func-call-spacing) Enforce spacing between functions and their invocations. eslint: [`func-call-spacing`](https://eslint.org/docs/rules/func-call-spacing) + + ```javascript + // bad + func (); + + func + (); + + // good + func(); + ``` + + - [19.17](#whitespace--key-spacing) Enforce spacing between keys and values in object literal properties. eslint: [`key-spacing`](https://eslint.org/docs/rules/key-spacing) + + ```javascript + // bad + var obj = { "foo" : 42 }; + var obj2 = { "foo":42 }; + + // good + var obj = { "foo": 42 }; + ``` + + - [19.18](#whitespace--no-trailing-spaces) Avoid trailing spaces at the end of lines. eslint: [`no-trailing-spaces`](https://eslint.org/docs/rules/no-trailing-spaces) + + - [19.19](#whitespace--no-multiple-empty-lines) Avoid multiple empty lines and only allow one newline at the end of files. eslint: [`no-multiple-empty-lines`](https://eslint.org/docs/rules/no-multiple-empty-lines) + + + ```javascript + // bad + var x = 1; + + + + var y = 2; + + // good + var x = 1; + + var y = 2; + ``` + + **[⬆ back to top](#table-of-contents)** ## Commas From 71e54f2af8e17c6147f1e8f7baafdbcf86d1d2d9 Mon Sep 17 00:00:00 2001 From: Vse Mozhet Byt Date: Fri, 4 May 2018 11:11:55 +0300 Subject: [PATCH 127/480] doc: fix some nits in README.md * Add missing anchors for section references. * Correct a rule description. --- README.md | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 8a2cb4b6fc..8ef84ade85 100644 --- a/README.md +++ b/README.md @@ -1053,6 +1053,7 @@ Other Style Guides }; ``` + - [8.6](#whitespace--implicit-arrow-linebreak) Enforce the location of arrow function bodies with implicit returns. eslint: [`implicit-arrow-linebreak`](https://eslint.org/docs/rules/implicit-arrow-linebreak) ```javascript @@ -2682,6 +2683,7 @@ Other Style Guides .fail(() => console.log('You have failed this city.')); ``` + - [19.13](#whitespace--block-spacing) Require consistent spacing inside an open block token and the next token on the same line. This rule also enforces consistent spacing inside a close block token and previous token on the same line. eslint: [`block-spacing`](https://eslint.org/docs/rules/block-spacing) ```javascript @@ -2694,6 +2696,7 @@ Other Style Guides if (foo) { bar = 0; } ``` + - [19.14](#whitespace--comma-spacing) Avoid spaces before commas and require a space after commas. eslint: [`comma-spacing`](https://eslint.org/docs/rules/comma-spacing) ```javascript @@ -2706,7 +2709,8 @@ Other Style Guides var arr = [1, 2]; ``` - - [19.15](#whitespace--computed-property-spacing) Avoid spaces before commas and require a space after commas. eslint: [`computed-property-spacing`](https://eslint.org/docs/rules/computed-property-spacing) + + - [19.15](#whitespace--computed-property-spacing) Enforce spacing inside of computed properties. eslint: [`computed-property-spacing`](https://eslint.org/docs/rules/computed-property-spacing) ```javascript // bad @@ -2722,6 +2726,7 @@ Other Style Guides obj[foo[bar]] ``` + - [19.16](#whitespace--func-call-spacing) Enforce spacing between functions and their invocations. eslint: [`func-call-spacing`](https://eslint.org/docs/rules/func-call-spacing) ```javascript @@ -2735,6 +2740,7 @@ Other Style Guides func(); ``` + - [19.17](#whitespace--key-spacing) Enforce spacing between keys and values in object literal properties. eslint: [`key-spacing`](https://eslint.org/docs/rules/key-spacing) ```javascript @@ -2746,8 +2752,10 @@ Other Style Guides var obj = { "foo": 42 }; ``` + - [19.18](#whitespace--no-trailing-spaces) Avoid trailing spaces at the end of lines. eslint: [`no-trailing-spaces`](https://eslint.org/docs/rules/no-trailing-spaces) + - [19.19](#whitespace--no-multiple-empty-lines) Avoid multiple empty lines and only allow one newline at the end of files. eslint: [`no-multiple-empty-lines`](https://eslint.org/docs/rules/no-multiple-empty-lines) From 2bd77bc1e0fb6fb17f9601961cd9d5b878623c28 Mon Sep 17 00:00:00 2001 From: Jimmy Jia Date: Sat, 5 May 2018 22:34:19 -0400 Subject: [PATCH 128/480] [eslint config] [base] [patch] `label-has-for`: Remove redundant component Also make the rule configuration more explicit. --- packages/eslint-config-airbnb/rules/react-a11y.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/packages/eslint-config-airbnb/rules/react-a11y.js b/packages/eslint-config-airbnb/rules/react-a11y.js index 3e7f5c970c..f53b3d22f6 100644 --- a/packages/eslint-config-airbnb/rules/react-a11y.js +++ b/packages/eslint-config-airbnb/rules/react-a11y.js @@ -48,7 +48,13 @@ module.exports = { // require that JSX labels use "htmlFor" // https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/label-has-for.md - 'jsx-a11y/label-has-for': ['error', { components: ['label'] }], + 'jsx-a11y/label-has-for': ['error', { + components: [], + required: { + every: ['nesting', 'id'], + }, + allowChildren: false, + }], // 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 From 2ba36de952fcb6a931471980f4fbbdc4df468baa Mon Sep 17 00:00:00 2001 From: ParkSB Date: Sat, 5 May 2018 03:04:38 +0900 Subject: [PATCH 129/480] [guide] Add backticks --- README.md | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 8ef84ade85..969c65c0e4 100644 --- a/README.md +++ b/README.md @@ -370,7 +370,7 @@ Other Style Guides ``` - - [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) 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). ```javascript const foo = document.querySelectorAll('.foo'); @@ -786,7 +786,7 @@ Other Style Guides - [7.10](#functions--constructor) Never use the Function constructor to create a new function. eslint: [`no-new-func`](https://eslint.org/docs/rules/no-new-func) - > Why? Creating a function in this way evaluates a string similarly to eval(), which opens vulnerabilities. + > Why? Creating a function in this way evaluates a string similarly to `eval()`, which opens vulnerabilities. ```javascript // bad @@ -1167,7 +1167,7 @@ Other Style Guides ``` - - [9.4](#constructors--tostring) It’s okay to write a custom toString() method, just make sure it works successfully and causes no side effects. + - [9.4](#constructors--tostring) It’s okay to write a custom `toString()` method, just make sure it works successfully and causes no side effects. ```javascript class Jedi { @@ -1687,7 +1687,7 @@ Other Style Guides ``` - - [13.6](#variables--unary-increment-decrement) Avoid using unary increments and decrements (++, --). eslint [`no-plusplus`](https://eslint.org/docs/rules/no-plusplus) + - [13.6](#variables--unary-increment-decrement) Avoid using unary increments and decrements (`++`, `--`). eslint [`no-plusplus`](https://eslint.org/docs/rules/no-plusplus) > Why? Per the eslint documentation, unary increment and decrement statements are subject to automatic semicolon insertion and can cause silent errors with incrementing or decrementing values within an application. It is also more expressive to mutate your values with statements like `num += 1` instead of `num++` or `num ++`. Disallowing unary increment and decrement statements also prevents you from pre-incrementing/pre-decrementing values unintentionally which can also cause unexpected behavior in your programs. @@ -3295,7 +3295,7 @@ Other Style Guides - [24.1](#accessors--not-required) Accessor functions for properties are not required. - - [24.2](#accessors--no-getters-setters) Do not use JavaScript getters/setters as they cause unexpected side effects and are harder to test, maintain, and reason about. Instead, if you do make accessor functions, use getVal() and setVal('hello'). + - [24.2](#accessors--no-getters-setters) Do not use JavaScript getters/setters as they cause unexpected side effects and are harder to test, maintain, and reason about. Instead, if you do make accessor functions, use `getVal()` and `setVal('hello')`. ```javascript // bad @@ -3337,7 +3337,7 @@ Other Style Guides ``` - - [24.4](#accessors--consistent) It’s okay to create get() and set() functions, but be consistent. + - [24.4](#accessors--consistent) It’s okay to create `get()` and `set()` functions, but be consistent. ```javascript class Jedi { From c068d7cbf1bfb2f263bc928ca7fd895a6a6add7f Mon Sep 17 00:00:00 2001 From: Brett Date: Sat, 26 May 2018 13:38:45 -0700 Subject: [PATCH 130/480] 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 131/480] [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 132/480] 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 133/480] 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 134/480] 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 135/480] [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 136/480] 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 137/480] 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 138/480] [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 139/480] 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 140/480] [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 141/480] [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 142/480] [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 143/480] [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 144/480] [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 145/480] [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 146/480] [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 147/480] [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 148/480] [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 149/480] 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 150/480] [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 151/480] [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 152/480] [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 153/480] 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 154/480] [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 155/480] [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 156/480] 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 157/480] [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 158/480] [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 159/480] [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 160/480] [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 161/480] [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 162/480] [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 163/480] [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 164/480] [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 && +