From 5fd7c6f08c0650ed67297fc83c8a0590c9a92cc8 Mon Sep 17 00:00:00 2001 From: Estelle Date: Mon, 23 Mar 2015 18:48:19 -0700 Subject: [PATCH 001/702] 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 556846745cee3b2c9630ce69722c60986ea0c800 Mon Sep 17 00:00:00 2001 From: Mark Miyashita Date: Sun, 6 Nov 2016 05:19:22 -0800 Subject: [PATCH 002/702] [guide] Separate 19.2 code blocks into diff + javascript sections --- README.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 1ed011d564..fee8392863 100644 --- a/README.md +++ b/README.md @@ -2393,7 +2393,7 @@ Other Style Guides > 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. - ```javascript + ```diff // bad - git diff without trailing comma const hero = { firstName: 'Florence', @@ -2408,7 +2408,9 @@ Other Style Guides lastName: 'Nightingale', + inventorOf: ['coxcomb chart', 'modern nursing'], }; + ``` + ```javascript // bad const hero = { firstName: 'Dana', From 535cb799a9f94d8898071c0fd161810b18c7fa08 Mon Sep 17 00:00:00 2001 From: Jonathan Date: Wed, 2 Nov 2016 16:02:35 +0100 Subject: [PATCH 003/702] [guide] Mention both num++ and num ++ --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index fee8392863..5bc9c49f78 100644 --- a/README.md +++ b/README.md @@ -1547,15 +1547,15 @@ 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) - > 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 ++`. 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. + > 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. ```javascript // bad let array = [1, 2, 3]; let num = 1; - num ++; - -- num; + num++; + --num; let sum = 0; let truthyCount = 0; From 153c02b36cb2a3c980962ae9fabadf952c3c06e3 Mon Sep 17 00:00:00 2001 From: Jonathan Chen Date: Tue, 1 Nov 2016 06:31:17 -0400 Subject: [PATCH 004/702] Create LICENSE.md --- LICENSE.md | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 LICENSE.md diff --git a/LICENSE.md b/LICENSE.md new file mode 100644 index 0000000000..87081c1339 --- /dev/null +++ b/LICENSE.md @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2016 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 3ab19f07f468d3606ac3656f477104d19ff616fc Mon Sep 17 00:00:00 2001 From: Andrew Smith Date: Tue, 25 Oct 2016 14:47:25 -0700 Subject: [PATCH 005/702] [guide] Fix inconsistency in function expression rules. --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 5bc9c49f78..63dfc192f8 100644 --- a/README.md +++ b/README.md @@ -576,7 +576,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: [`requireFunctionDeclarations`](http://jscs.info/rule/requireFunctionDeclarations) - > 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. + > Why? Function declarations are hoisted, which means that it’s easy - too easy - to reference the function before it is defined in the file. This harms readability and maintainability. If you find that a function’s definition is large or complex enough that it is interfering with understanding the rest of the file, then perhaps it’s time to extract it to its own module! Don’t forget to name the expression - anonymous functions can make it harder to locate the problem in an Error's call stack. ([Discussion](https://github.com/airbnb/javascript/issues/794)) ```javascript // bad From 436cf3ee6366a4cf3382dbdee6078a90e92508d6 Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Sun, 6 Nov 2016 09:54:17 -0800 Subject: [PATCH 006/702] [eslint config] [base] [breaking] update `eslint`, `eslint-plugin-import`; enable `import/no-named-default` --- packages/eslint-config-airbnb-base/package.json | 8 ++++---- packages/eslint-config-airbnb-base/rules/imports.js | 4 ++++ 2 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 783eaa5c85..78abc8a524 100644 --- a/packages/eslint-config-airbnb-base/package.json +++ b/packages/eslint-config-airbnb-base/package.json @@ -47,16 +47,16 @@ "devDependencies": { "babel-preset-airbnb": "^2.1.1", "babel-tape-runner": "^2.0.1", - "eslint": "^3.9.0", + "eslint": "^3.9.1", "eslint-find-rules": "^1.14.3", - "eslint-plugin-import": "^2.0.1", + "eslint-plugin-import": "^2.1.0", "in-publish": "^2.0.0", "safe-publish-latest": "^1.1.1", "tape": "^4.6.2" }, "peerDependencies": { - "eslint": "^3.9.0", - "eslint-plugin-import": "^2.0.1" + "eslint": "^3.9.1", + "eslint-plugin-import": "^2.1.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 a8f4269cbd..2f9cac57ea 100644 --- a/packages/eslint-config-airbnb-base/rules/imports.js +++ b/packages/eslint-config-airbnb-base/rules/imports.js @@ -170,5 +170,9 @@ module.exports = { // https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/no-unassigned-import.md // importing for side effects is perfectly acceptable, if you need side effects. 'import/no-unassigned-import': 'off', + + // Prevent importing the default as if it were named + // https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/no-named-default.md + 'import/no-named-default': 'error', }, }; From 1399b3cbfa785f760c15ec63112f711b2c68fd28 Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Sun, 6 Nov 2016 09:54:42 -0800 Subject: [PATCH 007/702] [eslint config] [base] [breaking] prefer `**` over `Math.pow` --- packages/eslint-config-airbnb-base/rules/best-practices.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/packages/eslint-config-airbnb-base/rules/best-practices.js b/packages/eslint-config-airbnb-base/rules/best-practices.js index b7e3f60630..f8cdc208d1 100644 --- a/packages/eslint-config-airbnb-base/rules/best-practices.js +++ b/packages/eslint-config-airbnb-base/rules/best-practices.js @@ -186,6 +186,10 @@ module.exports = { }, { property: '__defineSetter__', message: 'Please use Object.defineProperty instead.', + }, { + object: 'Math', + property: 'pow', + message: 'Use the exponentiation operator (**) instead.', }], // disallow use of assignment in return statement From 2f9dddbe205145512978a9f07b08fe987505d4d7 Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Sun, 6 Nov 2016 10:01:36 -0800 Subject: [PATCH 008/702] [eslint config] [base] [patch] loosen `no-extraneous-dependencies` for test files. Relates to #959, #1089. --- 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 2f9cac57ea..2fb05df41d 100644 --- a/packages/eslint-config-airbnb-base/rules/imports.js +++ b/packages/eslint-config-airbnb-base/rules/imports.js @@ -66,8 +66,9 @@ module.exports = { // Forbid the use of extraneous packages // https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/no-extraneous-dependencies.md + // paths are treated both as absolute paths, and relative to process.cwd() 'import/no-extraneous-dependencies': ['error', { - devDependencies: false, + devDependencies: ['spec/**', 'test/**', 'tests/**', '**/__tests__/**'], optionalDependencies: false, }], From c4a9d28485f39005464571db45ecfe8f83dd732d Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Sun, 6 Nov 2016 10:34:29 -0800 Subject: [PATCH 009/702] [Tests] on `node` `v7` --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index 773761966a..f492123d64 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,5 +1,6 @@ language: node_js node_js: + - "7" - "6" - "5" - "4" From 9f51fd264b5b2bafb9f45bdebcef6732fefb241b Mon Sep 17 00:00:00 2001 From: Jordan Gensler Date: Mon, 12 Sep 2016 16:12:19 -0700 Subject: [PATCH 010/702] [guide] Add notes on acronyms and initialisms to naming --- README.md | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/README.md b/README.md index 63dfc192f8..4a844bcbb0 100644 --- a/README.md +++ b/README.md @@ -2761,6 +2761,36 @@ Other Style Guides export default AirbnbStyleGuide; ``` + + - [22.9](#naming--Acronyms-and-Initialisms) Acronyms and initialisms should always be all capitalized, or all lowercased. + + > Why? Names are for readability, not to appease a computer algorithm. + + ```javascript + // bad + import SmsContainer from './containers/SmsContainer'; + + // bad + const HttpRequests = [ + // ... + ]; + + // good + import SMSContainer from './containers/SMSContainer'; + + // good + const HTTPRequests = [ + // ... + ]; + + // best + import TextMessageContainer from './containers/TextMessageContainer'; + + // best + const Requests = [ + // ... + ]; + ``` **[⬆ back to top](#table-of-contents)** From 8c2df7493aebbf7a77778134d571e5b1f8fbd0dc Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Sun, 6 Nov 2016 10:41:38 -0800 Subject: [PATCH 011/702] [eslint config] [base] v10.0.0 --- packages/eslint-config-airbnb-base/CHANGELOG.md | 14 ++++++++++++++ packages/eslint-config-airbnb-base/package.json | 2 +- packages/eslint-config-airbnb-base/rules/style.js | 1 - 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/packages/eslint-config-airbnb-base/CHANGELOG.md b/packages/eslint-config-airbnb-base/CHANGELOG.md index 17f218bd65..ad3ef6f8c6 100644 --- a/packages/eslint-config-airbnb-base/CHANGELOG.md +++ b/packages/eslint-config-airbnb-base/CHANGELOG.md @@ -1,3 +1,17 @@ +10.0.0 / 2016-11-06 +================== + - [breaking] prefer `**` over `Math.pow` + - [breaking] `comma-dangle`: require trailing commas for functions + - [breaking] enable `no-useless-return` + - [breaking] tighten up `indent` + - [breaking] tighten up `spaced-comment` + - [breaking] enable `import/no-named-default` + - [patch] loosen `max-len` with `ignoreRegExpLiterals` option + - [patch] loosen `no-extraneous-dependencies` for test files (#959, #1089) + - [deps] update `eslint`, `eslint-plugin-import` + - [dev deps] update `eslint-find-rules` + - [Tests] on `node` `v7` + 9.0.0 / 2016-10-16 ================== - [breaking] Add `ForOfStatement` to `no-restricted-syntax` (#1122, #1134) diff --git a/packages/eslint-config-airbnb-base/package.json b/packages/eslint-config-airbnb-base/package.json index 78abc8a524..b057319032 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": "9.0.0", + "version": "10.0.0", "description": "Airbnb's base JS ESLint config, following our styleguide", "main": "index.js", "scripts": { diff --git a/packages/eslint-config-airbnb-base/rules/style.js b/packages/eslint-config-airbnb-base/rules/style.js index c9e7c0f7a9..536cd5320b 100644 --- a/packages/eslint-config-airbnb-base/rules/style.js +++ b/packages/eslint-config-airbnb-base/rules/style.js @@ -352,7 +352,6 @@ module.exports = { // require or disallow a space immediately following the // or /* in a comment // http://eslint.org/docs/rules/spaced-comment - // TODO: semver-major: set balanced to "false" 'spaced-comment': ['error', 'always', { line: { exceptions: ['-', '+'], From 38bd170e2cd8d28c99b69b5566f50362d6548cd7 Mon Sep 17 00:00:00 2001 From: Spen Taylor Date: Mon, 7 Nov 2016 10:39:00 +1100 Subject: [PATCH 012/702] [guide] Update syntax in `eol-last` examples --- README.md | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index 4a844bcbb0..274dd79ab4 100644 --- a/README.md +++ b/README.md @@ -2115,24 +2115,24 @@ Other Style Guides ```javascript // bad - (function (global) { - // ...stuff... - })(this); + import { es6 } from './AirbnbStyleGuide'; + // ... + export default es6; ``` ```javascript // bad - (function (global) { - // ...stuff... - })(this);↵ + import { es6 } from './AirbnbStyleGuide'; + // ... + export default es6;↵ ↵ ``` ```javascript // good - (function (global) { - // ...stuff... - })(this);↵ + import { es6 } from './AirbnbStyleGuide'; + // ... + export default es6;↵ ``` From c3044f811e139cf68d16ea026a6603c4c5f90a79 Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Sun, 6 Nov 2016 16:02:50 -0800 Subject: [PATCH 013/702] [eslint config] [breaking] [deps] update `eslint-config-airbnb-base`, `eslint`, `eslint-plugin-import`, `eslint-plugin-react` --- packages/eslint-config-airbnb-base/test/.eslintrc | 3 --- packages/eslint-config-airbnb/package.json | 14 +++++++------- packages/eslint-config-airbnb/test/.eslintrc | 8 ++------ 3 files changed, 9 insertions(+), 16 deletions(-) diff --git a/packages/eslint-config-airbnb-base/test/.eslintrc b/packages/eslint-config-airbnb-base/test/.eslintrc index 02ab3c48bb..5808be6186 100644 --- a/packages/eslint-config-airbnb-base/test/.eslintrc +++ b/packages/eslint-config-airbnb-base/test/.eslintrc @@ -4,8 +4,5 @@ "no-shadow": 0, // tests uses `t` for tape "id-length": [2, {"min": 2, "properties": "never", "exceptions": ["t"]}], - "import/no-extraneous-dependencies": [2, { - "devDependencies": true - }], } } diff --git a/packages/eslint-config-airbnb/package.json b/packages/eslint-config-airbnb/package.json index 12c23441f6..37c9d25029 100644 --- a/packages/eslint-config-airbnb/package.json +++ b/packages/eslint-config-airbnb/package.json @@ -45,26 +45,26 @@ }, "homepage": "https://github.com/airbnb/javascript", "dependencies": { - "eslint-config-airbnb-base": "^9.0.0" + "eslint-config-airbnb-base": "^10.0.0" }, "devDependencies": { "babel-preset-airbnb": "^2.1.1", "babel-tape-runner": "^2.0.1", - "eslint": "^3.9.0", + "eslint": "^3.9.1", "eslint-find-rules": "^1.14.3", - "eslint-plugin-import": "^2.0.1", + "eslint-plugin-import": "^2.1.0", "eslint-plugin-jsx-a11y": "^2.2.3", - "eslint-plugin-react": "^6.4.1", + "eslint-plugin-react": "^6.6.0", "in-publish": "^2.0.0", "react": ">= 0.13.0", "safe-publish-latest": "^1.1.1", "tape": "^4.6.2" }, "peerDependencies": { - "eslint": "^3.9.0", + "eslint": "^3.9.1", "eslint-plugin-jsx-a11y": "^2.2.3", - "eslint-plugin-import": "^2.0.1", - "eslint-plugin-react": "^6.4.1" + "eslint-plugin-import": "^2.1.0", + "eslint-plugin-react": "^6.6.0" }, "engines": { "node": ">= 4" diff --git a/packages/eslint-config-airbnb/test/.eslintrc b/packages/eslint-config-airbnb/test/.eslintrc index eafcdbffa6..9c23197fab 100644 --- a/packages/eslint-config-airbnb/test/.eslintrc +++ b/packages/eslint-config-airbnb/test/.eslintrc @@ -1,13 +1,9 @@ { "rules": { - // disabled because I find it tedious to write tests while following this - // rule + // disabled because I find it tedious to write tests while following this rule "no-shadow": 0, // tests uses `t` for tape - "id-length": [2, {"min": 2, "properties": "never", "exceptions": ["t"]}], - - // tests can import things in devDependencies - "import/no-extraneous-dependencies": [2, {"devDependencies": true}] + "id-length": [2, {"min": 2, "properties": "never", "exceptions": ["t"]}] } } From 3e656750e68acaa166fb53e4783b66b42473db9f Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Sun, 6 Nov 2016 22:07:50 -0800 Subject: [PATCH 014/702] [eslint config] [breaking] re-enable `react/no-unused-prop-types` --- packages/eslint-config-airbnb/rules/react.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/eslint-config-airbnb/rules/react.js b/packages/eslint-config-airbnb/rules/react.js index 38b7dc25df..262b30927c 100644 --- a/packages/eslint-config-airbnb/rules/react.js +++ b/packages/eslint-config-airbnb/rules/react.js @@ -271,7 +271,7 @@ module.exports = { // Prevent unused propType definitions // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/no-unused-prop-types.md - 'react/no-unused-prop-types': ['warn', { + 'react/no-unused-prop-types': ['error', { customValidators: [ ], skipShapeProps: true, From 24b8f35f18e6baab92d4da7aa2c10c4fc2374245 Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Sun, 6 Nov 2016 22:14:05 -0800 Subject: [PATCH 015/702] [eslint config] v13.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 4dde06abe3..b2cb3456c9 100644 --- a/packages/eslint-config-airbnb/CHANGELOG.md +++ b/packages/eslint-config-airbnb/CHANGELOG.md @@ -1,3 +1,13 @@ +13.0.0 / 2016-11-06 +================== +- [breaking] Enable `import/no-webpack-loader-syntax` rule (#1123) +- [patch] `class-methods-use-this`: exempt React `getChildContext` (#1094) +- [patch] set `react/no-unused-prop-types` skipShapeProps (#1099) +- [deps] [breaking] update `eslint`, `eslint-config-airbnb-base`, `eslint-plugin-jsx-a11y`, `eslint-plugin-react`, `eslint-plugin-import` +- [dev deps] update `babel-preset-airbnb`, `eslint`, `eslint-find-rules`, `tape`, `safe-publish-latest` +- [Tests] on `node` `v7` +- [docs] ensure latest version of config is installed (#1121) + 12.0.0 / 2016-09-24 ================== - [breaking] Enable react rules: `react/no-unescaped-entities`, `react/no-children-prop` diff --git a/packages/eslint-config-airbnb/package.json b/packages/eslint-config-airbnb/package.json index 37c9d25029..4033c46f1f 100644 --- a/packages/eslint-config-airbnb/package.json +++ b/packages/eslint-config-airbnb/package.json @@ -1,6 +1,6 @@ { "name": "eslint-config-airbnb", - "version": "12.0.0", + "version": "13.0.0", "description": "Airbnb's ESLint config, following our styleguide", "main": "index.js", "scripts": { From 97575b2087a3371d6223f86960f90eee7426f7c8 Mon Sep 17 00:00:00 2001 From: Pete Pirasis <1pete@users.noreply.github.com> Date: Thu, 27 Oct 2016 03:04:31 +0700 Subject: [PATCH 016/702] Fix broken rule reference link `import/first` --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 274dd79ab4..95dc926d06 100644 --- a/README.md +++ b/README.md @@ -1239,7 +1239,7 @@ Other Style Guides - [10.7](#modules--imports-first) Put all `import`s above non-import statements. - eslint: [`import/imports-first`](https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/imports-first.md) + eslint: [`import/first`](https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/first.md) > Why? Since `import`s are hoisted, keeping them all at the top prevents surprising behavior. ```javascript From a2cb4a2cd6721672a9cd03a7d0c4d529e298e335 Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Mon, 7 Nov 2016 00:48:12 -0800 Subject: [PATCH 017/702] [eslint config] [base] [fix] legacy config should not require `**` Per https://github.com/airbnb/javascript/commit/1399b3cbfa785f760c15ec63112f711b2c68fd28#commitcomment-19718532 --- packages/eslint-config-airbnb-base/legacy.js | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/packages/eslint-config-airbnb-base/legacy.js b/packages/eslint-config-airbnb-base/legacy.js index 3de97acd21..a73de7d8f7 100644 --- a/packages/eslint-config-airbnb-base/legacy.js +++ b/packages/eslint-config-airbnb-base/legacy.js @@ -18,5 +18,16 @@ module.exports = { rules: { 'comma-dangle': ['error', 'never'], 'prefer-numeric-literals': 'off', + 'no-restricted-properties': ['error', { + object: 'arguments', + property: 'callee', + message: 'arguments.callee is deprecated', + }, { + property: '__defineGetter__', + message: 'Please use Object.defineProperty instead.', + }, { + property: '__defineSetter__', + message: 'Please use Object.defineProperty instead.', + }], } }; From f82857512d42c89e6561d96061a6edc54becd695 Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Mon, 7 Nov 2016 00:49:02 -0800 Subject: [PATCH 018/702] [eslint config] [base] v10.0.1 --- packages/eslint-config-airbnb-base/CHANGELOG.md | 4 ++++ packages/eslint-config-airbnb-base/package.json | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/packages/eslint-config-airbnb-base/CHANGELOG.md b/packages/eslint-config-airbnb-base/CHANGELOG.md index ad3ef6f8c6..1fa42086a7 100644 --- a/packages/eslint-config-airbnb-base/CHANGELOG.md +++ b/packages/eslint-config-airbnb-base/CHANGELOG.md @@ -1,3 +1,7 @@ +10.0.1 / 2016-11-07 +================== + - [fix] legacy config should not require `**` + 10.0.0 / 2016-11-06 ================== - [breaking] prefer `**` over `Math.pow` diff --git a/packages/eslint-config-airbnb-base/package.json b/packages/eslint-config-airbnb-base/package.json index b057319032..7cde827bf3 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": "10.0.0", + "version": "10.0.1", "description": "Airbnb's base JS ESLint config, following our styleguide", "main": "index.js", "scripts": { From ae1c0f89cbc02610cf647896d6957bca7e7b3cc5 Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Mon, 7 Nov 2016 01:01:15 -0800 Subject: [PATCH 019/702] [eslint config] [deps] update `eslint-config-airbnb-base` --- 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 4033c46f1f..467267475d 100644 --- a/packages/eslint-config-airbnb/package.json +++ b/packages/eslint-config-airbnb/package.json @@ -45,7 +45,7 @@ }, "homepage": "https://github.com/airbnb/javascript", "dependencies": { - "eslint-config-airbnb-base": "^10.0.0" + "eslint-config-airbnb-base": "^10.0.1" }, "devDependencies": { "babel-preset-airbnb": "^2.1.1", From ec08ca84ba756543df99bee9c268866512634622 Mon Sep 17 00:00:00 2001 From: "C. T. Lin" Date: Wed, 9 Nov 2016 12:46:11 +0800 Subject: [PATCH 020/702] [eslint config] [base] `import/no-extraneous-dependencies`: added ignore patterns for config files Fixes #1168 --- packages/eslint-config-airbnb-base/rules/imports.js | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/packages/eslint-config-airbnb-base/rules/imports.js b/packages/eslint-config-airbnb-base/rules/imports.js index 2fb05df41d..f1555aca7e 100644 --- a/packages/eslint-config-airbnb-base/rules/imports.js +++ b/packages/eslint-config-airbnb-base/rules/imports.js @@ -68,7 +68,17 @@ module.exports = { // https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/no-extraneous-dependencies.md // paths are treated both as absolute paths, and relative to process.cwd() 'import/no-extraneous-dependencies': ['error', { - devDependencies: ['spec/**', 'test/**', 'tests/**', '**/__tests__/**'], + devDependencies: [ + 'spec/**', + 'test/**', + 'tests/**', + '**/__tests__/**', + '**/webpack.config.js', + '**/webpack.config.*.js', + '**/rollup.config.js', + '**/gulpfile.js', + '**/Gruntfile', + ], optionalDependencies: false, }], From b73649925a43b05fc35a74de16f09df51d3370fc Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Wed, 9 Nov 2016 22:53:09 -0800 Subject: [PATCH 021/702] [guide] [react] add note that defaultProps must always be provided for non-required props --- react/README.md | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/react/README.md b/react/README.md index 714eea947a..4bef241a24 100644 --- a/react/README.md +++ b/react/README.md @@ -337,6 +337,35 @@ ))} ``` + - Always define explicit defaultProps for all non-required props. + + > Why? propTypes are a form of documentation, and providing defaultProps means the reader of your code doesn’t have to assume as much. In addition, it can mean that your code can omit certain type checks. + + ```jsx + // bad + function SFC({ foo, bar, children }) { + return
{foo}{bar}{children}
; + } + SFC.propTypes = { + foo: PropTypes.number.isRequired, + bar: PropTypes.string, + children: PropTypes.node, + }; + + // good + function SFC({ foo, bar }) { + return
{foo}{bar}
; + } + SFC.propTypes = { + foo: PropTypes.number.isRequired, + bar: PropTypes.string, + }; + SFC.defaultProps = { + bar: '', + children: null, + }; + ``` + ## 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 72eb3e443e49da634a83b56660fbe56698775cbb Mon Sep 17 00:00:00 2001 From: ViZhe Date: Tue, 8 Nov 2016 19:35:36 +0300 Subject: [PATCH 022/702] [eslint config] [breaking] [deps] update `eslint-plugin-jsx-a11y` to v3 --- packages/eslint-config-airbnb/package.json | 4 ++-- packages/eslint-config-airbnb/rules/react-a11y.js | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/packages/eslint-config-airbnb/package.json b/packages/eslint-config-airbnb/package.json index 467267475d..0f688ca6a5 100644 --- a/packages/eslint-config-airbnb/package.json +++ b/packages/eslint-config-airbnb/package.json @@ -53,7 +53,7 @@ "eslint": "^3.9.1", "eslint-find-rules": "^1.14.3", "eslint-plugin-import": "^2.1.0", - "eslint-plugin-jsx-a11y": "^2.2.3", + "eslint-plugin-jsx-a11y": "^3.0.1", "eslint-plugin-react": "^6.6.0", "in-publish": "^2.0.0", "react": ">= 0.13.0", @@ -62,7 +62,7 @@ }, "peerDependencies": { "eslint": "^3.9.1", - "eslint-plugin-jsx-a11y": "^2.2.3", + "eslint-plugin-jsx-a11y": "^3.0.1", "eslint-plugin-import": "^2.1.0", "eslint-plugin-react": "^6.6.0" }, diff --git a/packages/eslint-config-airbnb/rules/react-a11y.js b/packages/eslint-config-airbnb/rules/react-a11y.js index 1df39103ab..b101a93e5b 100644 --- a/packages/eslint-config-airbnb/rules/react-a11y.js +++ b/packages/eslint-config-airbnb/rules/react-a11y.js @@ -9,7 +9,7 @@ module.exports = { rules: { // Enforce that anchors have content // https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/anchor-has-content.md - 'jsx-a11y/anchor-has-content': ['error', ['']], + 'jsx-a11y/anchor-has-content': ['error', { components: [''] }], // Require ARIA roles to be valid and non-abstract // https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/aria-role.md @@ -30,7 +30,7 @@ module.exports = { // disallow href "#" // https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/href-no-hash.md - 'jsx-a11y/href-no-hash': ['error', ['a']], + 'jsx-a11y/href-no-hash': ['error', { components: ['a'] }], // Require to have a non-empty `alt` prop, or role="presentation" // https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/img-has-alt.md @@ -42,7 +42,7 @@ 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', ['label']], + 'jsx-a11y/label-has-for': ['error', { components: ['label'] }], // require that mouseover/out come with focus/blur, for keyboard-only users // TODO: evaluate @@ -82,7 +82,7 @@ module.exports = { // ensure tags have content and are not aria-hidden // https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/heading-has-content.md - 'jsx-a11y/heading-has-content': ['error', ['']], + 'jsx-a11y/heading-has-content': ['error', { components: [''] }], // require HTML elements to have a "lang" prop // https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/html-has-lang.md From 25d03b8b67c5a77ab7a886939187460f4175a525 Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Mon, 14 Nov 2016 13:52:26 -0800 Subject: [PATCH 023/702] [eslint config] [*] [breaking] [deps] update `eslint`, `eslint-plugin-import`, `eslint-plugin-react` --- packages/eslint-config-airbnb-base/package.json | 8 ++++---- .../rules/best-practices.js | 3 +++ packages/eslint-config-airbnb/package.json | 12 ++++++------ packages/eslint-config-airbnb/rules/react.js | 10 +++++++++- 4 files changed, 22 insertions(+), 11 deletions(-) diff --git a/packages/eslint-config-airbnb-base/package.json b/packages/eslint-config-airbnb-base/package.json index 7cde827bf3..fe729c4308 100644 --- a/packages/eslint-config-airbnb-base/package.json +++ b/packages/eslint-config-airbnb-base/package.json @@ -47,16 +47,16 @@ "devDependencies": { "babel-preset-airbnb": "^2.1.1", "babel-tape-runner": "^2.0.1", - "eslint": "^3.9.1", + "eslint": "^3.10.1", "eslint-find-rules": "^1.14.3", - "eslint-plugin-import": "^2.1.0", + "eslint-plugin-import": "^2.2.0", "in-publish": "^2.0.0", "safe-publish-latest": "^1.1.1", "tape": "^4.6.2" }, "peerDependencies": { - "eslint": "^3.9.1", - "eslint-plugin-import": "^2.1.0" + "eslint": "^3.10.1", + "eslint-plugin-import": "^2.2.0" }, "engines": { "node": ">= 4" diff --git a/packages/eslint-config-airbnb-base/rules/best-practices.js b/packages/eslint-config-airbnb-base/rules/best-practices.js index f8cdc208d1..d909fbd5c3 100644 --- a/packages/eslint-config-airbnb-base/rules/best-practices.js +++ b/packages/eslint-config-airbnb-base/rules/best-practices.js @@ -195,6 +195,9 @@ module.exports = { // disallow use of assignment in return statement 'no-return-assign': 'error', + // disallow redundant `return await` + 'no-return-await': 'error', + // disallow use of `javascript:` urls. 'no-script-url': 'error', diff --git a/packages/eslint-config-airbnb/package.json b/packages/eslint-config-airbnb/package.json index 0f688ca6a5..235a39cfed 100644 --- a/packages/eslint-config-airbnb/package.json +++ b/packages/eslint-config-airbnb/package.json @@ -50,21 +50,21 @@ "devDependencies": { "babel-preset-airbnb": "^2.1.1", "babel-tape-runner": "^2.0.1", - "eslint": "^3.9.1", + "eslint": "^3.10.1", "eslint-find-rules": "^1.14.3", - "eslint-plugin-import": "^2.1.0", + "eslint-plugin-import": "^2.2.0", "eslint-plugin-jsx-a11y": "^3.0.1", - "eslint-plugin-react": "^6.6.0", + "eslint-plugin-react": "^6.7.0", "in-publish": "^2.0.0", "react": ">= 0.13.0", "safe-publish-latest": "^1.1.1", "tape": "^4.6.2" }, "peerDependencies": { - "eslint": "^3.9.1", + "eslint": "^3.10.1", "eslint-plugin-jsx-a11y": "^3.0.1", - "eslint-plugin-import": "^2.1.0", - "eslint-plugin-react": "^6.6.0" + "eslint-plugin-import": "^2.2.0", + "eslint-plugin-react": "^6.7.0" }, "engines": { "node": ">= 4" diff --git a/packages/eslint-config-airbnb/rules/react.js b/packages/eslint-config-airbnb/rules/react.js index 262b30927c..50c4ba4d28 100644 --- a/packages/eslint-config-airbnb/rules/react.js +++ b/packages/eslint-config-airbnb/rules/react.js @@ -287,7 +287,15 @@ module.exports = { // Prevent passing of children as props // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/no-children-prop.md - 'react/no-children-prop': 'error' + '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 + 'react/jsx-tag-spacing': ['error', { + closingSlash: 'never', + beforeSelfClosing: 'always', + afterOpening: 'never' + }], }, settings: { From 97da1f0f9d6fc5f592349317b296c74766d1d4ab Mon Sep 17 00:00:00 2001 From: Andrey Polischuk Date: Sat, 12 Nov 2016 14:32:05 +0300 Subject: [PATCH 024/702] [eslint config] [base] [patch] add `import/no-extraneous-dependencies` ignore patterns for test files Fixes #1174 --- packages/eslint-config-airbnb-base/rules/imports.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/packages/eslint-config-airbnb-base/rules/imports.js b/packages/eslint-config-airbnb-base/rules/imports.js index f1555aca7e..2eb76e8f98 100644 --- a/packages/eslint-config-airbnb-base/rules/imports.js +++ b/packages/eslint-config-airbnb-base/rules/imports.js @@ -73,6 +73,9 @@ module.exports = { 'test/**', 'tests/**', '**/__tests__/**', + 'test.js', + 'test-*.js', + '**/*.test.js', '**/webpack.config.js', '**/webpack.config.*.js', '**/rollup.config.js', From f3f7124fcc7a97048f14148554219150cd0c76df Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Mon, 14 Nov 2016 17:58:12 -0800 Subject: [PATCH 025/702] [eslint config] [base] [patch] `import/no-extraneous-dependencies`: add some comments to ignore patterns. --- .../rules/imports.js | 24 +++++++++---------- 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/packages/eslint-config-airbnb-base/rules/imports.js b/packages/eslint-config-airbnb-base/rules/imports.js index 2eb76e8f98..59970d877f 100644 --- a/packages/eslint-config-airbnb-base/rules/imports.js +++ b/packages/eslint-config-airbnb-base/rules/imports.js @@ -69,18 +69,18 @@ module.exports = { // paths are treated both as absolute paths, and relative to process.cwd() 'import/no-extraneous-dependencies': ['error', { devDependencies: [ - 'spec/**', - 'test/**', - 'tests/**', - '**/__tests__/**', - 'test.js', - 'test-*.js', - '**/*.test.js', - '**/webpack.config.js', - '**/webpack.config.*.js', - '**/rollup.config.js', - '**/gulpfile.js', - '**/Gruntfile', + 'test/**', // tape, common npm pattern + 'tests/**', // also common npm pattern + 'spec/**', // mocha, rspec-like pattern + '**/__tests__/**', // jest pattern + 'test.js', // repos with a single test file + 'test-*.js', // repos with multiple top-level test files + '**/*.test.js', // tests where the extension denotes that it is a test + '**/webpack.config.js', // webpack config + '**/webpack.config.*.js', // webpack config + '**/rollup.config.js', // rollup config + '**/gulpfile.js', // gulp config + '**/Gruntfile', // grunt config ], optionalDependencies: false, }], From 1ab6aaede9b146235d22b643d5f5076f7daa9b2e Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Fri, 18 Nov 2016 10:39:38 -0800 Subject: [PATCH 026/702] [eslint config] [*] [deps] update `eslint`, `eslint-plugin-react` --- packages/eslint-config-airbnb-base/package.json | 4 ++-- packages/eslint-config-airbnb/package.json | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/packages/eslint-config-airbnb-base/package.json b/packages/eslint-config-airbnb-base/package.json index fe729c4308..07305d68cd 100644 --- a/packages/eslint-config-airbnb-base/package.json +++ b/packages/eslint-config-airbnb-base/package.json @@ -47,7 +47,7 @@ "devDependencies": { "babel-preset-airbnb": "^2.1.1", "babel-tape-runner": "^2.0.1", - "eslint": "^3.10.1", + "eslint": "^3.10.2", "eslint-find-rules": "^1.14.3", "eslint-plugin-import": "^2.2.0", "in-publish": "^2.0.0", @@ -55,7 +55,7 @@ "tape": "^4.6.2" }, "peerDependencies": { - "eslint": "^3.10.1", + "eslint": "^3.10.2", "eslint-plugin-import": "^2.2.0" }, "engines": { diff --git a/packages/eslint-config-airbnb/package.json b/packages/eslint-config-airbnb/package.json index 235a39cfed..51d89c84d7 100644 --- a/packages/eslint-config-airbnb/package.json +++ b/packages/eslint-config-airbnb/package.json @@ -50,21 +50,21 @@ "devDependencies": { "babel-preset-airbnb": "^2.1.1", "babel-tape-runner": "^2.0.1", - "eslint": "^3.10.1", + "eslint": "^3.10.2", "eslint-find-rules": "^1.14.3", "eslint-plugin-import": "^2.2.0", "eslint-plugin-jsx-a11y": "^3.0.1", - "eslint-plugin-react": "^6.7.0", + "eslint-plugin-react": "^6.7.1", "in-publish": "^2.0.0", "react": ">= 0.13.0", "safe-publish-latest": "^1.1.1", "tape": "^4.6.2" }, "peerDependencies": { - "eslint": "^3.10.1", + "eslint": "^3.10.2", "eslint-plugin-jsx-a11y": "^3.0.1", "eslint-plugin-import": "^2.2.0", - "eslint-plugin-react": "^6.7.0" + "eslint-plugin-react": "^6.7.1" }, "engines": { "node": ">= 4" From 54aa8f1b3580d397b4ba77faa806e75e77705cb1 Mon Sep 17 00:00:00 2001 From: Giuseppe Burtini Date: Mon, 29 Aug 2016 08:16:34 -0700 Subject: [PATCH 027/702] [guide] Fix no-interpolation template string example The example showed a template string being used with no interpolation as "good". While it met the rule being described, it violated another rule for no reason. --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 95dc926d06..6c3db4c02d 100644 --- a/README.md +++ b/README.md @@ -565,7 +565,7 @@ Other Style Guides // good const foo = '\'this\' is "quoted"'; - const foo = `'this' is "quoted"`; + const foo = `my name is '${name}'`; ``` **[⬆ back to top](#table-of-contents)** From 664877a60149dbeb5065f5487d7ffcefc0158850 Mon Sep 17 00:00:00 2001 From: Joe Lencioni Date: Thu, 1 Dec 2016 09:11:00 -0800 Subject: [PATCH 028/702] Avoid i++ in array spreads example This style guide recommends using `i += 1` over `i++`. Even though this appears in a "bad" example, the example will be clearest if it is "bad" in fewer ways. --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 6c3db4c02d..04ef1903c2 100644 --- a/README.md +++ b/README.md @@ -350,7 +350,7 @@ Other Style Guides const itemsCopy = []; let i; - for (i = 0; i < len; i++) { + for (i = 0; i < len; i += 1) { itemsCopy[i] = items[i]; } @@ -565,7 +565,7 @@ Other Style Guides // good const foo = '\'this\' is "quoted"'; - const foo = `my name is '${name}'`; + const foo = `my name is '${name}'`; ``` **[⬆ back to top](#table-of-contents)** From 780be0dcd9df8942660f707c072ae3766493ac29 Mon Sep 17 00:00:00 2001 From: soulchainer Date: Sun, 4 Dec 2016 02:11:48 +0100 Subject: [PATCH 029/702] =?UTF-8?q?[guide][react]=20Add=20missing=20parent?= =?UTF-8?q?hesis=20in=20=C2=ABRefs=C2=BB=20recommendation?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit As is, actual «good» usage fires the arrow-parens rule. Parenthesis are needed to follow the current style guide. --- react/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/react/README.md b/react/README.md index 4bef241a24..851e233302 100644 --- a/react/README.md +++ b/react/README.md @@ -378,7 +378,7 @@ // good { this.myRef = ref; }} + ref={(ref) => { this.myRef = ref; }} /> ``` From 0b3b5a178fb32bfc60096738369e069c8cfcfa91 Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Tue, 6 Dec 2016 01:58:13 -0800 Subject: [PATCH 030/702] [eslint config] [base] [deps] update `eslint`, `tape` --- packages/eslint-config-airbnb-base/package.json | 6 +++--- .../rules/best-practices.js | 4 ++++ packages/eslint-config-airbnb-base/rules/style.js | 15 +++++++++++++++ 3 files changed, 22 insertions(+), 3 deletions(-) diff --git a/packages/eslint-config-airbnb-base/package.json b/packages/eslint-config-airbnb-base/package.json index 07305d68cd..51c99818bb 100644 --- a/packages/eslint-config-airbnb-base/package.json +++ b/packages/eslint-config-airbnb-base/package.json @@ -47,15 +47,15 @@ "devDependencies": { "babel-preset-airbnb": "^2.1.1", "babel-tape-runner": "^2.0.1", - "eslint": "^3.10.2", + "eslint": "^3.11.1", "eslint-find-rules": "^1.14.3", "eslint-plugin-import": "^2.2.0", "in-publish": "^2.0.0", "safe-publish-latest": "^1.1.1", - "tape": "^4.6.2" + "tape": "^4.6.3" }, "peerDependencies": { - "eslint": "^3.10.2", + "eslint": "^3.11.1", "eslint-plugin-import": "^2.2.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 d909fbd5c3..def0b9fb6f 100644 --- a/packages/eslint-config-airbnb-base/rules/best-practices.js +++ b/packages/eslint-config-airbnb-base/rules/best-practices.js @@ -256,6 +256,10 @@ module.exports = { // 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 + 'require-await': 'off', + // requires to declare all vars on top of their containing scope 'vars-on-top': 'error', diff --git a/packages/eslint-config-airbnb-base/rules/style.js b/packages/eslint-config-airbnb-base/rules/style.js index 536cd5320b..9ea0f0f759 100644 --- a/packages/eslint-config-airbnb-base/rules/style.js +++ b/packages/eslint-config-airbnb-base/rules/style.js @@ -13,6 +13,21 @@ module.exports = { // require camel case names camelcase: ['error', { properties: 'never' }], + // enforce or disallow capitalization of the first letter of a comment + // http://eslint.org/docs/rules/capitalized-comments + 'capitalized-comments': ['off', 'never', { + line: { + ignorePattern: '.*', + ignoreInlineComments: true, + ignoreConsecutiveComments: true, + }, + block: { + ignorePattern: '.*', + ignoreInlineComments: true, + ignoreConsecutiveComments: true, + }, + }], + // enforce spacing before and after comma 'comma-spacing': ['error', { before: false, after: true }], From 243d824fb446b01feb0edcdcf567e44cf0d87827 Mon Sep 17 00:00:00 2001 From: alejandro garcia Date: Wed, 7 Dec 2016 19:19:54 +0100 Subject: [PATCH 031/702] [guide] [react] Added react jsx guide in spanish --- react/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/react/README.md b/react/README.md index 851e233302..419033de18 100644 --- a/react/README.md +++ b/react/README.md @@ -618,5 +618,6 @@ - ![kr](https://raw.githubusercontent.com/gosquared/flags/master/flags/flags/shiny/24/South-Korea.png) **Korean**: [apple77y/javascript](https://github.com/apple77y/javascript/tree/master/react) - ![Br](https://raw.githubusercontent.com/gosquared/flags/master/flags/flags/shiny/24/Brazil.png) **Portuguese**: [ronal2do/javascript](https://github.com/ronal2do/airbnb-react-styleguide) - ![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/tree/master/react) + - ![es](https://raw.githubusercontent.com/gosquared/flags/master/flags/flags/shiny/24/Spain.png) **Español**: [agrcrobles/javascript](https://github.com/agrcrobles/javascript/tree/master/react) **[⬆ back to top](#table-of-contents)** From a56f239b953a11ce490c7f3d07f22cb3cbb58766 Mon Sep 17 00:00:00 2001 From: Kevin Boudot Date: Thu, 8 Dec 2016 15:29:06 +0100 Subject: [PATCH 032/702] [inthewild] Add Bonhomme --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 04ef1903c2..203feb1657 100644 --- a/README.md +++ b/README.md @@ -3135,6 +3135,7 @@ Other Style Guides - **Billabong**: [billabong/javascript](https://github.com/billabong/javascript) - **Bisk**: [bisk/javascript](https://github.com/Bisk/javascript/) - **Blendle**: [blendle/javascript](https://github.com/blendle/javascript) + - **Bonhomme**: [bonhommeparis/javascript](https://github.com/bonhommeparis/javascript) - **Brainshark**: [brainshark/javascript](https://github.com/brainshark/javascript) - **Chartboost**: [ChartBoost/javascript-style-guide](https://github.com/ChartBoost/javascript-style-guide) - **ComparaOnline**: [comparaonline/javascript](https://github.com/comparaonline/javascript-style-guide) From 1df98256d0ea57049f118d4e8f83a493211bc9dd Mon Sep 17 00:00:00 2001 From: Sara Gudeman Date: Fri, 9 Dec 2016 11:29:03 -0800 Subject: [PATCH 033/702] [guide] add map example to iterators --- README.md | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 203feb1657..621f79fe39 100644 --- a/README.md +++ b/README.md @@ -1309,7 +1309,6 @@ Other Style Guides for (let num of numbers) { sum += num; } - sum === 15; // good @@ -1320,6 +1319,19 @@ Other Style Guides // best (use the functional force) const sum = numbers.reduce((total, num) => total + num, 0); sum === 15; + + // bad + const modified = []; + for (let i = 0; i < numbers.length; i++) { + modified.push(numbers[i] + 1); + } + + // good + const modified = []; + numbers.forEach(num => modified.push(num + 1)); + + // best (keeping it functional) + const modified = numbers.map(num => num + 1); ``` From 4d68ddc4bb774584b50ca893887ef9219a41128a Mon Sep 17 00:00:00 2001 From: Eric Churchill Date: Sat, 10 Dec 2016 23:17:10 -0800 Subject: [PATCH 034/702] Change "modified" to "increasedByOne" to minimize ambiguity --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 621f79fe39..66ea1bd300 100644 --- a/README.md +++ b/README.md @@ -1321,17 +1321,17 @@ Other Style Guides sum === 15; // bad - const modified = []; + const increasedByOne = []; for (let i = 0; i < numbers.length; i++) { modified.push(numbers[i] + 1); } // good - const modified = []; + const increasedByOne = []; numbers.forEach(num => modified.push(num + 1)); // best (keeping it functional) - const modified = numbers.map(num => num + 1); + const increasedByOne = numbers.map(num => num + 1); ``` From 898a70e7fe90dd6239a09a445b5cf750d041c3fb Mon Sep 17 00:00:00 2001 From: Arturo Pie Date: Sun, 11 Dec 2016 11:42:07 -0500 Subject: [PATCH 035/702] [inthewild] Add Nulogy (https://nulogy.com/) --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 66ea1bd300..fe5be0921b 100644 --- a/README.md +++ b/README.md @@ -3188,6 +3188,7 @@ Other Style Guides - **National Geographic**: [natgeo/javascript](https://github.com/natgeo/javascript) - **National Park Service**: [nationalparkservice/javascript](https://github.com/nationalparkservice/javascript) - **Nimbl3**: [nimbl3/javascript](https://github.com/nimbl3/javascript) + - **Nulogy**: [nulogy/javascript](https://github.com/nulogy/javascript) - **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) From e037d29b93e5b61434deb9ba485f76c6406b7cb3 Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Sun, 11 Dec 2016 10:44:37 -0800 Subject: [PATCH 036/702] [eslint config] [base] [deps] [breaking] update `eslint`; enable `no-await-in-loop` --- packages/eslint-config-airbnb-base/package.json | 4 ++-- packages/eslint-config-airbnb-base/rules/errors.js | 4 ++++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/packages/eslint-config-airbnb-base/package.json b/packages/eslint-config-airbnb-base/package.json index 51c99818bb..982d27bcd9 100644 --- a/packages/eslint-config-airbnb-base/package.json +++ b/packages/eslint-config-airbnb-base/package.json @@ -47,7 +47,7 @@ "devDependencies": { "babel-preset-airbnb": "^2.1.1", "babel-tape-runner": "^2.0.1", - "eslint": "^3.11.1", + "eslint": "^3.12.0", "eslint-find-rules": "^1.14.3", "eslint-plugin-import": "^2.2.0", "in-publish": "^2.0.0", @@ -55,7 +55,7 @@ "tape": "^4.6.3" }, "peerDependencies": { - "eslint": "^3.11.1", + "eslint": "^3.12.0", "eslint-plugin-import": "^2.2.0" }, "engines": { diff --git a/packages/eslint-config-airbnb-base/rules/errors.js b/packages/eslint-config-airbnb-base/rules/errors.js index 1849e8db4d..bade2a1cec 100644 --- a/packages/eslint-config-airbnb-base/rules/errors.js +++ b/packages/eslint-config-airbnb-base/rules/errors.js @@ -9,6 +9,10 @@ module.exports = { functions: 'always-multiline', }], + // Disallow await inside of loops + // http://eslint.org/docs/rules/no-await-in-loop + 'no-await-in-loop': 'error', + // disallow assignment in conditional expressions 'no-cond-assign': ['error', 'always'], From 4a005b1322e8baecec4b4951ce8974af641922f9 Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Sun, 11 Dec 2016 23:03:53 -0800 Subject: [PATCH 037/702] [eslint config] [base] disable `no-duplicate-imports` rule - obsoleted by `import/no-duplicates`. Closes #1188. Closes #1195. Closes #1054. --- packages/eslint-config-airbnb-base/rules/es6.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/eslint-config-airbnb-base/rules/es6.js b/packages/eslint-config-airbnb-base/rules/es6.js index 063ee2cfa5..ff90669dd0 100644 --- a/packages/eslint-config-airbnb-base/rules/es6.js +++ b/packages/eslint-config-airbnb-base/rules/es6.js @@ -55,7 +55,8 @@ module.exports = { // disallow importing from the same path more than once // http://eslint.org/docs/rules/no-duplicate-imports - 'no-duplicate-imports': 'error', + // 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 From b178cf9be021c3eab1eac0124476054a4334ab90 Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Sun, 11 Dec 2016 23:09:49 -0800 Subject: [PATCH 038/702] [eslint config] [base] v11.0.0 --- packages/eslint-config-airbnb-base/CHANGELOG.md | 9 +++++++++ packages/eslint-config-airbnb-base/package.json | 2 +- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/packages/eslint-config-airbnb-base/CHANGELOG.md b/packages/eslint-config-airbnb-base/CHANGELOG.md index 1fa42086a7..2d1b1618a5 100644 --- a/packages/eslint-config-airbnb-base/CHANGELOG.md +++ b/packages/eslint-config-airbnb-base/CHANGELOG.md @@ -1,3 +1,12 @@ +11.0.0 / 2016-12-11 +================== + - [breaking] enable `no-await-in-loop` + - [patch] disable `no-duplicate-imports` rule (#1188, #1195, #1054) + - [patch] `import/no-extraneous-dependencies`: add some comments to ignore patterns + - [patch] add `import/no-extraneous-dependencies` ignore patterns for test files (#1174) + - [patch] `import/no-extraneous-dependencies`: added ignore patterns for config files (#1168) + - [deps] update `eslint`, `eslint-plugin-import`, `tape` + 10.0.1 / 2016-11-07 ================== - [fix] legacy config should not require `**` diff --git a/packages/eslint-config-airbnb-base/package.json b/packages/eslint-config-airbnb-base/package.json index 982d27bcd9..8a10a06b28 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": "10.0.1", + "version": "11.0.0", "description": "Airbnb's base JS ESLint config, following our styleguide", "main": "index.js", "scripts": { From 6c4456d354ad4c49923806c52f5f8412e6ca2952 Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Sun, 11 Dec 2016 23:16:12 -0800 Subject: [PATCH 039/702] [eslint config] [deps] update `eslint`, `eslint-plugin-react`, `tape`, `eslint-config-airbnb-base` --- packages/eslint-config-airbnb/package.json | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/packages/eslint-config-airbnb/package.json b/packages/eslint-config-airbnb/package.json index 51d89c84d7..92cb1365d4 100644 --- a/packages/eslint-config-airbnb/package.json +++ b/packages/eslint-config-airbnb/package.json @@ -45,26 +45,26 @@ }, "homepage": "https://github.com/airbnb/javascript", "dependencies": { - "eslint-config-airbnb-base": "^10.0.1" + "eslint-config-airbnb-base": "^11.0.0" }, "devDependencies": { "babel-preset-airbnb": "^2.1.1", "babel-tape-runner": "^2.0.1", - "eslint": "^3.10.2", + "eslint": "^3.12.0", "eslint-find-rules": "^1.14.3", "eslint-plugin-import": "^2.2.0", "eslint-plugin-jsx-a11y": "^3.0.1", - "eslint-plugin-react": "^6.7.1", + "eslint-plugin-react": "^6.8.0", "in-publish": "^2.0.0", "react": ">= 0.13.0", "safe-publish-latest": "^1.1.1", - "tape": "^4.6.2" + "tape": "^4.6.3" }, "peerDependencies": { - "eslint": "^3.10.2", + "eslint": "^3.12.0", "eslint-plugin-jsx-a11y": "^3.0.1", "eslint-plugin-import": "^2.2.0", - "eslint-plugin-react": "^6.7.1" + "eslint-plugin-react": "^6.8.0" }, "engines": { "node": ">= 4" From e1a307ae0a1eab781d310ead825b7e8f6c85d022 Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Sun, 11 Dec 2016 23:25:40 -0800 Subject: [PATCH 040/702] [eslint config] [breaking] enable `react/no-array-index-key`, `react/require-default-props` --- packages/eslint-config-airbnb/rules/react.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/packages/eslint-config-airbnb/rules/react.js b/packages/eslint-config-airbnb/rules/react.js index 50c4ba4d28..ad717eab61 100644 --- a/packages/eslint-config-airbnb/rules/react.js +++ b/packages/eslint-config-airbnb/rules/react.js @@ -296,6 +296,14 @@ module.exports = { beforeSelfClosing: 'always', afterOpening: 'never' }], + + // Prevent usage of Array index in keys + // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/no-array-index-key.md + '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', }, settings: { From 24f004027bfb97050c46a031e4291f84f58d5d2d Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Mon, 12 Dec 2016 14:33:55 -0800 Subject: [PATCH 041/702] [eslint config] [*] [deps] update `eslint` --- 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 8a10a06b28..6189f9e88f 100644 --- a/packages/eslint-config-airbnb-base/package.json +++ b/packages/eslint-config-airbnb-base/package.json @@ -47,7 +47,7 @@ "devDependencies": { "babel-preset-airbnb": "^2.1.1", "babel-tape-runner": "^2.0.1", - "eslint": "^3.12.0", + "eslint": "^3.12.1", "eslint-find-rules": "^1.14.3", "eslint-plugin-import": "^2.2.0", "in-publish": "^2.0.0", @@ -55,7 +55,7 @@ "tape": "^4.6.3" }, "peerDependencies": { - "eslint": "^3.12.0", + "eslint": "^3.12.1", "eslint-plugin-import": "^2.2.0" }, "engines": { diff --git a/packages/eslint-config-airbnb/package.json b/packages/eslint-config-airbnb/package.json index 92cb1365d4..3caa6bcf67 100644 --- a/packages/eslint-config-airbnb/package.json +++ b/packages/eslint-config-airbnb/package.json @@ -50,7 +50,7 @@ "devDependencies": { "babel-preset-airbnb": "^2.1.1", "babel-tape-runner": "^2.0.1", - "eslint": "^3.12.0", + "eslint": "^3.12.1", "eslint-find-rules": "^1.14.3", "eslint-plugin-import": "^2.2.0", "eslint-plugin-jsx-a11y": "^3.0.1", @@ -61,7 +61,7 @@ "tape": "^4.6.3" }, "peerDependencies": { - "eslint": "^3.12.0", + "eslint": "^3.12.1", "eslint-plugin-jsx-a11y": "^3.0.1", "eslint-plugin-import": "^2.2.0", "eslint-plugin-react": "^6.8.0" From e947cace2c998b2872c09fd59efa88ecb0188701 Mon Sep 17 00:00:00 2001 From: David Knaack Date: Mon, 12 Dec 2016 17:49:00 +0100 Subject: [PATCH 042/702] [eslint config] [base] [patch] add gulpfile.*.js to import/no-extraneous-dependencies Otherwise e.g. gulpfile.babel.js won't be matched --- 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 59970d877f..42706a506c 100644 --- a/packages/eslint-config-airbnb-base/rules/imports.js +++ b/packages/eslint-config-airbnb-base/rules/imports.js @@ -80,6 +80,7 @@ module.exports = { '**/webpack.config.*.js', // webpack config '**/rollup.config.js', // rollup config '**/gulpfile.js', // gulp config + '**/gulpfile.*.js', // gulp config '**/Gruntfile', // grunt config ], optionalDependencies: false, From c30adcc60de1d8ae3448bac64ebc7058e929343c Mon Sep 17 00:00:00 2001 From: Simen Bekkhus Date: Sun, 2 Oct 2016 23:50:41 +0200 Subject: [PATCH 043/702] Add editorconfig --- .editorconfig | 11 +++++++++++ packages/eslint-config-airbnb-base/.editorconfig | 1 + packages/eslint-config-airbnb-base/package.json | 2 ++ packages/eslint-config-airbnb/.editorconfig | 1 + packages/eslint-config-airbnb/package.json | 2 ++ 5 files changed, 17 insertions(+) create mode 100644 .editorconfig create mode 120000 packages/eslint-config-airbnb-base/.editorconfig create mode 120000 packages/eslint-config-airbnb/.editorconfig diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000000..49c154da45 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,11 @@ +root = true + +[*] +indent_style = space +indent_size = 2 +charset = utf-8 +trim_trailing_whitespace = true +insert_final_newline = true +end_of_line = lf +# editorconfig-tools is unable to ignore longs strings or urls +max_line_length = null diff --git a/packages/eslint-config-airbnb-base/.editorconfig b/packages/eslint-config-airbnb-base/.editorconfig new file mode 120000 index 0000000000..1b3ce07def --- /dev/null +++ b/packages/eslint-config-airbnb-base/.editorconfig @@ -0,0 +1 @@ +../../.editorconfig \ No newline at end of file diff --git a/packages/eslint-config-airbnb-base/package.json b/packages/eslint-config-airbnb-base/package.json index 6189f9e88f..3594335618 100644 --- a/packages/eslint-config-airbnb-base/package.json +++ b/packages/eslint-config-airbnb-base/package.json @@ -4,6 +4,7 @@ "description": "Airbnb's base JS ESLint config, following our styleguide", "main": "index.js", "scripts": { + "prelint": "editorconfig-tools check * rules/* test/*", "lint": "eslint .", "tests-only": "babel-tape-runner ./test/test-*.js", "prepublish": "(in-install || eslint-find-rules --unused) && (not-in-publish || npm test) && safe-publish-latest", @@ -47,6 +48,7 @@ "devDependencies": { "babel-preset-airbnb": "^2.1.1", "babel-tape-runner": "^2.0.1", + "editorconfig-tools": "^0.1.1", "eslint": "^3.12.1", "eslint-find-rules": "^1.14.3", "eslint-plugin-import": "^2.2.0", diff --git a/packages/eslint-config-airbnb/.editorconfig b/packages/eslint-config-airbnb/.editorconfig new file mode 120000 index 0000000000..1b3ce07def --- /dev/null +++ b/packages/eslint-config-airbnb/.editorconfig @@ -0,0 +1 @@ +../../.editorconfig \ No newline at end of file diff --git a/packages/eslint-config-airbnb/package.json b/packages/eslint-config-airbnb/package.json index 3caa6bcf67..bb96633dfe 100644 --- a/packages/eslint-config-airbnb/package.json +++ b/packages/eslint-config-airbnb/package.json @@ -4,6 +4,7 @@ "description": "Airbnb's ESLint config, following our styleguide", "main": "index.js", "scripts": { + "prelint": "editorconfig-tools check * rules/* test/*", "lint": "eslint .", "tests-only": "babel-tape-runner ./test/test-*.js", "prepublish": "(in-install || eslint-find-rules --unused) && (not-in-publish || npm test) && safe-publish-latest", @@ -50,6 +51,7 @@ "devDependencies": { "babel-preset-airbnb": "^2.1.1", "babel-tape-runner": "^2.0.1", + "editorconfig-tools": "^0.1.1", "eslint": "^3.12.1", "eslint-find-rules": "^1.14.3", "eslint-plugin-import": "^2.2.0", From 019a6edaaaa6d0c4c69b9ef10870962c9279a9e0 Mon Sep 17 00:00:00 2001 From: woojoo666 Date: Mon, 19 Dec 2016 07:24:50 -0800 Subject: [PATCH 044/702] [eslint config] [*] [docs] Updated instructions to support non-bash users --- packages/eslint-config-airbnb-base/README.md | 16 ++++++++++++++-- packages/eslint-config-airbnb/README.md | 9 ++++++++- 2 files changed, 22 insertions(+), 3 deletions(-) diff --git a/packages/eslint-config-airbnb-base/README.md b/packages/eslint-config-airbnb-base/README.md index d293a8ad90..68fb1b1c03 100644 --- a/packages/eslint-config-airbnb-base/README.md +++ b/packages/eslint-config-airbnb-base/README.md @@ -12,7 +12,13 @@ We export two ESLint configurations for your usage. Our default export contains all of our ESLint rules, including ECMAScript 6+. It requires `eslint` and `eslint-plugin-import`. -1. Ensure packages are installed with correct version numbers by running: +1. Install the correct versions of each package, which are listed by the command: + + ```sh + npm info "eslint-config-airbnb@latest" peerDependencies + ``` + + Linux/OSX users can simply run ```sh ( export PKG=eslint-config-airbnb-base; @@ -32,7 +38,13 @@ Our default export contains all of our ESLint rules, including ECMAScript 6+. It Lints ES5 and below. Requires `eslint` and `eslint-plugin-import`. -1. Ensure packages are installed with correct version numbers by running: +1. Install the correct versions of each package, which are listed by the command: + + ```sh + npm info "eslint-config-airbnb@latest" peerDependencies + ``` + + Linux/OSX users can simply run ```sh ( export PKG=eslint-config-airbnb-base; diff --git a/packages/eslint-config-airbnb/README.md b/packages/eslint-config-airbnb/README.md index 5014173d27..e8d66eca0c 100644 --- a/packages/eslint-config-airbnb/README.md +++ b/packages/eslint-config-airbnb/README.md @@ -12,7 +12,14 @@ We export three ESLint configurations for your usage. Our default export contains all of our ESLint rules, including ECMAScript 6+ and React. It requires `eslint`, `eslint-plugin-import`, `eslint-plugin-react`, and `eslint-plugin-jsx-a11y`. -1. Ensure packages are installed with correct version numbers by running: +1. Install the correct versions of each package, which are listed by the command: + + ```sh + npm info "eslint-config-airbnb@latest" peerDependencies + ``` + + Linux/OSX users can simply run + ```sh ( export PKG=eslint-config-airbnb; From 6eacbc2aad2d3c8d424b93861c5b6ea7ab44b3b5 Mon Sep 17 00:00:00 2001 From: Pedro Pablo Aste Kompen Date: Wed, 21 Dec 2016 16:06:56 -0300 Subject: [PATCH 045/702] [guide] Fix chaining example to be consistent with string interpolation --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index fe5be0921b..be89682471 100644 --- a/README.md +++ b/README.md @@ -2174,7 +2174,7 @@ Other Style Guides // bad const leds = stage.selectAll('.led').data(data).enter().append('svg:svg').classed('led', true) .attr('width', (radius + margin) * 2).append('svg:g') - .attr('transform', 'translate(' + (radius + margin) + ',' + (radius + margin) + ')') + .attr('transform', `translate(${radius + margin},${radius + margin})`) .call(tron.led); // good @@ -2184,7 +2184,7 @@ Other Style Guides .classed('led', true) .attr('width', (radius + margin) * 2) .append('svg:g') - .attr('transform', 'translate(' + (radius + margin) + ',' + (radius + margin) + ')') + .attr('transform', `translate(${radius + margin},${radius + margin})`) .call(tron.led); // good From c9edc92a800490b42d4aba07dfc5f52761876581 Mon Sep 17 00:00:00 2001 From: Giang Nguyen Date: Fri, 23 Dec 2016 18:24:50 +0700 Subject: [PATCH 046/702] [guide] update vietnamese translation link --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index be89682471..a64dd80df9 100644 --- a/README.md +++ b/README.md @@ -3235,7 +3235,7 @@ Other Style Guides - ![ru](https://raw.githubusercontent.com/gosquared/flags/master/flags/flags/shiny/24/Russia.png) **Russian**: [uprock/javascript](https://github.com/uprock/javascript) - ![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) - - ![vn](https://raw.githubusercontent.com/gosquared/flags/master/flags/flags/shiny/24/Vietnam.png) **Vietnam**: [giangpii/javascript-style-guide](https://github.com/giangpii/javascript-style-guide) + - ![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 b7cc2dc89f1e3b3aa10288ca6c2178a564facb0c Mon Sep 17 00:00:00 2001 From: Maxim Samoilov Date: Sun, 25 Dec 2016 06:27:52 +0300 Subject: [PATCH 047/702] [docs] Fix package name in eslint-config-airbnb-base --- packages/eslint-config-airbnb-base/README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/eslint-config-airbnb-base/README.md b/packages/eslint-config-airbnb-base/README.md index 68fb1b1c03..a79376be85 100644 --- a/packages/eslint-config-airbnb-base/README.md +++ b/packages/eslint-config-airbnb-base/README.md @@ -15,7 +15,7 @@ Our default export contains all of our ESLint rules, including ECMAScript 6+. It 1. Install the correct versions of each package, which are listed by the command: ```sh - npm info "eslint-config-airbnb@latest" peerDependencies + npm info "eslint-config-airbnb-base@latest" peerDependencies ``` Linux/OSX users can simply run @@ -41,7 +41,7 @@ Lints ES5 and below. Requires `eslint` and `eslint-plugin-import`. 1. Install the correct versions of each package, which are listed by the command: ```sh - npm info "eslint-config-airbnb@latest" peerDependencies + npm info "eslint-config-airbnb-base@latest" peerDependencies ``` Linux/OSX users can simply run From c6b7c9ef94571bf458d4f7aae98806cfbdb55fc0 Mon Sep 17 00:00:00 2001 From: Kamron Batman Date: Wed, 28 Dec 2016 11:57:14 -0800 Subject: [PATCH 048/702] [eslint config] [*] [deps] update `eslint`, `eslint-plugin-jsx-a11y` --- packages/eslint-config-airbnb-base/package.json | 4 ++-- packages/eslint-config-airbnb/package.json | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/packages/eslint-config-airbnb-base/package.json b/packages/eslint-config-airbnb-base/package.json index 3594335618..256ef85084 100644 --- a/packages/eslint-config-airbnb-base/package.json +++ b/packages/eslint-config-airbnb-base/package.json @@ -49,7 +49,7 @@ "babel-preset-airbnb": "^2.1.1", "babel-tape-runner": "^2.0.1", "editorconfig-tools": "^0.1.1", - "eslint": "^3.12.1", + "eslint": "^3.12.2", "eslint-find-rules": "^1.14.3", "eslint-plugin-import": "^2.2.0", "in-publish": "^2.0.0", @@ -57,7 +57,7 @@ "tape": "^4.6.3" }, "peerDependencies": { - "eslint": "^3.12.1", + "eslint": "^3.12.2", "eslint-plugin-import": "^2.2.0" }, "engines": { diff --git a/packages/eslint-config-airbnb/package.json b/packages/eslint-config-airbnb/package.json index bb96633dfe..a4d699bd02 100644 --- a/packages/eslint-config-airbnb/package.json +++ b/packages/eslint-config-airbnb/package.json @@ -52,10 +52,10 @@ "babel-preset-airbnb": "^2.1.1", "babel-tape-runner": "^2.0.1", "editorconfig-tools": "^0.1.1", - "eslint": "^3.12.1", + "eslint": "^3.12.2", "eslint-find-rules": "^1.14.3", "eslint-plugin-import": "^2.2.0", - "eslint-plugin-jsx-a11y": "^3.0.1", + "eslint-plugin-jsx-a11y": "^3.0.2", "eslint-plugin-react": "^6.8.0", "in-publish": "^2.0.0", "react": ">= 0.13.0", @@ -63,8 +63,8 @@ "tape": "^4.6.3" }, "peerDependencies": { - "eslint": "^3.12.1", - "eslint-plugin-jsx-a11y": "^3.0.1", + "eslint": "^3.12.2", + "eslint-plugin-jsx-a11y": "^3.0.2", "eslint-plugin-import": "^2.2.0", "eslint-plugin-react": "^6.8.0" }, From 6593964080c68e3b6d1975fc8c1b77c575933c3b Mon Sep 17 00:00:00 2001 From: Felix Sanz Date: Thu, 29 Dec 2016 02:25:03 +0100 Subject: [PATCH 049/702] Fixed Functions (7.1) JSCS rule --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index a64dd80df9..2404cd5000 100644 --- a/README.md +++ b/README.md @@ -574,7 +574,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: [`requireFunctionDeclarations`](http://jscs.info/rule/requireFunctionDeclarations) + - [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)) From b48438141c799cd1cae6fa2a4f9ec303bbe810a9 Mon Sep 17 00:00:00 2001 From: Kamron Batman Date: Wed, 28 Dec 2016 12:53:51 -0800 Subject: [PATCH 050/702] [inthewild] Adds BashPros --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 2404cd5000..b56f1b7401 100644 --- a/README.md +++ b/README.md @@ -3144,6 +3144,7 @@ Other Style Guides - **Ascribe**: [ascribe/javascript](https://github.com/ascribe/javascript) - **Avalara**: [avalara/javascript](https://github.com/avalara/javascript) - **Avant**: [avantcredit/javascript](https://github.com/avantcredit/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/) - **Blendle**: [blendle/javascript](https://github.com/blendle/javascript) From 266860b597a7b341d337f7f44195fac63b677ba2 Mon Sep 17 00:00:00 2001 From: nathanhleung Date: Fri, 6 Jan 2017 17:04:28 -0500 Subject: [PATCH 051/702] [eslint config] [*] [docs] add note about `install-peerdeps` Closes #1233. --- packages/eslint-config-airbnb-base/README.md | 13 +++++++++++++ packages/eslint-config-airbnb/README.md | 13 +++++++++++++ 2 files changed, 26 insertions(+) diff --git a/packages/eslint-config-airbnb-base/README.md b/packages/eslint-config-airbnb-base/README.md index a79376be85..4350a5dbd6 100644 --- a/packages/eslint-config-airbnb-base/README.md +++ b/packages/eslint-config-airbnb-base/README.md @@ -32,6 +32,19 @@ Our default export contains all of our ESLint rules, including ECMAScript 6+. It npm install --save-dev eslint-config-airbnb-base eslint@^#.#.# eslint-plugin-import@^#.#.# ``` + 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-base + ``` + + The cli will produce and run a command like: + + ```sh + npm install --save-dev eslint-config-airbnb-base eslint@^#.#.# eslint-plugin-import@^#.#.# + ``` + 2. Add `"extends": "airbnb-base"` to your .eslintrc ### eslint-config-airbnb-base/legacy diff --git a/packages/eslint-config-airbnb/README.md b/packages/eslint-config-airbnb/README.md index e8d66eca0c..122eaf2e7f 100644 --- a/packages/eslint-config-airbnb/README.md +++ b/packages/eslint-config-airbnb/README.md @@ -33,6 +33,19 @@ Our default export contains all of our ESLint rules, including ECMAScript 6+ and 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. + + ```sh + npm install -g install-peerdeps + install-peerdeps --dev eslint-config-airbnb + ``` + + The cli will produce and run a command like: + + ```sh + npm install --save-dev eslint-config-airbnb eslint@^#.#.# eslint-plugin-jsx-a11y@^#.#.# eslint-plugin-import@^#.#.# eslint-plugin-react@^#.#.# + ``` + 2. Add `"extends": "airbnb"` to your .eslintrc ### eslint-config-airbnb/base From 097047202edd77b40d473aef1c648aef034f1863 Mon Sep 17 00:00:00 2001 From: Ricardo Ambrogi Date: Sun, 8 Jan 2017 11:19:15 -0200 Subject: [PATCH 052/702] [guide] fix Array name in examples --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index b56f1b7401..873a0a3ee4 100644 --- a/README.md +++ b/README.md @@ -1323,12 +1323,12 @@ Other Style Guides // bad const increasedByOne = []; for (let i = 0; i < numbers.length; i++) { - modified.push(numbers[i] + 1); + increasedByOne.push(numbers[i] + 1); } // good const increasedByOne = []; - numbers.forEach(num => modified.push(num + 1)); + numbers.forEach(num => increasedByOne.push(num + 1)); // best (keeping it functional) const increasedByOne = numbers.map(num => num + 1); From 7e865a4e8ab5e26062fcdc9437166c6e1c269599 Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Sun, 8 Jan 2017 14:55:09 -0800 Subject: [PATCH 053/702] [eslint config] [base] [deps] update `eslint` --- packages/eslint-config-airbnb-base/package.json | 4 ++-- packages/eslint-config-airbnb-base/rules/es6.js | 10 ++++++++++ 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/packages/eslint-config-airbnb-base/package.json b/packages/eslint-config-airbnb-base/package.json index 256ef85084..055228843f 100644 --- a/packages/eslint-config-airbnb-base/package.json +++ b/packages/eslint-config-airbnb-base/package.json @@ -49,7 +49,7 @@ "babel-preset-airbnb": "^2.1.1", "babel-tape-runner": "^2.0.1", "editorconfig-tools": "^0.1.1", - "eslint": "^3.12.2", + "eslint": "^3.13.0", "eslint-find-rules": "^1.14.3", "eslint-plugin-import": "^2.2.0", "in-publish": "^2.0.0", @@ -57,7 +57,7 @@ "tape": "^4.6.3" }, "peerDependencies": { - "eslint": "^3.12.2", + "eslint": "^3.13.0", "eslint-plugin-import": "^2.2.0" }, "engines": { diff --git a/packages/eslint-config-airbnb-base/rules/es6.js b/packages/eslint-config-airbnb-base/rules/es6.js index ff90669dd0..8b7ac24d14 100644 --- a/packages/eslint-config-airbnb-base/rules/es6.js +++ b/packages/eslint-config-airbnb-base/rules/es6.js @@ -108,6 +108,16 @@ module.exports = { ignoreReadBeforeAssign: true, }], + // Prefer destructuring from arrays and objects + // http://eslint.org/docs/rules/prefer-destructuring + // TODO: enable + 'prefer-destructuring': ['off', { + array: true, + object: true, + }, { + enforceForRenamedProperties: false, + }], + // disallow parseInt() in favor of binary, octal, and hexadecimal literals // http://eslint.org/docs/rules/prefer-numeric-literals 'prefer-numeric-literals': 'error', From 7963b97438d7a5d8c82af4f267528b7be912d736 Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Sun, 8 Jan 2017 15:00:08 -0800 Subject: [PATCH 054/702] [eslint config] [base] v11.0.1 --- packages/eslint-config-airbnb-base/CHANGELOG.md | 6 ++++++ packages/eslint-config-airbnb-base/package.json | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/packages/eslint-config-airbnb-base/CHANGELOG.md b/packages/eslint-config-airbnb-base/CHANGELOG.md index 2d1b1618a5..58bc3468b8 100644 --- a/packages/eslint-config-airbnb-base/CHANGELOG.md +++ b/packages/eslint-config-airbnb-base/CHANGELOG.md @@ -1,3 +1,9 @@ +11.0.1 / 2017-01-08 +================== + - [deps] update `eslint` + - [docs] add note about `install-peerdeps` (#1234) + - [docs] Updated instructions to support non-bash users (#1214) + 11.0.0 / 2016-12-11 ================== - [breaking] enable `no-await-in-loop` diff --git a/packages/eslint-config-airbnb-base/package.json b/packages/eslint-config-airbnb-base/package.json index 055228843f..b6e3da2c6c 100644 --- a/packages/eslint-config-airbnb-base/package.json +++ b/packages/eslint-config-airbnb-base/package.json @@ -1,6 +1,6 @@ { "name": "eslint-config-airbnb-base", - "version": "11.0.0", + "version": "11.0.1", "description": "Airbnb's base JS ESLint config, following our styleguide", "main": "index.js", "scripts": { From 7ec81d2a9457bad1db0bf5b9cc17599a47b5bd17 Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Sun, 8 Jan 2017 14:57:32 -0800 Subject: [PATCH 055/702] [eslint config] [deps] update `eslint`, `eslint-plugin-react`, `eslint-config-airbnb-base` --- 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 a4d699bd02..526b74d98f 100644 --- a/packages/eslint-config-airbnb/package.json +++ b/packages/eslint-config-airbnb/package.json @@ -46,27 +46,27 @@ }, "homepage": "https://github.com/airbnb/javascript", "dependencies": { - "eslint-config-airbnb-base": "^11.0.0" + "eslint-config-airbnb-base": "^11.0.1" }, "devDependencies": { "babel-preset-airbnb": "^2.1.1", "babel-tape-runner": "^2.0.1", "editorconfig-tools": "^0.1.1", - "eslint": "^3.12.2", + "eslint": "^3.13.0", "eslint-find-rules": "^1.14.3", "eslint-plugin-import": "^2.2.0", "eslint-plugin-jsx-a11y": "^3.0.2", - "eslint-plugin-react": "^6.8.0", + "eslint-plugin-react": "^6.9.0", "in-publish": "^2.0.0", "react": ">= 0.13.0", "safe-publish-latest": "^1.1.1", "tape": "^4.6.3" }, "peerDependencies": { - "eslint": "^3.12.2", + "eslint": "^3.13.0", "eslint-plugin-jsx-a11y": "^3.0.2", "eslint-plugin-import": "^2.2.0", - "eslint-plugin-react": "^6.8.0" + "eslint-plugin-react": "^6.9.0" }, "engines": { "node": ">= 4" From 846d687936fa68f3fdf213f724719f01bfe97cdf Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Sun, 8 Jan 2017 15:19:26 -0800 Subject: [PATCH 056/702] [eslint config] v14.0.0 --- packages/eslint-config-airbnb/CHANGELOG.md | 8 ++++++++ packages/eslint-config-airbnb/package.json | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/packages/eslint-config-airbnb/CHANGELOG.md b/packages/eslint-config-airbnb/CHANGELOG.md index b2cb3456c9..e3025d5a28 100644 --- a/packages/eslint-config-airbnb/CHANGELOG.md +++ b/packages/eslint-config-airbnb/CHANGELOG.md @@ -1,3 +1,11 @@ +14.0.0 / 2017-01-08 +================== +- [breaking] enable `react/no-array-index-key`, `react/require-default-props` +- [breaking] [deps] update `eslint`, `eslint-plugin-import`, `eslint-plugin-react`, `eslint-config-airbnb-base` +- [breaking] [deps] update `eslint-plugin-jsx-a11y` to v3 (#1166) +- [docs] add note about `install-peerdeps` (#1234) +- [docs] Updated instructions to support non-bash users (#1214) + 13.0.0 / 2016-11-06 ================== - [breaking] Enable `import/no-webpack-loader-syntax` rule (#1123) diff --git a/packages/eslint-config-airbnb/package.json b/packages/eslint-config-airbnb/package.json index 526b74d98f..ce821f90b3 100644 --- a/packages/eslint-config-airbnb/package.json +++ b/packages/eslint-config-airbnb/package.json @@ -1,6 +1,6 @@ { "name": "eslint-config-airbnb", - "version": "13.0.0", + "version": "14.0.0", "description": "Airbnb's ESLint config, following our styleguide", "main": "index.js", "scripts": { From 2df021eb8398de90ce5f3e02b2623e559e38e0e7 Mon Sep 17 00:00:00 2001 From: Ivan Zusko Date: Wed, 4 Jan 2017 10:58:43 +0200 Subject: [PATCH 057/702] [guide] [react] Added React/JSX Style Guide in Ukrainian --- react/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/react/README.md b/react/README.md index 419033de18..0264768f3f 100644 --- a/react/README.md +++ b/react/README.md @@ -619,5 +619,6 @@ - ![Br](https://raw.githubusercontent.com/gosquared/flags/master/flags/flags/shiny/24/Brazil.png) **Portuguese**: [ronal2do/javascript](https://github.com/ronal2do/airbnb-react-styleguide) - ![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/tree/master/react) - ![es](https://raw.githubusercontent.com/gosquared/flags/master/flags/flags/shiny/24/Spain.png) **Español**: [agrcrobles/javascript](https://github.com/agrcrobles/javascript/tree/master/react) + - ![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 b7aabb938d20f61ba3d617f473dc9006e6e48a59 Mon Sep 17 00:00:00 2001 From: Jeff Cousins Date: Mon, 9 Jan 2017 17:10:10 -0600 Subject: [PATCH 058/702] Add semicolon to named function expression variable declaration --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 873a0a3ee4..3667c6128e 100644 --- a/README.md +++ b/README.md @@ -1671,7 +1671,7 @@ Other Style Guides var named = function named() { console.log('named'); - } + }; } ``` From d892cc9117c08f14e58a544a0556cc7147023b7d Mon Sep 17 00:00:00 2001 From: Wooram Jun Date: Tue, 10 Jan 2017 20:33:04 +0900 Subject: [PATCH 059/702] [eslint config] [base] Update a deprecated 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 def0b9fb6f..5d35f67431 100644 --- a/packages/eslint-config-airbnb-base/rules/best-practices.js +++ b/packages/eslint-config-airbnb-base/rules/best-practices.js @@ -37,7 +37,7 @@ module.exports = { // require the use of === and !== // http://eslint.org/docs/rules/eqeqeq - eqeqeq: ['error', 'allow-null'], + eqeqeq: ['error', 'always', { null: 'ignore' }], // make sure for-in loops have an if statement 'guard-for-in': 'error', From 73e27ef03624fdaeb44033d17015858379967302 Mon Sep 17 00:00:00 2001 From: Greg Werner Date: Tue, 10 Jan 2017 23:27:55 -0500 Subject: [PATCH 060/702] add 3blades reference --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 3667c6128e..4e84dd550b 100644 --- a/README.md +++ b/README.md @@ -3136,6 +3136,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. + - **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) - **Adult Swim**: [adult-swim/javascript](https://github.com/adult-swim/javascript) From 712e010f2921237113bf6af6f9131302092d785f Mon Sep 17 00:00:00 2001 From: oshalygin Date: Wed, 11 Jan 2017 15:36:59 -0800 Subject: [PATCH 061/702] Update common function body comment - This commit provides a canonical way of describing that the function body contains code of some sort. - The convention chosen was '// ...'. - This change is persisted throughout the readme file where appropriate --- README.md | 73 ++++++++++++++++++++++++++++++++++++++----------------- 1 file changed, 51 insertions(+), 22 deletions(-) diff --git a/README.md b/README.md index 4e84dd550b..639a62e550 100644 --- a/README.md +++ b/README.md @@ -581,14 +581,17 @@ Other Style Guides ```javascript // bad const foo = function () { + // ... }; // bad function foo() { + // ... } // good const foo = function bar() { + // ... }; ``` @@ -632,13 +635,13 @@ Other Style Guides ```javascript // bad - function nope(name, options, arguments) { - // ...stuff... + function foo(name, options, arguments) { + // ... } // good - function yup(name, options, args) { - // ...stuff... + function foo(name, options, args) { + // ... } ``` @@ -774,18 +777,22 @@ Other Style Guides // bad function f1(a) { a = 1; + // ... } function f2(a) { if (!a) { a = 1; } + // ... } // good function f3(a) { const b = a || 1; + // ... } function f4(a = 1) { + // ... } ``` @@ -818,7 +825,7 @@ Other Style Guides function foo(bar, baz, quux) { - // body + // ... } // good @@ -827,7 +834,7 @@ Other Style Guides baz, quux, ) { - // body + // ... } // bad @@ -1347,39 +1354,56 @@ Other Style Guides ```js // bad function * foo() { + // ... } + // bad const bar = function * () { + // ... } + // bad const baz = function *() { + // ... } + // bad const quux = function*() { + // ... } + // bad function*foo() { + // ... } + // bad function *foo() { + // ... } // very bad function * foo() { + // ... } + // very bad const wat = function * () { + // ... } // good function* foo() { + // ... } + // good const foo = function* () { + // ... } ``` @@ -1721,32 +1745,32 @@ Other Style Guides ```javascript // bad if (isValid === true) { - // ...stuff... + // ... } // good if (isValid) { - // ...stuff... + // ... } // bad if (name) { - // ...stuff... + // ... } // good if (name !== '') { - // ...stuff... + // ... } // bad if (collection.length) { - // ...stuff... + // ... } // good if (collection.length > 0) { - // ...stuff... + // ... } ``` @@ -1770,7 +1794,9 @@ Other Style Guides const y = 2; break; case 3: - function f() {} + function f() { + // ... + } break; default: class C {} @@ -1787,7 +1813,9 @@ Other Style Guides break; } case 3: { - function f() {} + function f() { + // ... + } break; } case 4: @@ -1910,7 +1938,7 @@ Other Style Guides // @return {Element} element function make(tag) { - // ...stuff... + // ... return element; } @@ -1922,7 +1950,7 @@ Other Style Guides */ function make(tag) { - // ...stuff... + // ... return element; } @@ -1985,7 +2013,7 @@ Other Style Guides */ function make(tag) { - // ...stuff... + // ... return element; } @@ -1997,7 +2025,7 @@ Other Style Guides */ function make(tag) { - // ...stuff... + // ... return element; } @@ -2624,12 +2652,12 @@ Other Style Guides ```javascript // bad function q() { - // ...stuff... + // ... } // good function query() { - // ..stuff.. + // ... } ``` @@ -2756,6 +2784,7 @@ Other Style Guides ```javascript function makeStyleGuide() { + // ... } export default makeStyleGuide; @@ -2933,7 +2962,7 @@ Other Style Guides function setSidebar() { $('.sidebar').hide(); - // ...stuff... + // ... $('.sidebar').css({ 'background-color': 'pink' @@ -2945,7 +2974,7 @@ Other Style Guides const $sidebar = $('.sidebar'); $sidebar.hide(); - // ...stuff... + // ... $sidebar.css({ 'background-color': 'pink' From b06c5c6621942f512ceac6150be93d79c7dfd3ba Mon Sep 17 00:00:00 2001 From: Olivier Tassinari Date: Sun, 15 Jan 2017 12:39:30 +0100 Subject: [PATCH 062/702] Avoid octal number interpretation Some JavaScript versions interpret numbers as octal if they are written with a leading zero. Babel interpreter throws with an `Invalid number` message. --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 639a62e550..6428f82088 100644 --- a/README.md +++ b/README.md @@ -811,10 +811,10 @@ Other Style Guides console.log(...x); // bad - new (Function.prototype.bind.apply(Date, [null, 2016, 08, 05])); + new (Function.prototype.bind.apply(Date, [null, 2016, 8, 5])); // good - new Date(...[2016, 08, 05]); + new Date(...[2016, 8, 5]); ``` From a6a6f4b488806edec59cd92b97f6a0680091474c Mon Sep 17 00:00:00 2001 From: Christian Oliff Date: Tue, 17 Jan 2017 17:09:27 +0900 Subject: [PATCH 063/702] Update copyright year --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 6428f82088..dc2e8fe9d7 100644 --- a/README.md +++ b/README.md @@ -3285,7 +3285,7 @@ Other Style Guides (The MIT License) -Copyright (c) 2014-2016 Airbnb +Copyright (c) 2014-2017 Airbnb Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the From cdbe705fc486cb8e18b8cd8a6723fc17326dd521 Mon Sep 17 00:00:00 2001 From: Irving Barajas Date: Wed, 18 Jan 2017 18:32:23 -0800 Subject: [PATCH 064/702] [inthewild] Adds SwoopApp --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index dc2e8fe9d7..9edd321c29 100644 --- a/README.md +++ b/README.md @@ -3234,6 +3234,7 @@ Other Style Guides - **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) + - **SwoopApp**: [swoopapp/javascript](https://github.com/swoopapp/javascript) - **SysGarage**: [sysgarage/javascript-style-guide](https://github.com/sysgarage/javascript-style-guide) - **Syzygy Warsaw**: [syzygypl/javascript](https://github.com/syzygypl/javascript) - **Target**: [target/javascript](https://github.com/target/javascript) From 40d5797b353354265d8a32c943cb6958f1b60749 Mon Sep 17 00:00:00 2001 From: Harkirat Saluja Date: Tue, 17 Jan 2017 14:59:41 +0530 Subject: [PATCH 065/702] [guide] [react] Add missing trailing comma --- react/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/react/README.md b/react/README.md index 0264768f3f..9401b72596 100644 --- a/react/README.md +++ b/react/README.md @@ -359,6 +359,7 @@ SFC.propTypes = { foo: PropTypes.number.isRequired, bar: PropTypes.string, + children: PropTypes.node, }; SFC.defaultProps = { bar: '', From d8c3048f247f3d7cb0d3bf27d901bd5819ef9ce3 Mon Sep 17 00:00:00 2001 From: Vse Mozhet Byt Date: Wed, 18 Jan 2017 06:56:07 +0200 Subject: [PATCH 066/702] [guide] ```js -> ```javascript for consistency --- README.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 9edd321c29..aa38130a80 100644 --- a/README.md +++ b/README.md @@ -907,7 +907,7 @@ Other Style Guides > Why? It shows clearly where the function starts and ends. - ```js + ```javascript // bad ['get', 'post', 'put'].map(httpMethod => Object.prototype.hasOwnProperty.call( httpMagicObjectWithAVeryLongName, @@ -929,7 +929,7 @@ Other Style Guides > Why? Less visual clutter. - ```js + ```javascript // bad [1, 2, 3].map((x) => x * x); @@ -957,7 +957,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) - ```js + ```javascript // bad const itemHeight = item => item.height > 256 ? item.largeSize : item.smallSize; @@ -1351,7 +1351,7 @@ Other Style Guides > Why? `function` and `*` are part of the same conceptual keyword - `*` is not a modifier for `function`, `function*` is a unique construct, different from `function`. - ```js + ```javascript // bad function * foo() { // ... From 41fa95eef91b59048a8d0e9f055d41f98e20b27e Mon Sep 17 00:00:00 2001 From: Vse Mozhet Byt Date: Wed, 18 Jan 2017 07:02:56 +0200 Subject: [PATCH 067/702] [guide] fix indentation for consistency --- README.md | 130 +++++++++++++++++++++++++++--------------------------- 1 file changed, 65 insertions(+), 65 deletions(-) diff --git a/README.md b/README.md index aa38130a80..ec1044a809 100644 --- a/README.md +++ b/README.md @@ -255,63 +255,63 @@ 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) - > Why? In general we consider it subjectively easier to read. It improves syntax highlighting, and is also more easily optimized by many JS engines. - - ```javascript - // bad - const bad = { - 'foo': 3, - 'bar': 4, - 'data-blah': 5, - }; - - // good - const good = { - foo: 3, - bar: 4, - 'data-blah': 5, - }; - ``` + > Why? In general we consider it subjectively easier to read. It improves syntax highlighting, and is also more easily optimized by many JS engines. + + ```javascript + // bad + const bad = { + 'foo': 3, + 'bar': 4, + 'data-blah': 5, + }; + + // good + const good = { + foo: 3, + bar: 4, + 'data-blah': 5, + }; + ``` - [3.7](#objects--prototype-builtins) Do not call `Object.prototype` methods directly, such as `hasOwnProperty`, `propertyIsEnumerable`, and `isPrototypeOf`. - > Why? These methods may be shadowed by properties on the object in question - consider `{ hasOwnProperty: false }` - or, the object may be a null object (`Object.create(null)`). + > Why? These methods may be shadowed by properties on the object in question - consider `{ hasOwnProperty: false }` - or, the object may be a null object (`Object.create(null)`). - ```javascript - // bad - console.log(object.hasOwnProperty(key)); + ```javascript + // bad + console.log(object.hasOwnProperty(key)); - // good - console.log(Object.prototype.hasOwnProperty.call(object, key)); + // good + console.log(Object.prototype.hasOwnProperty.call(object, key)); - // best - const has = Object.prototype.hasOwnProperty; // cache the lookup once, in module scope. - /* or */ - import has from 'has'; - … - console.log(has.call(object, key)); - ``` + // best + const has = Object.prototype.hasOwnProperty; // cache the lookup once, in module scope. + /* or */ + import has from 'has'; + … + console.log(has.call(object, key)); + ``` - [3.8](#objects--rest-spread) Prefer the object spread operator over [`Object.assign`](https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/Object/assign) to shallow-copy objects. Use the object rest operator to get a new object with certain properties omitted. - ```javascript - // very bad - const original = { a: 1, b: 2 }; - const copy = Object.assign(original, { c: 3 }); // this mutates `original` ಠ_ಠ - delete copy.a; // so does this + ```javascript + // very bad + const original = { a: 1, b: 2 }; + const copy = Object.assign(original, { c: 3 }); // this mutates `original` ಠ_ಠ + delete copy.a; // so does this - // bad - const original = { a: 1, b: 2 }; - const copy = Object.assign({}, original, { c: 3 }); // copy => { a: 1, b: 2, c: 3 } + // bad + const original = { a: 1, b: 2 }; + const copy = Object.assign({}, original, { c: 3 }); // copy => { a: 1, b: 2, c: 3 } - // good - const original = { a: 1, b: 2 }; - const copy = { ...original, c: 3 }; // copy => { a: 1, b: 2, c: 3 } + // good + const original = { a: 1, b: 2 }; + const copy = { ...original, c: 3 }; // copy => { a: 1, b: 2, c: 3 } - const { a, ...noA } = copy; // noA => { b: 2, c: 3 } - ``` + const { a, ...noA } = copy; // noA => { b: 2, c: 3 } + ``` **[⬆ back to top](#table-of-contents)** @@ -1586,32 +1586,32 @@ Other Style Guides > 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. ```javascript - // bad + // bad - let array = [1, 2, 3]; - let num = 1; - num++; - --num; + let array = [1, 2, 3]; + let num = 1; + num++; + --num; - let sum = 0; - let truthyCount = 0; - for(let i = 0; i < array.length; i++){ - let value = array[i]; - sum += value; - if (value) { - truthyCount++; - } + let sum = 0; + let truthyCount = 0; + for(let i = 0; i < array.length; i++){ + let value = array[i]; + sum += value; + if (value) { + truthyCount++; } + } - // good + // good - let array = [1, 2, 3]; - let num = 1; - num += 1; - num -= 1; + let array = [1, 2, 3]; + let num = 1; + num += 1; + num -= 1; - const sum = array.reduce((a, b) => a + b, 0); - const truthyCount = array.filter(Boolean).length; + const sum = array.reduce((a, b) => a + b, 0); + const truthyCount = array.filter(Boolean).length; ``` **[⬆ back to top](#table-of-contents)** @@ -1780,9 +1780,9 @@ Other Style Guides - [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`). - > 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. + > Why? Lexical declarations are visible in the entire `switch` block but only get initialized when assigned, which only happens when its `case` is reached. This causes problems when multiple `case` clauses attempt to define the same thing. - eslint rules: [`no-case-declarations`](http://eslint.org/docs/rules/no-case-declarations.html). + eslint rules: [`no-case-declarations`](http://eslint.org/docs/rules/no-case-declarations.html). ```javascript // bad From ee492a73baeb66f226a2bcbc61317035243d2da3 Mon Sep 17 00:00:00 2001 From: Vse Mozhet Byt Date: Wed, 18 Jan 2017 07:06:04 +0200 Subject: [PATCH 068/702] [guide] comment out ellipses --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index ec1044a809..a448e91b29 100644 --- a/README.md +++ b/README.md @@ -289,7 +289,7 @@ Other Style Guides const has = Object.prototype.hasOwnProperty; // cache the lookup once, in module scope. /* or */ import has from 'has'; - … + // ... console.log(has.call(object, key)); ``` @@ -2915,7 +2915,7 @@ Other Style Guides // bad $(this).trigger('listingUpdated', listing.id); - ... + // ... $(this).on('listingUpdated', (e, listingId) => { // do something with listingId @@ -2928,7 +2928,7 @@ Other Style Guides // good $(this).trigger('listingUpdated', { listingId: listing.id }); - ... + // ... $(this).on('listingUpdated', (e, data) => { // do something with data.listingId From d9284873a8107212bd21b6493697ee0dc362c20a Mon Sep 17 00:00:00 2001 From: Vse Mozhet Byt Date: Wed, 18 Jan 2017 07:10:09 +0200 Subject: [PATCH 069/702] [guide] const -> let --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index a448e91b29..c9daa7c3a5 100644 --- a/README.md +++ b/README.md @@ -2073,17 +2073,17 @@ Other Style Guides ```javascript // bad function foo() { - ∙∙∙∙const name; + ∙∙∙∙let name; } // bad function bar() { - ∙const name; + ∙let name; } // good function baz() { - ∙∙const name; + ∙∙let name; } ``` From 9fdd6d6ffac6928fdcb00b2db98e3bf152c4acd9 Mon Sep 17 00:00:00 2001 From: Vse Mozhet Byt Date: Wed, 18 Jan 2017 07:15:57 +0200 Subject: [PATCH 070/702] [guide] add / remove semicolons --- README.md | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/README.md b/README.md index c9daa7c3a5..c82feb9312 100644 --- a/README.md +++ b/README.md @@ -760,12 +760,12 @@ Other Style Guides // bad function f1(obj) { obj.key = 1; - }; + } // good function f2(obj) { const key = Object.prototype.hasOwnProperty.call(obj, 'key') ? obj.key : 1; - }; + } ``` @@ -1023,7 +1023,7 @@ Other Style Guides inherits(PeekableQueue, Queue); PeekableQueue.prototype.peek = function () { return this._queue[0]; - } + }; // good class PeekableQueue extends Queue { @@ -1225,11 +1225,11 @@ Other Style Guides ```javascript // bad let foo = 3; - export { foo } + export { foo }; // good const foo = 3; - export { foo } + export { foo }; ``` @@ -1360,17 +1360,17 @@ Other Style Guides // bad const bar = function * () { // ... - } + }; // bad const baz = function *() { // ... - } + }; // bad const quux = function*() { // ... - } + }; // bad function*foo() { @@ -1394,7 +1394,7 @@ Other Style Guides * () { // ... - } + }; // good function* foo() { @@ -1404,7 +1404,7 @@ Other Style Guides // good const foo = function* () { // ... - } + }; ``` **[⬆ back to top](#table-of-contents)** @@ -2521,7 +2521,7 @@ Other Style Guides lastName, inventorOf, ...heroArgs - ) + ); ``` **[⬆ back to top](#table-of-contents)** @@ -2620,9 +2620,9 @@ Other Style Guides - [21.5](#coercion--bitwise) **Note:** Be careful when using bitshift operations. Numbers are represented as [64-bit values](https://es5.github.io/#x4.3.19), but bitshift operations always return a 32-bit integer ([source](https://es5.github.io/#x11.7)). Bitshift can lead to unexpected behavior for integer values larger than 32 bits. [Discussion](https://github.com/airbnb/javascript/issues/109). Largest signed 32-bit Int is 2,147,483,647: ```javascript - 2147483647 >> 0 //=> 2147483647 - 2147483648 >> 0 //=> -2147483648 - 2147483649 >> 0 //=> -2147483647 + 2147483647 >> 0; //=> 2147483647 + 2147483648 >> 0; //=> -2147483648 + 2147483649 >> 0; //=> -2147483647 ``` From 9bb29860bc79e9e0420b502fd82ef9632848c856 Mon Sep 17 00:00:00 2001 From: Vse Mozhet Byt Date: Wed, 18 Jan 2017 07:17:30 +0200 Subject: [PATCH 071/702] [guide] add spaces --- README.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index c82feb9312..247fbc70f5 100644 --- a/README.md +++ b/README.md @@ -1595,7 +1595,7 @@ Other Style Guides let sum = 0; let truthyCount = 0; - for(let i = 0; i < array.length; i++){ + for (let i = 0; i < array.length; i++) { let value = array[i]; sum += value; if (value) { @@ -2620,9 +2620,9 @@ Other Style Guides - [21.5](#coercion--bitwise) **Note:** Be careful when using bitshift operations. Numbers are represented as [64-bit values](https://es5.github.io/#x4.3.19), but bitshift operations always return a 32-bit integer ([source](https://es5.github.io/#x11.7)). Bitshift can lead to unexpected behavior for integer values larger than 32 bits. [Discussion](https://github.com/airbnb/javascript/issues/109). Largest signed 32-bit Int is 2,147,483,647: ```javascript - 2147483647 >> 0; //=> 2147483647 - 2147483648 >> 0; //=> -2147483648 - 2147483649 >> 0; //=> -2147483647 + 2147483647 >> 0; // => 2147483647 + 2147483648 >> 0; // => -2147483648 + 2147483649 >> 0; // => -2147483647 ``` From 231317408f7501f22108768ae05a9c2016765d61 Mon Sep 17 00:00:00 2001 From: Vse Mozhet Byt Date: Wed, 18 Jan 2017 07:27:18 +0200 Subject: [PATCH 072/702] [guide] add trailing commas --- README.md | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 247fbc70f5..09c9293b12 100644 --- a/README.md +++ b/README.md @@ -898,7 +898,7 @@ Other Style Guides // good [1, 2, 3].map((number, index) => ({ - [index]: number + [index]: number, })); ``` @@ -911,7 +911,7 @@ Other Style Guides // bad ['get', 'post', 'put'].map(httpMethod => Object.prototype.hasOwnProperty.call( httpMagicObjectWithAVeryLongName, - httpMethod + httpMethod, ) ); @@ -919,7 +919,7 @@ Other Style Guides ['get', 'post', 'put'].map(httpMethod => ( Object.prototype.hasOwnProperty.call( httpMagicObjectWithAVeryLongName, - httpMethod + httpMethod, ) )); ``` @@ -2796,7 +2796,7 @@ Other Style Guides ```javascript const AirbnbStyleGuide = { es6: { - } + }, }; export default AirbnbStyleGuide; @@ -2965,7 +2965,7 @@ Other Style Guides // ... $('.sidebar').css({ - 'background-color': 'pink' + 'background-color': 'pink', }); } @@ -2977,7 +2977,7 @@ Other Style Guides // ... $sidebar.css({ - 'background-color': 'pink' + 'background-color': 'pink', }); } ``` From 6e4859d7c694afcc45366a26f1818d416db5764b Mon Sep 17 00:00:00 2001 From: Vse Mozhet Byt Date: Wed, 18 Jan 2017 07:33:11 +0200 Subject: [PATCH 073/702] [guide] remove trailing or leading underscores --- README.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 09c9293b12..6d28041dca 100644 --- a/README.md +++ b/README.md @@ -1022,13 +1022,13 @@ Other Style Guides } inherits(PeekableQueue, Queue); PeekableQueue.prototype.peek = function () { - return this._queue[0]; + return this.queue[0]; }; // good class PeekableQueue extends Queue { peek() { - return this._queue[0]; + return this.queue[0]; } } ``` @@ -1971,7 +1971,7 @@ Other Style Guides function getType() { console.log('fetching type...'); // set the default type to 'no type' - const type = this._type || 'no type'; + const type = this.type || 'no type'; return type; } @@ -1981,7 +1981,7 @@ Other Style Guides console.log('fetching type...'); // set the default type to 'no type' - const type = this._type || 'no type'; + const type = this.type || 'no type'; return type; } @@ -1989,7 +1989,7 @@ Other Style Guides // also good function getType() { // set the default type to 'no type' - const type = this._type || 'no type'; + const type = this.type || 'no type'; return type; } From cb32f443c9ea94c6b25f9c183776eebf8445c87e Mon Sep 17 00:00:00 2001 From: Vse Mozhet Byt Date: Wed, 18 Jan 2017 07:42:53 +0200 Subject: [PATCH 074/702] [guide] fix arrow IIFE call Currently, it throws. --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 6d28041dca..b8785cb852 100644 --- a/README.md +++ b/README.md @@ -2546,10 +2546,10 @@ Other Style Guides }()); // good, but legacy (guards against the function becoming an argument when two files with IIFEs are concatenated) - ;(() => { + ;((() => { const name = 'Skywalker'; return name; - }()); + })()); ``` [Read more](https://stackoverflow.com/questions/7365172/semicolon-before-self-invoking-function/7365214%237365214). From 8e12091e8ff05c304e34e28944596bebfb3f75a0 Mon Sep 17 00:00:00 2001 From: Leonid Lebedev Date: Wed, 18 Jan 2017 21:00:35 +0300 Subject: [PATCH 075/702] [guide] Update russian translation --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index b8785cb852..775fc6fb07 100644 --- a/README.md +++ b/README.md @@ -3264,7 +3264,7 @@ Other Style Guides - ![jp](https://raw.githubusercontent.com/gosquared/flags/master/flags/flags/shiny/24/Japan.png) **Japanese**: [mitsuruog/javascript-style-guide](https://github.com/mitsuruog/javascript-style-guide) - ![kr](https://raw.githubusercontent.com/gosquared/flags/master/flags/flags/shiny/24/South-Korea.png) **Korean**: [tipjs/javascript-style-guide](https://github.com/tipjs/javascript-style-guide) - ![pl](https://raw.githubusercontent.com/gosquared/flags/master/flags/flags/shiny/24/Poland.png) **Polish**: [mjurczyk/javascript](https://github.com/mjurczyk/javascript) - - ![ru](https://raw.githubusercontent.com/gosquared/flags/master/flags/flags/shiny/24/Russia.png) **Russian**: [uprock/javascript](https://github.com/uprock/javascript) + - ![ru](https://raw.githubusercontent.com/gosquared/flags/master/flags/flags/shiny/24/Russia.png) **Russian**: [leonidlebedev/javascript-airbnb](https://github.com/leonidlebedev/javascript-airbnb) - ![es](https://raw.githubusercontent.com/gosquared/flags/master/flags/flags/shiny/24/Spain.png) **Spanish**: [paolocarrasco/javascript-style-guide](https://github.com/paolocarrasco/javascript-style-guide) - ![th](https://raw.githubusercontent.com/gosquared/flags/master/flags/flags/shiny/24/Thailand.png) **Thai**: [lvarayut/javascript-style-guide](https://github.com/lvarayut/javascript-style-guide) - ![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 62a1edecdbb13dc821ff9a63bd03875c0e6f4181 Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Fri, 20 Jan 2017 13:44:25 -0800 Subject: [PATCH 076/702] [eslint config] [base] [deps] update `eslint` --- packages/eslint-config-airbnb-base/package.json | 4 ++-- packages/eslint-config-airbnb-base/rules/best-practices.js | 5 +++++ packages/eslint-config-airbnb-base/rules/style.js | 5 +++++ 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/packages/eslint-config-airbnb-base/package.json b/packages/eslint-config-airbnb-base/package.json index b6e3da2c6c..988669c5c1 100644 --- a/packages/eslint-config-airbnb-base/package.json +++ b/packages/eslint-config-airbnb-base/package.json @@ -49,7 +49,7 @@ "babel-preset-airbnb": "^2.1.1", "babel-tape-runner": "^2.0.1", "editorconfig-tools": "^0.1.1", - "eslint": "^3.13.0", + "eslint": "^3.14.0", "eslint-find-rules": "^1.14.3", "eslint-plugin-import": "^2.2.0", "in-publish": "^2.0.0", @@ -57,7 +57,7 @@ "tape": "^4.6.3" }, "peerDependencies": { - "eslint": "^3.13.0", + "eslint": "^3.14.0", "eslint-plugin-import": "^2.2.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 5d35f67431..2587bc55e9 100644 --- a/packages/eslint-config-airbnb-base/rules/best-practices.js +++ b/packages/eslint-config-airbnb-base/rules/best-practices.js @@ -253,6 +253,11 @@ module.exports = { // disallow use of the with statement 'no-with': 'error', + // require using Error objects as Promise rejection reasons + // http://eslint.org/docs/rules/prefer-promise-reject-errors + // TODO: enable, semver-major + 'prefer-promise-reject-errors': ['off', { allowEmptyReject: true }], + // require use of the second argument for parseInt() radix: 'error', diff --git a/packages/eslint-config-airbnb-base/rules/style.js b/packages/eslint-config-airbnb-base/rules/style.js index 9ea0f0f759..c02baa0f7c 100644 --- a/packages/eslint-config-airbnb-base/rules/style.js +++ b/packages/eslint-config-airbnb-base/rules/style.js @@ -231,6 +231,11 @@ module.exports = { // disallow mixed spaces and tabs for indentation 'no-mixed-spaces-and-tabs': 'error', + // disallow use of chained assignment expressions + // http://eslint.org/docs/rules/no-multi-assign + // TODO: enable, semver-minor + 'no-multi-assign': ['off'], + // disallow multiple empty lines and only one newline at the end 'no-multiple-empty-lines': ['error', { max: 2, maxEOF: 1 }], From d0fb7635bc421cebc4a317bcd12bc853dd8875ef Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Fri, 20 Jan 2017 13:45:50 -0800 Subject: [PATCH 077/702] [eslint config] [base] enable `no-multi-assign` --- 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 c02baa0f7c..f5b7ab8d1d 100644 --- a/packages/eslint-config-airbnb-base/rules/style.js +++ b/packages/eslint-config-airbnb-base/rules/style.js @@ -233,8 +233,7 @@ module.exports = { // disallow use of chained assignment expressions // http://eslint.org/docs/rules/no-multi-assign - // TODO: enable, semver-minor - 'no-multi-assign': ['off'], + 'no-multi-assign': ['error'], // disallow multiple empty lines and only one newline at the end 'no-multiple-empty-lines': ['error', { max: 2, maxEOF: 1 }], From 897b8fcc1cdf5356dbcf7f0a5aa111abdad118e6 Mon Sep 17 00:00:00 2001 From: Florian Berger Date: Wed, 1 Feb 2017 18:30:47 +0200 Subject: [PATCH 078/702] Change function order in functions (7.1) example Part 7.1 says first why function declarations are not good and after that it recommends to give a name to function expression. The same order could be used in example too. --- README.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 775fc6fb07..ec99a55ec0 100644 --- a/README.md +++ b/README.md @@ -580,14 +580,14 @@ Other Style Guides ```javascript // bad - const foo = function () { + function foo() { // ... - }; + } // bad - function foo() { + const foo = function () { // ... - } + }; // good const foo = function bar() { From e22f02cda3ab7bcf30a149480bcc8beedce90c4f Mon Sep 17 00:00:00 2001 From: Florian Berger Date: Wed, 1 Feb 2017 19:22:34 +0200 Subject: [PATCH 079/702] Update React link in organizations --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index ec99a55ec0..92a1e7cec2 100644 --- a/README.md +++ b/README.md @@ -3225,7 +3225,7 @@ Other Style Guides - **Peerby**: [Peerby/javascript](https://github.com/Peerby/javascript) - **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/react/blob/master/CONTRIBUTING.md#style-guide](https://github.com/facebook/react/blob/master/CONTRIBUTING.md#style-guide) + - **React**: [facebook.github.io/react/contributing/how-to-contribute.html#style-guide](https://facebook.github.io/react/contributing/how-to-contribute.html#style-guide) - **REI**: [reidev/js-style-guide](https://github.com/rei/code-style-guides/blob/master/docs/javascript.md) - **Ripple**: [ripple/javascript-style-guide](https://github.com/ripple/javascript-style-guide) - **SeekingAlpha**: [seekingalpha/javascript-style-guide](https://github.com/seekingalpha/javascript-style-guide) From 9375fb59b3fe958d11a446e3ef2673c6771930eb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robin=20Pokorn=C3=BD?= Date: Thu, 2 Feb 2017 13:31:10 +0100 Subject: [PATCH 080/702] [guide] Use const when not reassigning reference --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 92a1e7cec2..9906ed7fa4 100644 --- a/README.md +++ b/README.md @@ -1588,7 +1588,7 @@ Other Style Guides ```javascript // bad - let array = [1, 2, 3]; + const array = [1, 2, 3]; let num = 1; num++; --num; @@ -1605,7 +1605,7 @@ Other Style Guides // good - let array = [1, 2, 3]; + const array = [1, 2, 3]; let num = 1; num += 1; num -= 1; From 4d024be5a48bf7038c5fa5fe3b3eb3c284a7f665 Mon Sep 17 00:00:00 2001 From: Eric Martin Date: Thu, 2 Feb 2017 19:13:13 -0500 Subject: [PATCH 081/702] [guide] Added documentation for arrow function parens with one arg Added explanation for using parentheses with explicit returns and alternatives with the eslint "always" option. --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 9906ed7fa4..a1a0cc57e4 100644 --- a/README.md +++ b/README.md @@ -925,7 +925,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. eslint: [`arrow-parens`](http://eslint.org/docs/rules/arrow-parens.html) jscs: [`disallowParenthesesAroundArrowParam`](http://jscs.info/rule/disallowParenthesesAroundArrowParam) + - [8.4](#arrows--one-arg-parens) If your function takes a single argument and doesn’t use braces, omit the parentheses. Otherwise, always include parentheses around arguments for clarity and consistency. Note: it is also acceptable to always use parentheses, in which case use the ["always" option](http://eslint.org/docs/rules/arrow-parens#always) for eslint or do not include [`disallowParenthesesAroundArrowParam`](http://jscs.info/rule/disallowParenthesesAroundArrowParam) for jscs. eslint: [`arrow-parens`](http://eslint.org/docs/rules/arrow-parens.html) jscs: [`disallowParenthesesAroundArrowParam`](http://jscs.info/rule/disallowParenthesesAroundArrowParam) > Why? Less visual clutter. From a8d2f94884e3f4fdd435f3810f68193739c40523 Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Sun, 5 Feb 2017 10:28:13 -0800 Subject: [PATCH 082/702] [eslint config] [base] update `eslint`, `babel-preset-airbnb` --- packages/eslint-config-airbnb-base/package.json | 6 +++--- packages/eslint-config-airbnb-base/rules/style.js | 5 +++++ 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/packages/eslint-config-airbnb-base/package.json b/packages/eslint-config-airbnb-base/package.json index 988669c5c1..49b8ad3896 100644 --- a/packages/eslint-config-airbnb-base/package.json +++ b/packages/eslint-config-airbnb-base/package.json @@ -46,10 +46,10 @@ }, "homepage": "https://github.com/airbnb/javascript", "devDependencies": { - "babel-preset-airbnb": "^2.1.1", + "babel-preset-airbnb": "^2.2.3", "babel-tape-runner": "^2.0.1", "editorconfig-tools": "^0.1.1", - "eslint": "^3.14.0", + "eslint": "^3.15.0", "eslint-find-rules": "^1.14.3", "eslint-plugin-import": "^2.2.0", "in-publish": "^2.0.0", @@ -57,7 +57,7 @@ "tape": "^4.6.3" }, "peerDependencies": { - "eslint": "^3.14.0", + "eslint": "^3.15.0", "eslint-plugin-import": "^2.2.0" }, "engines": { diff --git a/packages/eslint-config-airbnb-base/rules/style.js b/packages/eslint-config-airbnb-base/rules/style.js index f5b7ab8d1d..1d315bc51a 100644 --- a/packages/eslint-config-airbnb-base/rules/style.js +++ b/packages/eslint-config-airbnb-base/rules/style.js @@ -383,6 +383,11 @@ module.exports = { } }], + // Require or disallow spacing between template tags and their literals + // http://eslint.org/docs/rules/template-tag-spacing + // TODO: enable, semver-major + 'template-tag-spacing': ['off', 'never'], + // require or disallow the Unicode Byte Order Mark // http://eslint.org/docs/rules/unicode-bom 'unicode-bom': ['error', 'never'], From b6fc6dc7c3cb76497db0bb81edaa54d8f3427796 Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Sun, 5 Feb 2017 10:31:04 -0800 Subject: [PATCH 083/702] [eslint config] [base] v11.1.0 --- packages/eslint-config-airbnb-base/CHANGELOG.md | 6 ++++++ packages/eslint-config-airbnb-base/package.json | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/packages/eslint-config-airbnb-base/CHANGELOG.md b/packages/eslint-config-airbnb-base/CHANGELOG.md index 58bc3468b8..b14a4d6b26 100644 --- a/packages/eslint-config-airbnb-base/CHANGELOG.md +++ b/packages/eslint-config-airbnb-base/CHANGELOG.md @@ -1,3 +1,9 @@ +11.1.0 / 2017-01-08 +================== + - [minor] enable `no-multi-assign` + - [deps] update `eslint`, `babel-preset-airbnb` + - Update a deprecated option (`eqeqeq`) (#1244) + 11.0.1 / 2017-01-08 ================== - [deps] update `eslint` diff --git a/packages/eslint-config-airbnb-base/package.json b/packages/eslint-config-airbnb-base/package.json index 49b8ad3896..63efb3588d 100644 --- a/packages/eslint-config-airbnb-base/package.json +++ b/packages/eslint-config-airbnb-base/package.json @@ -1,6 +1,6 @@ { "name": "eslint-config-airbnb-base", - "version": "11.0.1", + "version": "11.1.0", "description": "Airbnb's base JS ESLint config, following our styleguide", "main": "index.js", "scripts": { From de5cd510b8beaef5ecd66b4d5dc924467ba2ec55 Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Sun, 5 Feb 2017 10:43:32 -0800 Subject: [PATCH 084/702] [eslint config] [deps] update `eslint-config-airbnb-base`, `babel-preset-airbnb`, `eslint` --- packages/eslint-config-airbnb/package.json | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/eslint-config-airbnb/package.json b/packages/eslint-config-airbnb/package.json index ce821f90b3..c11bc564cd 100644 --- a/packages/eslint-config-airbnb/package.json +++ b/packages/eslint-config-airbnb/package.json @@ -46,13 +46,13 @@ }, "homepage": "https://github.com/airbnb/javascript", "dependencies": { - "eslint-config-airbnb-base": "^11.0.1" + "eslint-config-airbnb-base": "^11.1.0" }, "devDependencies": { - "babel-preset-airbnb": "^2.1.1", + "babel-preset-airbnb": "^2.2.3", "babel-tape-runner": "^2.0.1", "editorconfig-tools": "^0.1.1", - "eslint": "^3.13.0", + "eslint": "^3.15.0", "eslint-find-rules": "^1.14.3", "eslint-plugin-import": "^2.2.0", "eslint-plugin-jsx-a11y": "^3.0.2", @@ -63,7 +63,7 @@ "tape": "^4.6.3" }, "peerDependencies": { - "eslint": "^3.13.0", + "eslint": "^3.15.0", "eslint-plugin-jsx-a11y": "^3.0.2", "eslint-plugin-import": "^2.2.0", "eslint-plugin-react": "^6.9.0" From a8ecaa8a5aa40b59409f8c026e77aad3452fd1a3 Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Sun, 5 Feb 2017 10:50:34 -0800 Subject: [PATCH 085/702] [eslint config] [deps] [patch] allow `eslint-plugin-jsx-a11y` to be v3 or v4. Remove `no-marquee` rule temporarily. --- packages/eslint-config-airbnb/package.json | 4 ++-- packages/eslint-config-airbnb/rules/react-a11y.js | 4 ---- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/packages/eslint-config-airbnb/package.json b/packages/eslint-config-airbnb/package.json index c11bc564cd..4c3df79318 100644 --- a/packages/eslint-config-airbnb/package.json +++ b/packages/eslint-config-airbnb/package.json @@ -55,7 +55,7 @@ "eslint": "^3.15.0", "eslint-find-rules": "^1.14.3", "eslint-plugin-import": "^2.2.0", - "eslint-plugin-jsx-a11y": "^3.0.2", + "eslint-plugin-jsx-a11y": "^4.0.0", "eslint-plugin-react": "^6.9.0", "in-publish": "^2.0.0", "react": ">= 0.13.0", @@ -64,7 +64,7 @@ }, "peerDependencies": { "eslint": "^3.15.0", - "eslint-plugin-jsx-a11y": "^3.0.2", + "eslint-plugin-jsx-a11y": "^3.0.2 || ^4.0.0", "eslint-plugin-import": "^2.2.0", "eslint-plugin-react": "^6.9.0" }, diff --git a/packages/eslint-config-airbnb/rules/react-a11y.js b/packages/eslint-config-airbnb/rules/react-a11y.js index b101a93e5b..8418cecf63 100644 --- a/packages/eslint-config-airbnb/rules/react-a11y.js +++ b/packages/eslint-config-airbnb/rules/react-a11y.js @@ -92,10 +92,6 @@ module.exports = { // https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/lang.md 'jsx-a11y/lang': 'error', - // prevent marquee elements - // https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/no-marquee.md - 'jsx-a11y/no-marquee': 'error', - // only allow to have the "scope" attr // https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/scope.md 'jsx-a11y/scope': 'error', From 7e35c2dbfcc7f60fc07743d0966b4724da69f6e7 Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Sun, 5 Feb 2017 13:07:53 -0800 Subject: [PATCH 086/702] [eslint config] v14.1.0 --- packages/eslint-config-airbnb/CHANGELOG.md | 5 +++++ packages/eslint-config-airbnb/package.json | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/packages/eslint-config-airbnb/CHANGELOG.md b/packages/eslint-config-airbnb/CHANGELOG.md index e3025d5a28..487e14b5fd 100644 --- a/packages/eslint-config-airbnb/CHANGELOG.md +++ b/packages/eslint-config-airbnb/CHANGELOG.md @@ -1,3 +1,8 @@ +14.1.0 / 2017-02-05 +================== +- [patch] allow `eslint-plugin-jsx-a11y` to be v3 or v4. Remove `no-marquee` rule temporarily. +- [deps] update `eslint-config-airbnb-base`, `babel-preset-airbnb`, `eslint` + 14.0.0 / 2017-01-08 ================== - [breaking] enable `react/no-array-index-key`, `react/require-default-props` diff --git a/packages/eslint-config-airbnb/package.json b/packages/eslint-config-airbnb/package.json index 4c3df79318..18924cdebd 100644 --- a/packages/eslint-config-airbnb/package.json +++ b/packages/eslint-config-airbnb/package.json @@ -1,6 +1,6 @@ { "name": "eslint-config-airbnb", - "version": "14.0.0", + "version": "14.1.0", "description": "Airbnb's ESLint config, following our styleguide", "main": "index.js", "scripts": { From 6435f8ff23f5606e4c454b985abace51c586d9fe Mon Sep 17 00:00:00 2001 From: Colin Hamer Date: Thu, 9 Feb 2017 10:16:00 +0100 Subject: [PATCH 087/702] [inthewild] Adds CaseNine --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index a1a0cc57e4..f41cf2b4de 100644 --- a/README.md +++ b/README.md @@ -3180,6 +3180,7 @@ Other Style Guides - **Blendle**: [blendle/javascript](https://github.com/blendle/javascript) - **Bonhomme**: [bonhommeparis/javascript](https://github.com/bonhommeparis/javascript) - **Brainshark**: [brainshark/javascript](https://github.com/brainshark/javascript) + - **CaseNine**: [CaseNine/javascript](https://github.com/CaseNine/javascript) - **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 2c390ecea94772a61ce616b9ece45695f0216d68 Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Sun, 5 Feb 2017 14:00:41 -0800 Subject: [PATCH 088/702] [eslint config] [breaking] update eslint-plugin-jsx-a11y to v4, enable new rules --- packages/eslint-config-airbnb/package.json | 2 +- .../eslint-config-airbnb/rules/react-a11y.js | 28 ++++++++++++++++++- 2 files changed, 28 insertions(+), 2 deletions(-) diff --git a/packages/eslint-config-airbnb/package.json b/packages/eslint-config-airbnb/package.json index 18924cdebd..2ef0d65c51 100644 --- a/packages/eslint-config-airbnb/package.json +++ b/packages/eslint-config-airbnb/package.json @@ -64,7 +64,7 @@ }, "peerDependencies": { "eslint": "^3.15.0", - "eslint-plugin-jsx-a11y": "^3.0.2 || ^4.0.0", + "eslint-plugin-jsx-a11y": "^4.0.0", "eslint-plugin-import": "^2.2.0", "eslint-plugin-react": "^6.9.0" }, diff --git a/packages/eslint-config-airbnb/rules/react-a11y.js b/packages/eslint-config-airbnb/rules/react-a11y.js index 8418cecf63..a5443645de 100644 --- a/packages/eslint-config-airbnb/rules/react-a11y.js +++ b/packages/eslint-config-airbnb/rules/react-a11y.js @@ -13,7 +13,7 @@ module.exports = { // Require ARIA roles to be valid and non-abstract // https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/aria-role.md - 'jsx-a11y/aria-role': 'error', + 'jsx-a11y/aria-role': ['error', { ignoreNonDom: false }], // Enforce all aria-* props are valid. // https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/aria-props.md @@ -92,6 +92,12 @@ module.exports = { // https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/lang.md 'jsx-a11y/lang': 'error', + // prevent distracting elements, like and + // https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/no-distracting-elements.md + 'jsx-a11y/no-distracting-elements': ['error', { + elements: ['marquee', 'blink'], + }], + // only allow to have the "scope" attr // https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/scope.md 'jsx-a11y/scope': 'error', @@ -104,5 +110,25 @@ module.exports = { // Enforce that DOM elements without semantic behavior not have interaction handlers // https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/no-static-element-interactions.md 'jsx-a11y/no-static-element-interactions': 'error', + + // ensure emoji are accessible + // https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/accessible-emoji.md + 'jsx-a11y/accessible-emoji': 'error', + + // elements with aria-activedescendant must be tabbable + // https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/aria-activedescendant-has-tabindex.md + 'jsx-a11y/aria-activedescendant-has-tabindex': 'error', + + // ensure iframe elements have a unique title + // https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/iframe-has-title.md + 'jsx-a11y/iframe-has-title': 'error', + + // prohibit autoFocus prop + // https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/no-autofocus.md + 'jsx-a11y/no-autofocus': 'error', + + // ensure HTML elements do not specify redundant ARIA roles + // https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/no-redundant-roles.md + 'jsx-a11y/no-redundant-roles': 'error', }, }; From ec42fbecbfb1149c5b5e936f4144bdffa0b6fee0 Mon Sep 17 00:00:00 2001 From: nprescott Date: Sun, 22 Jan 2017 11:11:08 -0500 Subject: [PATCH 089/702] [guide] README update for JSCS deprecated links --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index f41cf2b4de..ea04f360a4 100644 --- a/README.md +++ b/README.md @@ -3098,7 +3098,7 @@ Other Style Guides - Code Style Linters + [ESlint](http://eslint.org/) - [Airbnb Style .eslintrc](https://github.com/airbnb/javascript/blob/master/linters/.eslintrc) + [JSHint](http://jshint.com/) - [Airbnb Style .jshintrc](https://github.com/airbnb/javascript/blob/master/linters/.jshintrc) - + [JSCS](https://github.com/jscs-dev/node-jscs) - [Airbnb Style Preset](https://github.com/jscs-dev/node-jscs/blob/master/presets/airbnb.json) + + [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)) **Other Style Guides** From c29e615be497767264b09fa826229f71fd015c38 Mon Sep 17 00:00:00 2001 From: Sota Yamashita Date: Sun, 12 Feb 2017 12:13:35 +0900 Subject: [PATCH 090/702] [inthewild] remove deleted repositories --- README.md | 4 ---- 1 file changed, 4 deletions(-) diff --git a/README.md b/README.md index ea04f360a4..686ca5d461 100644 --- a/README.md +++ b/README.md @@ -3177,7 +3177,6 @@ Other Style Guides - **BashPros**: [BashPros/javascript](https://github.com/BashPros/javascript) - **Billabong**: [billabong/javascript](https://github.com/billabong/javascript) - **Bisk**: [bisk/javascript](https://github.com/Bisk/javascript/) - - **Blendle**: [blendle/javascript](https://github.com/blendle/javascript) - **Bonhomme**: [bonhommeparis/javascript](https://github.com/bonhommeparis/javascript) - **Brainshark**: [brainshark/javascript](https://github.com/brainshark/javascript) - **CaseNine**: [CaseNine/javascript](https://github.com/CaseNine/javascript) @@ -3202,8 +3201,6 @@ Other Style Guides - **Huballin**: [huballin/javascript](https://github.com/huballin/javascript) - **HubSpot**: [HubSpot/javascript](https://github.com/HubSpot/javascript) - **Hyper**: [hyperoslo/javascript-playbook](https://github.com/hyperoslo/javascript-playbook/blob/master/style.md) - - **InfoJobs**: [InfoJobs/JavaScript-Style-Guide](https://github.com/InfoJobs/JavaScript-Style-Guide) - - **Intent Media**: [intentmedia/javascript](https://github.com/intentmedia/javascript) - **Jam3**: [Jam3/Javascript-Code-Conventions](https://github.com/Jam3/Javascript-Code-Conventions) - **JeopardyBot**: [kesne/jeopardy-bot](https://github.com/kesne/jeopardy-bot/blob/master/STYLEGUIDE.md) - **JSSolutions**: [JSSolutions/javascript](https://github.com/JSSolutions/javascript) @@ -3218,7 +3215,6 @@ Other Style Guides - **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) - - **National Park Service**: [nationalparkservice/javascript](https://github.com/nationalparkservice/javascript) - **Nimbl3**: [nimbl3/javascript](https://github.com/nimbl3/javascript) - **Nulogy**: [nulogy/javascript](https://github.com/nulogy/javascript) - **Orion Health**: [orionhealth/javascript](https://github.com/orionhealth/javascript) From 8cab89e792e2fc457ab177cdf2d97e767e03ecb6 Mon Sep 17 00:00:00 2001 From: Josh Duck Date: Tue, 14 Feb 2017 10:44:25 +1000 Subject: [PATCH 091/702] Add note to explain what a soft tab is A quick Google search shows that the name "soft tab" causes some confusion. Added a brief clarification. --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 686ca5d461..6e6c2d8eaa 100644 --- a/README.md +++ b/README.md @@ -2068,7 +2068,7 @@ Other Style Guides ## Whitespace - - [18.1](#whitespace--spaces) Use soft tabs set to 2 spaces. eslint: [`indent`](http://eslint.org/docs/rules/indent.html) jscs: [`validateIndentation`](http://jscs.info/rule/validateIndentation) + - [18.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) ```javascript // bad From 1841d2fb99287f01c2ed98f1ca6c6350b509ad11 Mon Sep 17 00:00:00 2001 From: Joe Lencioni Date: Tue, 14 Feb 2017 10:31:45 -0800 Subject: [PATCH 092/702] Add guidance around not using mixins Mixins will hopefully be removed from React eventually. In the meantime, we can avoid the damage they cause by not using them. Most of this was borrowed from @gaearon's blog post "Mixins Considered Harmful". https://facebook.github.io/react/blog/2016/07/13/mixins-considered-harmful.html --- react/README.md | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/react/README.md b/react/README.md index 9401b72596..5e481aa992 100644 --- a/react/README.md +++ b/react/README.md @@ -28,7 +28,7 @@ ## Class vs `React.createClass` vs stateless - - If you have internal state and/or refs, prefer `class extends React.Component` over `React.createClass` unless you have a very good reason to use mixins. eslint: [`react/prefer-es6-class`](https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/prefer-es6-class.md) [`react/prefer-stateless-function`](https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/prefer-stateless-function.md) + - If you have internal state and/or refs, prefer `class extends React.Component` over `React.createClass`. eslint: [`react/prefer-es6-class`](https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/prefer-es6-class.md) [`react/prefer-stateless-function`](https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/prefer-stateless-function.md) ```jsx // bad @@ -69,6 +69,12 @@ } ``` +## Mixins + + - [Do not use mixins](https://facebook.github.io/react/blog/2016/07/13/mixins-considered-harmful.html). + + > Why? Mixins introduce implicit dependencies, cause name clashes, and cause snowballing complexity. Most use cases for mixins can be accomplished in better ways via components, higher-order components, or utility modules. + ## Naming - **Extensions**: Use `.jsx` extension for React components. From d23b442799d591468100d19eab1344190e0b11ed Mon Sep 17 00:00:00 2001 From: Joe Lencioni Date: Tue, 14 Feb 2017 10:46:19 -0800 Subject: [PATCH 093/702] Add link to Mixins section in TOC I forgot this when I created the section. --- react/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/react/README.md b/react/README.md index 5e481aa992..c982f53787 100644 --- a/react/README.md +++ b/react/README.md @@ -6,6 +6,7 @@ 1. [Basic Rules](#basic-rules) 1. [Class vs `React.createClass` vs stateless](#class-vs-reactcreateclass-vs-stateless) + 1. [Mixins](#mixins) 1. [Naming](#naming) 1. [Declaration](#declaration) 1. [Alignment](#alignment) From bbbabf32f811dd8989e27cec4fbcc18025d9a515 Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Sun, 19 Feb 2017 16:51:19 -0800 Subject: [PATCH 094/702] [eslint config] [deps] update `eslint-plugin-react` MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - semver-patch: `jsx-max-props-per-line` “when” set to “multiline”, but left off for now. --- packages/eslint-config-airbnb/package.json | 4 ++-- packages/eslint-config-airbnb/rules/react.js | 20 ++++++++++++++++++-- 2 files changed, 20 insertions(+), 4 deletions(-) diff --git a/packages/eslint-config-airbnb/package.json b/packages/eslint-config-airbnb/package.json index 2ef0d65c51..51e0877b7e 100644 --- a/packages/eslint-config-airbnb/package.json +++ b/packages/eslint-config-airbnb/package.json @@ -56,7 +56,7 @@ "eslint-find-rules": "^1.14.3", "eslint-plugin-import": "^2.2.0", "eslint-plugin-jsx-a11y": "^4.0.0", - "eslint-plugin-react": "^6.9.0", + "eslint-plugin-react": "^6.10.0", "in-publish": "^2.0.0", "react": ">= 0.13.0", "safe-publish-latest": "^1.1.1", @@ -66,7 +66,7 @@ "eslint": "^3.15.0", "eslint-plugin-jsx-a11y": "^4.0.0", "eslint-plugin-import": "^2.2.0", - "eslint-plugin-react": "^6.9.0" + "eslint-plugin-react": "^6.10.0" }, "engines": { "node": ">= 4" diff --git a/packages/eslint-config-airbnb/rules/react.js b/packages/eslint-config-airbnb/rules/react.js index ad717eab61..407bf8fc78 100644 --- a/packages/eslint-config-airbnb/rules/react.js +++ b/packages/eslint-config-airbnb/rules/react.js @@ -71,7 +71,8 @@ module.exports = { // Limit maximum of props on a single line in JSX // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-max-props-per-line.md - 'react/jsx-max-props-per-line': ['off', { maximum: 1 }], + // TODO: enable (semver-minor) + 'react/jsx-max-props-per-line': ['off', { maximum: 1, when: 'multiline' }], // Prevent usage of .bind() in JSX props // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-no-bind.md @@ -118,6 +119,7 @@ module.exports = { callbacksLast: false, shorthandFirst: false, shorthandLast: false, + noSortAlphabetically: false, }], // Prevent React to be incorrectly marked as unused @@ -178,7 +180,7 @@ module.exports = { // Prevent missing props validation in a React component definition // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/prop-types.md - 'react/prop-types': ['error', { ignore: [], customValidators: [] }], + 'react/prop-types': ['error', { ignore: [], customValidators: [], skipUndeclared: false }], // Prevent missing React when using JSX // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/react-in-jsx-scope.md @@ -304,6 +306,20 @@ module.exports = { // 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', + + 'react/forbid-elements': ['off', { + forbid: [ + ], + }], + + // 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', + + // Prevent void DOM elements from receiving children + // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/void-dom-elements-no-children.md + // TODO: enable (semver-minor) + 'react/void-dom-elements-no-children': 'off', }, settings: { From 840d021d07e5dcc036e458e78f9a1f7201e20ba9 Mon Sep 17 00:00:00 2001 From: Adam Walsh Date: Wed, 22 Feb 2017 10:08:38 -0800 Subject: [PATCH 095/702] Add Honey to list of users --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 6e6c2d8eaa..57ef0ed0cb 100644 --- a/README.md +++ b/README.md @@ -3197,6 +3197,7 @@ Other Style Guides - **General Electric**: [GeneralElectric/javascript](https://github.com/GeneralElectric/javascript) - **GoodData**: [gooddata/gdc-js-style](https://github.com/gooddata/gdc-js-style) - **Grooveshark**: [grooveshark/javascript](https://github.com/grooveshark/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) - **HubSpot**: [HubSpot/javascript](https://github.com/HubSpot/javascript) From bc21501cc7f5549c3d33fb94682eae9d2ce01c47 Mon Sep 17 00:00:00 2001 From: Steve Mao Date: Thu, 23 Feb 2017 14:13:39 +1100 Subject: [PATCH 096/702] [eslint config] [base] [minor] add `**/*.spec.js` as a test files pattern (see #1131) --- 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 42706a506c..20b282a004 100644 --- a/packages/eslint-config-airbnb-base/rules/imports.js +++ b/packages/eslint-config-airbnb-base/rules/imports.js @@ -76,6 +76,7 @@ module.exports = { 'test.js', // repos with a single test file 'test-*.js', // repos with multiple top-level test files '**/*.test.js', // tests where the extension denotes that it is a test + '**/*.spec.js', // tests where the extension denotes that it is a test '**/webpack.config.js', // webpack config '**/webpack.config.*.js', // webpack config '**/rollup.config.js', // rollup config From b153231867170e28c199d6216d36b6367018aab0 Mon Sep 17 00:00:00 2001 From: Raj Nigam Date: Thu, 23 Feb 2017 11:36:24 -0500 Subject: [PATCH 097/702] Update renamed jsx-wrap-multilines `react/wrap-multilines` has been renamed to `react/jsx-wrap-multilines` --- react/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/react/README.md b/react/README.md index c982f53787..6accbc0445 100644 --- a/react/README.md +++ b/react/README.md @@ -392,7 +392,7 @@ ## Parentheses - - Wrap JSX tags in parentheses when they span more than one line. eslint: [`react/wrap-multilines`](https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/wrap-multilines.md) + - Wrap JSX tags in parentheses when they span more than one line. eslint: [`react/jsx-wrap-multilines`](https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-wrap-multilines.md) ```jsx // bad From 5ca6d46b7caf4a5bc75868cf769da9ce30b02a64 Mon Sep 17 00:00:00 2001 From: Harrison Shoff Date: Sat, 25 Feb 2017 14:12:37 -0800 Subject: [PATCH 098/702] [resources] add link to neutrino preset https://neutrino.js.org/presets/neutrino-preset-airbnb-base/ --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 57ef0ed0cb..e67c51ba61 100644 --- a/README.md +++ b/README.md @@ -3099,6 +3099,7 @@ Other Style Guides + [ESlint](http://eslint.org/) - [Airbnb Style .eslintrc](https://github.com/airbnb/javascript/blob/master/linters/.eslintrc) + [JSHint](http://jshint.com/) - [Airbnb Style .jshintrc](https://github.com/airbnb/javascript/blob/master/linters/.jshintrc) + [JSCS](https://github.com/jscs-dev/node-jscs) - [Airbnb Style Preset](https://github.com/jscs-dev/node-jscs/blob/master/presets/airbnb.json) (Deprecated, please use [ESlint](https://github.com/airbnb/javascript/tree/master/packages/eslint-config-airbnb-base)) + - Neutrino preset - [neutrino-preset-airbnb-base](https://neutrino.js.org/presets/neutrino-preset-airbnb-base/) **Other Style Guides** From 5ad25766fb33736af1c0f150533c11771928c156 Mon Sep 17 00:00:00 2001 From: Tihomir Opacic Date: Wed, 1 Mar 2017 20:31:43 +0100 Subject: [PATCH 099/702] Added OHD to a list of style guide users. --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index e67c51ba61..65f932a201 100644 --- a/README.md +++ b/README.md @@ -3219,6 +3219,7 @@ Other Style Guides - **National Geographic**: [natgeo/javascript](https://github.com/natgeo/javascript) - **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) - **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) From 93e91d3eb94ee24a82c013527b31d5b83f151025 Mon Sep 17 00:00:00 2001 From: Tom Wrenn Date: Fri, 3 Mar 2017 11:36:09 -0800 Subject: [PATCH 100/702] Add AltSchool to the "In The Wild" section of the README --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 65f932a201..6e09c01a23 100644 --- a/README.md +++ b/README.md @@ -3171,6 +3171,7 @@ Other Style Guides - **Aan Zee**: [AanZee/javascript](https://github.com/AanZee/javascript) - **Adult Swim**: [adult-swim/javascript](https://github.com/adult-swim/javascript) - **Airbnb**: [airbnb/javascript](https://github.com/airbnb/javascript) + - **AltSchool**: [AltSchool/javascript](https://github.com/AltSchool/javascript) - **Apartmint**: [apartmint/javascript](https://github.com/apartmint/javascript) - **Ascribe**: [ascribe/javascript](https://github.com/ascribe/javascript) - **Avalara**: [avalara/javascript](https://github.com/avalara/javascript) From c9490c698e50c428b5dbb64775684061ba86082d Mon Sep 17 00:00:00 2001 From: David Cameron Date: Fri, 3 Mar 2017 14:44:34 -0500 Subject: [PATCH 101/702] [guide] Added 'let' to rule defs regarding variables --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 6e09c01a23..15f4b92962 100644 --- a/README.md +++ b/README.md @@ -1450,7 +1450,7 @@ Other Style Guides ## Variables - - [13.1](#variables--const) Always use `const` 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`](http://eslint.org/docs/rules/no-undef) [`prefer-const`](http://eslint.org/docs/rules/prefer-const) ```javascript // bad @@ -1461,7 +1461,7 @@ Other Style Guides ``` - - [13.2](#variables--one-const) Use one `const` 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`](http://eslint.org/docs/rules/one-var.html) jscs: [`disallowMultipleVarDecl`](http://jscs.info/rule/disallowMultipleVarDecl) > Why? It's easier to add new variable declarations this way, and you never have to worry about swapping out a `;` for a `,` or introducing punctuation-only diffs. You can also step through each declaration with the debugger, instead of jumping through all of them at once. From 1a2edb9e9efe3c50ecaa7c4fa3295b24c68cc9c5 Mon Sep 17 00:00:00 2001 From: Ivan Zusko Date: Wed, 4 Jan 2017 10:58:43 +0200 Subject: [PATCH 102/702] Add ukrainian translation --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 15f4b92962..2680c19a4d 100644 --- a/README.md +++ b/README.md @@ -3254,6 +3254,7 @@ Other Style Guides This style guide is also available in other languages: + - ![ua](https://raw.githubusercontent.com/gosquared/flags/master/flags/flags/shiny/24/Ukraine.png) **Ukrainian**: [ivanzusko/javascript](https://github.com/ivanzusko/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) From 1f5999b2ed832bdf341b15a7a0a564e6c2684a0d Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Fri, 3 Mar 2017 13:33:24 -0800 Subject: [PATCH 103/702] [eslint config] [base] [deps] update `eslint` - fill out options in `no-use-before-define` - enable `ignoreRestSiblings` in `no-unused-vars` --- packages/eslint-config-airbnb-base/package.json | 4 ++-- packages/eslint-config-airbnb-base/rules/variables.js | 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 63efb3588d..ccab07d9b2 100644 --- a/packages/eslint-config-airbnb-base/package.json +++ b/packages/eslint-config-airbnb-base/package.json @@ -49,7 +49,7 @@ "babel-preset-airbnb": "^2.2.3", "babel-tape-runner": "^2.0.1", "editorconfig-tools": "^0.1.1", - "eslint": "^3.15.0", + "eslint": "^3.16.1", "eslint-find-rules": "^1.14.3", "eslint-plugin-import": "^2.2.0", "in-publish": "^2.0.0", @@ -57,7 +57,7 @@ "tape": "^4.6.3" }, "peerDependencies": { - "eslint": "^3.15.0", + "eslint": "^3.16.1", "eslint-plugin-import": "^2.2.0" }, "engines": { diff --git a/packages/eslint-config-airbnb-base/rules/variables.js b/packages/eslint-config-airbnb-base/rules/variables.js index 8af041c082..1eb7528aa8 100644 --- a/packages/eslint-config-airbnb-base/rules/variables.js +++ b/packages/eslint-config-airbnb-base/rules/variables.js @@ -34,9 +34,9 @@ module.exports = { 'no-undefined': 'off', // disallow declaration of variables that are not used in the code - 'no-unused-vars': ['error', { vars: 'local', args: 'after-used' }], + 'no-unused-vars': ['error', { vars: 'local', args: 'after-used', ignoreRestSiblings: true }], // disallow use of variables before they are defined - 'no-use-before-define': 'error' + 'no-use-before-define': ['error', { functions: true, classes: true, variables: true }], } }; From be0315eda1f0cbda7c4b5b1ad65fa9456f51ef8b Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Fri, 3 Mar 2017 13:35:36 -0800 Subject: [PATCH 104/702] [eslint config] [base] v11.1.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 b14a4d6b26..841ee45ce7 100644 --- a/packages/eslint-config-airbnb-base/CHANGELOG.md +++ b/packages/eslint-config-airbnb-base/CHANGELOG.md @@ -1,3 +1,8 @@ +11.1.1 / 2017-03-03 +================== + - [deps] update `eslint` + - [patch] enable `ignoreRestSiblings` in `no-unused-vars` + 11.1.0 / 2017-01-08 ================== - [minor] enable `no-multi-assign` diff --git a/packages/eslint-config-airbnb-base/package.json b/packages/eslint-config-airbnb-base/package.json index ccab07d9b2..959c88a568 100644 --- a/packages/eslint-config-airbnb-base/package.json +++ b/packages/eslint-config-airbnb-base/package.json @@ -1,6 +1,6 @@ { "name": "eslint-config-airbnb-base", - "version": "11.1.0", + "version": "11.1.1", "description": "Airbnb's base JS ESLint config, following our styleguide", "main": "index.js", "scripts": { From f9aff60f5327134f23655df24f74918083485a67 Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Fri, 3 Mar 2017 14:14:46 -0800 Subject: [PATCH 105/702] [eslint config] [deps] update `eslint`, `eslint-config-airbnb-base` --- packages/eslint-config-airbnb/package.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/eslint-config-airbnb/package.json b/packages/eslint-config-airbnb/package.json index 51e0877b7e..e279e45186 100644 --- a/packages/eslint-config-airbnb/package.json +++ b/packages/eslint-config-airbnb/package.json @@ -46,13 +46,13 @@ }, "homepage": "https://github.com/airbnb/javascript", "dependencies": { - "eslint-config-airbnb-base": "^11.1.0" + "eslint-config-airbnb-base": "^11.1.1" }, "devDependencies": { "babel-preset-airbnb": "^2.2.3", "babel-tape-runner": "^2.0.1", "editorconfig-tools": "^0.1.1", - "eslint": "^3.15.0", + "eslint": "^3.16.1", "eslint-find-rules": "^1.14.3", "eslint-plugin-import": "^2.2.0", "eslint-plugin-jsx-a11y": "^4.0.0", @@ -63,7 +63,7 @@ "tape": "^4.6.3" }, "peerDependencies": { - "eslint": "^3.15.0", + "eslint": "^3.16.1", "eslint-plugin-jsx-a11y": "^4.0.0", "eslint-plugin-import": "^2.2.0", "eslint-plugin-react": "^6.10.0" From 772bbb5b7d2f6990e519c3d70539f807257492fe Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Fri, 3 Mar 2017 15:08:41 -0800 Subject: [PATCH 106/702] [eslint config] [base] [deps] update `eslint` --- packages/eslint-config-airbnb-base/package.json | 4 ++-- packages/eslint-config-airbnb-base/rules/errors.js | 5 +++++ packages/eslint-config-airbnb-base/rules/style.js | 4 ++++ 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/packages/eslint-config-airbnb-base/package.json b/packages/eslint-config-airbnb-base/package.json index 959c88a568..4efe9b9365 100644 --- a/packages/eslint-config-airbnb-base/package.json +++ b/packages/eslint-config-airbnb-base/package.json @@ -49,7 +49,7 @@ "babel-preset-airbnb": "^2.2.3", "babel-tape-runner": "^2.0.1", "editorconfig-tools": "^0.1.1", - "eslint": "^3.16.1", + "eslint": "^3.17.0", "eslint-find-rules": "^1.14.3", "eslint-plugin-import": "^2.2.0", "in-publish": "^2.0.0", @@ -57,7 +57,7 @@ "tape": "^4.6.3" }, "peerDependencies": { - "eslint": "^3.16.1", + "eslint": "^3.17.0", "eslint-plugin-import": "^2.2.0" }, "engines": { diff --git a/packages/eslint-config-airbnb-base/rules/errors.js b/packages/eslint-config-airbnb-base/rules/errors.js index bade2a1cec..8f618e0661 100644 --- a/packages/eslint-config-airbnb-base/rules/errors.js +++ b/packages/eslint-config-airbnb-base/rules/errors.js @@ -13,6 +13,11 @@ module.exports = { // http://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 + // TODO: enable (semver-major) + 'no-compare-neg-zero': 'off', + // disallow assignment in conditional expressions 'no-cond-assign': ['error', 'always'], diff --git a/packages/eslint-config-airbnb-base/rules/style.js b/packages/eslint-config-airbnb-base/rules/style.js index 1d315bc51a..610caa218a 100644 --- a/packages/eslint-config-airbnb-base/rules/style.js +++ b/packages/eslint-config-airbnb-base/rules/style.js @@ -286,6 +286,10 @@ module.exports = { // http://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 + 'nonblock-statement-body-position': 'off', + // require padding inside curly braces 'object-curly-spacing': ['error', 'always'], From 34752644c395ff1d23dd8ce1a3bd040bf65e2b1f Mon Sep 17 00:00:00 2001 From: Christian Bundy Date: Wed, 15 Mar 2017 14:27:08 +0000 Subject: [PATCH 107/702] [eslint config] [base] Add ignorePropertyModificationsFor --- .../rules/best-practices.js | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 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 2587bc55e9..a3a9e1eaa6 100644 --- a/packages/eslint-config-airbnb-base/rules/best-practices.js +++ b/packages/eslint-config-airbnb-base/rules/best-practices.js @@ -164,9 +164,21 @@ module.exports = { 'no-octal-escape': 'error', // disallow reassignment of function parameters - // disallow parameter object manipulation + // disallow parameter object manipulation except for specific exclusions // rule: http://eslint.org/docs/rules/no-param-reassign.html - 'no-param-reassign': ['error', { props: true }], + 'no-param-reassign': ['error', { + props: true, + ignorePropertyModificationsFor: [ + 'acc', // for reduce accumulators + 'e', // for e.returnvalue + 'ctx', // for Koa routing + 'req', // for Express requests + 'request', // for Express requests + 'res', // for Express responses + 'response', // for Express responses + '$scope', // for Angular 1 scopes + ] + }], // disallow usage of __proto__ property 'no-proto': 'error', From 321fb271bd6ca826040ef59690396132bde714ce Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Wed, 15 Mar 2017 18:03:56 -0700 Subject: [PATCH 108/702] [eslint config] [*] [deps] update `eslint` --- 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 4efe9b9365..1182a06dd3 100644 --- a/packages/eslint-config-airbnb-base/package.json +++ b/packages/eslint-config-airbnb-base/package.json @@ -49,7 +49,7 @@ "babel-preset-airbnb": "^2.2.3", "babel-tape-runner": "^2.0.1", "editorconfig-tools": "^0.1.1", - "eslint": "^3.17.0", + "eslint": "^3.17.1", "eslint-find-rules": "^1.14.3", "eslint-plugin-import": "^2.2.0", "in-publish": "^2.0.0", @@ -57,7 +57,7 @@ "tape": "^4.6.3" }, "peerDependencies": { - "eslint": "^3.17.0", + "eslint": "^3.17.1", "eslint-plugin-import": "^2.2.0" }, "engines": { diff --git a/packages/eslint-config-airbnb/package.json b/packages/eslint-config-airbnb/package.json index e279e45186..1e80289881 100644 --- a/packages/eslint-config-airbnb/package.json +++ b/packages/eslint-config-airbnb/package.json @@ -52,7 +52,7 @@ "babel-preset-airbnb": "^2.2.3", "babel-tape-runner": "^2.0.1", "editorconfig-tools": "^0.1.1", - "eslint": "^3.16.1", + "eslint": "^3.17.1", "eslint-find-rules": "^1.14.3", "eslint-plugin-import": "^2.2.0", "eslint-plugin-jsx-a11y": "^4.0.0", @@ -63,7 +63,7 @@ "tape": "^4.6.3" }, "peerDependencies": { - "eslint": "^3.16.1", + "eslint": "^3.17.1", "eslint-plugin-jsx-a11y": "^4.0.0", "eslint-plugin-import": "^2.2.0", "eslint-plugin-react": "^6.10.0" From 5797f545d8c0840feadc6d1464120d8eb5f47c38 Mon Sep 17 00:00:00 2001 From: JPeer264 Date: Thu, 16 Mar 2017 09:05:59 +0100 Subject: [PATCH 109/702] [guide] Add array-bracket-newline (close #1338) --- README.md | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/README.md b/README.md index 2680c19a4d..48afd4b0e3 100644 --- a/README.md +++ b/README.md @@ -417,6 +417,45 @@ Other Style Guides **[⬆ back to top](#table-of-contents)** + + - [4.6](#arrays--bracket-newline) Use line breaks after open and before close array brackets if an array has multiple lines + + ```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 = [ + { + id: 1, + }, + { + id: 2, + }, + ]; + + const numberInArray = [ + 1, + 2, + ]; + ``` + +**[⬆ back to top](#table-of-contents)** + ## Destructuring From 13dc420a9eb5447330bcee75f615f280bc20bf3e Mon Sep 17 00:00:00 2001 From: Hugo Date: Tue, 21 Mar 2017 12:46:21 +1100 Subject: [PATCH 110/702] Fix Gitter badge in README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 48afd4b0e3..5d9a9073d1 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,7 @@ [![Downloads](https://img.shields.io/npm/dm/eslint-config-airbnb.svg)](https://www.npmjs.com/package/eslint-config-airbnb) [![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 Chat.svg)](https://gitter.im/airbnb/javascript?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge) +[![Gitter](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/airbnb/javascript?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge) Other Style Guides - [ES5 (Deprecated)](https://github.com/airbnb/javascript/tree/es5-deprecated/es5) From 98f1b19d9524cdf8b8e4de52cedfa6ec98c094dd Mon Sep 17 00:00:00 2001 From: Jaden Dessureault Date: Wed, 22 Mar 2017 19:55:14 -0500 Subject: [PATCH 111/702] Indent blockquotes in markdown guides This is required to make sure all code blocks have proper syntax highlighting --- css-in-javascript/README.md | 18 +++++++++--------- react/README.md | 12 ++++++------ 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/css-in-javascript/README.md b/css-in-javascript/README.md index 59c1c7bcbd..9c53bc3e0e 100644 --- a/css-in-javascript/README.md +++ b/css-in-javascript/README.md @@ -14,7 +14,7 @@ - Use camelCase for object keys (i.e. "selectors"). - > Why? We access these keys as properties on the `styles` object in the component, so it is most convenient to use camelCase. + > Why? We access these keys as properties on the `styles` object in the component, so it is most convenient to use camelCase. ```js // bad @@ -34,7 +34,7 @@ - Use an underscore for modifiers to other styles. - > Why? Similar to BEM, this naming convention makes it clear that the styles are intended to modify the element preceded by the underscore. Underscores do not need to be quoted, so they are preferred over other characters, such as dashes. + > Why? Similar to BEM, this naming convention makes it clear that the styles are intended to modify the element preceded by the underscore. Underscores do not need to be quoted, so they are preferred over other characters, such as dashes. ```js // bad @@ -64,7 +64,7 @@ - Use `selectorName_fallback` for sets of fallback styles. - > Why? Similar to modifiers, keeping the naming consistent helps reveal the relationship of these styles to the styles that override them in more adequate browsers. + > Why? Similar to modifiers, keeping the naming consistent helps reveal the relationship of these styles to the styles that override them in more adequate browsers. ```js // bad @@ -92,7 +92,7 @@ - Use a separate selector for sets of fallback styles. - > Why? Keeping fallback styles contained in a separate object clarifies their purpose, which improves readability. + > Why? Keeping fallback styles contained in a separate object clarifies their purpose, which improves readability. ```js // bad @@ -133,7 +133,7 @@ - Use device-agnostic names (e.g. "small", "medium", and "large") to name media query breakpoints. - > Why? Commonly used names like "phone", "tablet", and "desktop" do not match the characteristics of the devices in the real world. Using these names sets the wrong expectations. + > Why? Commonly used names like "phone", "tablet", and "desktop" do not match the characteristics of the devices in the real world. Using these names sets the wrong expectations. ```js // bad @@ -155,7 +155,7 @@ - Define styles after the component. - > Why? We use a higher-order component to theme our styles, which is naturally used after the component definition. Passing the styles object directly to this function reduces indirection. + > Why? We use a higher-order component to theme our styles, which is naturally used after the component definition. Passing the styles object directly to this function reduces indirection. ```jsx // bad @@ -198,7 +198,7 @@ - Leave a blank line between adjacent blocks at the same indentation level. - > Why? The whitespace improves readability and reduces the likelihood of merge conflicts. + > Why? The whitespace improves readability and reduces the likelihood of merge conflicts. ```js // bad @@ -234,7 +234,7 @@ - Use inline styles for styles that have a high cardinality (e.g. uses the value of a prop) and not for styles that have a low cardinality. - > Why? Generating themed stylesheets can be expensive, so they are best for discrete sets of styles. + > Why? Generating themed stylesheets can be expensive, so they are best for discrete sets of styles. ```jsx // bad @@ -373,7 +373,7 @@ - Define tricky fallback properties in themes. - > Why? Many CSS-in-JavaScript implementations merge style objects together which makes specifying fallbacks for the same property (e.g. `display`) a little tricky. To keep the approach unified, put these fallbacks in the theme. + > Why? Many CSS-in-JavaScript implementations merge style objects together which makes specifying fallbacks for the same property (e.g. `display`) a little tricky. To keep the approach unified, put these fallbacks in the theme. ```js // bad diff --git a/react/README.md b/react/README.md index 6accbc0445..1af002d8cc 100644 --- a/react/README.md +++ b/react/README.md @@ -110,7 +110,7 @@ ``` - **Higher-order Component Naming**: Use a composite of the higher-order component's name and the passed-in component's name as the `displayName` on the generated component. For example, the higher-order component `withFoo()`, when passed a component `Bar` should produce a component with a `displayName` of `withFoo(Bar)`. - > Why? A component's `displayName` may be used by developer tools or in error messages, and having a value that clearly expresses this relationship helps people understand what is happening. + > Why? A component's `displayName` may be used by developer tools or in error messages, and having a value that clearly expresses this relationship helps people understand what is happening. ```jsx // bad @@ -137,7 +137,7 @@ - **Props Naming**: Avoid using DOM component prop names for different purposes. - > Why? People expect props like `style` and `className` to mean one specific thing. Varying this API for a subset of your app makes the code less readable and less maintainable, and may cause bugs. + > Why? People expect props like `style` and `className` to mean one specific thing. Varying this API for a subset of your app makes the code less readable and less maintainable, and may cause bugs. ```jsx // bad @@ -194,7 +194,7 @@ - Always use double quotes (`"`) for JSX attributes, but single quotes (`'`) for all other JS. eslint: [`jsx-quotes`](http://eslint.org/docs/rules/jsx-quotes) - > Why? Regular HTML attributes also typically use double quotes instead of single, so JSX attributes mirror this convention. + > Why? Regular HTML attributes also typically use double quotes instead of single, so JSX attributes mirror this convention. ```jsx // bad @@ -289,7 +289,7 @@ - Do not use words like "image", "photo", or "picture" in `` `alt` props. eslint: [`jsx-a11y/img-redundant-alt`](https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/img-redundant-alt.md) - > Why? Screenreaders already announce `img` elements as images, so there is no need to include this information in the alt text. + > Why? Screenreaders already announce `img` elements as images, so there is no need to include this information in the alt text. ```jsx // bad @@ -466,7 +466,7 @@ - Bind event handlers for the render method in the constructor. eslint: [`react/jsx-no-bind`](https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-no-bind.md) - > Why? A bind call in the render path creates a brand new function on every single render. + > Why? A bind call in the render path creates a brand new function on every single render. ```jsx // bad @@ -499,7 +499,7 @@ ``` - Do not use underscore prefix for internal methods of a React component. - > Why? Underscore prefixes are sometimes used as a convention in other languages to denote privacy. But, unlike those languages, there is no native support for privacy in JavaScript, everything is public. Regardless of your intentions, adding underscore prefixes to your properties does not actually make them private, and any property (underscore-prefixed or not) should be treated as being public. See issues [#1024](https://github.com/airbnb/javascript/issues/1024), and [#490](https://github.com/airbnb/javascript/issues/490) for a more in-depth discussion. + > Why? Underscore prefixes are sometimes used as a convention in other languages to denote privacy. But, unlike those languages, there is no native support for privacy in JavaScript, everything is public. Regardless of your intentions, adding underscore prefixes to your properties does not actually make them private, and any property (underscore-prefixed or not) should be treated as being public. See issues [#1024](https://github.com/airbnb/javascript/issues/1024), and [#490](https://github.com/airbnb/javascript/issues/490) for a more in-depth discussion. ```jsx // bad From ae1c919cd4e8e13d5728a2beb3b38bff36eea0cd Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Sat, 25 Mar 2017 18:40:06 -0700 Subject: [PATCH 112/702] [eslint config] [base] [deps] update `eslint` --- packages/eslint-config-airbnb-base/package.json | 4 ++-- packages/eslint-config-airbnb-base/rules/best-practices.js | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/packages/eslint-config-airbnb-base/package.json b/packages/eslint-config-airbnb-base/package.json index 1182a06dd3..38be15baa4 100644 --- a/packages/eslint-config-airbnb-base/package.json +++ b/packages/eslint-config-airbnb-base/package.json @@ -49,7 +49,7 @@ "babel-preset-airbnb": "^2.2.3", "babel-tape-runner": "^2.0.1", "editorconfig-tools": "^0.1.1", - "eslint": "^3.17.1", + "eslint": "^3.18.0", "eslint-find-rules": "^1.14.3", "eslint-plugin-import": "^2.2.0", "in-publish": "^2.0.0", @@ -57,7 +57,7 @@ "tape": "^4.6.3" }, "peerDependencies": { - "eslint": "^3.17.1", + "eslint": "^3.18.0", "eslint-plugin-import": "^2.2.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 a3a9e1eaa6..c9f729c75f 100644 --- a/packages/eslint-config-airbnb-base/rules/best-practices.js +++ b/packages/eslint-config-airbnb-base/rules/best-practices.js @@ -234,6 +234,7 @@ module.exports = { 'no-unused-expressions': ['error', { allowShortCircuit: false, allowTernary: false, + allowTaggedTemplates: false, }], // disallow unused labels From 75d48c7570b2c5336c75c454ce91991a34d0554e Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Sat, 25 Mar 2017 18:43:29 -0700 Subject: [PATCH 113/702] [eslint config] [base] v11.1.2 --- 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 841ee45ce7..83a1763796 100644 --- a/packages/eslint-config-airbnb-base/CHANGELOG.md +++ b/packages/eslint-config-airbnb-base/CHANGELOG.md @@ -1,3 +1,8 @@ +11.1.2 / 2017-03-25 +================== + - [patch] `no-param-reassign`: add ignorePropertyModificationsFor (#1325) + - [deps] update `eslint` + 11.1.1 / 2017-03-03 ================== - [deps] update `eslint` diff --git a/packages/eslint-config-airbnb-base/package.json b/packages/eslint-config-airbnb-base/package.json index 38be15baa4..e4f92cb6b0 100644 --- a/packages/eslint-config-airbnb-base/package.json +++ b/packages/eslint-config-airbnb-base/package.json @@ -1,6 +1,6 @@ { "name": "eslint-config-airbnb-base", - "version": "11.1.1", + "version": "11.1.2", "description": "Airbnb's base JS ESLint config, following our styleguide", "main": "index.js", "scripts": { From b8d8d6e56f0c1d817af002da0f81b57f45ba24db Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Sat, 25 Mar 2017 21:32:09 -0700 Subject: [PATCH 114/702] [eslint config] [deps] update `eslint-config-airbnb-base`, `eslint`, `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 1e80289881..c1a5d90df6 100644 --- a/packages/eslint-config-airbnb/package.json +++ b/packages/eslint-config-airbnb/package.json @@ -46,27 +46,27 @@ }, "homepage": "https://github.com/airbnb/javascript", "dependencies": { - "eslint-config-airbnb-base": "^11.1.1" + "eslint-config-airbnb-base": "^11.1.2" }, "devDependencies": { "babel-preset-airbnb": "^2.2.3", "babel-tape-runner": "^2.0.1", "editorconfig-tools": "^0.1.1", - "eslint": "^3.17.1", + "eslint": "^3.18.0", "eslint-find-rules": "^1.14.3", "eslint-plugin-import": "^2.2.0", "eslint-plugin-jsx-a11y": "^4.0.0", - "eslint-plugin-react": "^6.10.0", + "eslint-plugin-react": "^6.10.3", "in-publish": "^2.0.0", "react": ">= 0.13.0", "safe-publish-latest": "^1.1.1", "tape": "^4.6.3" }, "peerDependencies": { - "eslint": "^3.17.1", + "eslint": "^3.18.0", "eslint-plugin-jsx-a11y": "^4.0.0", "eslint-plugin-import": "^2.2.0", - "eslint-plugin-react": "^6.10.0" + "eslint-plugin-react": "^6.10.3" }, "engines": { "node": ">= 4" From aa9bbf9f49f9eb2dfca152b25200e0893a9dbedb Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Mon, 3 Apr 2017 15:22:34 -0700 Subject: [PATCH 115/702] [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 e4f92cb6b0..14e9063b54 100644 --- a/packages/eslint-config-airbnb-base/package.json +++ b/packages/eslint-config-airbnb-base/package.json @@ -49,7 +49,7 @@ "babel-preset-airbnb": "^2.2.3", "babel-tape-runner": "^2.0.1", "editorconfig-tools": "^0.1.1", - "eslint": "^3.18.0", + "eslint": "^3.19.0", "eslint-find-rules": "^1.14.3", "eslint-plugin-import": "^2.2.0", "in-publish": "^2.0.0", @@ -57,7 +57,7 @@ "tape": "^4.6.3" }, "peerDependencies": { - "eslint": "^3.18.0", + "eslint": "^3.19.0", "eslint-plugin-import": "^2.2.0" }, "engines": { From 74071a809c22fa1104fe5d86bcd1eda949e1d0d9 Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Mon, 3 Apr 2017 15:23:00 -0700 Subject: [PATCH 116/702] [eslint config] [base] [patch] add error messages to `no-restricted-syntax` Fixes #1353. --- .../eslint-config-airbnb-base/rules/style.js | 20 +++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/packages/eslint-config-airbnb-base/rules/style.js b/packages/eslint-config-airbnb-base/rules/style.js index 610caa218a..237f16899d 100644 --- a/packages/eslint-config-airbnb-base/rules/style.js +++ b/packages/eslint-config-airbnb-base/rules/style.js @@ -256,10 +256,22 @@ module.exports = { // http://eslint.org/docs/rules/no-restricted-syntax 'no-restricted-syntax': [ 'error', - 'ForInStatement', - 'ForOfStatement', - 'LabeledStatement', - 'WithStatement', + { + selector: 'ForInStatement', + message: 'for..in loops iterate over the entire prototype chain, which is virtually never what you want. Use Object.{keys,values,entries}, and iterate over the resulting array.', + }, + { + selector: 'ForOfStatement', + message: 'iterators/generators require regenerator-runtime, which is too heavyweight for this guide to allow them. Separately, loops should be avoided in favor of array iterations.', + }, + { + selector: 'LabeledStatement', + message: 'Labels are a form of GOTO; using them makes code confusing and hard to maintain and understand.', + }, + { + selector: 'WithStatement', + message: '`with` is disallowed in strict mode because it makes code impossible to predict and optimize.', + }, ], // disallow space between function identifier and application From e43bdd98d52c3b248aef932645e4a431e598544d Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Mon, 3 Apr 2017 15:44:14 -0700 Subject: [PATCH 117/702] [eslint config] [base] v11.1.3 --- 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 83a1763796..8559e2277c 100644 --- a/packages/eslint-config-airbnb-base/CHANGELOG.md +++ b/packages/eslint-config-airbnb-base/CHANGELOG.md @@ -1,3 +1,8 @@ +11.1.3 / 2017-04-03 +================== + - [patch] add error messages to `no-restricted-syntax` (#1353) + - [deps] update `eslint` + 11.1.2 / 2017-03-25 ================== - [patch] `no-param-reassign`: add ignorePropertyModificationsFor (#1325) diff --git a/packages/eslint-config-airbnb-base/package.json b/packages/eslint-config-airbnb-base/package.json index 14e9063b54..d4f8951317 100644 --- a/packages/eslint-config-airbnb-base/package.json +++ b/packages/eslint-config-airbnb-base/package.json @@ -1,6 +1,6 @@ { "name": "eslint-config-airbnb-base", - "version": "11.1.2", + "version": "11.1.3", "description": "Airbnb's base JS ESLint config, following our styleguide", "main": "index.js", "scripts": { From fa0a82373eb46ff8e99ccc43ba80c2c18c319e01 Mon Sep 17 00:00:00 2001 From: Max Kaplan Date: Tue, 4 Apr 2017 09:52:16 -0400 Subject: [PATCH 118/702] adding sourcetoad to users --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 5d9a9073d1..17c09a3c67 100644 --- a/README.md +++ b/README.md @@ -3270,6 +3270,7 @@ Other Style Guides - **Ripple**: [ripple/javascript-style-guide](https://github.com/ripple/javascript-style-guide) - **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) - **StratoDem Analytics**: [stratodem/javascript](https://github.com/stratodem/javascript) - **SteelKiwi Development**: [steelkiwi/javascript](https://github.com/steelkiwi/javascript) From cb027cd0020e5f792015dbe3eeb25bc2dda2a99d Mon Sep 17 00:00:00 2001 From: Nikita Date: Wed, 12 Apr 2017 02:01:16 +0500 Subject: [PATCH 119/702] translation links sorted --- README.md | 2 +- react/README.md | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 17c09a3c67..538086c147 100644 --- a/README.md +++ b/README.md @@ -3294,7 +3294,6 @@ Other Style Guides This style guide is also available in other languages: - - ![ua](https://raw.githubusercontent.com/gosquared/flags/master/flags/flags/shiny/24/Ukraine.png) **Ukrainian**: [ivanzusko/javascript](https://github.com/ivanzusko/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) @@ -3309,6 +3308,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) + - ![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 diff --git a/react/README.md b/react/README.md index 1af002d8cc..9525bfbda1 100644 --- a/react/README.md +++ b/react/README.md @@ -622,11 +622,11 @@ This JSX/React style guide is also available in other languages: - ![cn](https://raw.githubusercontent.com/gosquared/flags/master/flags/flags/shiny/24/China.png) **Chinese (Simplified)**: [JasonBoy/javascript](https://github.com/JasonBoy/javascript/tree/master/react) - - ![pl](https://raw.githubusercontent.com/gosquared/flags/master/flags/flags/shiny/24/Poland.png) **Polish**: [pietraszekl/javascript](https://github.com/pietraszekl/javascript/tree/master/react) + - ![es](https://raw.githubusercontent.com/gosquared/flags/master/flags/flags/shiny/24/Spain.png) **Español**: [agrcrobles/javascript](https://github.com/agrcrobles/javascript/tree/master/react) + - ![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/tree/master/react) - ![kr](https://raw.githubusercontent.com/gosquared/flags/master/flags/flags/shiny/24/South-Korea.png) **Korean**: [apple77y/javascript](https://github.com/apple77y/javascript/tree/master/react) + - ![pl](https://raw.githubusercontent.com/gosquared/flags/master/flags/flags/shiny/24/Poland.png) **Polish**: [pietraszekl/javascript](https://github.com/pietraszekl/javascript/tree/master/react) - ![Br](https://raw.githubusercontent.com/gosquared/flags/master/flags/flags/shiny/24/Brazil.png) **Portuguese**: [ronal2do/javascript](https://github.com/ronal2do/airbnb-react-styleguide) - - ![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/tree/master/react) - - ![es](https://raw.githubusercontent.com/gosquared/flags/master/flags/flags/shiny/24/Spain.png) **Español**: [agrcrobles/javascript](https://github.com/agrcrobles/javascript/tree/master/react) - ![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 462ea7dd0ae82e2ab3f95f2761ccd7ddf210bcb5 Mon Sep 17 00:00:00 2001 From: Nikita Date: Wed, 12 Apr 2017 02:05:40 +0500 Subject: [PATCH 120/702] translation links in react guide updated --- react/README.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/react/README.md b/react/README.md index 9525bfbda1..4f31fc2110 100644 --- a/react/README.md +++ b/react/README.md @@ -622,11 +622,14 @@ This JSX/React style guide is also available in other languages: - ![cn](https://raw.githubusercontent.com/gosquared/flags/master/flags/flags/shiny/24/China.png) **Chinese (Simplified)**: [JasonBoy/javascript](https://github.com/JasonBoy/javascript/tree/master/react) + - ![tw](https://raw.githubusercontent.com/gosquared/flags/master/flags/flags/shiny/24/Taiwan.png) **Chinese (Traditional)**: [jigsawye/javascript](https://github.com/jigsawye/javascript/tree/master/react) - ![es](https://raw.githubusercontent.com/gosquared/flags/master/flags/flags/shiny/24/Spain.png) **Español**: [agrcrobles/javascript](https://github.com/agrcrobles/javascript/tree/master/react) - ![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/tree/master/react) - ![kr](https://raw.githubusercontent.com/gosquared/flags/master/flags/flags/shiny/24/South-Korea.png) **Korean**: [apple77y/javascript](https://github.com/apple77y/javascript/tree/master/react) - ![pl](https://raw.githubusercontent.com/gosquared/flags/master/flags/flags/shiny/24/Poland.png) **Polish**: [pietraszekl/javascript](https://github.com/pietraszekl/javascript/tree/master/react) - ![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) - ![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 2c0da30904d842e80d2b7d0404a65867ba19b6df Mon Sep 17 00:00:00 2001 From: Kaka Date: Wed, 12 Apr 2017 16:43:12 +0800 Subject: [PATCH 121/702] Fix the example of "propTypes" This example makes me confused. I guess it missed the use of "children" of good code. Is the example to explain that you should specify default values for non-required props? Thanks --- react/README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/react/README.md b/react/README.md index 4f31fc2110..ce6bbbd764 100644 --- a/react/README.md +++ b/react/README.md @@ -360,8 +360,8 @@ }; // good - function SFC({ foo, bar }) { - return
{foo}{bar}
; + function SFC({ foo, bar, children }) { + return
{foo}{bar}{children}
; } SFC.propTypes = { foo: PropTypes.number.isRequired, From 71932e1eed314dee508bdd7b3044c8e1e2d3609c Mon Sep 17 00:00:00 2001 From: Thomas Rix Date: Thu, 20 Apr 2017 16:51:02 -0400 Subject: [PATCH 122/702] [eslint config] Turn `ignorePureComponent` option on for react/prefer-stateless-function Otherwise, there is no way to write pure components that don't use state, refs, or lifecycle methods. Stateless functions are not treated internally as pure components, and are rerendered every time. --- packages/eslint-config-airbnb/rules/react.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/eslint-config-airbnb/rules/react.js b/packages/eslint-config-airbnb/rules/react.js index 407bf8fc78..caf62dd81c 100644 --- a/packages/eslint-config-airbnb/rules/react.js +++ b/packages/eslint-config-airbnb/rules/react.js @@ -176,7 +176,7 @@ module.exports = { // Require stateless functions when not using lifecycle methods, setState or ref // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/prefer-stateless-function.md - 'react/prefer-stateless-function': 'error', + 'react/prefer-stateless-function': ['error', { ignorePureComponent: true }], // Prevent missing props validation in a React component definition // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/prop-types.md From 8eee1f1b6927dcc7afe04b1ffbb5283a18017972 Mon Sep 17 00:00:00 2001 From: Martin Veith Date: Sat, 22 Apr 2017 18:16:18 +0200 Subject: [PATCH 123/702] [guide] [react] Add missing semicolons --- react/README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/react/README.md b/react/README.md index ce6bbbd764..65f1aeb68b 100644 --- a/react/README.md +++ b/react/README.md @@ -476,7 +476,7 @@ } render() { - return
+ return
; } } @@ -493,7 +493,7 @@ } render() { - return
+ return
; } } ``` @@ -575,7 +575,7 @@ } render() { - return {this.props.text} + return {this.props.text}; } } From 7abd9a929ca94468d6b5393986b5ca1695e3cf92 Mon Sep 17 00:00:00 2001 From: Nicolas Jakob Date: Mon, 24 Apr 2017 16:24:54 +0200 Subject: [PATCH 124/702] Add rollup.config.*.js to import/no-extraneous-dependencies ignore list --- 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 20b282a004..b081b59b6b 100644 --- a/packages/eslint-config-airbnb-base/rules/imports.js +++ b/packages/eslint-config-airbnb-base/rules/imports.js @@ -80,6 +80,7 @@ module.exports = { '**/webpack.config.js', // webpack config '**/webpack.config.*.js', // webpack config '**/rollup.config.js', // rollup config + '**/rollup.config.*.js', // rollup config '**/gulpfile.js', // gulp config '**/gulpfile.*.js', // gulp config '**/Gruntfile', // grunt config From 88a070cd0df0951b9282cd8f329ad7fc0eed434f Mon Sep 17 00:00:00 2001 From: Jonathan Dubin Date: Tue, 25 Apr 2017 10:37:54 -0700 Subject: [PATCH 125/702] Remove "simply" from Readme --- packages/eslint-config-airbnb/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/eslint-config-airbnb/README.md b/packages/eslint-config-airbnb/README.md index 122eaf2e7f..173e5c324c 100644 --- a/packages/eslint-config-airbnb/README.md +++ b/packages/eslint-config-airbnb/README.md @@ -18,7 +18,7 @@ Our default export contains all of our ESLint rules, including ECMAScript 6+ and npm info "eslint-config-airbnb@latest" peerDependencies ``` - Linux/OSX users can simply run + Linux/OSX users can run ```sh ( From 1997f8ee85f634d3fd02e179daaf6c74875aacbc Mon Sep 17 00:00:00 2001 From: Jonathan Dubin Date: Tue, 25 Apr 2017 10:47:50 -0700 Subject: [PATCH 126/702] Remove "simply" from Readme in base --- packages/eslint-config-airbnb-base/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/eslint-config-airbnb-base/README.md b/packages/eslint-config-airbnb-base/README.md index 4350a5dbd6..e27f3f3431 100644 --- a/packages/eslint-config-airbnb-base/README.md +++ b/packages/eslint-config-airbnb-base/README.md @@ -57,7 +57,7 @@ Lints ES5 and below. Requires `eslint` and `eslint-plugin-import`. npm info "eslint-config-airbnb-base@latest" peerDependencies ``` - Linux/OSX users can simply run + Linux/OSX users can run ```sh ( export PKG=eslint-config-airbnb-base; From 83711e089a5fb8a33f5454a8ddc2f6e29b98137c Mon Sep 17 00:00:00 2001 From: Diego Teliz Date: Thu, 27 Apr 2017 15:03:28 +1200 Subject: [PATCH 127/702] Add 'InterCity Group' on 'In the Wild' list --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 538086c147..19ff63449b 100644 --- a/README.md +++ b/README.md @@ -3243,6 +3243,7 @@ Other Style Guides - **Huballin**: [huballin/javascript](https://github.com/huballin/javascript) - **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) - **Jam3**: [Jam3/Javascript-Code-Conventions](https://github.com/Jam3/Javascript-Code-Conventions) - **JeopardyBot**: [kesne/jeopardy-bot](https://github.com/kesne/jeopardy-bot/blob/master/STYLEGUIDE.md) - **JSSolutions**: [JSSolutions/javascript](https://github.com/JSSolutions/javascript) From 3fe99604e625460d09a7d855bfe843a8c58f4e50 Mon Sep 17 00:00:00 2001 From: Denis Izmaylov Date: Sat, 29 Apr 2017 18:20:56 +0300 Subject: [PATCH 128/702] Add 'Axept' into 'In the Wild' section --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 19ff63449b..e7821f0d4a 100644 --- a/README.md +++ b/README.md @@ -3215,6 +3215,7 @@ Other Style Guides - **Ascribe**: [ascribe/javascript](https://github.com/ascribe/javascript) - **Avalara**: [avalara/javascript](https://github.com/avalara/javascript) - **Avant**: [avantcredit/javascript](https://github.com/avantcredit/javascript) + - **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/) From ee6b23d862bdf5e33934a658d117a157734d11cc Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Sun, 30 Apr 2017 21:19:58 -0700 Subject: [PATCH 129/702] [guide] remove remaining numbered links used as targets. --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index e7821f0d4a..3ab5d2f793 100644 --- a/README.md +++ b/README.md @@ -367,7 +367,7 @@ Other Style Guides ``` - - [4.5](#arrays--callback-return) Use return statements in array method callbacks. It's ok to omit the return if the function body consists of a single statement following [8.2](#8.2). eslint: [`array-callback-return`](http://eslint.org/docs/rules/array-callback-return) + - [4.5](#arrays--callback-return) Use return statements in array method callbacks. It's ok to omit the return if the function body consists of a single statement following [8.2](#arrows--implicit-return). eslint: [`array-callback-return`](http://eslint.org/docs/rules/array-callback-return) ```javascript // good @@ -2569,7 +2569,7 @@ Other Style Guides ## Semicolons - - [20.1](#20.1) **Yup.** eslint: [`semi`](http://eslint.org/docs/rules/semi.html) jscs: [`requireSemicolons`](http://jscs.info/rule/requireSemicolons) + - [20.1](#semicolons--required) **Yup.** eslint: [`semi`](http://eslint.org/docs/rules/semi.html) jscs: [`requireSemicolons`](http://jscs.info/rule/requireSemicolons) ```javascript // bad From 275d4bba983b76b1e9293751b7700380bc7e8696 Mon Sep 17 00:00:00 2001 From: Martin Veith Date: Sat, 29 Apr 2017 21:03:35 +0200 Subject: [PATCH 130/702] Add "Control statements" section --- README.md | 161 +++++++++++++++++++++++++++++++++++++----------------- 1 file changed, 110 insertions(+), 51 deletions(-) diff --git a/README.md b/README.md index 3ab5d2f793..ded9acf2f4 100644 --- a/README.md +++ b/README.md @@ -31,6 +31,7 @@ Other Style Guides 1. [Hoisting](#hoisting) 1. [Comparison Operators & Equality](#comparison-operators--equality) 1. [Blocks](#blocks) + 1. [Control Statements](#control-statements) 1. [Comments](#comments) 1. [Whitespace](#whitespace) 1. [Commas](#commas) @@ -647,7 +648,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`](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). @@ -1963,10 +1964,68 @@ Other Style Guides **[⬆ back to top](#table-of-contents)** +## 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. + + ```javascript + // bad + if ((foo === 123 || bar === 'abc') && doesItLookGoodWhenItBecomesThatLong() && isThisReallyHappening()) { + thing1(); + } + + // bad + if (foo === 123 && + bar === 'abc') { + thing1(); + } + + // bad + if (foo === 123 + && bar === 'abc') { + thing1(); + } + + // good + if ( + (foo === 123 || bar === "abc") && + doesItLookGoodWhenItBecomesThatLong() && + isThisReallyHappening() + ) { + thing1(); + } + + // good + if (foo === 123 && bar === 'abc') { + thing1(); + } + + // good + if ( + foo === 123 && + bar === 'abc' + ) { + thing1(); + } + + // good + if ( + foo === 123 + && bar === 'abc' + ) { + thing1(); + } + ``` + + +**[⬆ back to top](#table-of-contents)** + + ## Comments - - [17.1](#comments--multiline) Use `/** ... */` for multi-line comments. + - [18.1](#comments--multiline) Use `/** ... */` for multi-line comments. ```javascript // bad @@ -1996,7 +2055,7 @@ Other Style Guides ``` - - [17.2](#comments--singleline) Use `//` for single line comments. Place single line comments on a newline above the subject of the comment. Put an empty line before the comment unless it's on the first line of a block. + - [18.2](#comments--singleline) Use `//` for single line comments. Place single line comments on a newline above the subject of the comment. Put an empty line before the comment unless it's on the first line of a block. ```javascript // bad @@ -2034,7 +2093,7 @@ Other Style Guides } ``` - - [17.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`](http://eslint.org/docs/rules/spaced-comment) ```javascript // bad @@ -2071,10 +2130,10 @@ Other Style Guides ``` - - [17.4](#comments--actionitems) Prefixing your comments with `FIXME` or `TODO` helps other developers quickly understand if you're pointing out a problem that needs to be revisited, or if you're suggesting a solution to the problem that needs to be implemented. These are different than regular comments because they are actionable. The actions are `FIXME: -- need to figure this out` or `TODO: -- need to implement`. + - [18.4](#comments--actionitems) Prefixing your comments with `FIXME` or `TODO` helps other developers quickly understand if you're pointing out a problem that needs to be revisited, or if you're suggesting a solution to the problem that needs to be implemented. These are different than regular comments because they are actionable. The actions are `FIXME: -- need to figure this out` or `TODO: -- need to implement`. - - [17.5](#comments--fixme) Use `// FIXME:` to annotate problems. + - [18.5](#comments--fixme) Use `// FIXME:` to annotate problems. ```javascript class Calculator extends Abacus { @@ -2088,7 +2147,7 @@ Other Style Guides ``` - - [17.6](#comments--todo) Use `// TODO:` to annotate solutions to problems. + - [18.6](#comments--todo) Use `// TODO:` to annotate solutions to problems. ```javascript class Calculator extends Abacus { @@ -2107,7 +2166,7 @@ Other Style Guides ## Whitespace - - [18.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`](http://eslint.org/docs/rules/indent.html) jscs: [`validateIndentation`](http://jscs.info/rule/validateIndentation) ```javascript // bad @@ -2127,7 +2186,7 @@ Other Style Guides ``` - - [18.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`](http://eslint.org/docs/rules/space-before-blocks.html) jscs: [`requireSpaceBeforeBlockStatements`](http://jscs.info/rule/requireSpaceBeforeBlockStatements) ```javascript // bad @@ -2154,7 +2213,7 @@ Other Style Guides ``` - - [18.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`](http://eslint.org/docs/rules/keyword-spacing.html) jscs: [`requireSpaceAfterKeywords`](http://jscs.info/rule/requireSpaceAfterKeywords) ```javascript // bad @@ -2179,7 +2238,7 @@ Other Style Guides ``` - - [18.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`](http://eslint.org/docs/rules/space-infix-ops.html) jscs: [`requireSpaceBeforeBinaryOperators`](http://jscs.info/rule/requireSpaceBeforeBinaryOperators), [`requireSpaceAfterBinaryOperators`](http://jscs.info/rule/requireSpaceAfterBinaryOperators) ```javascript // bad @@ -2190,7 +2249,7 @@ Other Style Guides ``` - - [18.5](#whitespace--newline-at-end) End files with a single newline character. eslint: [`eol-last`](https://github.com/eslint/eslint/blob/master/docs/rules/eol-last.md) + - [19.5](#whitespace--newline-at-end) End files with a single newline character. eslint: [`eol-last`](https://github.com/eslint/eslint/blob/master/docs/rules/eol-last.md) ```javascript // bad @@ -2215,7 +2274,7 @@ Other Style Guides ``` - - [18.6](#whitespace--chains) Use indentation when making long method chains (more than 2 method chains). Use a leading dot, which + - [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) ```javascript @@ -2259,7 +2318,7 @@ Other Style Guides ``` - - [18.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. jscs: [`requirePaddingNewLinesAfterBlocks`](http://jscs.info/rule/requirePaddingNewLinesAfterBlocks) ```javascript // bad @@ -2317,7 +2376,7 @@ Other Style Guides ``` - - [18.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`](http://eslint.org/docs/rules/padded-blocks.html) jscs: [`disallowPaddingNewlinesInBlocks`](http://jscs.info/rule/disallowPaddingNewlinesInBlocks) ```javascript // bad @@ -2350,7 +2409,7 @@ Other Style Guides ``` - - [18.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`](http://eslint.org/docs/rules/space-in-parens.html) jscs: [`disallowSpacesInsideParentheses`](http://jscs.info/rule/disallowSpacesInsideParentheses) ```javascript // bad @@ -2375,7 +2434,7 @@ Other Style Guides ``` - - [18.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`](http://eslint.org/docs/rules/array-bracket-spacing.html) jscs: [`disallowSpacesInsideArrayBrackets`](http://jscs.info/rule/disallowSpacesInsideArrayBrackets) ```javascript // bad @@ -2388,7 +2447,7 @@ Other Style Guides ``` - - [18.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`](http://eslint.org/docs/rules/object-curly-spacing.html) jscs: [`requireSpacesInsideObjectBrackets`](http://jscs.info/rule/requireSpacesInsideObjectBrackets) ```javascript // bad @@ -2399,7 +2458,7 @@ Other Style Guides ``` - - [18.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`](http://eslint.org/docs/rules/max-len.html) jscs: [`maximumLineLength`](http://jscs.info/rule/maximumLineLength) > Why? This ensures readability and maintainability. @@ -2433,7 +2492,7 @@ Other Style Guides ## Commas - - [19.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`](http://eslint.org/docs/rules/comma-style.html) jscs: [`requireCommaBeforeLineBreak`](http://jscs.info/rule/requireCommaBeforeLineBreak) ```javascript // bad @@ -2468,7 +2527,7 @@ Other Style Guides ``` - - [19.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`](http://eslint.org/docs/rules/comma-dangle.html) jscs: [`requireTrailingComma`](http://jscs.info/rule/requireTrailingComma) > Why? This leads to cleaner git diffs. Also, transpilers like Babel will remove the additional trailing comma in the transpiled code which means you don't have to worry about the [trailing comma problem](https://github.com/airbnb/javascript/blob/es5-deprecated/es5/README.md#commas) in legacy browsers. @@ -2569,7 +2628,7 @@ Other Style Guides ## Semicolons - - [20.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`](http://eslint.org/docs/rules/semi.html) jscs: [`requireSemicolons`](http://jscs.info/rule/requireSemicolons) ```javascript // bad @@ -2599,10 +2658,10 @@ Other Style Guides ## Type Casting & Coercion - - [21.1](#coercion--explicit) Perform type coercion at the beginning of the statement. + - [22.1](#coercion--explicit) Perform type coercion at the beginning of the statement. - - [21.2](#coercion--strings) Strings: + - [22.2](#coercion--strings) Strings: ```javascript // => this.reviewScore = 9; @@ -2618,7 +2677,7 @@ Other Style Guides ``` - - [21.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) ```javascript const inputValue = '4'; @@ -2643,7 +2702,7 @@ Other Style Guides ``` - - [21.4](#coercion--comment-deviations) If for whatever reason you are doing something wild and `parseInt` is your bottleneck and need to use Bitshift for [performance reasons](https://jsperf.com/coercion-vs-casting/3), leave a comment explaining why and what you're doing. + - [22.4](#coercion--comment-deviations) If for whatever reason you are doing something wild and `parseInt` is your bottleneck and need to use Bitshift for [performance reasons](https://jsperf.com/coercion-vs-casting/3), leave a comment explaining why and what you're doing. ```javascript // good @@ -2656,7 +2715,7 @@ Other Style Guides ``` - - [21.5](#coercion--bitwise) **Note:** Be careful when using bitshift operations. Numbers are represented as [64-bit values](https://es5.github.io/#x4.3.19), but bitshift operations always return a 32-bit integer ([source](https://es5.github.io/#x11.7)). Bitshift can lead to unexpected behavior for integer values larger than 32 bits. [Discussion](https://github.com/airbnb/javascript/issues/109). Largest signed 32-bit Int is 2,147,483,647: + - [22.5](#coercion--bitwise) **Note:** Be careful when using bitshift operations. Numbers are represented as [64-bit values](https://es5.github.io/#x4.3.19), but bitshift operations always return a 32-bit integer ([source](https://es5.github.io/#x11.7)). Bitshift can lead to unexpected behavior for integer values larger than 32 bits. [Discussion](https://github.com/airbnb/javascript/issues/109). Largest signed 32-bit Int is 2,147,483,647: ```javascript 2147483647 >> 0; // => 2147483647 @@ -2665,7 +2724,7 @@ Other Style Guides ``` - - [21.6](#coercion--booleans) Booleans: + - [22.6](#coercion--booleans) Booleans: ```javascript const age = 0; @@ -2686,7 +2745,7 @@ Other Style Guides ## Naming Conventions - - [22.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`](http://eslint.org/docs/rules/id-length) ```javascript // bad @@ -2701,7 +2760,7 @@ Other Style Guides ``` - - [22.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`](http://eslint.org/docs/rules/camelcase.html) jscs: [`requireCamelCaseOrUpperCaseIdentifiers`](http://jscs.info/rule/requireCamelCaseOrUpperCaseIdentifiers) ```javascript // bad @@ -2715,7 +2774,7 @@ Other Style Guides ``` - - [22.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`](http://eslint.org/docs/rules/new-cap.html) jscs: [`requireCapitalizedConstructors`](http://jscs.info/rule/requireCapitalizedConstructors) ```javascript // bad @@ -2740,7 +2799,7 @@ Other Style Guides ``` - - [22.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`](http://eslint.org/docs/rules/no-underscore-dangle.html) jscs: [`disallowDanglingUnderscores`](http://jscs.info/rule/disallowDanglingUnderscores) > Why? JavaScript does not have the concept of privacy in terms of properties or methods. Although a leading underscore is a common convention to mean “private”, in fact, these properties are fully public, and as such, are part of your public API contract. This convention might lead developers to wrongly think that a change won't count as breaking, or that tests aren't needed. tl;dr: if you want something to be “private”, it must not be observably present. @@ -2755,7 +2814,7 @@ Other Style Guides ``` - - [22.5](#naming--self-this) Don't save references to `this`. Use arrow functions or [Function#bind](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/bind). jscs: [`disallowNodeTypes`](http://jscs.info/rule/disallowNodeTypes) + - [23.5](#naming--self-this) Don't save references to `this`. Use arrow functions or [Function#bind](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/bind). jscs: [`disallowNodeTypes`](http://jscs.info/rule/disallowNodeTypes) ```javascript // bad @@ -2783,7 +2842,7 @@ Other Style Guides ``` - - [22.6](#naming--filename-matches-export) A base filename should exactly match the name of its default export. + - [23.6](#naming--filename-matches-export) A base filename should exactly match the name of its default export. ```javascript // file 1 contents @@ -2819,7 +2878,7 @@ Other Style Guides ``` - - [22.7](#naming--camelCase-default-export) Use camelCase when you export-default a function. Your filename should be identical to your function's name. + - [23.7](#naming--camelCase-default-export) Use camelCase when you export-default a function. Your filename should be identical to your function's name. ```javascript function makeStyleGuide() { @@ -2830,7 +2889,7 @@ Other Style Guides ``` - - [22.8](#naming--PascalCase-singleton) Use PascalCase when you export a constructor / class / singleton / function library / bare object. + - [23.8](#naming--PascalCase-singleton) Use PascalCase when you export a constructor / class / singleton / function library / bare object. ```javascript const AirbnbStyleGuide = { @@ -2842,7 +2901,7 @@ Other Style Guides ``` - - [22.9](#naming--Acronyms-and-Initialisms) Acronyms and initialisms should always be all capitalized, or all lowercased. + - [23.9](#naming--Acronyms-and-Initialisms) Acronyms and initialisms should always be all capitalized, or all lowercased. > Why? Names are for readability, not to appease a computer algorithm. @@ -2878,10 +2937,10 @@ Other Style Guides ## Accessors - - [23.1](#accessors--not-required) Accessor functions for properties are not required. + - [24.1](#accessors--not-required) Accessor functions for properties are not required. - - [23.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 @@ -2908,7 +2967,7 @@ Other Style Guides ``` - - [23.3](#accessors--boolean-prefix) If the property/method is a `boolean`, use `isVal()` or `hasVal()`. + - [24.3](#accessors--boolean-prefix) If the property/method is a `boolean`, use `isVal()` or `hasVal()`. ```javascript // bad @@ -2923,7 +2982,7 @@ Other Style Guides ``` - - [23.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 { @@ -2948,7 +3007,7 @@ Other Style Guides ## Events - - [24.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 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 @@ -2980,7 +3039,7 @@ Other Style Guides ## jQuery - - [25.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 `$`. jscs: [`requireDollarBeforejQueryAssignment`](http://jscs.info/rule/requireDollarBeforejQueryAssignment) ```javascript // bad @@ -2994,7 +3053,7 @@ Other Style Guides ``` - - [25.2](#jquery--cache) Cache jQuery lookups. + - [26.2](#jquery--cache) Cache jQuery lookups. ```javascript // bad @@ -3022,10 +3081,10 @@ Other Style Guides ``` - - [25.3](#jquery--queries) For DOM queries use Cascading `$('.sidebar ul')` or parent > child `$('.sidebar > ul')`. [jsPerf](http://jsperf.com/jquery-find-vs-context-sel/16) + - [26.3](#jquery--queries) For DOM queries use Cascading `$('.sidebar ul')` or parent > child `$('.sidebar > ul')`. [jsPerf](http://jsperf.com/jquery-find-vs-context-sel/16) - - [25.4](#jquery--find) Use `find` with scoped jQuery object queries. + - [26.4](#jquery--find) Use `find` with scoped jQuery object queries. ```javascript // bad @@ -3050,7 +3109,7 @@ Other Style Guides ## ECMAScript 5 Compatibility - - [26.1](#es5-compat--kangax) Refer to [Kangax](https://twitter.com/kangax/)'s ES5 [compatibility table](https://kangax.github.io/es5-compat-table/). + - [27.1](#es5-compat--kangax) Refer to [Kangax](https://twitter.com/kangax/)'s ES5 [compatibility table](https://kangax.github.io/es5-compat-table/). **[⬆ back to top](#table-of-contents)** @@ -3058,7 +3117,7 @@ Other Style Guides ## ECMAScript 6+ (ES 2015+) Styles - - [27.1](#es6-styles) This is a collection of links to the various ES6 features. + - [28.1](#es6-styles) This is a collection of links to the various ES6 features. 1. [Arrow Functions](#arrow-functions) 1. [Classes](#classes--constructors) @@ -3075,7 +3134,7 @@ Other Style Guides 1. [Modules](#modules) - - [27.2](#tc39-proposals) Do not use [TC39 proposals](https://github.com/tc39/proposals) that have not reached stage 3. + - [28.2](#tc39-proposals) Do not use [TC39 proposals](https://github.com/tc39/proposals) that have not reached stage 3. > Why? [They are not finalized](https://tc39.github.io/process-document/), and they are subject to change or to be withdrawn entirely. We want to use JavaScript, and proposals are not JavaScript yet. @@ -3084,7 +3143,7 @@ Other Style Guides ## Testing - - [28.1](#testing--yup) **Yup.** + - [29.1](#testing--yup) **Yup.** ```javascript function foo() { @@ -3093,7 +3152,7 @@ Other Style Guides ``` - - [28.2](#testing--for-real) **No, but seriously**: + - [29.2](#testing--for-real) **No, but seriously**: - Whichever testing framework you use, you should be writing tests! - Strive to write many small pure functions, and minimize where mutations occur. - Be cautious about stubs and mocks - they can make your tests more brittle. From b87cb5cdad74199d3fcb83d135e466c29a56ff4e Mon Sep 17 00:00:00 2001 From: Vlad Shcherbin Date: Mon, 1 May 2017 10:57:49 +0300 Subject: [PATCH 131/702] [guide] [Fix] react/prefer-stateless-function "ignorePureComponents" option typo --- packages/eslint-config-airbnb/rules/react.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/eslint-config-airbnb/rules/react.js b/packages/eslint-config-airbnb/rules/react.js index caf62dd81c..63da3865fa 100644 --- a/packages/eslint-config-airbnb/rules/react.js +++ b/packages/eslint-config-airbnb/rules/react.js @@ -176,7 +176,7 @@ module.exports = { // Require stateless functions when not using lifecycle methods, setState or ref // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/prefer-stateless-function.md - 'react/prefer-stateless-function': ['error', { ignorePureComponent: true }], + 'react/prefer-stateless-function': ['error', { ignorePureComponents: true }], // Prevent missing props validation in a React component definition // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/prop-types.md From 3ca86a4a3c3d9db3295dffb4f6c53affe194a491 Mon Sep 17 00:00:00 2001 From: thomas Bell Date: Wed, 3 May 2017 14:16:32 -0400 Subject: [PATCH 132/702] added generation tux as in the wild --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index ded9acf2f4..b902d4ddd8 100644 --- a/README.md +++ b/README.md @@ -3296,6 +3296,7 @@ Other Style Guides - **Flexberry**: [Flexberry/javascript-style-guide](https://github.com/Flexberry/javascript-style-guide) - **Gawker Media**: [gawkermedia/javascript](https://github.com/gawkermedia/javascript) - **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) - **Grooveshark**: [grooveshark/javascript](https://github.com/grooveshark/javascript) - **Honey**: [honeyscience/javascript](https://github.com/honeyscience/javascript) From bfc85bddba7b62098798bcbb07d475f2801f3ddf Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Mon, 1 May 2017 12:21:54 -0700 Subject: [PATCH 133/702] [eslint config] [deps] update `eslint-config-airbnb-base`, `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 c1a5d90df6..28e2ae4ec9 100644 --- a/packages/eslint-config-airbnb/package.json +++ b/packages/eslint-config-airbnb/package.json @@ -46,13 +46,13 @@ }, "homepage": "https://github.com/airbnb/javascript", "dependencies": { - "eslint-config-airbnb-base": "^11.1.2" + "eslint-config-airbnb-base": "^11.1.3" }, "devDependencies": { "babel-preset-airbnb": "^2.2.3", "babel-tape-runner": "^2.0.1", "editorconfig-tools": "^0.1.1", - "eslint": "^3.18.0", + "eslint": "^3.19.0", "eslint-find-rules": "^1.14.3", "eslint-plugin-import": "^2.2.0", "eslint-plugin-jsx-a11y": "^4.0.0", @@ -63,7 +63,7 @@ "tape": "^4.6.3" }, "peerDependencies": { - "eslint": "^3.18.0", + "eslint": "^3.19.0", "eslint-plugin-jsx-a11y": "^4.0.0", "eslint-plugin-import": "^2.2.0", "eslint-plugin-react": "^6.10.3" From c9c5f7efbf91a7d00c0696f5d4318d6c58f81c5c Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Mon, 1 May 2017 12:22:24 -0700 Subject: [PATCH 134/702] [eslint config] [minor] enable rules: - `jsx-max-props-per-line` - `void-dom-elements-no-children` --- packages/eslint-config-airbnb/rules/react.js | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/packages/eslint-config-airbnb/rules/react.js b/packages/eslint-config-airbnb/rules/react.js index 63da3865fa..393132869d 100644 --- a/packages/eslint-config-airbnb/rules/react.js +++ b/packages/eslint-config-airbnb/rules/react.js @@ -71,8 +71,7 @@ module.exports = { // Limit maximum of props on a single line in JSX // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-max-props-per-line.md - // TODO: enable (semver-minor) - 'react/jsx-max-props-per-line': ['off', { maximum: 1, when: 'multiline' }], + 'react/jsx-max-props-per-line': ['error', { maximum: 1, when: 'multiline' }], // Prevent usage of .bind() in JSX props // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-no-bind.md @@ -318,8 +317,7 @@ module.exports = { // Prevent void DOM elements from receiving children // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/void-dom-elements-no-children.md - // TODO: enable (semver-minor) - 'react/void-dom-elements-no-children': 'off', + 'react/void-dom-elements-no-children': 'error', }, settings: { From ba35e31c76d3c1ab4aeaa7f7967fc4cb98a82787 Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Mon, 1 May 2017 12:22:41 -0700 Subject: [PATCH 135/702] [eslint config] [breaking] set default React version to 0.15 --- packages/eslint-config-airbnb/rules/react.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/eslint-config-airbnb/rules/react.js b/packages/eslint-config-airbnb/rules/react.js index 393132869d..70ede782e4 100644 --- a/packages/eslint-config-airbnb/rules/react.js +++ b/packages/eslint-config-airbnb/rules/react.js @@ -328,7 +328,7 @@ module.exports = { }, react: { pragma: 'React', - version: '0.14' + version: '0.15' }, } }; From 7cef8dad848c5648c6b843e26ea683b9b1f4d43d Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Mon, 1 May 2017 12:31:57 -0700 Subject: [PATCH 136/702] [eslint config] [docs] add rule documentation to `forbid-elements` entry --- packages/eslint-config-airbnb/rules/react.js | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/packages/eslint-config-airbnb/rules/react.js b/packages/eslint-config-airbnb/rules/react.js index 70ede782e4..aaa2eec733 100644 --- a/packages/eslint-config-airbnb/rules/react.js +++ b/packages/eslint-config-airbnb/rules/react.js @@ -266,6 +266,10 @@ module.exports = { // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/forbid-component-props.md 'react/forbid-component-props': ['off', { forbid: [] }], + // Forbid certain elements + // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/forbid-elements.md + 'react/forbid-elements': ['off', { forbid: [], }], + // Prevent problem with children and props.dangerouslySetInnerHTML // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/no-danger-with-children.md 'react/no-danger-with-children': 'error', @@ -306,11 +310,6 @@ module.exports = { // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/require-default-props.md 'react/require-default-props': 'error', - 'react/forbid-elements': ['off', { - forbid: [ - ], - }], - // 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', From 5dec8272e03ce792f3c1a5dc8cf94042609e0615 Mon Sep 17 00:00:00 2001 From: koooge Date: Thu, 3 Aug 2017 17:57:58 +0200 Subject: [PATCH 137/702] [eslint config] [base] [breaking] move `comma-dangle` to Stylistic Issues --- packages/eslint-config-airbnb-base/rules/errors.js | 9 --------- packages/eslint-config-airbnb-base/rules/style.js | 9 +++++++++ 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/packages/eslint-config-airbnb-base/rules/errors.js b/packages/eslint-config-airbnb-base/rules/errors.js index 02befbb5af..786b88ae1e 100644 --- a/packages/eslint-config-airbnb-base/rules/errors.js +++ b/packages/eslint-config-airbnb-base/rules/errors.js @@ -1,14 +1,5 @@ module.exports = { rules: { - // require trailing commas in multiline object literals - 'comma-dangle': ['error', { - arrays: 'always-multiline', - objects: 'always-multiline', - imports: 'always-multiline', - exports: 'always-multiline', - functions: 'always-multiline', - }], - // Enforce “for” loop update clause moving the counter in the right direction // http://eslint.org/docs/rules/for-direction // TODO: enable, semver-major until v3 is dropped; semver-minor otherwise diff --git a/packages/eslint-config-airbnb-base/rules/style.js b/packages/eslint-config-airbnb-base/rules/style.js index 42e820870e..82ef7018c2 100644 --- a/packages/eslint-config-airbnb-base/rules/style.js +++ b/packages/eslint-config-airbnb-base/rules/style.js @@ -38,6 +38,15 @@ module.exports = { }, }], + // require trailing commas in multiline object literals + 'comma-dangle': ['error', { + arrays: 'always-multiline', + objects: 'always-multiline', + imports: 'always-multiline', + exports: 'always-multiline', + functions: 'always-multiline', + }], + // enforce spacing before and after comma 'comma-spacing': ['error', { before: false, after: true }], From f5cd2869d35268cc158409195b561b28feca5d94 Mon Sep 17 00:00:00 2001 From: David Walsh Date: Tue, 4 Jul 2017 12:40:53 +1000 Subject: [PATCH 138/702] [guide] [eslint config] [base] [breaking] Rules prohibiting global isNaN, isFinite. - Update README with new Standard Library section. --- README.md | 45 ++++++++++++++++++- .../rules/best-practices.js | 24 ++++++++++ .../rules/variables.js | 3 +- 3 files changed, 68 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index b9887ff20a..4125081c2f 100644 --- a/README.md +++ b/README.md @@ -44,6 +44,7 @@ Other Style Guides 1. [jQuery](#jquery) 1. [ECMAScript 5 Compatibility](#ecmascript-5-compatibility) 1. [ECMAScript 6+ (ES 2015+) Styles](#ecmascript-6-es-2015-styles) + 1. [Standard Library](#standard-library) 1. [Testing](#testing) 1. [Performance](#performance) 1. [Resources](#resources) @@ -3148,10 +3149,50 @@ Other Style Guides **[⬆ back to top](#table-of-contents)** +## Standard Library + + The [Standard Library](https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects) + contains utilities that are functionally broken but remain for legacy reasons. + + + - [29.1](#standard-library--isnan) Use `Number.isNaN` instead of global `isNaN`. + eslint: [`no-restricted-globals`](http://eslint.org/docs/rules/no-restricted-globals) + + > Why? The global `isNaN` coerces non-numbers to numbers, returning true for anything that coerces to NaN. + If this behavior is desired, make it explicit. + + ```javascript + // bad + isNaN('1.2'); // false + isNaN('1.2.3'); // true + + // good + Number.isNaN('1.2.3'); // false + Number.isNaN(Number('1.2.3')); // true + ``` + + + - [29.2](#standard-library--isfinite) Use `Number.isFinite` instead of global `isFinite`. + eslint: [`no-restricted-globals`](http://eslint.org/docs/rules/no-restricted-globals) + + > Why? The global `isFinite` coerces non-numbers to numbers, returning true for anything that coerces to a finite number. + If this behavior is desired, make it explicit. + + ```javascript + // bad + isFinite('2e3'); // true + + // good + Number.isFinite('2e3'); // false + Number.isFinite(parseInt('2e3', 10)); // true + ``` + +**[⬆ back to top](#table-of-contents)** + ## Testing - - [29.1](#testing--yup) **Yup.** + - [30.1](#testing--yup) **Yup.** ```javascript function foo() { @@ -3160,7 +3201,7 @@ Other Style Guides ``` - - [29.2](#testing--for-real) **No, but seriously**: + - [30.2](#testing--for-real) **No, but seriously**: - Whichever testing framework you use, you should be writing tests! - Strive to write many small pure functions, and minimize where mutations occur. - Be cautious about stubs and mocks - they can make your tests more brittle. diff --git a/packages/eslint-config-airbnb-base/rules/best-practices.js b/packages/eslint-config-airbnb-base/rules/best-practices.js index 02ea3e23b3..11b18a2efd 100644 --- a/packages/eslint-config-airbnb-base/rules/best-practices.js +++ b/packages/eslint-config-airbnb-base/rules/best-practices.js @@ -194,6 +194,30 @@ module.exports = { object: 'arguments', property: 'callee', message: 'arguments.callee is deprecated', + }, { + object: 'global', + property: 'isFinite', + message: 'Please use Number.isFinite instead', + }, { + object: 'self', + property: 'isFinite', + message: 'Please use Number.isFinite instead', + }, { + object: 'window', + property: 'isFinite', + message: 'Please use Number.isFinite instead', + }, { + object: 'global', + property: 'isNaN', + message: 'Please use Number.isNaN instead', + }, { + object: 'self', + property: 'isNaN', + message: 'Please use Number.isNaN instead', + }, { + object: 'window', + property: 'isNaN', + message: 'Please use Number.isNaN instead', }, { property: '__defineGetter__', message: 'Please use Object.defineProperty instead.', diff --git a/packages/eslint-config-airbnb-base/rules/variables.js b/packages/eslint-config-airbnb-base/rules/variables.js index fe38ea5d60..805563a51a 100644 --- a/packages/eslint-config-airbnb-base/rules/variables.js +++ b/packages/eslint-config-airbnb-base/rules/variables.js @@ -16,8 +16,7 @@ module.exports = { 'no-label-var': 'error', // disallow specific globals - // TODO: enable, semver-major - 'no-restricted-globals': ['off'].concat(restrictedGlobals), + 'no-restricted-globals': ['error', 'isFinite', 'isNaN'].concat(restrictedGlobals), // disallow declaration of variables already declared in the outer scope 'no-shadow': 'error', From 5aa203eaa88fb7febfb1ccf8736e896ca0959049 Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Fri, 1 Sep 2017 22:25:31 -0700 Subject: [PATCH 139/702] [eslint config] [base] [deps] [breaking] require `eslint` v4 - enable `function-paren-newline`, `for-direction`, `getter-return`, `no-compare-neg-zero`, `semi-style`, `object-curly-newline`, `no-buffer-constructor`, `no-restricted-globals`, `switch-colon-spacing`, `template-tag-spacing`, `prefer-promise-reject-errors`, `prefer-restructuring` - improve `indent`, `no-multi-spaces`, `no-trailing-spaces`, `no-underscore-dangle` --- .travis.yml | 4 --- .../eslint-config-airbnb-base/package.json | 4 +-- .../rules/best-practices.js | 5 ++- .../eslint-config-airbnb-base/rules/errors.js | 9 ++--- .../eslint-config-airbnb-base/rules/es6.js | 3 +- .../eslint-config-airbnb-base/rules/node.js | 3 +- .../eslint-config-airbnb-base/rules/style.js | 33 +++++++++++-------- 7 files changed, 28 insertions(+), 33 deletions(-) diff --git a/.travis.yml b/.travis.yml index 7d887ca685..9e1091574d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -19,7 +19,6 @@ env: matrix: - 'TEST=true ESLINT=3 PACKAGE=eslint-config-airbnb' - 'TEST=true ESLINT=4 PACKAGE=eslint-config-airbnb' - - 'TEST=true ESLINT=3 PACKAGE=eslint-config-airbnb-base' - 'TEST=true ESLINT=4 PACKAGE=eslint-config-airbnb-base' matrix: fast_finish: true @@ -28,8 +27,6 @@ matrix: env: PREPUBLISH=true ESLINT=3 PACKAGE=eslint-config-airbnb - node_js: "node" env: PREPUBLISH=true ESLINT=4 PACKAGE=eslint-config-airbnb - - node_js: "node" - env: PREPUBLISH=true ESLINT=3 PACKAGE=eslint-config-airbnb-base - node_js: "node" env: PREPUBLISH=true ESLINT=4 PACKAGE=eslint-config-airbnb-base allow_failures: @@ -37,5 +34,4 @@ matrix: - node_js: "5" - env: PREPUBLISH=true ESLINT=3 PACKAGE=eslint-config-airbnb - env: PREPUBLISH=true ESLINT=4 PACKAGE=eslint-config-airbnb - - env: PREPUBLISH=true ESLINT=3 PACKAGE=eslint-config-airbnb-base - env: PREPUBLISH=true ESLINT=4 PACKAGE=eslint-config-airbnb-base diff --git a/packages/eslint-config-airbnb-base/package.json b/packages/eslint-config-airbnb-base/package.json index 90078eb1d0..f23359e969 100644 --- a/packages/eslint-config-airbnb-base/package.json +++ b/packages/eslint-config-airbnb-base/package.json @@ -51,7 +51,7 @@ "babel-preset-airbnb": "^2.4.0", "babel-tape-runner": "^2.0.1", "editorconfig-tools": "^0.1.1", - "eslint": "^4.5.0", + "eslint": "^4.6.0", "eslint-find-rules": "^3.1.1", "eslint-plugin-import": "^2.7.0", "in-publish": "^2.0.0", @@ -59,7 +59,7 @@ "tape": "^4.8.0" }, "peerDependencies": { - "eslint": "^3.19.0 || ^4.5.0", + "eslint": "^4.6.0", "eslint-plugin-import": "^2.7.0" }, "engines": { diff --git a/packages/eslint-config-airbnb-base/rules/best-practices.js b/packages/eslint-config-airbnb-base/rules/best-practices.js index 11b18a2efd..83808bb879 100644 --- a/packages/eslint-config-airbnb-base/rules/best-practices.js +++ b/packages/eslint-config-airbnb-base/rules/best-practices.js @@ -143,7 +143,7 @@ module.exports = { // disallow use of multiple spaces 'no-multi-spaces': ['error', { - // ignoreEOLComments: false, // TODO: uncomment once v3 is dropped + ignoreEOLComments: false, }], // disallow use of multiline strings @@ -294,8 +294,7 @@ module.exports = { // require using Error objects as Promise rejection reasons // http://eslint.org/docs/rules/prefer-promise-reject-errors - // TODO: enable, semver-major - 'prefer-promise-reject-errors': ['off', { allowEmptyReject: true }], + 'prefer-promise-reject-errors': ['error', { allowEmptyReject: true }], // require use of the second argument for parseInt() radix: 'error', diff --git a/packages/eslint-config-airbnb-base/rules/errors.js b/packages/eslint-config-airbnb-base/rules/errors.js index 786b88ae1e..19b815a09b 100644 --- a/packages/eslint-config-airbnb-base/rules/errors.js +++ b/packages/eslint-config-airbnb-base/rules/errors.js @@ -2,13 +2,11 @@ module.exports = { rules: { // Enforce “for” loop update clause moving the counter in the right direction // http://eslint.org/docs/rules/for-direction - // TODO: enable, semver-major until v3 is dropped; semver-minor otherwise - 'for-direction': 'off', + 'for-direction': 'error', // Enforces that a return statement is present in property getters // http://eslint.org/docs/rules/getter-return - // TODO: enable, semver-major when v3 is dropped - 'getter-return': ['off', { allowImplicit: true }], + 'getter-return': ['error', { allowImplicit: true }], // Disallow await inside of loops // http://eslint.org/docs/rules/no-await-in-loop @@ -16,8 +14,7 @@ module.exports = { // Disallow comparisons to negative zero // http://eslint.org/docs/rules/no-compare-neg-zero - // TODO: enable (semver-major) - 'no-compare-neg-zero': 'off', + 'no-compare-neg-zero': 'error', // disallow assignment in conditional expressions 'no-cond-assign': ['error', 'always'], diff --git a/packages/eslint-config-airbnb-base/rules/es6.js b/packages/eslint-config-airbnb-base/rules/es6.js index a77f3a6641..f53814d1e7 100644 --- a/packages/eslint-config-airbnb-base/rules/es6.js +++ b/packages/eslint-config-airbnb-base/rules/es6.js @@ -110,8 +110,7 @@ module.exports = { // Prefer destructuring from arrays and objects // http://eslint.org/docs/rules/prefer-destructuring - // TODO: enable - 'prefer-destructuring': ['off', { + 'prefer-destructuring': ['error', { VariableDeclarator: { array: false, object: true, diff --git a/packages/eslint-config-airbnb-base/rules/node.js b/packages/eslint-config-airbnb-base/rules/node.js index d890a67c1b..9413b5483a 100644 --- a/packages/eslint-config-airbnb-base/rules/node.js +++ b/packages/eslint-config-airbnb-base/rules/node.js @@ -16,8 +16,7 @@ module.exports = { // disallow use of the Buffer() constructor // http://eslint.org/docs/rules/no-buffer-constructor - // TODO: enable, semver-major - 'no-buffer-constructor': 'off', + 'no-buffer-constructor': 'error', // disallow mixing regular variable and require declarations 'no-mixed-requires': ['off', false], diff --git a/packages/eslint-config-airbnb-base/rules/style.js b/packages/eslint-config-airbnb-base/rules/style.js index 82ef7018c2..bcd83778e1 100644 --- a/packages/eslint-config-airbnb-base/rules/style.js +++ b/packages/eslint-config-airbnb-base/rules/style.js @@ -82,6 +82,10 @@ module.exports = { // TODO: enable 'func-style': ['off', 'expression'], + // enforce consistent line breaks inside function parentheses + // https://eslint.org/docs/rules/function-paren-newline + 'function-paren-newline': ['error', 'multiline'], + // Blacklist certain identifiers to prevent them being used // http://eslint.org/docs/rules/id-blacklist 'id-blacklist': 'off', @@ -100,9 +104,6 @@ module.exports = { VariableDeclarator: 1, outerIIFEBody: 1, // MemberExpression: null, - // CallExpression: { - // parameters: null, - // }, FunctionDeclaration: { parameters: 1, body: 1 @@ -110,7 +111,15 @@ module.exports = { FunctionExpression: { parameters: 1, body: 1 - } + }, + CallExpression: { + 'arguments': 1 + }, + ArrayExpression: 1, + ObjectExpression: 1, + ImportDeclaration: 1, + flatTernaryExpressions: false, + ignoredNodes: ['JSXElement *'] }], // specify whether double or single quotes should be used in JSX attributes @@ -305,7 +314,7 @@ module.exports = { // disallow trailing whitespace at the end of lines 'no-trailing-spaces': ['error', { skipBlankLines: false, - // ignoreComments: false, // TODO: uncomment once v3 is dropped + ignoreComments: false, }], // disallow dangling underscores in identifiers @@ -313,7 +322,7 @@ module.exports = { allow: [], allowAfterThis: false, allowAfterSuper: false, - // enforceInMethodNames: false, // TODO: uncoment and enable, semver-minor once v3 is dropped + enforceInMethodNames: false, }], // disallow the use of Boolean literals in conditional expressions @@ -334,8 +343,7 @@ module.exports = { // enforce line breaks between braces // http://eslint.org/docs/rules/object-curly-newline - // TODO: enable once https://github.com/eslint/eslint/issues/6488 is resolved and v3 is dropped - 'object-curly-newline': ['off', { + 'object-curly-newline': ['error', { ObjectExpression: { minProperties: 3, multiline: true, consistent: true }, ObjectPattern: { minProperties: 3, multiline: true, consistent: true } }], @@ -386,8 +394,7 @@ module.exports = { // Enforce location of semicolons // http://eslint.org/docs/rules/semi-style - // TODO: enable, semver-major until v3 is dropped, semver-minor otherwise - 'semi-style': ['off', 'last'], + 'semi-style': ['error', 'last'], // requires object keys to be sorted 'sort-keys': ['off', 'asc', { caseSensitive: false, natural: true }], @@ -437,13 +444,11 @@ module.exports = { // Enforce spacing around colons of switch statements // http://eslint.org/docs/rules/switch-colon-spacing - // TODO: enable, semver-major - 'switch-colon-spacing': ['off', { after: true, before: false }], + 'switch-colon-spacing': ['error', { after: true, before: false }], // Require or disallow spacing between template tags and their literals // http://eslint.org/docs/rules/template-tag-spacing - // TODO: enable, semver-major - 'template-tag-spacing': ['off', 'never'], + 'template-tag-spacing': ['error', 'never'], // require or disallow the Unicode Byte Order Mark // http://eslint.org/docs/rules/unicode-bom From f878edad256fabd4fdcdfdffabd884744b0924d4 Mon Sep 17 00:00:00 2001 From: Thomas Grainger Date: Fri, 5 May 2017 11:42:43 +0100 Subject: [PATCH 140/702] [eslint config] [base] [patch] also disallow padding in classes and switches --- README.md | 10 +++++++++- packages/eslint-config-airbnb-base/rules/style.js | 4 ++-- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 4125081c2f..27070b7792 100644 --- a/README.md +++ b/README.md @@ -2396,7 +2396,7 @@ Other Style Guides } - // also bad + // bad if (baz) { console.log(qux); @@ -2405,6 +2405,14 @@ Other Style Guides } + // bad + class Foo { + + constructor(bar) { + this.bar = bar; + } + } + // good function bar() { console.log(foo); diff --git a/packages/eslint-config-airbnb-base/rules/style.js b/packages/eslint-config-airbnb-base/rules/style.js index bcd83778e1..d36309a808 100644 --- a/packages/eslint-config-airbnb-base/rules/style.js +++ b/packages/eslint-config-airbnb-base/rules/style.js @@ -368,8 +368,8 @@ module.exports = { // enforce operators to be placed before or after line breaks 'operator-linebreak': 'off', - // enforce padding within blocks - 'padded-blocks': ['error', 'never'], + // disallow padding within blocks + 'padded-blocks': ['error', { blocks: 'never', classes: 'never', switches: 'never' }], // Require or disallow padding lines between statements // http://eslint.org/docs/rules/padding-line-between-statements From 121a95d71524032bfa858271b318aa6e19553dfc Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Fri, 5 May 2017 12:16:58 -0700 Subject: [PATCH 141/702] [eslint config] [deps] [breaking] update `eslint-plugin-jsx-a11y` --- packages/eslint-config-airbnb/package.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/eslint-config-airbnb/package.json b/packages/eslint-config-airbnb/package.json index 28e2ae4ec9..d6635e2c0c 100644 --- a/packages/eslint-config-airbnb/package.json +++ b/packages/eslint-config-airbnb/package.json @@ -55,7 +55,7 @@ "eslint": "^3.19.0", "eslint-find-rules": "^1.14.3", "eslint-plugin-import": "^2.2.0", - "eslint-plugin-jsx-a11y": "^4.0.0", + "eslint-plugin-jsx-a11y": "^5.0.0", "eslint-plugin-react": "^6.10.3", "in-publish": "^2.0.0", "react": ">= 0.13.0", @@ -64,7 +64,7 @@ }, "peerDependencies": { "eslint": "^3.19.0", - "eslint-plugin-jsx-a11y": "^4.0.0", + "eslint-plugin-jsx-a11y": "^5.0.0", "eslint-plugin-import": "^2.2.0", "eslint-plugin-react": "^6.10.3" }, From 01e39775972e3457defd64af2e94843a848d4fe2 Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Fri, 5 May 2017 12:34:00 -0700 Subject: [PATCH 142/702] [eslint config] [breaking] enable rules: - `no-autofocus`: enable `ignoreNonDOM` - add options to `no-static-element-interactions` - remove `onclick-has-role` - add `alt-text` (replaces `img-has-alt`) - add `interactive-supports-focus` (replaces `onclick-has-focus`) - add `no-noninteractive-element-interactions` - add `media-has-caption` - add `no-interactive-element-to-noninteractive-role` - add `no-noninteractive-element-to-interactive-role` - add `no-noninteractive-tabindex` --- .../eslint-config-airbnb/rules/react-a11y.js | 80 ++++++++++++++++--- 1 file changed, 67 insertions(+), 13 deletions(-) diff --git a/packages/eslint-config-airbnb/rules/react-a11y.js b/packages/eslint-config-airbnb/rules/react-a11y.js index a5443645de..8bc1426f0f 100644 --- a/packages/eslint-config-airbnb/rules/react-a11y.js +++ b/packages/eslint-config-airbnb/rules/react-a11y.js @@ -32,9 +32,15 @@ module.exports = { // https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/href-no-hash.md 'jsx-a11y/href-no-hash': ['error', { components: ['a'] }], - // Require to have a non-empty `alt` prop, or role="presentation" - // https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/img-has-alt.md - 'jsx-a11y/img-has-alt': 'error', + // Enforce that all elements that require alternative text have meaningful information + // https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/alt-text.md + 'jsx-a11y/alt-text': ['error', { + elements: ['img', 'object', 'area', 'input[type="image"]'], + img: [], + object: [], + area: [], + 'input[type="image"]': [], + }], // Prevent img alt text from containing redundant words like "image", "picture", or "photo" // https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/img-redundant-alt.md @@ -57,14 +63,9 @@ module.exports = { // https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/no-onchange.md 'jsx-a11y/no-onchange': 'off', - // Enforce that elements with onClick handlers must be focusable. - // TODO: evaluate - // https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/onclick-has-focus.md - 'jsx-a11y/onclick-has-focus': 'off', - - // require things with onClick to have an aria role - // https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/onclick-has-role.md - 'jsx-a11y/onclick-has-role': 'off', + // Elements with an interactive role and interaction handlers must be focusable + // https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/interactive-supports-focus.md + 'jsx-a11y/interactive-supports-focus': 'error', // Enforce that elements with ARIA roles must have all required attributes // for that role. @@ -109,7 +110,29 @@ module.exports = { // Enforce that DOM elements without semantic behavior not have interaction handlers // https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/no-static-element-interactions.md - 'jsx-a11y/no-static-element-interactions': 'error', + 'jsx-a11y/no-static-element-interactions': ['error', { + handlers: [ + 'onClick', + 'onMouseDown', + 'onMouseUp', + 'onKeyPress', + 'onKeyDown', + 'onKeyUp', + ] + }], + + // A non-interactive element does not support event handlers (mouse and key handlers) + // https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/no-noninteractive-element-interactions.md + 'jsx-a11y/no-noninteractive-element-interactions': ['error', { + handlers: [ + 'onClick', + 'onMouseDown', + 'onMouseUp', + 'onKeyPress', + 'onKeyDown', + 'onKeyUp', + ] + }], // ensure emoji are accessible // https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/accessible-emoji.md @@ -125,10 +148,41 @@ module.exports = { // prohibit autoFocus prop // https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/no-autofocus.md - 'jsx-a11y/no-autofocus': 'error', + 'jsx-a11y/no-autofocus': ['error', { ignoreNonDOM: true }], // ensure HTML elements do not specify redundant ARIA roles // https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/no-redundant-roles.md 'jsx-a11y/no-redundant-roles': 'error', + + // media elements must have captions + // https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/media-has-caption.md + 'jsx-a11y/media-has-caption': ['error', { + audio: [], + video: [], + track: [], + }], + + // WAI-ARIA roles should not be used to convert an interactive element to non-interactive + // https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/no-interactive-element-to-noninteractive-role.md + 'jsx-a11y/no-interactive-element-to-noninteractive-role': ['error', { + tr: ['none', 'presentation'], + }], + + // WAI-ARIA roles should not be used to convert a non-interactive element to interactive + // https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/no-noninteractive-element-to-interactive-role.md + 'jsx-a11y/no-noninteractive-element-to-interactive-role': ['error', { + ul: ['listbox', 'menu', 'menubar', 'radiogroup', 'tablist', 'tree', 'treegrid'], + ol: ['listbox', 'menu', 'menubar', 'radiogroup', 'tablist', 'tree', 'treegrid'], + li: ['menuitem', 'option', 'row', 'tab', 'treeitem'], + table: ['grid'], + td: ['gridcell'], + }], + + // Tab key navigation should be limited to elements on the page that can be interacted with. + // https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/no-noninteractive-tabindex.md + 'jsx-a11y/no-noninteractive-tabindex': ['error', { + tags: [], + roles: ['tabpanel'], + }], }, }; From d469bb25c1e8b762de65bbb5e21ed98d9bf934f7 Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Fri, 5 May 2017 23:52:17 -0700 Subject: [PATCH 143/702] [eslint config] [deps] [breaking] update `eslint-plugin-react` - enable `react/no-will-update-set-state` - delete removed rules - `jsx-wrap-multilines`: enable `arrow` option - `jsx-first-prop-new-line`: change to `multiline-multiprop` - disable `jsx-space-before-closing` in favor of `jsx-tag-spacing` --- packages/eslint-config-airbnb/package.json | 4 +-- packages/eslint-config-airbnb/rules/react.js | 30 ++++++++++---------- 2 files changed, 17 insertions(+), 17 deletions(-) diff --git a/packages/eslint-config-airbnb/package.json b/packages/eslint-config-airbnb/package.json index d6635e2c0c..d246d23e45 100644 --- a/packages/eslint-config-airbnb/package.json +++ b/packages/eslint-config-airbnb/package.json @@ -56,7 +56,7 @@ "eslint-find-rules": "^1.14.3", "eslint-plugin-import": "^2.2.0", "eslint-plugin-jsx-a11y": "^5.0.0", - "eslint-plugin-react": "^6.10.3", + "eslint-plugin-react": "^7.0.0", "in-publish": "^2.0.0", "react": ">= 0.13.0", "safe-publish-latest": "^1.1.1", @@ -66,7 +66,7 @@ "eslint": "^3.19.0", "eslint-plugin-jsx-a11y": "^5.0.0", "eslint-plugin-import": "^2.2.0", - "eslint-plugin-react": "^6.10.3" + "eslint-plugin-react": "^7.0.0" }, "engines": { "node": ">= 4" diff --git a/packages/eslint-config-airbnb/rules/react.js b/packages/eslint-config-airbnb/rules/react.js index aaa2eec733..de9ba3aed3 100644 --- a/packages/eslint-config-airbnb/rules/react.js +++ b/packages/eslint-config-airbnb/rules/react.js @@ -119,6 +119,7 @@ module.exports = { shorthandFirst: false, shorthandLast: false, noSortAlphabetically: false, + reservedFirst: true, }], // Prevent React to be incorrectly marked as unused @@ -139,11 +140,15 @@ 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'], + 'react/no-did-mount-set-state': 'error', // Prevent usage of setState in componentDidUpdate // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/no-did-update-set-state.md - 'react/no-did-update-set-state': ['error'], + 'react/no-did-update-set-state': 'error', + + // Prevent usage of setState in componentWillUpdate + // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/no-will-update-set-state.md + 'react/no-will-update-set-state': 'error', // Prevent direct mutation of this.state // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/no-direct-mutation-state.md @@ -185,11 +190,6 @@ module.exports = { // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/react-in-jsx-scope.md 'react/react-in-jsx-scope': 'error', - // Restrict file extensions that may be required - // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/require-extension.md - // deprecated in favor of import/extensions - 'react/require-extension': ['off', { extensions: ['.jsx', '.js'] }], - // Require render() methods to return something // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/require-render-return.md 'react/require-render-return': 'error', @@ -198,10 +198,6 @@ module.exports = { // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/self-closing-comp.md 'react/self-closing-comp': 'error', - // Enforce spaces before the closing bracket of self-closing JSX elements - // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-space-before-closing.md - 'react/jsx-space-before-closing': ['error', 'always'], - // Enforce component methods order // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/sort-comp.md 'react/sort-comp': ['error', { @@ -221,13 +217,13 @@ module.exports = { 'react/jsx-wrap-multilines': ['error', { declaration: true, assignment: true, - return: true + return: true, + arrow: true, }], - 'react/wrap-multilines': 'off', // deprecated version // Require that the first prop in a JSX element be on a new line when the element is multiline // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-first-prop-new-line.md - 'react/jsx-first-prop-new-line': ['error', 'multiline'], + 'react/jsx-first-prop-new-line': ['error', 'multiline-multiprop'], // Enforce spacing around jsx equals signs // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-equals-spacing.md @@ -248,7 +244,6 @@ module.exports = { // prevent accidental JS comments from being injected into JSX as text // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-no-comment-textnodes.md 'react/jsx-no-comment-textnodes': 'error', - 'react/no-comment-textnodes': 'off', // deprecated version // disallow using React.render/ReactDOM.render's return value // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/no-render-return-value.md @@ -302,6 +297,11 @@ module.exports = { afterOpening: 'never' }], + // Enforce spaces before the closing bracket of self-closing JSX elements + // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-space-before-closing.md + // Deprecated in favor of jsx-tag-spacing + 'react/jsx-space-before-closing': ['off', 'always'], + // Prevent usage of Array index in keys // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/no-array-index-key.md 'react/no-array-index-key': 'error', From 18e5ac9a8c95ce055d0c99e090d5ff38b0ca3691 Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Tue, 9 May 2017 10:30:16 -0700 Subject: [PATCH 144/702] [eslint config] [deps] update `eslint-plugin-jsx-a11y` --- packages/eslint-config-airbnb/package.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/eslint-config-airbnb/package.json b/packages/eslint-config-airbnb/package.json index d246d23e45..1e6a334810 100644 --- a/packages/eslint-config-airbnb/package.json +++ b/packages/eslint-config-airbnb/package.json @@ -55,7 +55,7 @@ "eslint": "^3.19.0", "eslint-find-rules": "^1.14.3", "eslint-plugin-import": "^2.2.0", - "eslint-plugin-jsx-a11y": "^5.0.0", + "eslint-plugin-jsx-a11y": "^5.0.1", "eslint-plugin-react": "^7.0.0", "in-publish": "^2.0.0", "react": ">= 0.13.0", @@ -64,7 +64,7 @@ }, "peerDependencies": { "eslint": "^3.19.0", - "eslint-plugin-jsx-a11y": "^5.0.0", + "eslint-plugin-jsx-a11y": "^5.0.1", "eslint-plugin-import": "^2.2.0", "eslint-plugin-react": "^7.0.0" }, From 2f912c1dd37fb34419fb14698653442e31e19235 Mon Sep 17 00:00:00 2001 From: Trevor Sayre Date: Tue, 9 May 2017 13:12:09 -0400 Subject: [PATCH 145/702] [guide] [react] Update React README ref to jsx-a11y/img-has-alt https://github.com/evcohen/eslint-plugin-jsx-a11y/pull/220 --- react/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/react/README.md b/react/README.md index 65f1aeb68b..e5581b9788 100644 --- a/react/README.md +++ b/react/README.md @@ -271,7 +271,7 @@ /> ``` - - Always include an `alt` prop on `` tags. If the image is presentational, `alt` can be an empty string or the `` must have `role="presentation"`. eslint: [`jsx-a11y/img-has-alt`](https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/img-has-alt.md) + - Always include an `alt` prop on `` tags. If the image is presentational, `alt` can be an empty string or the `` must have `role="presentation"`. eslint: [`jsx-a11y/alt-text`](https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/alt-text.md) ```jsx // bad From 152eaa6669c353d16f606cc29b324a59761979f5 Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Tue, 9 May 2017 10:39:35 -0700 Subject: [PATCH 146/702] [guide] [react] Update React README ref to jsx-a11y/jsx-space-before-closing --- react/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/react/README.md b/react/README.md index e5581b9788..16bf2420ac 100644 --- a/react/README.md +++ b/react/README.md @@ -212,7 +212,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-space-before-closing`](https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-space-before-closing.md) + - 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) ```jsx // bad From 655886fc8762a5ab3c2b467bccba56da6488888e Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Sat, 13 May 2017 14:12:21 -0700 Subject: [PATCH 147/702] [eslint config] [deps] update `eslint-plugin-react` --- 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 1e6a334810..b780bfad30 100644 --- a/packages/eslint-config-airbnb/package.json +++ b/packages/eslint-config-airbnb/package.json @@ -56,7 +56,7 @@ "eslint-find-rules": "^1.14.3", "eslint-plugin-import": "^2.2.0", "eslint-plugin-jsx-a11y": "^5.0.1", - "eslint-plugin-react": "^7.0.0", + "eslint-plugin-react": "^7.0.1", "in-publish": "^2.0.0", "react": ">= 0.13.0", "safe-publish-latest": "^1.1.1", @@ -66,7 +66,7 @@ "eslint": "^3.19.0", "eslint-plugin-jsx-a11y": "^5.0.1", "eslint-plugin-import": "^2.2.0", - "eslint-plugin-react": "^7.0.0" + "eslint-plugin-react": "^7.0.1" }, "engines": { "node": ">= 4" From 5bcb840abe438a76c37e2b37f8cb9fe223d263bd Mon Sep 17 00:00:00 2001 From: Siddharth Doshi Date: Fri, 12 May 2017 01:08:33 +0530 Subject: [PATCH 148/702] [eslint config] [base] [minor] Disallow unused global variables --- packages/eslint-config-airbnb-base/rules/variables.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/eslint-config-airbnb-base/rules/variables.js b/packages/eslint-config-airbnb-base/rules/variables.js index 1eb7528aa8..3fc5f6ef93 100644 --- a/packages/eslint-config-airbnb-base/rules/variables.js +++ b/packages/eslint-config-airbnb-base/rules/variables.js @@ -34,7 +34,7 @@ module.exports = { 'no-undefined': 'off', // disallow declaration of variables that are not used in the code - 'no-unused-vars': ['error', { vars: 'local', args: 'after-used', ignoreRestSiblings: true }], + 'no-unused-vars': ['error', { vars: 'all', args: 'after-used', ignoreRestSiblings: true }], // disallow use of variables before they are defined 'no-use-before-define': ['error', { functions: true, classes: true, variables: true }], From d48083796c3a1442e44c86b050cc65a353f9bf43 Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Sun, 14 May 2017 16:53:50 -0700 Subject: [PATCH 149/702] [eslint config] [base] v11.2.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 8559e2277c..9407b90a6d 100644 --- a/packages/eslint-config-airbnb-base/CHANGELOG.md +++ b/packages/eslint-config-airbnb-base/CHANGELOG.md @@ -1,3 +1,7 @@ +11.2.0 / 2017-05-14 +================== + - [minor] Disallow unused global variables + 11.1.3 / 2017-04-03 ================== - [patch] add error messages to `no-restricted-syntax` (#1353) diff --git a/packages/eslint-config-airbnb-base/package.json b/packages/eslint-config-airbnb-base/package.json index d4f8951317..d604e51ea8 100644 --- a/packages/eslint-config-airbnb-base/package.json +++ b/packages/eslint-config-airbnb-base/package.json @@ -1,6 +1,6 @@ { "name": "eslint-config-airbnb-base", - "version": "11.1.3", + "version": "11.2.0", "description": "Airbnb's base JS ESLint config, following our styleguide", "main": "index.js", "scripts": { From 0449d9b5711c3135ec479b03f8928ec35e06d882 Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Sun, 14 May 2017 16:58:38 -0700 Subject: [PATCH 150/702] [eslint config] [deps] update `eslint-config-airbnb-base` --- 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 b780bfad30..a48d8c0bb7 100644 --- a/packages/eslint-config-airbnb/package.json +++ b/packages/eslint-config-airbnb/package.json @@ -46,7 +46,7 @@ }, "homepage": "https://github.com/airbnb/javascript", "dependencies": { - "eslint-config-airbnb-base": "^11.1.3" + "eslint-config-airbnb-base": "^11.2.0" }, "devDependencies": { "babel-preset-airbnb": "^2.2.3", From 58e6cd323ad1d010e81fb5d064a40c35e5370556 Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Sun, 14 May 2017 17:05:45 -0700 Subject: [PATCH 151/702] [eslint config] v15.0.0 --- packages/eslint-config-airbnb/CHANGELOG.md | 9 +++++++++ packages/eslint-config-airbnb/package.json | 2 +- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/packages/eslint-config-airbnb/CHANGELOG.md b/packages/eslint-config-airbnb/CHANGELOG.md index 487e14b5fd..26af9a5317 100644 --- a/packages/eslint-config-airbnb/CHANGELOG.md +++ b/packages/eslint-config-airbnb/CHANGELOG.md @@ -1,3 +1,12 @@ +15.0.0 / 2017-05-14 +================== +- [breaking] set default React version to 0.15 +- [breaking] `update eslint-plugin-jsx-a11y` to v5, enable new rules +- [breaking] `update eslint-plugin-react` to v7, enable new rules +- [minor] enable rules: `jsx-max-props-per-line`, `void-dom-elements-no-children` +- [patch] Turn `ignorePureComponent` option on for react/prefer-stateless-function (#1378, #1398) +- [deps] update `eslint`, `eslint-plugin-react`, `eslint-config-airbnb-base` + 14.1.0 / 2017-02-05 ================== - [patch] allow `eslint-plugin-jsx-a11y` to be v3 or v4. Remove `no-marquee` rule temporarily. diff --git a/packages/eslint-config-airbnb/package.json b/packages/eslint-config-airbnb/package.json index a48d8c0bb7..a5c9954ca4 100644 --- a/packages/eslint-config-airbnb/package.json +++ b/packages/eslint-config-airbnb/package.json @@ -1,6 +1,6 @@ { "name": "eslint-config-airbnb", - "version": "14.1.0", + "version": "15.0.0", "description": "Airbnb's ESLint config, following our styleguide", "main": "index.js", "scripts": { From fe65e4b6492342dd40d3b163090ce82a51863033 Mon Sep 17 00:00:00 2001 From: Billy Janitsch Date: Mon, 15 May 2017 12:39:37 -0400 Subject: [PATCH 152/702] [eslint config] [patch] Fix reported React version Fixes #1414. --- packages/eslint-config-airbnb/rules/react.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/eslint-config-airbnb/rules/react.js b/packages/eslint-config-airbnb/rules/react.js index de9ba3aed3..0b159de81e 100644 --- a/packages/eslint-config-airbnb/rules/react.js +++ b/packages/eslint-config-airbnb/rules/react.js @@ -327,7 +327,7 @@ module.exports = { }, react: { pragma: 'React', - version: '0.15' + version: '15.0' }, } }; From 8cabe49b943b6407ac4a16f776c6945b6e0b34e4 Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Mon, 15 May 2017 17:54:47 -0700 Subject: [PATCH 153/702] [eslint config] v15.0.1 --- 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 26af9a5317..770f56fefb 100644 --- a/packages/eslint-config-airbnb/CHANGELOG.md +++ b/packages/eslint-config-airbnb/CHANGELOG.md @@ -1,3 +1,7 @@ +15.0.1 / 2017-05-15 +================== +- [fix] set default React version to 15.0 (#1415) + 15.0.0 / 2017-05-14 ================== - [breaking] set default React version to 0.15 diff --git a/packages/eslint-config-airbnb/package.json b/packages/eslint-config-airbnb/package.json index a5c9954ca4..eb656660d2 100644 --- a/packages/eslint-config-airbnb/package.json +++ b/packages/eslint-config-airbnb/package.json @@ -1,6 +1,6 @@ { "name": "eslint-config-airbnb", - "version": "15.0.0", + "version": "15.0.1", "description": "Airbnb's ESLint config, following our styleguide", "main": "index.js", "scripts": { From 324bf9c834dead53d6c06ffdf50f764e7d35beb3 Mon Sep 17 00:00:00 2001 From: Vlad Shcherbin Date: Fri, 19 May 2017 15:04:22 +0300 Subject: [PATCH 154/702] Fix option typo --- packages/eslint-config-airbnb/CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/eslint-config-airbnb/CHANGELOG.md b/packages/eslint-config-airbnb/CHANGELOG.md index 770f56fefb..4900db6c74 100644 --- a/packages/eslint-config-airbnb/CHANGELOG.md +++ b/packages/eslint-config-airbnb/CHANGELOG.md @@ -8,7 +8,7 @@ - [breaking] `update eslint-plugin-jsx-a11y` to v5, enable new rules - [breaking] `update eslint-plugin-react` to v7, enable new rules - [minor] enable rules: `jsx-max-props-per-line`, `void-dom-elements-no-children` -- [patch] Turn `ignorePureComponent` option on for react/prefer-stateless-function (#1378, #1398) +- [patch] Turn `ignorePureComponents` option on for react/prefer-stateless-function (#1378, #1398) - [deps] update `eslint`, `eslint-plugin-react`, `eslint-config-airbnb-base` 14.1.0 / 2017-02-05 From 0dd3dbd7b62061e1ca3d1c5467ed3fbca1e5daf6 Mon Sep 17 00:00:00 2001 From: Siddharth Doshi Date: Sat, 20 May 2017 15:41:37 +0530 Subject: [PATCH 155/702] [eslint config] [base] [breaking] Blacklist confusing globals --- packages/eslint-config-airbnb-base/package.json | 3 +++ packages/eslint-config-airbnb-base/rules/variables.js | 4 +++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/packages/eslint-config-airbnb-base/package.json b/packages/eslint-config-airbnb-base/package.json index d604e51ea8..92fa71298c 100644 --- a/packages/eslint-config-airbnb-base/package.json +++ b/packages/eslint-config-airbnb-base/package.json @@ -62,5 +62,8 @@ }, "engines": { "node": ">= 4" + }, + "dependencies": { + "eslint-restricted-globals": "^0.1.1" } } diff --git a/packages/eslint-config-airbnb-base/rules/variables.js b/packages/eslint-config-airbnb-base/rules/variables.js index 3fc5f6ef93..fc0b5b11d4 100644 --- a/packages/eslint-config-airbnb-base/rules/variables.js +++ b/packages/eslint-config-airbnb-base/rules/variables.js @@ -1,3 +1,5 @@ +const restrictedGlobals = require('eslint-restricted-globals'); + module.exports = { rules: { // enforce or disallow variable initializations at definition @@ -14,7 +16,7 @@ module.exports = { 'no-label-var': 'error', // disallow specific globals - 'no-restricted-globals': 'off', + 'no-restricted-globals': ['error'].concat(restrictedGlobals), // disallow declaration of variables already declared in the outer scope 'no-shadow': 'error', From f86aacae447725d6d0edd787d620fad54ac1b187 Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Tue, 23 May 2017 12:53:26 -0700 Subject: [PATCH 156/702] [eslint config] [fix] jsx should be enabled via parserOptions, not via a root ecmaFeatures. From https://github.com/airbnb/javascript/issues/1410#issuecomment-303368921 --- packages/eslint-config-airbnb/rules/react-a11y.js | 8 ++++++-- packages/eslint-config-airbnb/rules/react.js | 4 +--- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/packages/eslint-config-airbnb/rules/react-a11y.js b/packages/eslint-config-airbnb/rules/react-a11y.js index 8bc1426f0f..77fcb93d9c 100644 --- a/packages/eslint-config-airbnb/rules/react-a11y.js +++ b/packages/eslint-config-airbnb/rules/react-a11y.js @@ -3,9 +3,13 @@ module.exports = { 'jsx-a11y', 'react' ], - ecmaFeatures: { - jsx: true + + parserOptions: { + ecmaFeatures: { + jsx: true, + }, }, + rules: { // Enforce that anchors have content // https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/anchor-has-content.md diff --git a/packages/eslint-config-airbnb/rules/react.js b/packages/eslint-config-airbnb/rules/react.js index 0b159de81e..4392d678ea 100644 --- a/packages/eslint-config-airbnb/rules/react.js +++ b/packages/eslint-config-airbnb/rules/react.js @@ -2,14 +2,12 @@ module.exports = { plugins: [ 'react', ], + parserOptions: { ecmaFeatures: { jsx: true, }, }, - ecmaFeatures: { - jsx: true, - }, // View link below for react rules documentation // https://github.com/yannickcr/eslint-plugin-react#list-of-supported-rules From 44ca3c2b3a1650ae5b8961ff3d5f3d166fde52db Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Tue, 23 May 2017 12:54:02 -0700 Subject: [PATCH 157/702] [eslint config] [deps] update `eslint-plugin-jsx-a11y` --- packages/eslint-config-airbnb/package.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/eslint-config-airbnb/package.json b/packages/eslint-config-airbnb/package.json index eb656660d2..dd5c99a010 100644 --- a/packages/eslint-config-airbnb/package.json +++ b/packages/eslint-config-airbnb/package.json @@ -55,7 +55,7 @@ "eslint": "^3.19.0", "eslint-find-rules": "^1.14.3", "eslint-plugin-import": "^2.2.0", - "eslint-plugin-jsx-a11y": "^5.0.1", + "eslint-plugin-jsx-a11y": "^5.0.3", "eslint-plugin-react": "^7.0.1", "in-publish": "^2.0.0", "react": ">= 0.13.0", @@ -64,7 +64,7 @@ }, "peerDependencies": { "eslint": "^3.19.0", - "eslint-plugin-jsx-a11y": "^5.0.1", + "eslint-plugin-jsx-a11y": "^5.0.3", "eslint-plugin-import": "^2.2.0", "eslint-plugin-react": "^7.0.1" }, From 0f8f30dcd0b8292a9e49148fa6f77046aadbeee2 Mon Sep 17 00:00:00 2001 From: Daniel Axelrod Date: Sun, 21 May 2017 16:10:51 -0400 Subject: [PATCH 158/702] [6.5] Add no-eval eslint rule to docs Add reference to the eslint `no-eval` rule to the README. This rule is already set to `error` in best-practices.js in eslint-airbnb-config-base. --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index b902d4ddd8..2a851fae40 100644 --- a/README.md +++ b/README.md @@ -592,7 +592,7 @@ Other Style Guides ``` - - [6.4](#strings--eval) Never use `eval()` on a string, it opens too many vulnerabilities. + - [6.4](#strings--eval) Never use `eval()` on a string, it opens too many vulnerabilities. eslint: [`no-eval`](http://eslint.org/docs/rules/no-eval) - [6.5](#strings--escaping) Do not unnecessarily escape characters in strings. eslint: [`no-useless-escape`](http://eslint.org/docs/rules/no-useless-escape) From f3c9639abe26bd03339f13dc1ab21868399c5beb Mon Sep 17 00:00:00 2001 From: Ken Powers Date: Wed, 24 May 2017 15:43:56 -0400 Subject: [PATCH 159/702] [eslint config] [base] [patch] Allow jsx extensions for test files --- packages/eslint-config-airbnb-base/rules/imports.js | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/packages/eslint-config-airbnb-base/rules/imports.js b/packages/eslint-config-airbnb-base/rules/imports.js index b081b59b6b..3b6c6cef60 100644 --- a/packages/eslint-config-airbnb-base/rules/imports.js +++ b/packages/eslint-config-airbnb-base/rules/imports.js @@ -73,10 +73,9 @@ module.exports = { 'tests/**', // also common npm pattern 'spec/**', // mocha, rspec-like pattern '**/__tests__/**', // jest pattern - 'test.js', // repos with a single test file - 'test-*.js', // repos with multiple top-level test files - '**/*.test.js', // tests where the extension denotes that it is a test - '**/*.spec.js', // tests where the extension denotes that it is a test + 'test.{js,jsx}', // repos with a single test file + 'test-*.{js,jsx}', // repos with multiple top-level test files + '**/*.{test,spec}.{js,jsx}', // tests where the extension denotes that it is a test '**/webpack.config.js', // webpack config '**/webpack.config.*.js', // webpack config '**/rollup.config.js', // rollup config From ac6de2fdb8c185597998aa4bf1cc35358d4a3d28 Mon Sep 17 00:00:00 2001 From: Joe Lencioni Date: Fri, 2 Jun 2017 12:05:41 -0700 Subject: [PATCH 160/702] Bump copyright year 2016 -> 2017 in license --- LICENSE.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/LICENSE.md b/LICENSE.md index 87081c1339..2867dece2b 100644 --- a/LICENSE.md +++ b/LICENSE.md @@ -1,6 +1,6 @@ MIT License -Copyright (c) 2016 Airbnb +Copyright (c) 2017 Airbnb Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal From 98f2224ec2f4378028cbb61a62dbbaa44a2fcc56 Mon Sep 17 00:00:00 2001 From: Daniel Axelrod Date: Fri, 2 Jun 2017 17:10:16 +0000 Subject: [PATCH 161/702] Add linting for Markdown prose Codify existing practices for writing Markdown in style guides and enforce them via Markdownlint. A new npm script "lint" in the top level package.json runs before tests or as the first step of the "travis" script. Only modify documents in cases where they had bugs or isolated cases of inconsistency: README.md: 10: MD007 Unordered list indentation Inconsistent with all other top level lists README.md: 10: MD032 Lists should be surrounded by blank lines Some Markdown parsers don't handle this correctly README.md: 3156-3161: MD005 Inconsistent indentation for list items at the same level Bug, looks like it's intended to be another list level but GitHub renders it at the same level as the "No but seriously" README.md & css-in-javascript/README.md: throughout: MD012 Multiple consecutive blank lines README.md: throughout: MD004 Unordered list style Some nested lists used plusses, now everything consistently uses dashes. --- README.md | 85 +++++++------------- css-in-javascript/README.md | 1 - linters/.markdownlint.json | 154 ++++++++++++++++++++++++++++++++++++ package.json | 8 +- 4 files changed, 190 insertions(+), 58 deletions(-) create mode 100644 linters/.markdownlint.json diff --git a/README.md b/README.md index 2a851fae40..00742a0855 100644 --- a/README.md +++ b/README.md @@ -7,11 +7,12 @@ [![Gitter](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/airbnb/javascript?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge) Other Style Guides - - [ES5 (Deprecated)](https://github.com/airbnb/javascript/tree/es5-deprecated/es5) - - [React](react/) - - [CSS-in-JavaScript](css-in-javascript/) - - [CSS & Sass](https://github.com/airbnb/css) - - [Ruby](https://github.com/airbnb/ruby) + + - [ES5 (Deprecated)](https://github.com/airbnb/javascript/tree/es5-deprecated/es5) + - [React](react/) + - [CSS-in-JavaScript](css-in-javascript/) + - [CSS & Sass](https://github.com/airbnb/css) + - [Ruby](https://github.com/airbnb/ruby) ## Table of Contents @@ -58,11 +59,11 @@ Other Style Guides - [1.1](#types--primitives) **Primitives**: When you access a primitive type you work directly on its value. - + `string` - + `number` - + `boolean` - + `null` - + `undefined` + - `string` + - `number` + - `boolean` + - `null` + - `undefined` ```javascript const foo = 1; @@ -76,9 +77,9 @@ Other Style Guides - [1.2](#types--complex) **Complex**: When you access a complex type you work on a reference to its value. - + `object` - + `array` - + `function` + - `object` + - `array` + - `function` ```javascript const foo = [1, 2]; @@ -524,7 +525,6 @@ Other Style Guides const { left, top } = processInput(input); ``` - **[⬆ back to top](#table-of-contents)** ## Strings @@ -610,7 +610,6 @@ Other Style Guides **[⬆ back to top](#table-of-contents)** - ## Functions @@ -1016,7 +1015,6 @@ Other Style Guides **[⬆ back to top](#table-of-contents)** - ## Classes & Constructors @@ -1035,7 +1033,6 @@ Other Style Guides return value; }; - // good class Queue { constructor(contents = []) { @@ -1110,7 +1107,6 @@ Other Style Guides .setHeight(20); ``` - - [9.4](#constructors--tostring) It's okay to write a custom toString() method, just make sure it works successfully and causes no side effects. @@ -1182,10 +1178,8 @@ Other Style Guides } ``` - **[⬆ back to top](#table-of-contents)** - ## Modules @@ -1449,7 +1443,6 @@ Other Style Guides **[⬆ back to top](#table-of-contents)** - ## Properties @@ -1486,7 +1479,6 @@ Other Style Guides **[⬆ back to top](#table-of-contents)** - ## Variables @@ -1656,7 +1648,6 @@ Other Style Guides **[⬆ back to top](#table-of-contents)** - ## Hoisting @@ -1756,7 +1747,6 @@ Other Style Guides **[⬆ back to top](#table-of-contents)** - ## Comparison Operators & Equality @@ -1765,12 +1755,12 @@ Other Style Guides - [15.2](#comparison--if) Conditional statements such as the `if` statement evaluate their expression using coercion with the `ToBoolean` abstract method and always follow these simple rules: - + **Objects** evaluate to **true** - + **Undefined** evaluates to **false** - + **Null** evaluates to **false** - + **Booleans** evaluate to **the value of the boolean** - + **Numbers** evaluate to **false** if **+0, -0, or NaN**, otherwise **true** - + **Strings** evaluate to **false** if an empty string `''`, otherwise **true** + - **Objects** evaluate to **true** + - **Undefined** evaluates to **false** + - **Null** evaluates to **false** + - **Booleans** evaluate to **the value of the boolean** + - **Numbers** evaluate to **false** if **+0, -0, or NaN**, otherwise **true** + - **Strings** evaluate to **false** if an empty string `''`, otherwise **true** ```javascript if ([0] && []) { @@ -1910,7 +1900,6 @@ Other Style Guides **[⬆ back to top](#table-of-contents)** - ## Blocks @@ -1960,10 +1949,8 @@ Other Style Guides } ``` - **[⬆ back to top](#table-of-contents)** - ## Control Statements @@ -2018,10 +2005,8 @@ Other Style Guides } ``` - **[⬆ back to top](#table-of-contents)** - ## Comments @@ -2162,7 +2147,6 @@ Other Style Guides **[⬆ back to top](#table-of-contents)** - ## Whitespace @@ -2624,7 +2608,6 @@ Other Style Guides **[⬆ back to top](#table-of-contents)** - ## Semicolons @@ -2654,7 +2637,6 @@ Other Style Guides **[⬆ back to top](#table-of-contents)** - ## Type Casting & Coercion @@ -2741,7 +2723,6 @@ Other Style Guides **[⬆ back to top](#table-of-contents)** - ## Naming Conventions @@ -2933,7 +2914,6 @@ Other Style Guides **[⬆ back to top](#table-of-contents)** - ## Accessors @@ -3003,7 +2983,6 @@ Other Style Guides **[⬆ back to top](#table-of-contents)** - ## Events @@ -3035,7 +3014,6 @@ Other Style Guides **[⬆ back to top](#table-of-contents)** - ## jQuery @@ -3105,7 +3083,6 @@ Other Style Guides **[⬆ back to top](#table-of-contents)** - ## ECMAScript 5 Compatibility @@ -3153,16 +3130,15 @@ Other Style Guides - [29.2](#testing--for-real) **No, but seriously**: - - Whichever testing framework you use, you should be writing tests! - - Strive to write many small pure functions, and minimize where mutations occur. - - Be cautious about stubs and mocks - they can make your tests more brittle. - - We primarily use [`mocha`](https://www.npmjs.com/package/mocha) at Airbnb. [`tape`](https://www.npmjs.com/package/tape) is also used occasionally for small, separate modules. - - 100% test coverage is a good goal to strive for, even if it's not always practical to reach it. - - Whenever you fix a bug, _write a regression test_. A bug fixed without a regression test is almost certainly going to break again in the future. + - Whichever testing framework you use, you should be writing tests! + - Strive to write many small pure functions, and minimize where mutations occur. + - Be cautious about stubs and mocks - they can make your tests more brittle. + - We primarily use [`mocha`](https://www.npmjs.com/package/mocha) at Airbnb. [`tape`](https://www.npmjs.com/package/tape) is also used occasionally for small, separate modules. + - 100% test coverage is a good goal to strive for, even if it's not always practical to reach it. + - Whenever you fix a bug, _write a regression test_. A bug fixed without a regression test is almost certainly going to break again in the future. **[⬆ back to top](#table-of-contents)** - ## Performance - [On Layout & Web Performance](https://www.kellegous.com/j/2013/01/26/layout-performance/) @@ -3177,7 +3153,6 @@ Other Style Guides **[⬆ back to top](#table-of-contents)** - ## Resources **Learning ES6** @@ -3194,9 +3169,9 @@ Other Style Guides **Tools** - Code Style Linters - + [ESlint](http://eslint.org/) - [Airbnb Style .eslintrc](https://github.com/airbnb/javascript/blob/master/linters/.eslintrc) - + [JSHint](http://jshint.com/) - [Airbnb Style .jshintrc](https://github.com/airbnb/javascript/blob/master/linters/.jshintrc) - + [JSCS](https://github.com/jscs-dev/node-jscs) - [Airbnb Style Preset](https://github.com/jscs-dev/node-jscs/blob/master/presets/airbnb.json) (Deprecated, please use [ESlint](https://github.com/airbnb/javascript/tree/master/packages/eslint-config-airbnb-base)) + - [ESlint](http://eslint.org/) - [Airbnb Style .eslintrc](https://github.com/airbnb/javascript/blob/master/linters/.eslintrc) + - [JSHint](http://jshint.com/) - [Airbnb Style .jshintrc](https://github.com/airbnb/javascript/blob/master/linters/.jshintrc) + - [JSCS](https://github.com/jscs-dev/node-jscs) - [Airbnb Style Preset](https://github.com/jscs-dev/node-jscs/blob/master/presets/airbnb.json) (Deprecated, please use [ESlint](https://github.com/airbnb/javascript/tree/master/packages/eslint-config-airbnb-base)) - Neutrino preset - [neutrino-preset-airbnb-base](https://neutrino.js.org/presets/neutrino-preset-airbnb-base/) **Other Style Guides** @@ -3257,7 +3232,6 @@ Other Style Guides - [JavaScript Air](https://javascriptair.com/) - [JavaScript Jabber](https://devchat.tv/js-jabber/) - **[⬆ back to top](#table-of-contents)** ## In the Wild @@ -3385,7 +3359,6 @@ Other Style Guides - [View Contributors](https://github.com/airbnb/javascript/graphs/contributors) - ## License (The MIT License) diff --git a/css-in-javascript/README.md b/css-in-javascript/README.md index 9c53bc3e0e..13099410a9 100644 --- a/css-in-javascript/README.md +++ b/css-in-javascript/README.md @@ -176,7 +176,6 @@ export default withStyles(() => styles)(MyComponent); - // good function MyComponent({ styles }) { return ( diff --git a/linters/.markdownlint.json b/linters/.markdownlint.json new file mode 100644 index 0000000000..e7a019fed8 --- /dev/null +++ b/linters/.markdownlint.json @@ -0,0 +1,154 @@ +{ + "comment": "Be explicit by listing every available rule. https://github.com/DavidAnson/markdownlint/blob/master/doc/Rules.md", + "comment": "Note that there will be numeric gaps, not every MD number is implemented in markdownlint.", + + "comment": "MD001: Header levels should only increment by one level at a time", + "header-increment": true, + + "comment": "MD002: First header should be a top level header", + "first-header-h1": true, + + "comment": "MD003: Header style: start with hashes", + "header-style": { + "style": "atx" + }, + + "comment": "MD004: Unordered list style", + "ul-style": { + "style": "dash" + }, + + "comment": "MD005: Consistent indentation for list items at the same level", + "list-indent": true, + + "comment": "MD006: Consider starting bulleted lists at the beginning of the line", + "ul-start-left": false, + + "comment": "MD007: Unordered list indentation: 2 spaces", + "ul-indent": { + "indent": 2 + }, + + "comment": "MD009: Disallow trailing spaces", + "no-trailing-spaces": { + "br-spaces": 0, + "comment": "Empty lines inside list items should not be indented", + "list_item_empty_lines": false + }, + + "comment": "MD010: No hard tabs, not even in code blocks", + "no-hard-tabs": { + "code_blocks": true + }, + + "comment": "MD011: Prevent reversed link syntax", + "no-reversed-links": true, + + "comment": "MD012: Disallow multiple consecutive blank lines", + "no-multiple-blanks": { + "maximum": 1 + }, + + "comment": "MD013: Line length", + "line-length": false, + + "comment": "MD014: Disallow dollar signs used before commands without showing output", + "commands-show-output": true, + + "comment": "MD018: Disallow space after hash on atx style header", + "no-missing-space-atx": true, + + "comment": "MD019: Dissalow multiple spaces after hash on atx style header", + "no-multiple-space-atx": true, + + "comment": "MD020: No space inside hashes on closed atx style header", + "no-missing-space-closed-atx": true, + + "comment": "MD021: Disallow multiple spaces inside hashes on closed atx style header", + "no-multiple-space-closed-atx": true, + + "comment": "MD022: Headers should be surrounded by blank lines", + "comment": "Some headers have preceeding HTML anchors. Unfortunate that we have to disable this, as it otherwise catches a real problem that trips up some Markdown renderers", + "blanks-around-headers": false, + + "comment": "MD023: Headers must start at the beginning of the line", + "header-start-left": true, + + "comment": "MD024: Disallow multiple headers with the same content", + "no-duplicate-header": true, + + "comment": "MD025: Disallow multiple top level headers in the same document", + "comment": "Gotta have a matching closing brace at the end", + "single-h1": false, + + "comment": "MD026: Disallow trailing punctuation in header", + "comment": "Gotta have a semicolon after the ending closing brace", + "no-trailing-punctuation": { + "punctuation" : ".,:!?" + }, + "comment": "MD027: Dissalow multiple spaces after blockquote symbol", + "no-multiple-space-blockquote": true, + + "comment": "MD028: Blank line inside blockquote", + "comment": "Some 'Why?' and 'Why not?' blocks are separated by a blank line", + "no-blanks-blockquote": false, + + "comment": "MD029: Ordered list item prefix", + "ol-prefix": { + "style": "one" + }, + + "comment": "MD030: Spaces after list markers", + "list-marker-space": { + "ul_single": 1, + "ol_single": 1, + "ul_multi": 1, + "ol_multi": 1 + }, + + "comment": "MD031: Fenced code blocks should be surrounded by blank lines", + "blanks-around-fences": true, + + "comment": "MD032: Lists should be surrounded by blank lines", + "comment": "Some lists have preceeding HTML anchors. Unfortunate that we have to disable this, as it otherwise catches a real problem that trips up some Markdown renderers", + "blanks-around-lists": false, + + "comment": "MD033: Disallow inline HTML", + "comment": "HTML is needed for explicit anchors", + "no-inline-html": false, + + "comment": "MD034: No bare URLs used", + "no-bare-urls": true, + + "comment": "MD035: Horizontal rule style", + "hr-style": { + "style": "consistent" + }, + + "comment": "MD036: Do not use emphasis instead of a header", + "no-emphasis-as-header": false, + + "comment": "MD037: Disallow spaces inside emphasis markers", + "no-space-in-emphasis": true, + + "comment": "MD038: Disallow spaces inside code span elements", + "no-space-in-code": true, + + "comment": "MD039: Disallow spaces inside link text", + "no-space-in-links": true, + + "comment": "MD040: Fenced code blocks should have a language specified", + "fenced-code-language": true, + + "comment": "MD041: First line in file should be a top level header", + "first-line-h1": true, + + "comment": "MD042: No empty links", + "no-empty-links": true, + + "comment": "MD043: Required header structure", + "required-headers": false, + + "comment": "MD044: Proper names should have the correct capitalization", + "proper-names": false +} diff --git a/package.json b/package.json index a977f26b3d..b50dd7a121 100644 --- a/package.json +++ b/package.json @@ -6,9 +6,12 @@ "preinstall": "npm run install:config && npm run install:config:base", "install:config": "cd packages/eslint-config-airbnb && npm prune && npm install", "install:config:base": "cd packages/eslint-config-airbnb-base && npm prune && npm install", + "lint": "markdownlint --config linters/.markdownlint.json README.md */README.md", + "pretest": "npm run --silent lint", "test": "npm run --silent test:config && npm run --silent test:config:base", "test:config": "cd packages/eslint-config-airbnb; npm test", "test:config:base": "cd packages/eslint-config-airbnb-base; npm test", + "pretravis": "npm run --silent lint", "travis": "npm run --silent travis:config && npm run --silent travis:config:base", "travis:config": "cd packages/eslint-config-airbnb; npm run travis", "travis:config:base": "cd packages/eslint-config-airbnb-base; npm run travis" @@ -31,5 +34,8 @@ "bugs": { "url": "https://github.com/airbnb/javascript/issues" }, - "homepage": "https://github.com/airbnb/javascript" + "homepage": "https://github.com/airbnb/javascript", + "devDependencies": { + "markdownlint-cli": "^0.3.1" + } } From 5ba31498feaec1c977008b62c2768f4ea5d498df Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Sat, 3 Jun 2017 23:37:10 -0700 Subject: [PATCH 162/702] Only apps should have lockfiles. --- .gitignore | 6 ++++++ .npmrc | 1 + packages/eslint-config-airbnb-base/.npmrc | 1 + packages/eslint-config-airbnb/.npmrc | 1 + 4 files changed, 9 insertions(+) create mode 100644 .npmrc create mode 120000 packages/eslint-config-airbnb-base/.npmrc create mode 120000 packages/eslint-config-airbnb/.npmrc diff --git a/.gitignore b/.gitignore index 3c3629e647..ac10dfe528 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,7 @@ +# gitignore + node_modules + +# Only apps should have lockfiles +yarn.lock +package-lock.json diff --git a/.npmrc b/.npmrc new file mode 100644 index 0000000000..43c97e719a --- /dev/null +++ b/.npmrc @@ -0,0 +1 @@ +package-lock=false diff --git a/packages/eslint-config-airbnb-base/.npmrc b/packages/eslint-config-airbnb-base/.npmrc new file mode 120000 index 0000000000..cba44bb384 --- /dev/null +++ b/packages/eslint-config-airbnb-base/.npmrc @@ -0,0 +1 @@ +../../.npmrc \ No newline at end of file diff --git a/packages/eslint-config-airbnb/.npmrc b/packages/eslint-config-airbnb/.npmrc new file mode 120000 index 0000000000..cba44bb384 --- /dev/null +++ b/packages/eslint-config-airbnb/.npmrc @@ -0,0 +1 @@ +../../.npmrc \ No newline at end of file From 1a38734d63a3624887de6c5ffa5602b4da9d3db4 Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Sat, 3 Jun 2017 23:38:22 -0700 Subject: [PATCH 163/702] [Tests] npm v4.6+ breaks in node < v1; npm 5+ breaks in node < v4 --- .travis.yml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index f492123d64..ba1b67ece5 100644 --- a/.travis.yml +++ b/.travis.yml @@ -9,8 +9,10 @@ env: - 'TEST_DIR=packages/eslint-config-airbnb-base' before_install: - 'cd $TEST_DIR' - - 'if [ "${TRAVIS_NODE_VERSION}" != "0.9" ]; then case "$(npm --version)" in 1.*) npm install -g npm@1.4.28 ;; 2.*) npm install -g npm@2 ;; esac ; fi' - - 'if [ "${TRAVIS_NODE_VERSION}" != "0.6" ] && [ "${TRAVIS_NODE_VERSION}" != "0.9" ]; then npm install -g npm; fi' + - 'if [ "${TRAVIS_NODE_VERSION}" = "0.6" ]; then npm install -g npm@1.3 ; elif [ "${TRAVIS_NODE_VERSION}" != "0.9" ]; then case "$(npm --version)" in 1.*) npm install -g npm@1.4.28 ;; 2.*) npm install -g npm@2 ;; esac ; fi' + - 'if [ "${TRAVIS_NODE_VERSION%${TRAVIS_NODE_VERSION#[0-9]}}" = "0" ] || [ "${TRAVIS_NODE_VERSION:0:4}" = "iojs" ]; then npm install -g npm@4.5 ; elif [ "${TRAVIS_NODE_VERSION}" != "0.6" ] && [ "${TRAVIS_NODE_VERSION}" != "0.9" ]; then npm install -g npm; fi' +install: + - 'if [ "${TRAVIS_NODE_VERSION}" = "0.6" ]; then nvm install 0.8 && npm install -g npm@1.3 && npm install -g npm@1.4.28 && npm install -g npm@2 && npm install && nvm use "${TRAVIS_NODE_VERSION}"; else npm install; fi;' script: - 'npm run travis' sudo: false From 721af5498fade08b3a5fe9e613aa6e33baa51e37 Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Sat, 3 Jun 2017 23:39:24 -0700 Subject: [PATCH 164/702] [Tests] on `node` `v8` --- .travis.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.travis.yml b/.travis.yml index ba1b67ece5..d28e6fd12e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,5 +1,6 @@ language: node_js node_js: + - "8" - "7" - "6" - "5" @@ -18,3 +19,6 @@ script: sudo: false matrix: fast_finish: true + allow_failures: + - node_js: "7" + - node_js: "5" From 00c9e52aec17b9a44fbf03494a931346e8f090de Mon Sep 17 00:00:00 2001 From: Radu Serbanescu Date: Wed, 7 Jun 2017 13:18:38 +0300 Subject: [PATCH 165/702] [eslint config] [base] [minor] Balanced spacing for inline block comments Fixes #1425. --- packages/eslint-config-airbnb-base/rules/style.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/eslint-config-airbnb-base/rules/style.js b/packages/eslint-config-airbnb-base/rules/style.js index 237f16899d..c617e57fd3 100644 --- a/packages/eslint-config-airbnb-base/rules/style.js +++ b/packages/eslint-config-airbnb-base/rules/style.js @@ -395,7 +395,7 @@ module.exports = { block: { exceptions: ['-', '+'], markers: ['=', '!'], // space here to support sprockets directives - balanced: false, + balanced: true, } }], From 1bbac742862720fd6905712ccf87cae45f327307 Mon Sep 17 00:00:00 2001 From: Gustavo Isensee Date: Tue, 13 Jun 2017 00:59:43 -0300 Subject: [PATCH 166/702] Updated "how to define propTypes..." Imported from new prop-types module. --- react/README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/react/README.md b/react/README.md index 16bf2420ac..b86f743f23 100644 --- a/react/README.md +++ b/react/README.md @@ -557,7 +557,8 @@ - How to define `propTypes`, `defaultProps`, `contextTypes`, etc... ```jsx - import React, { PropTypes } from 'react'; + import React from 'react'; + import PropTypes from 'prop-types'; const propTypes = { id: PropTypes.number.isRequired, From fd8cbec8e0b312dcf31a579fe3b1e7098ae0bfe7 Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Tue, 13 Jun 2017 01:06:34 -0700 Subject: [PATCH 167/702] [guide] change straight quotes to curly quotes --- README.md | 38 +++++++++++++++++++------------------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/README.md b/README.md index 00742a0855..69a7b9982f 100644 --- a/README.md +++ b/README.md @@ -227,7 +227,7 @@ Other Style Guides - [3.5](#objects--grouped-shorthand) Group your shorthand properties at the beginning of your object declaration. - > Why? It's easier to tell which properties are using the shorthand. + > Why? It’s easier to tell which properties are using the shorthand. ```javascript const anakinSkywalker = 'Anakin Skywalker'; @@ -369,7 +369,7 @@ Other Style Guides ``` - - [4.5](#arrays--callback-return) Use return statements in array method callbacks. It's ok to omit the return if the function body consists of a single statement following [8.2](#arrows--implicit-return). eslint: [`array-callback-return`](http://eslint.org/docs/rules/array-callback-return) + - [4.5](#arrays--callback-return) Use return statements in array method callbacks. It’s ok to omit the return if the function body consists of a single statement following [8.2](#arrows--implicit-return). eslint: [`array-callback-return`](http://eslint.org/docs/rules/array-callback-return) ```javascript // good @@ -615,7 +615,7 @@ Other Style Guides - [7.1](#functions--declarations) Use named function expressions instead of function declarations. eslint: [`func-style`](http://eslint.org/docs/rules/func-style) jscs: [`disallowFunctionDeclarations`](http://jscs.info/rule/disallowFunctionDeclarations) - > Why? Function declarations are hoisted, which means that it’s easy - too easy - to reference the function before it is defined in the file. This harms readability and maintainability. If you find that a function’s definition is large or complex enough that it is interfering with understanding the rest of the file, then perhaps it’s time to extract it to its own module! Don’t forget to name the expression - anonymous functions can make it harder to locate the problem in an Error's call stack. ([Discussion](https://github.com/airbnb/javascript/issues/794)) + > Why? Function declarations are hoisted, which means that it’s easy - too easy - to reference the function before it is defined in the file. This harms readability and maintainability. If you find that a function’s definition is large or complex enough that it is interfering with understanding the rest of the file, then perhaps it’s time to extract it to its own module! Don’t forget to name the expression - anonymous functions can make it harder to locate the problem in an Error’s call stack. ([Discussion](https://github.com/airbnb/javascript/issues/794)) ```javascript // bad @@ -650,7 +650,7 @@ Other Style Guides - [7.3](#functions--in-blocks) Never declare a function in a non-function block (`if`, `while`, etc). Assign the function to a variable instead. Browsers will allow you to do it, but they all interpret it differently, which is bad news bears. eslint: [`no-loop-func`](http://eslint.org/docs/rules/no-loop-func.html) - - [7.4](#functions--note-on-blocks) **Note:** ECMA-262 defines a `block` as a list of statements. A function declaration is not a statement. [Read ECMA-262's note on this issue](http://www.ecma-international.org/publications/files/ECMA-ST/Ecma-262.pdf#page=97). + - [7.4](#functions--note-on-blocks) **Note:** ECMA-262 defines a `block` as a list of statements. A function declaration is not a statement. [Read ECMA-262’s note on this issue](http://www.ecma-international.org/publications/files/ECMA-ST/Ecma-262.pdf#page=97). ```javascript // bad @@ -838,7 +838,7 @@ Other Style Guides - [7.14](#functions--spread-vs-apply) Prefer the use of the spread operator `...` to call variadic functions. eslint: [`prefer-spread`](http://eslint.org/docs/rules/prefer-spread) - > Why? It's cleaner, you don't need to supply a context, and you can not easily compose `new` with `apply`. + > Why? It’s cleaner, you don't need to supply a context, and you can not easily compose `new` with `apply`. ```javascript // bad @@ -964,7 +964,7 @@ Other Style Guides ``` - - [8.4](#arrows--one-arg-parens) If your function takes a single argument and doesn’t use braces, omit the parentheses. Otherwise, always include parentheses around arguments for clarity and consistency. Note: it is also acceptable to always use parentheses, in which case use the ["always" option](http://eslint.org/docs/rules/arrow-parens#always) for eslint or do not include [`disallowParenthesesAroundArrowParam`](http://jscs.info/rule/disallowParenthesesAroundArrowParam) for jscs. eslint: [`arrow-parens`](http://eslint.org/docs/rules/arrow-parens.html) jscs: [`disallowParenthesesAroundArrowParam`](http://jscs.info/rule/disallowParenthesesAroundArrowParam) + - [8.4](#arrows--one-arg-parens) If your function takes a single argument and doesn’t use braces, omit the parentheses. Otherwise, always include parentheses around arguments for clarity and consistency. Note: it is also acceptable to always use parentheses, in which case use the [“always” option](http://eslint.org/docs/rules/arrow-parens#always) for eslint or do not include [`disallowParenthesesAroundArrowParam`](http://jscs.info/rule/disallowParenthesesAroundArrowParam) for jscs. eslint: [`arrow-parens`](http://eslint.org/docs/rules/arrow-parens.html) jscs: [`disallowParenthesesAroundArrowParam`](http://jscs.info/rule/disallowParenthesesAroundArrowParam) > Why? Less visual clutter. @@ -1108,7 +1108,7 @@ Other Style Guides ``` - - [9.4](#constructors--tostring) It's okay to write a custom toString() method, just make sure it works successfully and causes no side effects. + - [9.4](#constructors--tostring) It’s okay to write a custom toString() method, just make sure it works successfully and causes no side effects. ```javascript class Jedi { @@ -1185,7 +1185,7 @@ Other Style Guides - [10.1](#modules--use-them) Always use modules (`import`/`export`) over a non-standard module system. You can always transpile to your preferred module system. - > Why? Modules are the future, let's start using the future now. + > Why? Modules are the future, let’s start using the future now. ```javascript // bad @@ -1336,7 +1336,7 @@ Other Style Guides ## Iterators and Generators - - [11.1](#iterators--nope) Don't use iterators. Prefer JavaScript's higher-order functions instead of loops like `for-in` or `for-of`. eslint: [`no-iterator`](http://eslint.org/docs/rules/no-iterator.html) [`no-restricted-syntax`](http://eslint.org/docs/rules/no-restricted-syntax) + - [11.1](#iterators--nope) Don't use iterators. Prefer JavaScript’s higher-order functions instead of loops like `for-in` or `for-of`. eslint: [`no-iterator`](http://eslint.org/docs/rules/no-iterator.html) [`no-restricted-syntax`](http://eslint.org/docs/rules/no-restricted-syntax) > Why? This enforces our immutable rule. Dealing with pure functions that return values is easier to reason about than side effects. @@ -1495,7 +1495,7 @@ Other Style Guides - [13.2](#variables--one-const) Use one `const` or `let` declaration per variable. eslint: [`one-var`](http://eslint.org/docs/rules/one-var.html) jscs: [`disallowMultipleVarDecl`](http://jscs.info/rule/disallowMultipleVarDecl) - > Why? It's easier to add new variable declarations this way, and you never have to worry about swapping out a `;` for a `,` or introducing punctuation-only diffs. You can also step through each declaration with the debugger, instead of jumping through all of them at once. + > Why? It’s easier to add new variable declarations this way, and you never have to worry about swapping out a `;` for a `,` or introducing punctuation-only diffs. You can also step through each declaration with the debugger, instead of jumping through all of them at once. ```javascript // bad @@ -1651,7 +1651,7 @@ Other Style Guides ## Hoisting - - [14.1](#hoisting--about) `var` declarations get hoisted to the top of their scope, their assignment does not. `const` and `let` declarations are blessed with a new concept called [Temporal Dead Zones (TDZ)](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/let#Temporal_dead_zone_and_errors_with_let). It's important to know why [typeof is no longer safe](http://es-discourse.com/t/why-typeof-is-no-longer-safe/15). + - [14.1](#hoisting--about) `var` declarations get hoisted to the top of their scope, their assignment does not. `const` and `let` declarations are blessed with a new concept called [Temporal Dead Zones (TDZ)](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/let#Temporal_dead_zone_and_errors_with_let). It’s important to know why [typeof is no longer safe](http://es-discourse.com/t/why-typeof-is-no-longer-safe/15). ```javascript // we know this wouldn't work (assuming there @@ -1928,7 +1928,7 @@ Other Style Guides ``` - - [16.2](#blocks--cuddled-elses) If you're using multi-line blocks with `if` and `else`, put `else` on the same line as your `if` block's closing brace. eslint: [`brace-style`](http://eslint.org/docs/rules/brace-style.html) jscs: [`disallowNewlineBeforeBlockStatements`](http://jscs.info/rule/disallowNewlineBeforeBlockStatements) + - [16.2](#blocks--cuddled-elses) If you're using multi-line blocks with `if` and `else`, put `else` on the same line as your `if` block’s closing brace. eslint: [`brace-style`](http://eslint.org/docs/rules/brace-style.html) jscs: [`disallowNewlineBeforeBlockStatements`](http://jscs.info/rule/disallowNewlineBeforeBlockStatements) ```javascript // bad @@ -1954,7 +1954,7 @@ Other Style Guides ## Control Statements - - [17.1](#control-statements) In case your control statement (`if`, `while` etc.) gets too long or exceeds the maximum line length, each (grouped) condition could be put into a new line. It's up to you whether the logical operator should begin or end the line. + - [17.1](#control-statements) In case your control statement (`if`, `while` etc.) gets too long or exceeds the maximum line length, each (grouped) condition could be put into a new line. It’s up to you whether the logical operator should begin or end the line. ```javascript // bad @@ -2040,7 +2040,7 @@ Other Style Guides ``` - - [18.2](#comments--singleline) Use `//` for single line comments. Place single line comments on a newline above the subject of the comment. Put an empty line before the comment unless it's on the first line of a block. + - [18.2](#comments--singleline) Use `//` for single line comments. Place single line comments on a newline above the subject of the comment. Put an empty line before the comment unless it’s on the first line of a block. ```javascript // bad @@ -2859,7 +2859,7 @@ Other Style Guides ``` - - [23.7](#naming--camelCase-default-export) Use camelCase when you export-default a function. Your filename should be identical to your function's name. + - [23.7](#naming--camelCase-default-export) Use camelCase when you export-default a function. Your filename should be identical to your function’s name. ```javascript function makeStyleGuide() { @@ -2962,7 +2962,7 @@ Other Style Guides ``` - - [24.4](#accessors--consistent) It's okay to create get() and set() functions, but be consistent. + - [24.4](#accessors--consistent) It’s okay to create get() and set() functions, but be consistent. ```javascript class Jedi { @@ -3086,7 +3086,7 @@ Other Style Guides ## ECMAScript 5 Compatibility - - [27.1](#es5-compat--kangax) Refer to [Kangax](https://twitter.com/kangax/)'s ES5 [compatibility table](https://kangax.github.io/es5-compat-table/). + - [27.1](#es5-compat--kangax) Refer to [Kangax](https://twitter.com/kangax/)’s ES5 [compatibility table](https://kangax.github.io/es5-compat-table/). **[⬆ back to top](#table-of-contents)** @@ -3134,7 +3134,7 @@ Other Style Guides - Strive to write many small pure functions, and minimize where mutations occur. - Be cautious about stubs and mocks - they can make your tests more brittle. - We primarily use [`mocha`](https://www.npmjs.com/package/mocha) at Airbnb. [`tape`](https://www.npmjs.com/package/tape) is also used occasionally for small, separate modules. - - 100% test coverage is a good goal to strive for, even if it's not always practical to reach it. + - 100% test coverage is a good goal to strive for, even if it’s not always practical to reach it. - Whenever you fix a bug, _write a regression test_. A bug fixed without a regression test is almost certainly going to break again in the future. **[⬆ back to top](#table-of-contents)** @@ -3388,6 +3388,6 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ## Amendments -We encourage you to fork this guide and change the rules to fit your team's style guide. Below, you may list some amendments to the style guide. This allows you to periodically update your style guide without having to deal with merge conflicts. +We encourage you to fork this guide and change the rules to fit your team’s style guide. Below, you may list some amendments to the style guide. This allows you to periodically update your style guide without having to deal with merge conflicts. # }; From c43fc749c4213e4574a4b4a3d0fe8784d5cd5b5e Mon Sep 17 00:00:00 2001 From: Fernando Pasik Date: Tue, 13 Jun 2017 22:06:55 +0100 Subject: [PATCH 168/702] [eslint config] [docs] Remove TODO in prefer-reflect as it's deprecated --- packages/eslint-config-airbnb-base/rules/es6.js | 1 - 1 file changed, 1 deletion(-) diff --git a/packages/eslint-config-airbnb-base/rules/es6.js b/packages/eslint-config-airbnb-base/rules/es6.js index 8b7ac24d14..14d777e640 100644 --- a/packages/eslint-config-airbnb-base/rules/es6.js +++ b/packages/eslint-config-airbnb-base/rules/es6.js @@ -124,7 +124,6 @@ module.exports = { // suggest using Reflect methods where applicable // http://eslint.org/docs/rules/prefer-reflect - // TODO: enable? 'prefer-reflect': 'off', // use rest parameters instead of arguments From 4499ee0094239c1e02506ee30c2a3945aa032591 Mon Sep 17 00:00:00 2001 From: Felipe Vargas Date: Mon, 12 Jun 2017 15:41:11 -0700 Subject: [PATCH 169/702] [guide] No arrow function implicit return with side effects --- README.md | 30 ++++++++++++++++++++++++++---- 1 file changed, 26 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 69a7b9982f..8ff1a8f2ce 100644 --- a/README.md +++ b/README.md @@ -369,7 +369,7 @@ Other Style Guides ``` - - [4.5](#arrays--callback-return) Use return statements in array method callbacks. It’s ok to omit the return if the function body consists of a single statement following [8.2](#arrows--implicit-return). eslint: [`array-callback-return`](http://eslint.org/docs/rules/array-callback-return) + - [4.5](#arrays--callback-return) Use return statements in array method callbacks. It’s ok to omit the return if the function body consists of a single statement returning an expression without side effects, following [8.2](#arrows--implicit-return). eslint: [`array-callback-return`](http://eslint.org/docs/rules/array-callback-return) ```javascript // good @@ -915,7 +915,7 @@ Other Style Guides ``` - - [8.2](#arrows--implicit-return) If the function body consists of a single expression, omit the braces and use the implicit return. Otherwise, keep the braces and use a `return` statement. eslint: [`arrow-parens`](http://eslint.org/docs/rules/arrow-parens.html), [`arrow-body-style`](http://eslint.org/docs/rules/arrow-body-style.html) jscs: [`disallowParenthesesAroundArrowParam`](http://jscs.info/rule/disallowParenthesesAroundArrowParam), [`requireShorthandArrowFunctions`](http://jscs.info/rule/requireShorthandArrowFunctions) + - [8.2](#arrows--implicit-return) If the function body consists of a single statement returning an [expression](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Expressions_and_Operators#Expressions) without side effects, omit the braces and use the implicit return. Otherwise, keep the braces and use a `return` statement. eslint: [`arrow-parens`](http://eslint.org/docs/rules/arrow-parens.html), [`arrow-body-style`](http://eslint.org/docs/rules/arrow-body-style.html) jscs: [`disallowParenthesesAroundArrowParam`](http://jscs.info/rule/disallowParenthesesAroundArrowParam), [`requireShorthandArrowFunctions`](http://jscs.info/rule/requireShorthandArrowFunctions) > Why? Syntactic sugar. It reads well when multiple functions are chained together. @@ -939,6 +939,24 @@ Other Style Guides [1, 2, 3].map((number, index) => ({ [index]: number, })); + + // No implicit return with side effects + function foo(callback) { + const val = callback(); + if (val === true) { + // Do something if callback returns true + } + } + + let bool = false; + + // bad + foo(() => bool = true); + + // good + foo(() => { + bool = true; + } ``` @@ -1354,7 +1372,9 @@ Other Style Guides // good let sum = 0; - numbers.forEach(num => sum += num); + numbers.forEach((num) => { + sum += num; + ); sum === 15; // best (use the functional force) @@ -1369,7 +1389,9 @@ Other Style Guides // good const increasedByOne = []; - numbers.forEach(num => increasedByOne.push(num + 1)); + numbers.forEach((num) => { + increasedByOne.push(num + 1); + ); // best (keeping it functional) const increasedByOne = numbers.map(num => num + 1); From cd4ec6245ef0b3d3fcb9bbef89bf34ea0ec0c7fb Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Wed, 14 Jun 2017 12:09:46 -0700 Subject: [PATCH 170/702] [guide] change more straight quotes to curly quotes --- README.md | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/README.md b/README.md index 8ff1a8f2ce..21e17fae7e 100644 --- a/README.md +++ b/README.md @@ -97,7 +97,7 @@ Other Style Guides - [2.1](#references--prefer-const) Use `const` for all of your references; avoid using `var`. eslint: [`prefer-const`](http://eslint.org/docs/rules/prefer-const.html), [`no-const-assign`](http://eslint.org/docs/rules/no-const-assign.html) - > Why? This ensures that you can't reassign your references, which can lead to bugs and difficult to comprehend code. + > Why? This ensures that you can’t reassign your references, which can lead to bugs and difficult to comprehend code. ```javascript // bad @@ -708,7 +708,7 @@ Other Style Guides ```javascript // really bad function handleThings(opts) { - // No! We shouldn't mutate function arguments. + // No! We shouldn’t mutate function arguments. // Double bad: if opts is falsy it'll be set to an object which may // be what you want but it can introduce subtle bugs. opts = opts || {}; @@ -838,7 +838,7 @@ Other Style Guides - [7.14](#functions--spread-vs-apply) Prefer the use of the spread operator `...` to call variadic functions. eslint: [`prefer-spread`](http://eslint.org/docs/rules/prefer-spread) - > Why? It’s cleaner, you don't need to supply a context, and you can not easily compose `new` with `apply`. + > Why? It’s cleaner, you don’t need to supply a context, and you can not easily compose `new` with `apply`. ```javascript // bad @@ -1354,7 +1354,7 @@ Other Style Guides ## Iterators and Generators - - [11.1](#iterators--nope) Don't use iterators. Prefer JavaScript’s higher-order functions instead of loops like `for-in` or `for-of`. eslint: [`no-iterator`](http://eslint.org/docs/rules/no-iterator.html) [`no-restricted-syntax`](http://eslint.org/docs/rules/no-restricted-syntax) + - [11.1](#iterators--nope) Don’t use iterators. Prefer JavaScript’s higher-order functions instead of loops like `for-in` or `for-of`. eslint: [`no-iterator`](http://eslint.org/docs/rules/no-iterator.html) [`no-restricted-syntax`](http://eslint.org/docs/rules/no-restricted-syntax) > Why? This enforces our immutable rule. Dealing with pure functions that return values is easier to reason about than side effects. @@ -1398,9 +1398,9 @@ Other Style Guides ``` - - [11.2](#generators--nope) Don't use generators for now. + - [11.2](#generators--nope) Don’t use generators for now. - > Why? They don't transpile well to ES5. + > Why? They don’t transpile well to ES5. - [11.3](#generators--spacing) If you must use generators, or if you disregard [our advice](#generators--nope), make sure their function signature is spaced properly. eslint: [`generator-star-spacing`](http://eslint.org/docs/rules/generator-star-spacing) @@ -1602,7 +1602,7 @@ Other Style Guides } ``` - - [13.5](#variables--no-chain-assignment) Don't chain variable assignments. + - [13.5](#variables--no-chain-assignment) Don’t chain variable assignments. > Why? Chaining variable assignments creates implicit global variables. @@ -1676,7 +1676,7 @@ Other Style Guides - [14.1](#hoisting--about) `var` declarations get hoisted to the top of their scope, their assignment does not. `const` and `let` declarations are blessed with a new concept called [Temporal Dead Zones (TDZ)](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/let#Temporal_dead_zone_and_errors_with_let). It’s important to know why [typeof is no longer safe](http://es-discourse.com/t/why-typeof-is-no-longer-safe/15). ```javascript - // we know this wouldn't work (assuming there + // we know this wouldn’t work (assuming there // is no notDefined global variable) function example() { console.log(notDefined); // => throws a ReferenceError @@ -2147,7 +2147,7 @@ Other Style Guides constructor() { super(); - // FIXME: shouldn't use a global here + // FIXME: shouldn’t use a global here total = 0; } } @@ -2535,7 +2535,7 @@ Other Style Guides - [20.2](#commas--dangling) Additional trailing comma: **Yup.** eslint: [`comma-dangle`](http://eslint.org/docs/rules/comma-dangle.html) jscs: [`requireTrailingComma`](http://jscs.info/rule/requireTrailingComma) - > Why? This leads to cleaner git diffs. Also, transpilers like Babel will remove the additional trailing comma in the transpiled code which means you don't have to worry about the [trailing comma problem](https://github.com/airbnb/javascript/blob/es5-deprecated/es5/README.md#commas) in legacy browsers. + > Why? This leads to cleaner git diffs. Also, transpilers like Babel will remove the additional trailing comma in the transpiled code which means you don’t have to worry about the [trailing comma problem](https://github.com/airbnb/javascript/blob/es5-deprecated/es5/README.md#commas) in legacy browsers. ```diff // bad - git diff without trailing comma @@ -2674,7 +2674,7 @@ Other Style Guides const totalScore = this.reviewScore + ''; // invokes this.reviewScore.valueOf() // bad - const totalScore = this.reviewScore.toString(); // isn't guaranteed to return a string + const totalScore = this.reviewScore.toString(); // isn’t guaranteed to return a string // good const totalScore = String(this.reviewScore); @@ -2804,7 +2804,7 @@ Other Style Guides - [23.4](#naming--leading-underscore) Do not use trailing or leading underscores. eslint: [`no-underscore-dangle`](http://eslint.org/docs/rules/no-underscore-dangle.html) jscs: [`disallowDanglingUnderscores`](http://jscs.info/rule/disallowDanglingUnderscores) - > Why? JavaScript does not have the concept of privacy in terms of properties or methods. Although a leading underscore is a common convention to mean “private”, in fact, these properties are fully public, and as such, are part of your public API contract. This convention might lead developers to wrongly think that a change won't count as breaking, or that tests aren't needed. tl;dr: if you want something to be “private”, it must not be observably present. + > Why? JavaScript does not have the concept of privacy in terms of properties or methods. Although a leading underscore is a common convention to mean “private”, in fact, these properties are fully public, and as such, are part of your public API contract. This convention might lead developers to wrongly think that a change won’t count as breaking, or that tests aren’t needed. tl;dr: if you want something to be “private”, it must not be observably present. ```javascript // bad @@ -2817,7 +2817,7 @@ Other Style Guides ``` - - [23.5](#naming--self-this) Don't save references to `this`. Use arrow functions or [Function#bind](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/bind). jscs: [`disallowNodeTypes`](http://jscs.info/rule/disallowNodeTypes) + - [23.5](#naming--self-this) Don’t save references to `this`. Use arrow functions or [Function#bind](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/bind). jscs: [`disallowNodeTypes`](http://jscs.info/rule/disallowNodeTypes) ```javascript // bad @@ -3234,7 +3234,7 @@ Other Style Guides - [Third Party JavaScript](https://www.manning.com/books/third-party-javascript) - Ben Vinegar and Anton Kovalyov - [Effective JavaScript: 68 Specific Ways to Harness the Power of JavaScript](http://amzn.com/0321812182) - David Herman - [Eloquent JavaScript](http://eloquentjavascript.net/) - Marijn Haverbeke - - [You Don't Know JS: ES6 & Beyond](http://shop.oreilly.com/product/0636920033769.do) - Kyle Simpson + - [You Don’t Know JS: ES6 & Beyond](http://shop.oreilly.com/product/0636920033769.do) - Kyle Simpson **Blogs** From 7bb8c9f905b4bc34e57ef39002cbfb32818cd003 Mon Sep 17 00:00:00 2001 From: Ben Schroeder Date: Wed, 14 Jun 2017 09:13:43 -0400 Subject: [PATCH 171/702] [guide] Fix iterator code example error The first "good" example was missing a closing bracket (line 1377). --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 21e17fae7e..6a64de53af 100644 --- a/README.md +++ b/README.md @@ -1374,7 +1374,7 @@ Other Style Guides let sum = 0; numbers.forEach((num) => { sum += num; - ); + }); sum === 15; // best (use the functional force) From 0c9e22e039d7a1ad8a522768991db2ad431d3d69 Mon Sep 17 00:00:00 2001 From: Rahul Gandhi Date: Sat, 17 Jun 2017 18:18:40 +0530 Subject: [PATCH 172/702] [guide] replacing undefined with ReferenceError Fixes #1457 --- README.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 6a64de53af..06347f5708 100644 --- a/README.md +++ b/README.md @@ -1616,7 +1616,7 @@ Other Style Guides let a = b = c = 1; }()); - console.log(a); // undefined + console.log(a); // throws ReferenceError console.log(b); // 1 console.log(c); // 1 @@ -1627,9 +1627,9 @@ Other Style Guides let c = a; }()); - console.log(a); // undefined - console.log(b); // undefined - console.log(c); // undefined + console.log(a); // throws ReferenceError + console.log(b); // throws ReferenceError + console.log(c); // throws ReferenceError // the same applies for `const` ``` From 3a9e1c830f9141207322254fc83ec3efae7b790b Mon Sep 17 00:00:00 2001 From: elmehri Date: Thu, 15 Jun 2017 16:52:48 +0100 Subject: [PATCH 173/702] [eslint config] [base] [patch] Support Protractor config files in import/no-extraneous-dependencies --- packages/eslint-config-airbnb-base/rules/imports.js | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/eslint-config-airbnb-base/rules/imports.js b/packages/eslint-config-airbnb-base/rules/imports.js index 3b6c6cef60..ab324b79ca 100644 --- a/packages/eslint-config-airbnb-base/rules/imports.js +++ b/packages/eslint-config-airbnb-base/rules/imports.js @@ -83,6 +83,7 @@ module.exports = { '**/gulpfile.js', // gulp config '**/gulpfile.*.js', // gulp config '**/Gruntfile', // grunt config + '**/protractor.conf.*.js', // protractor config ], optionalDependencies: false, }], From 57ff032b0740ba2a46af4bc40cf5638a3e62a365 Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Sun, 18 Jun 2017 09:27:33 -0700 Subject: [PATCH 174/702] [eslint config] [base] [minor] `no-return-assign`: strengthen linting against returning assignments. --- packages/eslint-config-airbnb-base/rules/best-practices.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/eslint-config-airbnb-base/rules/best-practices.js b/packages/eslint-config-airbnb-base/rules/best-practices.js index c9f729c75f..3d97bb6e55 100644 --- a/packages/eslint-config-airbnb-base/rules/best-practices.js +++ b/packages/eslint-config-airbnb-base/rules/best-practices.js @@ -205,7 +205,7 @@ module.exports = { }], // disallow use of assignment in return statement - 'no-return-assign': 'error', + 'no-return-assign': ['error', 'always'], // disallow redundant `return await` 'no-return-await': 'error', From 4380284b05337f6e48798ff4fd76ab606d5adf94 Mon Sep 17 00:00:00 2001 From: Jason Ellis Date: Tue, 20 Jun 2017 09:37:19 -0500 Subject: [PATCH 175/702] [guide] Add missing close parenthesis and semicolon to section 8.2 --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 06347f5708..e59dc9b940 100644 --- a/README.md +++ b/README.md @@ -956,7 +956,7 @@ Other Style Guides // good foo(() => { bool = true; - } + }); ``` From cd720b4c7bededa4edda232e9e9e6b5e3b5a438d Mon Sep 17 00:00:00 2001 From: Dan Dascalescu Date: Thu, 22 Jun 2017 09:19:08 -0700 Subject: [PATCH 176/702] [eslint config] [*] [docs] add yarn instructions Fixes #1462. --- packages/eslint-config-airbnb-base/README.md | 8 +++++--- packages/eslint-config-airbnb/README.md | 4 +++- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/packages/eslint-config-airbnb-base/README.md b/packages/eslint-config-airbnb-base/README.md index e27f3f3431..968cec06cd 100644 --- a/packages/eslint-config-airbnb-base/README.md +++ b/packages/eslint-config-airbnb-base/README.md @@ -2,7 +2,7 @@ [![npm version](https://badge.fury.io/js/eslint-config-airbnb-base.svg)](http://badge.fury.io/js/eslint-config-airbnb-base) -This package provides Airbnb's base JS .eslintrc as an extensible shared config. +This package provides Airbnb's base JS .eslintrc (without React plugins) as an extensible shared config. ## Usage @@ -12,13 +12,15 @@ We export two ESLint configurations for your usage. Our default export contains all of our ESLint rules, including ECMAScript 6+. It requires `eslint` and `eslint-plugin-import`. +If you use yarn, run `yarn add --dev eslint-config-airbnb-base eslint-plugin-import`, or see below for npm instructions. + 1. Install the correct versions of each package, which are listed by the command: ```sh npm info "eslint-config-airbnb-base@latest" peerDependencies ``` - Linux/OSX users can simply run + Linux/OSX users can run ```sh ( export PKG=eslint-config-airbnb-base; @@ -45,7 +47,7 @@ Our default export contains all of our ESLint rules, including ECMAScript 6+. It npm install --save-dev eslint-config-airbnb-base eslint@^#.#.# eslint-plugin-import@^#.#.# ``` -2. Add `"extends": "airbnb-base"` to your .eslintrc +2. Add `"extends": "airbnb-base"` to your .eslintrc. ### eslint-config-airbnb-base/legacy diff --git a/packages/eslint-config-airbnb/README.md b/packages/eslint-config-airbnb/README.md index 173e5c324c..7996b4ac56 100644 --- a/packages/eslint-config-airbnb/README.md +++ b/packages/eslint-config-airbnb/README.md @@ -10,7 +10,9 @@ We export three ESLint configurations for your usage. ### eslint-config-airbnb -Our default export contains all of our ESLint rules, including ECMAScript 6+ and React. It requires `eslint`, `eslint-plugin-import`, `eslint-plugin-react`, and `eslint-plugin-jsx-a11y`. +Our default export contains all of our ESLint rules, including ECMAScript 6+ and React. It requires `eslint`, `eslint-plugin-import`, `eslint-plugin-react`, and `eslint-plugin-jsx-a11y`. If you don't need React, see [eslint-config-airbnb-base](https://npmjs.com/eslint-config-airbnb-base). + +If you use yarn, run `yarn add --dev eslint-config-airbnb-base eslint-plugin-import eslint-plugin-react eslint-plugin-jsx-a11`, and see below for npm instructions. 1. Install the correct versions of each package, which are listed by the command: From 2666db559dc0ef41887a1138cff4f59b3879892a Mon Sep 17 00:00:00 2001 From: Dan Dascalescu Date: Fri, 23 Jun 2017 22:16:35 -0700 Subject: [PATCH 177/702] Fix typo in a11y for yarn --- packages/eslint-config-airbnb/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/eslint-config-airbnb/README.md b/packages/eslint-config-airbnb/README.md index 7996b4ac56..a3a7c71340 100644 --- a/packages/eslint-config-airbnb/README.md +++ b/packages/eslint-config-airbnb/README.md @@ -12,7 +12,7 @@ We export three ESLint configurations for your usage. Our default export contains all of our ESLint rules, including ECMAScript 6+ and React. It requires `eslint`, `eslint-plugin-import`, `eslint-plugin-react`, and `eslint-plugin-jsx-a11y`. If you don't need React, see [eslint-config-airbnb-base](https://npmjs.com/eslint-config-airbnb-base). -If you use yarn, run `yarn add --dev eslint-config-airbnb-base eslint-plugin-import eslint-plugin-react eslint-plugin-jsx-a11`, and see below for npm instructions. +If you use yarn, run `yarn add --dev eslint-config-airbnb-base eslint-plugin-import eslint-plugin-react eslint-plugin-jsx-a11y`, and see below for npm instructions. 1. Install the correct versions of each package, which are listed by the command: From 84487061205285be7aa2e22a8ba704da4d99e6cc Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Tue, 4 Jul 2017 12:32:01 -0700 Subject: [PATCH 178/702] [eslint config] [deps] update `babel-preset-airbnb`, `eslint-find-rules`, `eslint-plugin-import`, `eslint-plugin-jsx-a11y`, `eslint-plugin-react`, `tape` --- packages/eslint-config-airbnb/package.json | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/packages/eslint-config-airbnb/package.json b/packages/eslint-config-airbnb/package.json index dd5c99a010..993b476495 100644 --- a/packages/eslint-config-airbnb/package.json +++ b/packages/eslint-config-airbnb/package.json @@ -49,24 +49,24 @@ "eslint-config-airbnb-base": "^11.2.0" }, "devDependencies": { - "babel-preset-airbnb": "^2.2.3", + "babel-preset-airbnb": "^2.4.0", "babel-tape-runner": "^2.0.1", "editorconfig-tools": "^0.1.1", "eslint": "^3.19.0", - "eslint-find-rules": "^1.14.3", - "eslint-plugin-import": "^2.2.0", - "eslint-plugin-jsx-a11y": "^5.0.3", - "eslint-plugin-react": "^7.0.1", + "eslint-find-rules": "^3.1.1", + "eslint-plugin-import": "^2.6.1", + "eslint-plugin-jsx-a11y": "^5.1.1", + "eslint-plugin-react": "^7.1.0", "in-publish": "^2.0.0", "react": ">= 0.13.0", "safe-publish-latest": "^1.1.1", - "tape": "^4.6.3" + "tape": "^4.7.0" }, "peerDependencies": { "eslint": "^3.19.0", - "eslint-plugin-jsx-a11y": "^5.0.3", - "eslint-plugin-import": "^2.2.0", - "eslint-plugin-react": "^7.0.1" + "eslint-plugin-jsx-a11y": "^5.1.1", + "eslint-plugin-import": "^2.6.1", + "eslint-plugin-react": "^7.1.0" }, "engines": { "node": ">= 4" From c68fa632624f088b4bbe81192a50554b0c6af970 Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Tue, 4 Jul 2017 12:36:18 -0700 Subject: [PATCH 179/702] [eslint config] v15.0.2 --- packages/eslint-config-airbnb/CHANGELOG.md | 5 +++++ packages/eslint-config-airbnb/package.json | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/packages/eslint-config-airbnb/CHANGELOG.md b/packages/eslint-config-airbnb/CHANGELOG.md index 4900db6c74..ca35490985 100644 --- a/packages/eslint-config-airbnb/CHANGELOG.md +++ b/packages/eslint-config-airbnb/CHANGELOG.md @@ -1,3 +1,8 @@ +15.0.2 / 2017-07-04 +================== +- [fix] jsx should be enabled via parserOptions, not via a root ecmaFeatures +- [deps] update `babel-preset-airbnb`, `eslint-find-rules`, `eslint-plugin-import`, `eslint-plugin-jsx-a11y`, `eslint-plugin-react`, `tape` + 15.0.1 / 2017-05-15 ================== - [fix] set default React version to 15.0 (#1415) diff --git a/packages/eslint-config-airbnb/package.json b/packages/eslint-config-airbnb/package.json index 993b476495..7d4f0b941e 100644 --- a/packages/eslint-config-airbnb/package.json +++ b/packages/eslint-config-airbnb/package.json @@ -1,6 +1,6 @@ { "name": "eslint-config-airbnb", - "version": "15.0.1", + "version": "15.0.2", "description": "Airbnb's ESLint config, following our styleguide", "main": "index.js", "scripts": { From d806859320b198eeb850966ed5d091828bc55b64 Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Tue, 4 Jul 2017 12:49:09 -0700 Subject: [PATCH 180/702] [Tests] run prepublish tests as allowed failures --- .travis.yml | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/.travis.yml b/.travis.yml index d28e6fd12e..cc7f3495a7 100644 --- a/.travis.yml +++ b/.travis.yml @@ -5,20 +5,28 @@ node_js: - "6" - "5" - "4" -env: - - 'TEST_DIR=packages/eslint-config-airbnb' - - 'TEST_DIR=packages/eslint-config-airbnb-base' before_install: - - 'cd $TEST_DIR' - 'if [ "${TRAVIS_NODE_VERSION}" = "0.6" ]; then npm install -g npm@1.3 ; elif [ "${TRAVIS_NODE_VERSION}" != "0.9" ]; then case "$(npm --version)" in 1.*) npm install -g npm@1.4.28 ;; 2.*) npm install -g npm@2 ;; esac ; fi' - 'if [ "${TRAVIS_NODE_VERSION%${TRAVIS_NODE_VERSION#[0-9]}}" = "0" ] || [ "${TRAVIS_NODE_VERSION:0:4}" = "iojs" ]; then npm install -g npm@4.5 ; elif [ "${TRAVIS_NODE_VERSION}" != "0.6" ] && [ "${TRAVIS_NODE_VERSION}" != "0.9" ]; then npm install -g npm; fi' install: + - 'cd "packages/${PACKAGE}"' - 'if [ "${TRAVIS_NODE_VERSION}" = "0.6" ]; then nvm install 0.8 && npm install -g npm@1.3 && npm install -g npm@1.4.28 && npm install -g npm@2 && npm install && nvm use "${TRAVIS_NODE_VERSION}"; else npm install; fi;' script: - - 'npm run travis' + - 'if [ -n "${PREPUBLISH-}" ]; then npm run prepublish; else npm run travis; fi' sudo: false +env: + matrix: + - 'TEST=true PACKAGE=eslint-config-airbnb' + - 'TEST=true PACKAGE=eslint-config-airbnb-base' matrix: fast_finish: true + include: + - node_js: "node" + env: PREPUBLISH=true PACKAGE=eslint-config-airbnb + - node_js: "node" + env: PREPUBLISH=true PACKAGE=eslint-config-airbnb-base allow_failures: - node_js: "7" - node_js: "5" + - env: PREPUBLISH=true PACKAGE=eslint-config-airbnb + - env: PREPUBLISH=true PACKAGE=eslint-config-airbnb-base From e5b403cd49aa2aa44a592d8fdfe0b6dd61ff9553 Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Tue, 4 Jul 2017 14:36:47 -0700 Subject: [PATCH 181/702] [eslint config] [base] [deps] update `babel-preset-airbnb`, `eslint-find-rules`, `eslint-plugin-import`, `tape` --- packages/eslint-config-airbnb-base/package.json | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/packages/eslint-config-airbnb-base/package.json b/packages/eslint-config-airbnb-base/package.json index 92fa71298c..2424f2a857 100644 --- a/packages/eslint-config-airbnb-base/package.json +++ b/packages/eslint-config-airbnb-base/package.json @@ -46,19 +46,19 @@ }, "homepage": "https://github.com/airbnb/javascript", "devDependencies": { - "babel-preset-airbnb": "^2.2.3", + "babel-preset-airbnb": "^2.4.0", "babel-tape-runner": "^2.0.1", "editorconfig-tools": "^0.1.1", "eslint": "^3.19.0", - "eslint-find-rules": "^1.14.3", - "eslint-plugin-import": "^2.2.0", + "eslint-find-rules": "^3.1.1", + "eslint-plugin-import": "^2.6.1", "in-publish": "^2.0.0", "safe-publish-latest": "^1.1.1", - "tape": "^4.6.3" + "tape": "^4.7.0" }, "peerDependencies": { "eslint": "^3.19.0", - "eslint-plugin-import": "^2.2.0" + "eslint-plugin-import": "^2.6.1" }, "engines": { "node": ">= 4" From 7768e01625fd7136872dca2a8bf7ef407fd19df5 Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Tue, 4 Jul 2017 14:30:29 -0700 Subject: [PATCH 182/702] [eslint config] [*] Add missing rules --- .../eslint-config-airbnb-base/rules/imports.js | 11 +++++++++++ packages/eslint-config-airbnb/rules/react-a11y.js | 9 +++++++++ packages/eslint-config-airbnb/rules/react.js | 15 +++++++++++++++ 3 files changed, 35 insertions(+) diff --git a/packages/eslint-config-airbnb-base/rules/imports.js b/packages/eslint-config-airbnb-base/rules/imports.js index ab324b79ca..0150724f6b 100644 --- a/packages/eslint-config-airbnb-base/rules/imports.js +++ b/packages/eslint-config-airbnb-base/rules/imports.js @@ -191,5 +191,16 @@ module.exports = { // Prevent importing the default as if it were named // https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/no-named-default.md 'import/no-named-default': 'error', + + // Reports if a module's default export is unnamed + // https://github.com/benmosher/eslint-plugin-import/blob/d9b712ac7fd1fddc391f7b234827925c160d956f/docs/rules/no-anonymous-default-export.md + 'import/no-anonymous-default-export': ['off', { + allowArray: false, + allowArrowFunction: false, + allowAnonymousClass: false, + allowAnonymousFunction: false, + allowLiteral: false, + allowObject: false, + }], }, }; diff --git a/packages/eslint-config-airbnb/rules/react-a11y.js b/packages/eslint-config-airbnb/rules/react-a11y.js index 77fcb93d9c..4cdf1cf39c 100644 --- a/packages/eslint-config-airbnb/rules/react-a11y.js +++ b/packages/eslint-config-airbnb/rules/react-a11y.js @@ -188,5 +188,14 @@ module.exports = { tags: [], roles: ['tabpanel'], }], + + // ensure tags are valid + // https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/0745af376cdc8686d85a361ce36952b1fb1ccf6e/docs/rules/anchor-is-valid.md + // TODO: enable, semver-major + 'jsx-a11y/anchor-is-valid': ['off', { + components: ['Link'], + specialLink: [], + aspects: ['noHref', 'invalidHref', 'preferButton'], + }], }, }; diff --git a/packages/eslint-config-airbnb/rules/react.js b/packages/eslint-config-airbnb/rules/react.js index 4392d678ea..96e5f4a75d 100644 --- a/packages/eslint-config-airbnb/rules/react.js +++ b/packages/eslint-config-airbnb/rules/react.js @@ -48,6 +48,11 @@ module.exports = { // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-closing-bracket-location.md 'react/jsx-closing-bracket-location': ['error', 'line-aligned'], + // Validate closing tag location in JSX + // https://github.com/yannickcr/eslint-plugin-react/blob/9e13ae2c51e44872b45cc15bf1ac3a72105bdd0e/docs/rules/jsx-closing-tag-location.md + // TODO: enable, semver-minor + 'react/jsx-closing-tag-location': 'off', + // Enforce or disallow spaces inside of curly braces in JSX attributes // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-curly-spacing.md 'react/jsx-curly-spacing': ['error', 'never', { allowMultiline: true }], @@ -315,6 +320,16 @@ module.exports = { // Prevent void DOM elements from receiving children // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/void-dom-elements-no-children.md 'react/void-dom-elements-no-children': 'error', + + // Enforce all defaultProps have a corresponding non-required PropType + // https://github.com/yannickcr/eslint-plugin-react/blob/9e13ae2c51e44872b45cc15bf1ac3a72105bdd0e/docs/rules/default-props-match-prop-types.md + // TODO: enable, semver-minor + 'react/default-props-match-prop-types': ['off', { allowRequiredDefaults: false }], + + // Prevent usage of shouldComponentUpdate when extending React.PureComponent + // https://github.com/yannickcr/eslint-plugin-react/blob/9e13ae2c51e44872b45cc15bf1ac3a72105bdd0e/docs/rules/no-redundant-should-component-update.md + // TODO: enable, semver-major + 'react/no-redundant-should-component-update': 'off', }, settings: { From fc7fae620f625701a5614fb9cf9ec1e9c49bcc70 Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Tue, 4 Jul 2017 16:15:18 -0700 Subject: [PATCH 183/702] [Tests] add pretravis/posttravis scripts --- .travis.yml | 2 +- packages/eslint-config-airbnb-base/package.json | 4 +++- packages/eslint-config-airbnb/package.json | 4 +++- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index cc7f3495a7..27a719227a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -12,7 +12,7 @@ install: - 'cd "packages/${PACKAGE}"' - 'if [ "${TRAVIS_NODE_VERSION}" = "0.6" ]; then nvm install 0.8 && npm install -g npm@1.3 && npm install -g npm@1.4.28 && npm install -g npm@2 && npm install && nvm use "${TRAVIS_NODE_VERSION}"; else npm install; fi;' script: - - 'if [ -n "${PREPUBLISH-}" ]; then npm run prepublish; else npm run travis; fi' + - 'if [ -n "${PREPUBLISH-}" ]; then npm run pretravis && npm run prepublish && npm run posttravis; else npm run travis; fi' sudo: false env: matrix: diff --git a/packages/eslint-config-airbnb-base/package.json b/packages/eslint-config-airbnb-base/package.json index 2424f2a857..70ff6a46b4 100644 --- a/packages/eslint-config-airbnb-base/package.json +++ b/packages/eslint-config-airbnb-base/package.json @@ -10,7 +10,9 @@ "prepublish": "(in-install || eslint-find-rules --unused) && (not-in-publish || npm test) && safe-publish-latest", "pretest": "npm run --silent lint", "test": "npm run --silent tests-only", - "travis": "npm run --silent test" + "pretravis": ":", + "travis": "npm run --silent test", + "posttravis": ":" }, "repository": { "type": "git", diff --git a/packages/eslint-config-airbnb/package.json b/packages/eslint-config-airbnb/package.json index 7d4f0b941e..7c5df67583 100644 --- a/packages/eslint-config-airbnb/package.json +++ b/packages/eslint-config-airbnb/package.json @@ -10,7 +10,9 @@ "prepublish": "(in-install || eslint-find-rules --unused) && (not-in-publish || npm test) && safe-publish-latest", "pretest": "npm run --silent lint", "test": "npm run --silent tests-only", - "travis": "cd ../eslint-config-airbnb-base && npm install && npm link && cd - && npm link eslint-config-airbnb-base && npm run --silent test ; npm unlink eslint-config-airbnb-base >/dev/null &" + "pretravis": "cd ../eslint-config-airbnb-base && npm install && npm link && cd - && npm link --no-save eslint-config-airbnb-base", + "travis": "npm run --silent test", + "posttravis": "npm unlink eslint-config-airbnb-base >/dev/null &" }, "repository": { "type": "git", From 22c97fa6787ce7df7124782bea1b3fe29fe76e01 Mon Sep 17 00:00:00 2001 From: Valentina Pegler Date: Wed, 12 Jul 2017 18:12:38 +0200 Subject: [PATCH 184/702] [inthewild] Add LEINWAND to the organizations list --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index e59dc9b940..d2098852ff 100644 --- a/README.md +++ b/README.md @@ -3306,6 +3306,7 @@ Other Style Guides - **JSSolutions**: [JSSolutions/javascript](https://github.com/JSSolutions/javascript) - **KickorStick**: [kickorstick/javascript](https://github.com/kickorstick/javascript) - **Kinetica Solutions**: [kinetica/javascript](https://github.com/kinetica/Javascript-style-guide) + - **LEINWAND**: [LEINWAND/javascript](https://github.com/LEINWAND/javascript) - **Lonely Planet**: [lonelyplanet/javascript](https://github.com/lonelyplanet/javascript) - **M2GEN**: [M2GEN/javascript](https://github.com/M2GEN/javascript) - **Mighty Spring**: [mightyspring/javascript](https://github.com/mightyspring/javascript) From 6331c2c3e2751b02af2636bce88bbb4a5489e9a5 Mon Sep 17 00:00:00 2001 From: Chaitanya Mutyala Date: Wed, 12 Jul 2017 10:43:11 -0700 Subject: [PATCH 185/702] [guide] Typo fix on example --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index d2098852ff..0a9103e958 100644 --- a/README.md +++ b/README.md @@ -1391,7 +1391,7 @@ Other Style Guides const increasedByOne = []; numbers.forEach((num) => { increasedByOne.push(num + 1); - ); + }); // best (keeping it functional) const increasedByOne = numbers.map(num => num + 1); From cdc1c4fb76a67827c0aa52fd67cdda122828f583 Mon Sep 17 00:00:00 2001 From: Chris Atkin Date: Sun, 23 Jul 2017 14:30:32 +0100 Subject: [PATCH 186/702] [inthewild] Add Sainsbury's Supermarkets to the organizations list --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 0a9103e958..0fbd0ffe8f 100644 --- a/README.md +++ b/README.md @@ -3327,6 +3327,7 @@ Other Style Guides - **React**: [facebook.github.io/react/contributing/how-to-contribute.html#style-guide](https://facebook.github.io/react/contributing/how-to-contribute.html#style-guide) - **REI**: [reidev/js-style-guide](https://github.com/rei/code-style-guides/blob/master/docs/javascript.md) - **Ripple**: [ripple/javascript-style-guide](https://github.com/ripple/javascript-style-guide) + - **Sainsbury's Supermarkets**: [github/jsainsburyplc](https://github.com/jsainsburyplc) - **SeekingAlpha**: [seekingalpha/javascript-style-guide](https://github.com/seekingalpha/javascript-style-guide) - **Shutterfly**: [shutterfly/javascript](https://github.com/shutterfly/javascript) - **Sourcetoad**: [sourcetoad/javascript](https://github.com/sourcetoad/javascript) From b4995b6416faa714299a39976a0b7107ad7b2afe Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Sun, 23 Jul 2017 13:04:22 -0700 Subject: [PATCH 187/702] [eslint config] [base] revert breaking part of #1420 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit I’ll re-enable it in the next major. --- packages/eslint-config-airbnb-base/rules/variables.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/eslint-config-airbnb-base/rules/variables.js b/packages/eslint-config-airbnb-base/rules/variables.js index fc0b5b11d4..fe38ea5d60 100644 --- a/packages/eslint-config-airbnb-base/rules/variables.js +++ b/packages/eslint-config-airbnb-base/rules/variables.js @@ -16,7 +16,8 @@ module.exports = { 'no-label-var': 'error', // disallow specific globals - 'no-restricted-globals': ['error'].concat(restrictedGlobals), + // TODO: enable, semver-major + 'no-restricted-globals': ['off'].concat(restrictedGlobals), // disallow declaration of variables already declared in the outer scope 'no-shadow': 'error', From 399420f46f1c1161106655ade5f7c9b95723574b Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Sun, 23 Jul 2017 10:39:12 -0700 Subject: [PATCH 188/702] [Tests] add an explicit eslint version to travis.yml --- .travis.yml | 13 +++++++------ packages/eslint-config-airbnb-base/package.json | 2 +- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/.travis.yml b/.travis.yml index 27a719227a..ae03a0ee56 100644 --- a/.travis.yml +++ b/.travis.yml @@ -11,22 +11,23 @@ before_install: install: - 'cd "packages/${PACKAGE}"' - 'if [ "${TRAVIS_NODE_VERSION}" = "0.6" ]; then nvm install 0.8 && npm install -g npm@1.3 && npm install -g npm@1.4.28 && npm install -g npm@2 && npm install && nvm use "${TRAVIS_NODE_VERSION}"; else npm install; fi;' + - 'if [ -n "${ESLINT}" ]; then npm install --no-save "eslint@${ESLINT}"; fi' script: - 'if [ -n "${PREPUBLISH-}" ]; then npm run pretravis && npm run prepublish && npm run posttravis; else npm run travis; fi' sudo: false env: matrix: - - 'TEST=true PACKAGE=eslint-config-airbnb' - - 'TEST=true PACKAGE=eslint-config-airbnb-base' + - 'TEST=true ESLINT=3 PACKAGE=eslint-config-airbnb' + - 'TEST=true ESLINT=3 PACKAGE=eslint-config-airbnb-base' matrix: fast_finish: true include: - node_js: "node" - env: PREPUBLISH=true PACKAGE=eslint-config-airbnb + env: PREPUBLISH=true ESLINT=3 PACKAGE=eslint-config-airbnb - node_js: "node" - env: PREPUBLISH=true PACKAGE=eslint-config-airbnb-base + env: PREPUBLISH=true ESLINT=3 PACKAGE=eslint-config-airbnb-base allow_failures: - node_js: "7" - node_js: "5" - - env: PREPUBLISH=true PACKAGE=eslint-config-airbnb - - env: PREPUBLISH=true PACKAGE=eslint-config-airbnb-base + - env: PREPUBLISH=true ESLINT=3 PACKAGE=eslint-config-airbnb + - env: PREPUBLISH=true ESLINT=3 PACKAGE=eslint-config-airbnb-base diff --git a/packages/eslint-config-airbnb-base/package.json b/packages/eslint-config-airbnb-base/package.json index 70ff6a46b4..d57b9e579d 100644 --- a/packages/eslint-config-airbnb-base/package.json +++ b/packages/eslint-config-airbnb-base/package.json @@ -51,7 +51,7 @@ "babel-preset-airbnb": "^2.4.0", "babel-tape-runner": "^2.0.1", "editorconfig-tools": "^0.1.1", - "eslint": "^3.19.0", + "eslint": "^4.3.0", "eslint-find-rules": "^3.1.1", "eslint-plugin-import": "^2.6.1", "in-publish": "^2.0.0", From 811392725efde953d8126ed22c3b475e4f8b3ea9 Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Sun, 23 Jul 2017 11:35:51 -0700 Subject: [PATCH 189/702] [Deps] allow eslint v3 or v4; update `eslint-plugin-import` Part of #1447. --- .travis.yml | 4 ++ .../eslint-config-airbnb-base/package.json | 6 +-- .../rules/best-practices.js | 4 +- .../eslint-config-airbnb-base/rules/errors.js | 12 +++++ .../eslint-config-airbnb-base/rules/es6.js | 10 ++++- .../eslint-config-airbnb-base/rules/node.js | 5 +++ .../eslint-config-airbnb-base/rules/style.js | 44 ++++++++++++++++--- 7 files changed, 73 insertions(+), 12 deletions(-) diff --git a/.travis.yml b/.travis.yml index ae03a0ee56..4256a0dcfd 100644 --- a/.travis.yml +++ b/.travis.yml @@ -19,6 +19,7 @@ env: matrix: - 'TEST=true ESLINT=3 PACKAGE=eslint-config-airbnb' - 'TEST=true ESLINT=3 PACKAGE=eslint-config-airbnb-base' + - 'TEST=true ESLINT=4 PACKAGE=eslint-config-airbnb-base' matrix: fast_finish: true include: @@ -26,8 +27,11 @@ matrix: env: PREPUBLISH=true ESLINT=3 PACKAGE=eslint-config-airbnb - node_js: "node" env: PREPUBLISH=true ESLINT=3 PACKAGE=eslint-config-airbnb-base + - node_js: "node" + env: PREPUBLISH=true ESLINT=4 PACKAGE=eslint-config-airbnb-base allow_failures: - node_js: "7" - node_js: "5" - env: PREPUBLISH=true ESLINT=3 PACKAGE=eslint-config-airbnb - env: PREPUBLISH=true ESLINT=3 PACKAGE=eslint-config-airbnb-base + - env: PREPUBLISH=true ESLINT=4 PACKAGE=eslint-config-airbnb-base diff --git a/packages/eslint-config-airbnb-base/package.json b/packages/eslint-config-airbnb-base/package.json index d57b9e579d..8fe35062fd 100644 --- a/packages/eslint-config-airbnb-base/package.json +++ b/packages/eslint-config-airbnb-base/package.json @@ -53,14 +53,14 @@ "editorconfig-tools": "^0.1.1", "eslint": "^4.3.0", "eslint-find-rules": "^3.1.1", - "eslint-plugin-import": "^2.6.1", + "eslint-plugin-import": "^2.7.0", "in-publish": "^2.0.0", "safe-publish-latest": "^1.1.1", "tape": "^4.7.0" }, "peerDependencies": { - "eslint": "^3.19.0", - "eslint-plugin-import": "^2.6.1" + "eslint": "^3.19.0 || ^4.3.0", + "eslint-plugin-import": "^2.7.0" }, "engines": { "node": ">= 4" diff --git a/packages/eslint-config-airbnb-base/rules/best-practices.js b/packages/eslint-config-airbnb-base/rules/best-practices.js index 3d97bb6e55..02ea3e23b3 100644 --- a/packages/eslint-config-airbnb-base/rules/best-practices.js +++ b/packages/eslint-config-airbnb-base/rules/best-practices.js @@ -142,7 +142,9 @@ module.exports = { }], // disallow use of multiple spaces - 'no-multi-spaces': 'error', + 'no-multi-spaces': ['error', { + // ignoreEOLComments: false, // TODO: uncomment once v3 is dropped + }], // disallow use of multiline strings 'no-multi-str': 'error', diff --git a/packages/eslint-config-airbnb-base/rules/errors.js b/packages/eslint-config-airbnb-base/rules/errors.js index 8f618e0661..02befbb5af 100644 --- a/packages/eslint-config-airbnb-base/rules/errors.js +++ b/packages/eslint-config-airbnb-base/rules/errors.js @@ -9,6 +9,16 @@ module.exports = { functions: 'always-multiline', }], + // Enforce “for” loop update clause moving the counter in the right direction + // http://eslint.org/docs/rules/for-direction + // TODO: enable, semver-major until v3 is dropped; semver-minor otherwise + 'for-direction': 'off', + + // Enforces that a return statement is present in property getters + // http://eslint.org/docs/rules/getter-return + // TODO: enable, semver-major when v3 is dropped + 'getter-return': ['off', { allowImplicit: true }], + // Disallow await inside of loops // http://eslint.org/docs/rules/no-await-in-loop 'no-await-in-loop': 'error', @@ -61,6 +71,8 @@ module.exports = { conditionalAssign: true, nestedBinaryExpressions: false, returnAssign: false, + ignoreJSX: 'all', // delegate to eslint-plugin-react + enforceForArrowConditionals: false, }], // disallow unnecessary semicolons diff --git a/packages/eslint-config-airbnb-base/rules/es6.js b/packages/eslint-config-airbnb-base/rules/es6.js index 14d777e640..a77f3a6641 100644 --- a/packages/eslint-config-airbnb-base/rules/es6.js +++ b/packages/eslint-config-airbnb-base/rules/es6.js @@ -112,8 +112,14 @@ module.exports = { // http://eslint.org/docs/rules/prefer-destructuring // TODO: enable 'prefer-destructuring': ['off', { - array: true, - object: true, + VariableDeclarator: { + array: false, + object: true, + }, + AssignmentExpression: { + array: true, + object: true, + }, }, { enforceForRenamedProperties: false, }], diff --git a/packages/eslint-config-airbnb-base/rules/node.js b/packages/eslint-config-airbnb-base/rules/node.js index e4a71a6a5a..d890a67c1b 100644 --- a/packages/eslint-config-airbnb-base/rules/node.js +++ b/packages/eslint-config-airbnb-base/rules/node.js @@ -14,6 +14,11 @@ module.exports = { // enforces error handling in callbacks (node environment) 'handle-callback-err': 'off', + // disallow use of the Buffer() constructor + // http://eslint.org/docs/rules/no-buffer-constructor + // TODO: enable, semver-major + 'no-buffer-constructor': 'off', + // disallow mixing regular variable and require declarations 'no-mixed-requires': ['off', false], diff --git a/packages/eslint-config-airbnb-base/rules/style.js b/packages/eslint-config-airbnb-base/rules/style.js index c617e57fd3..42e820870e 100644 --- a/packages/eslint-config-airbnb-base/rules/style.js +++ b/packages/eslint-config-airbnb-base/rules/style.js @@ -1,5 +1,15 @@ module.exports = { rules: { + // enforce line breaks after opening and before closing array brackets + // http://eslint.org/docs/rules/array-bracket-newline + // TODO: enable? semver-major + 'array-bracket-newline': ['off', { multiline: true, minItems: 3 }], + + // enforce line breaks between array elements + // http://eslint.org/docs/rules/array-element-newline + // TODO: enable? semver-major + 'array-element-newline': ['off', { multiline: true, minItems: 3 }], + // enforce spacing inside array brackets 'array-bracket-spacing': ['error', 'never'], @@ -82,7 +92,7 @@ module.exports = { outerIIFEBody: 1, // MemberExpression: null, // CallExpression: { - // parameters: null, + // parameters: null, // }, FunctionDeclaration: { parameters: 1, @@ -284,10 +294,18 @@ module.exports = { 'no-ternary': 'off', // disallow trailing whitespace at the end of lines - 'no-trailing-spaces': 'error', + 'no-trailing-spaces': ['error', { + skipBlankLines: false, + // ignoreComments: false, // TODO: uncomment once v3 is dropped + }], // disallow dangling underscores in identifiers - 'no-underscore-dangle': ['error', { allowAfterThis: false }], + 'no-underscore-dangle': ['error', { + allow: [], + allowAfterThis: false, + allowAfterSuper: false, + // enforceInMethodNames: false, // TODO: uncoment and enable, semver-minor once v3 is dropped + }], // disallow the use of Boolean literals in conditional expressions // also, prefer `a || b` over `a ? a : b` @@ -307,10 +325,10 @@ module.exports = { // enforce line breaks between braces // http://eslint.org/docs/rules/object-curly-newline - // TODO: enable once https://github.com/eslint/eslint/issues/6488 is resolved + // TODO: enable once https://github.com/eslint/eslint/issues/6488 is resolved and v3 is dropped 'object-curly-newline': ['off', { - ObjectExpression: { minProperties: 0, multiline: true }, - ObjectPattern: { minProperties: 0, multiline: true } + ObjectExpression: { minProperties: 3, multiline: true, consistent: true }, + ObjectPattern: { minProperties: 3, multiline: true, consistent: true } }], // enforce "same line" or "multiple line" on object properties. @@ -336,6 +354,10 @@ module.exports = { // enforce padding within blocks 'padded-blocks': ['error', 'never'], + // Require or disallow padding lines between statements + // http://eslint.org/docs/rules/padding-line-between-statements + 'padding-line-between-statements': 'off', + // require quotes around object literal property names // http://eslint.org/docs/rules/quote-props.html 'quote-props': ['error', 'as-needed', { keywords: false, unnecessary: true, numbers: false }], @@ -353,6 +375,11 @@ module.exports = { // enforce spacing before and after semicolons 'semi-spacing': ['error', { before: false, after: true }], + // Enforce location of semicolons + // http://eslint.org/docs/rules/semi-style + // TODO: enable, semver-major until v3 is dropped, semver-minor otherwise + 'semi-style': ['off', 'last'], + // requires object keys to be sorted 'sort-keys': ['off', 'asc', { caseSensitive: false, natural: true }], @@ -399,6 +426,11 @@ module.exports = { } }], + // Enforce spacing around colons of switch statements + // http://eslint.org/docs/rules/switch-colon-spacing + // TODO: enable, semver-major + 'switch-colon-spacing': ['off', { after: true, before: false }], + // Require or disallow spacing between template tags and their literals // http://eslint.org/docs/rules/template-tag-spacing // TODO: enable, semver-major From 55219bfdcf417700f677c5f31a8584a6b8c34c6b Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Sun, 23 Jul 2017 13:08:57 -0700 Subject: [PATCH 190/702] v11.3.0 --- packages/eslint-config-airbnb-base/CHANGELOG.md | 12 ++++++++++++ packages/eslint-config-airbnb-base/package.json | 2 +- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/packages/eslint-config-airbnb-base/CHANGELOG.md b/packages/eslint-config-airbnb-base/CHANGELOG.md index 9407b90a6d..80e394da8d 100644 --- a/packages/eslint-config-airbnb-base/CHANGELOG.md +++ b/packages/eslint-config-airbnb-base/CHANGELOG.md @@ -1,3 +1,15 @@ +11.3.0 / 2017-07-23 +================== + - [deps] allow eslint v3 or v4 (#1447) + - [deps] update `eslint-plugin-import` + - [minor] Balanced spacing for inline block comments (#1440) + - [minor] `no-return-assign`: strengthen linting against returning assignments + - [patch] Allow jsx extensions for test files (#1427) + - [patch] `no-restricted-globals`: add confusing globals; leave disabled for now (#1420) + - [patch] Support Protractor config files in import/no-extraneous-dependencies (#1456) + - [docs] Remove TODO in prefer-reflect as it's deprecated (#1452) + - [docs] add yarn instructions (#1463, #1464) + 11.2.0 / 2017-05-14 ================== - [minor] Disallow unused global variables diff --git a/packages/eslint-config-airbnb-base/package.json b/packages/eslint-config-airbnb-base/package.json index 8fe35062fd..008b1e198b 100644 --- a/packages/eslint-config-airbnb-base/package.json +++ b/packages/eslint-config-airbnb-base/package.json @@ -1,6 +1,6 @@ { "name": "eslint-config-airbnb-base", - "version": "11.2.0", + "version": "11.3.0", "description": "Airbnb's base JS ESLint config, following our styleguide", "main": "index.js", "scripts": { From 18255d14d45bafd17038b2d9032006fe9e1e1003 Mon Sep 17 00:00:00 2001 From: Tonni Date: Mon, 26 Jun 2017 23:00:26 +0800 Subject: [PATCH 191/702] [guide] Add documentation for exponentiation operator (`**`). --- README.md | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 0fbd0ffe8f..59d2c994ac 100644 --- a/README.md +++ b/README.md @@ -1498,6 +1498,16 @@ Other Style Guides const isJedi = getProp('jedi'); ``` + + - [12.3](#es2016-properties--exponentiation-operator) Use exponentiation operator `**` when calculating exponentiations. eslint: [`no-restricted-properties`](http://eslint.org/docs/rules/no-restricted-properties). + + ```javascript + // bad + const binary = Math.pow(2, 10); + + // good + const binary = 2 ** 10; + ``` **[⬆ back to top](#table-of-contents)** @@ -3116,7 +3126,7 @@ Other Style Guides ## ECMAScript 6+ (ES 2015+) Styles - - [28.1](#es6-styles) This is a collection of links to the various ES6 features. + - [28.1](#es6-styles) This is a collection of links to the various ES6+ features. 1. [Arrow Functions](#arrow-functions) 1. [Classes](#classes--constructors) @@ -3129,6 +3139,7 @@ Other Style Guides 1. [Rest](#es6-rest) 1. [Array Spreads](#es6-array-spreads) 1. [Let and Const](#references) +1. [Exponentiation Operator](#es2016-properties--exponentiation-operator) 1. [Iterators and Generators](#iterators-and-generators) 1. [Modules](#modules) From b687a9ceb8030dcdc467adb51c33e37a9a1c6101 Mon Sep 17 00:00:00 2001 From: elmehri Date: Tue, 29 Aug 2017 15:27:08 +0100 Subject: [PATCH 192/702] [eslint config] [base] [patch] support Protractor config files in import/no-extraneous-dependencies --- packages/eslint-config-airbnb-base/rules/imports.js | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/eslint-config-airbnb-base/rules/imports.js b/packages/eslint-config-airbnb-base/rules/imports.js index 2700194efe..81b845a871 100644 --- a/packages/eslint-config-airbnb-base/rules/imports.js +++ b/packages/eslint-config-airbnb-base/rules/imports.js @@ -84,6 +84,7 @@ module.exports = { '**/gulpfile.js', // gulp config '**/gulpfile.*.js', // gulp config '**/Gruntfile{,.js}', // grunt config + '**/protractor.conf.js', // protractor config '**/protractor.conf.*.js', // protractor config ], optionalDependencies: false, From 9d91990221d47b2782f586370451033460e0a32b Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Fri, 1 Sep 2017 22:59:54 -0700 Subject: [PATCH 193/702] [Tests] stop testing on eslint v3 --- .travis.yml | 4 ---- 1 file changed, 4 deletions(-) diff --git a/.travis.yml b/.travis.yml index 9e1091574d..c083bda347 100644 --- a/.travis.yml +++ b/.travis.yml @@ -17,14 +17,11 @@ script: sudo: false env: matrix: - - 'TEST=true ESLINT=3 PACKAGE=eslint-config-airbnb' - 'TEST=true ESLINT=4 PACKAGE=eslint-config-airbnb' - 'TEST=true ESLINT=4 PACKAGE=eslint-config-airbnb-base' matrix: fast_finish: true include: - - node_js: "node" - env: PREPUBLISH=true ESLINT=3 PACKAGE=eslint-config-airbnb - node_js: "node" env: PREPUBLISH=true ESLINT=4 PACKAGE=eslint-config-airbnb - node_js: "node" @@ -32,6 +29,5 @@ matrix: allow_failures: - node_js: "7" - node_js: "5" - - env: PREPUBLISH=true ESLINT=3 PACKAGE=eslint-config-airbnb - env: PREPUBLISH=true ESLINT=4 PACKAGE=eslint-config-airbnb - env: PREPUBLISH=true ESLINT=4 PACKAGE=eslint-config-airbnb-base From 63d1ae175e01391ded18c0a4d03c0eca4c49edbe Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Fri, 1 Sep 2017 23:00:41 -0700 Subject: [PATCH 194/702] [Tests] fix linting error caused by updated base config --- packages/eslint-config-airbnb-base/rules/style.js | 6 +++--- packages/eslint-config-airbnb-base/test/test-base.js | 4 ++-- packages/eslint-config-airbnb/rules/react.js | 6 +++++- 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/packages/eslint-config-airbnb-base/rules/style.js b/packages/eslint-config-airbnb-base/rules/style.js index d36309a808..4aa35aeafe 100644 --- a/packages/eslint-config-airbnb-base/rules/style.js +++ b/packages/eslint-config-airbnb-base/rules/style.js @@ -113,7 +113,7 @@ module.exports = { body: 1 }, CallExpression: { - 'arguments': 1 + arguments: 1 }, ArrayExpression: 1, ObjectExpression: 1, @@ -344,8 +344,8 @@ module.exports = { // enforce line breaks between braces // http://eslint.org/docs/rules/object-curly-newline 'object-curly-newline': ['error', { - ObjectExpression: { minProperties: 3, multiline: true, consistent: true }, - ObjectPattern: { minProperties: 3, multiline: true, consistent: true } + ObjectExpression: { minProperties: 4, multiline: true, consistent: true }, + ObjectPattern: { minProperties: 4, multiline: true, consistent: true } }], // enforce "same line" or "multiple line" on object properties. diff --git a/packages/eslint-config-airbnb-base/test/test-base.js b/packages/eslint-config-airbnb-base/test/test-base.js index 810c8000b0..6936e0eb24 100644 --- a/packages/eslint-config-airbnb-base/test/test-base.js +++ b/packages/eslint-config-airbnb-base/test/test-base.js @@ -11,9 +11,9 @@ fs.readdirSync(path.join(__dirname, '../rules')).forEach((name) => { files[name] = require(`../rules/${name}`); // eslint-disable-line global-require }); -Object.keys(files).forEach(( +Object.keys(files).forEach(( // eslint-disable-line function-paren-newline name, // trailing function comma is to test parsing -) => { +) => { // eslint-disable-line function-paren-newline const config = files[name]; test(`${name}: does not reference react`, (t) => { diff --git a/packages/eslint-config-airbnb/rules/react.js b/packages/eslint-config-airbnb/rules/react.js index 96b1d25644..15324c8608 100644 --- a/packages/eslint-config-airbnb/rules/react.js +++ b/packages/eslint-config-airbnb/rules/react.js @@ -186,7 +186,11 @@ module.exports = { // Prevent missing props validation in a React component definition // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/prop-types.md - 'react/prop-types': ['error', { ignore: [], customValidators: [], skipUndeclared: false }], + 'react/prop-types': ['error', { + ignore: [], + customValidators: [], + skipUndeclared: false + }], // Prevent missing React when using JSX // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/react-in-jsx-scope.md From 1f5ca4c976b906a94d4faa2e01dfff2c9a106bfb Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Fri, 1 Sep 2017 22:57:11 -0700 Subject: [PATCH 195/702] [eslint config] [base] v12.0.0 --- packages/eslint-config-airbnb-base/CHANGELOG.md | 10 ++++++++++ packages/eslint-config-airbnb-base/package.json | 2 +- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/packages/eslint-config-airbnb-base/CHANGELOG.md b/packages/eslint-config-airbnb-base/CHANGELOG.md index 6dcd4587a5..5e268d704b 100644 --- a/packages/eslint-config-airbnb-base/CHANGELOG.md +++ b/packages/eslint-config-airbnb-base/CHANGELOG.md @@ -1,3 +1,13 @@ +12.0.0 / 2017-09-02 +================== + - [deps] [breaking] require `eslint` v4 + - enable `function-paren-newline`, `for-direction`, `getter-return`, `no-compare-neg-zero`, `semi-style`, `object-curly-newline`, `no-buffer-constructor`, `no-restricted-globals`, `switch-colon-spacing`, `template-tag-spacing`, `prefer-promise-reject-errors`, `prefer-restructuring` + - improve `indent`, `no-multi-spaces`, `no-trailing-spaces`, `no-underscore-dangle` + - [breaking] move `comma-dangle` to Stylistic Issues (#1514) + - [breaking] Rules prohibiting global isNaN, isFinite (#1477) + - [patch] also disallow padding in classes and switches (#1403) + - [patch] support Protractor config files in import/no-extraneous-dependencies (#1543) + 11.3.2 / 2017-08-22 ================== - [patch] Add jest.config.js to import/no-extraneous-dependencies devDeps (#1522) diff --git a/packages/eslint-config-airbnb-base/package.json b/packages/eslint-config-airbnb-base/package.json index f23359e969..6c18415998 100644 --- a/packages/eslint-config-airbnb-base/package.json +++ b/packages/eslint-config-airbnb-base/package.json @@ -1,6 +1,6 @@ { "name": "eslint-config-airbnb-base", - "version": "11.3.2", + "version": "12.0.0", "description": "Airbnb's base JS ESLint config, following our styleguide", "main": "index.js", "scripts": { From 7b30681227ffec7e5ff958a43f0ba31633ad045d Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Sat, 2 Sep 2017 10:24:51 -0700 Subject: [PATCH 196/702] [eslint config] [breaking] [deps] require `eslint` `v4`, update `eslint-config-airbnb-base` --- packages/eslint-config-airbnb/package.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/eslint-config-airbnb/package.json b/packages/eslint-config-airbnb/package.json index d1aa120358..e424218002 100644 --- a/packages/eslint-config-airbnb/package.json +++ b/packages/eslint-config-airbnb/package.json @@ -48,13 +48,13 @@ }, "homepage": "https://github.com/airbnb/javascript", "dependencies": { - "eslint-config-airbnb-base": "^11.3.2" + "eslint-config-airbnb-base": "^12.0.0" }, "devDependencies": { "babel-preset-airbnb": "^2.4.0", "babel-tape-runner": "^2.0.1", "editorconfig-tools": "^0.1.1", - "eslint": "^3.19.0 || ^4.5.0", + "eslint": "^4.6.0", "eslint-find-rules": "^3.1.1", "eslint-plugin-import": "^2.7.0", "eslint-plugin-jsx-a11y": "^5.1.1", @@ -65,7 +65,7 @@ "tape": "^4.8.0" }, "peerDependencies": { - "eslint": "^3.19.0 || ^4.5.0", + "eslint": "^4.6.0", "eslint-plugin-jsx-a11y": "^5.1.1", "eslint-plugin-import": "^2.7.0", "eslint-plugin-react": "^7.3.0" From 074b2f81b810519421a875bff94e15be118c2cd2 Mon Sep 17 00:00:00 2001 From: Stephen Wyatt Bush Date: Wed, 5 Jul 2017 15:47:54 -0700 Subject: [PATCH 197/702] [eslint config] [breaking] [deps] Upgrade `eslint-plugin-jsx-a11y` to `v6` - enable more a11y rules --- packages/eslint-config-airbnb/package.json | 4 ++-- packages/eslint-config-airbnb/rules/react-a11y.js | 15 ++++----------- 2 files changed, 6 insertions(+), 13 deletions(-) diff --git a/packages/eslint-config-airbnb/package.json b/packages/eslint-config-airbnb/package.json index e424218002..5edc1665fe 100644 --- a/packages/eslint-config-airbnb/package.json +++ b/packages/eslint-config-airbnb/package.json @@ -57,7 +57,7 @@ "eslint": "^4.6.0", "eslint-find-rules": "^3.1.1", "eslint-plugin-import": "^2.7.0", - "eslint-plugin-jsx-a11y": "^5.1.1", + "eslint-plugin-jsx-a11y": "^6.0.2", "eslint-plugin-react": "^7.3.0", "in-publish": "^2.0.0", "react": ">= 0.13.0", @@ -66,7 +66,7 @@ }, "peerDependencies": { "eslint": "^4.6.0", - "eslint-plugin-jsx-a11y": "^5.1.1", + "eslint-plugin-jsx-a11y": "^6.0.2", "eslint-plugin-import": "^2.7.0", "eslint-plugin-react": "^7.3.0" }, diff --git a/packages/eslint-config-airbnb/rules/react-a11y.js b/packages/eslint-config-airbnb/rules/react-a11y.js index 4cdf1cf39c..6e1c395656 100644 --- a/packages/eslint-config-airbnb/rules/react-a11y.js +++ b/packages/eslint-config-airbnb/rules/react-a11y.js @@ -13,7 +13,7 @@ module.exports = { rules: { // Enforce that anchors have content // https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/anchor-has-content.md - 'jsx-a11y/anchor-has-content': ['error', { components: [''] }], + 'jsx-a11y/anchor-has-content': ['error', { components: [] }], // Require ARIA roles to be valid and non-abstract // https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/aria-role.md @@ -32,10 +32,6 @@ module.exports = { // https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/aria-unsupported-elements.md 'jsx-a11y/aria-unsupported-elements': 'error', - // disallow href "#" - // https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/href-no-hash.md - 'jsx-a11y/href-no-hash': ['error', { components: ['a'] }], - // Enforce that all elements that require alternative text have meaningful information // https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/alt-text.md 'jsx-a11y/alt-text': ['error', { @@ -55,9 +51,8 @@ module.exports = { 'jsx-a11y/label-has-for': ['error', { components: ['label'] }], // require that mouseover/out come with focus/blur, for keyboard-only users - // TODO: evaluate // https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/mouse-events-have-key-events.md - 'jsx-a11y/mouse-events-have-key-events': 'off', + 'jsx-a11y/mouse-events-have-key-events': 'error', // Prevent use of `accessKey` // https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/no-access-key.md @@ -109,8 +104,7 @@ module.exports = { // require onClick be accompanied by onKeyUp/onKeyDown/onKeyPress // https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/click-events-have-key-events.md - // TODO: enable? - 'jsx-a11y/click-events-have-key-events': 'off', + 'jsx-a11y/click-events-have-key-events': 'error', // Enforce that DOM elements without semantic behavior not have interaction handlers // https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/no-static-element-interactions.md @@ -191,8 +185,7 @@ module.exports = { // ensure tags are valid // https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/0745af376cdc8686d85a361ce36952b1fb1ccf6e/docs/rules/anchor-is-valid.md - // TODO: enable, semver-major - 'jsx-a11y/anchor-is-valid': ['off', { + 'jsx-a11y/anchor-is-valid': ['error', { components: ['Link'], specialLink: [], aspects: ['noHref', 'invalidHref', 'preferButton'], From 583544356ad043da72eea26045b20471ea00885e Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Sun, 23 Jul 2017 22:26:33 -0700 Subject: [PATCH 198/702] [eslint config] [deps] update `eslint-plugin-import`, `eslint-config-airbnb-base` --- packages/eslint-config-airbnb/package.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/eslint-config-airbnb/package.json b/packages/eslint-config-airbnb/package.json index 7c5df67583..161581986c 100644 --- a/packages/eslint-config-airbnb/package.json +++ b/packages/eslint-config-airbnb/package.json @@ -48,7 +48,7 @@ }, "homepage": "https://github.com/airbnb/javascript", "dependencies": { - "eslint-config-airbnb-base": "^11.2.0" + "eslint-config-airbnb-base": "^11.3.0" }, "devDependencies": { "babel-preset-airbnb": "^2.4.0", @@ -56,7 +56,7 @@ "editorconfig-tools": "^0.1.1", "eslint": "^3.19.0", "eslint-find-rules": "^3.1.1", - "eslint-plugin-import": "^2.6.1", + "eslint-plugin-import": "^2.7.0", "eslint-plugin-jsx-a11y": "^5.1.1", "eslint-plugin-react": "^7.1.0", "in-publish": "^2.0.0", @@ -67,7 +67,7 @@ "peerDependencies": { "eslint": "^3.19.0", "eslint-plugin-jsx-a11y": "^5.1.1", - "eslint-plugin-import": "^2.6.1", + "eslint-plugin-import": "^2.7.0", "eslint-plugin-react": "^7.1.0" }, "engines": { From 16c73d0a7a92c38d7a03db621dbf42f0c5576fd2 Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Sun, 23 Jul 2017 22:33:05 -0700 Subject: [PATCH 199/702] [eslint config] [deps] allow eslint v3 or v4 Closes #1447. --- .travis.yml | 4 ++++ packages/eslint-config-airbnb/package.json | 4 ++-- packages/eslint-config-airbnb/test/test-react-order.js | 3 +-- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/.travis.yml b/.travis.yml index 4256a0dcfd..7d887ca685 100644 --- a/.travis.yml +++ b/.travis.yml @@ -18,6 +18,7 @@ sudo: false env: matrix: - 'TEST=true ESLINT=3 PACKAGE=eslint-config-airbnb' + - 'TEST=true ESLINT=4 PACKAGE=eslint-config-airbnb' - 'TEST=true ESLINT=3 PACKAGE=eslint-config-airbnb-base' - 'TEST=true ESLINT=4 PACKAGE=eslint-config-airbnb-base' matrix: @@ -25,6 +26,8 @@ matrix: include: - node_js: "node" env: PREPUBLISH=true ESLINT=3 PACKAGE=eslint-config-airbnb + - node_js: "node" + env: PREPUBLISH=true ESLINT=4 PACKAGE=eslint-config-airbnb - node_js: "node" env: PREPUBLISH=true ESLINT=3 PACKAGE=eslint-config-airbnb-base - node_js: "node" @@ -33,5 +36,6 @@ matrix: - node_js: "7" - node_js: "5" - env: PREPUBLISH=true ESLINT=3 PACKAGE=eslint-config-airbnb + - env: PREPUBLISH=true ESLINT=4 PACKAGE=eslint-config-airbnb - env: PREPUBLISH=true ESLINT=3 PACKAGE=eslint-config-airbnb-base - env: PREPUBLISH=true ESLINT=4 PACKAGE=eslint-config-airbnb-base diff --git a/packages/eslint-config-airbnb/package.json b/packages/eslint-config-airbnb/package.json index 161581986c..1b06b38a97 100644 --- a/packages/eslint-config-airbnb/package.json +++ b/packages/eslint-config-airbnb/package.json @@ -54,7 +54,7 @@ "babel-preset-airbnb": "^2.4.0", "babel-tape-runner": "^2.0.1", "editorconfig-tools": "^0.1.1", - "eslint": "^3.19.0", + "eslint": "^3.19.0 || ^4.3.0", "eslint-find-rules": "^3.1.1", "eslint-plugin-import": "^2.7.0", "eslint-plugin-jsx-a11y": "^5.1.1", @@ -65,7 +65,7 @@ "tape": "^4.7.0" }, "peerDependencies": { - "eslint": "^3.19.0", + "eslint": "^3.19.0 || ^4.3.0", "eslint-plugin-jsx-a11y": "^5.1.1", "eslint-plugin-import": "^2.7.0", "eslint-plugin-react": "^7.1.0" diff --git a/packages/eslint-config-airbnb/test/test-react-order.js b/packages/eslint-config-airbnb/test/test-react-order.js index 0257a40a92..0e7fd9e6ec 100644 --- a/packages/eslint-config-airbnb/test/test-react-order.js +++ b/packages/eslint-config-airbnb/test/test-react-order.js @@ -49,8 +49,7 @@ test('validate react prop order', (t) => { setBar() {} someMethod() {} renderDogs() {} - render() { return
; } -`)); + render() { return
; }`)); t.notOk(result.warningCount, 'no warnings'); t.notOk(result.errorCount, 'no errors'); From 2c0126543ff93e060e00faf9c3e98e40f58b0d1e Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Mon, 24 Jul 2017 00:00:58 -0700 Subject: [PATCH 200/702] [eslint config] v15.1.0 --- packages/eslint-config-airbnb/CHANGELOG.md | 5 +++++ packages/eslint-config-airbnb/package.json | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/packages/eslint-config-airbnb/CHANGELOG.md b/packages/eslint-config-airbnb/CHANGELOG.md index ca35490985..a1c3b5d188 100644 --- a/packages/eslint-config-airbnb/CHANGELOG.md +++ b/packages/eslint-config-airbnb/CHANGELOG.md @@ -1,3 +1,8 @@ +15.1.0 / 2017-07-24 +================== +- [deps] allow eslint v3 or v4 (#1447) +- [deps] update `eslint-plugin-import`, `eslint-config-airbnb-base` + 15.0.2 / 2017-07-04 ================== - [fix] jsx should be enabled via parserOptions, not via a root ecmaFeatures diff --git a/packages/eslint-config-airbnb/package.json b/packages/eslint-config-airbnb/package.json index 1b06b38a97..4f48b8fee2 100644 --- a/packages/eslint-config-airbnb/package.json +++ b/packages/eslint-config-airbnb/package.json @@ -1,6 +1,6 @@ { "name": "eslint-config-airbnb", - "version": "15.0.2", + "version": "15.1.0", "description": "Airbnb's ESLint config, following our styleguide", "main": "index.js", "scripts": { From 0d938aecf20e2a6ad586e08155e177a25d12bc5e Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Mon, 24 Jul 2017 11:58:15 -0700 Subject: [PATCH 201/702] [eslint config] [base] [fix] `legacy`: remove top-level `ecmaFeatures` --- packages/eslint-config-airbnb-base/legacy.js | 2 -- 1 file changed, 2 deletions(-) diff --git a/packages/eslint-config-airbnb-base/legacy.js b/packages/eslint-config-airbnb-base/legacy.js index a73de7d8f7..7cc2441ab3 100644 --- a/packages/eslint-config-airbnb-base/legacy.js +++ b/packages/eslint-config-airbnb-base/legacy.js @@ -13,8 +13,6 @@ module.exports = { mocha: false, jasmine: false }, - ecmaFeatures: {}, - globals: {}, rules: { 'comma-dangle': ['error', 'never'], 'prefer-numeric-literals': 'off', From 106a58ec1ad903d702c2490880793aac577d8fb4 Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Mon, 24 Jul 2017 12:07:43 -0700 Subject: [PATCH 202/702] [eslint config] [base] v11.3.1 --- packages/eslint-config-airbnb-base/CHANGELOG.md | 4 ++++ packages/eslint-config-airbnb-base/package.json | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/packages/eslint-config-airbnb-base/CHANGELOG.md b/packages/eslint-config-airbnb-base/CHANGELOG.md index 80e394da8d..b238e2e329 100644 --- a/packages/eslint-config-airbnb-base/CHANGELOG.md +++ b/packages/eslint-config-airbnb-base/CHANGELOG.md @@ -1,3 +1,7 @@ +11.3.1 / 2017-07-24 +================== + - [fix] `legacy`: remove top-level `ecmaFeatures` + 11.3.0 / 2017-07-23 ================== - [deps] allow eslint v3 or v4 (#1447) diff --git a/packages/eslint-config-airbnb-base/package.json b/packages/eslint-config-airbnb-base/package.json index 008b1e198b..b4a676ac05 100644 --- a/packages/eslint-config-airbnb-base/package.json +++ b/packages/eslint-config-airbnb-base/package.json @@ -1,6 +1,6 @@ { "name": "eslint-config-airbnb-base", - "version": "11.3.0", + "version": "11.3.1", "description": "Airbnb's base JS ESLint config, following our styleguide", "main": "index.js", "scripts": { From 3cc6269c86ab5eb5cf4f307eb6573a7734b7fbfd Mon Sep 17 00:00:00 2001 From: Asher Dale Date: Thu, 20 Jul 2017 11:21:29 -0400 Subject: [PATCH 203/702] Updated README, deleted extra 'back to top' There was an extra 'back to top' link in between sections 4.5 and 4.6 in the 'Arrays' section. --- README.md | 2 -- 1 file changed, 2 deletions(-) diff --git a/README.md b/README.md index 59d2c994ac..6a7f905af9 100644 --- a/README.md +++ b/README.md @@ -417,8 +417,6 @@ Other Style Guides }); ``` -**[⬆ back to top](#table-of-contents)** - - [4.6](#arrays--bracket-newline) Use line breaks after open and before close array brackets if an array has multiple lines From a371d73414bfe534ce24d852877bed8135ebcc0a Mon Sep 17 00:00:00 2001 From: Asher Dale Date: Tue, 25 Jul 2017 15:46:30 -0400 Subject: [PATCH 204/702] Update README, fixed badly-styled eslint links There were links to eslint rules in a style that didn't match the style of the rest of the document. Specifically, most links in the document use the following style: "eslint: ['no-unneeded-ternary']", but there were badly styled links that looks like this: "eslint rule: ['no-unneeded-ternary']." Additionally, the badly styled links were on their own line, whereas all the other links are not placed on their own line. --- README.md | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index 6a7f905af9..2264a12558 100644 --- a/README.md +++ b/README.md @@ -1838,12 +1838,10 @@ Other Style Guides - [15.4](#comparison--moreinfo) For more information see [Truth Equality and JavaScript](https://javascriptweblog.wordpress.com/2011/02/07/truth-equality-and-javascript/#more-2108) by Angus Croll. - - [15.5](#comparison--switch-blocks) Use braces to create blocks in `case` and `default` clauses that contain lexical declarations (e.g. `let`, `const`, `function`, and `class`). + - [15.5](#comparison--switch-blocks) Use braces to create blocks in `case` and `default` clauses that contain lexical declarations (e.g. `let`, `const`, `function`, and `class`). eslint rules: [`no-case-declarations`](http://eslint.org/docs/rules/no-case-declarations.html) > Why? Lexical declarations are visible in the entire `switch` block but only get initialized when assigned, which only happens when its `case` is reached. This causes problems when multiple `case` clauses attempt to define the same thing. - eslint rules: [`no-case-declarations`](http://eslint.org/docs/rules/no-case-declarations.html). - ```javascript // bad switch (foo) { @@ -1888,9 +1886,7 @@ Other Style Guides ``` - - [15.6](#comparison--nested-ternaries) Ternaries should not be nested and generally be single line expressions. - - eslint rules: [`no-nested-ternary`](http://eslint.org/docs/rules/no-nested-ternary.html). + - [15.6](#comparison--nested-ternaries) Ternaries should not be nested and generally be single line expressions. eslint: [`no-nested-ternary`](http://eslint.org/docs/rules/no-nested-ternary.html) ```javascript // bad @@ -1912,9 +1908,7 @@ Other Style Guides ``` - - [15.7](#comparison--unneeded-ternary) Avoid unneeded ternary statements. - - eslint rules: [`no-unneeded-ternary`](http://eslint.org/docs/rules/no-unneeded-ternary.html). + - [15.7](#comparison--unneeded-ternary) Avoid unneeded ternary statements. eslint: [`no-unneeded-ternary`](http://eslint.org/docs/rules/no-unneeded-ternary.html) ```javascript // bad From 9393e6ab10f38dbf4b020fed81c20152ac9b8558 Mon Sep 17 00:00:00 2001 From: Asher Dale Date: Tue, 25 Jul 2017 15:50:10 -0400 Subject: [PATCH 205/702] Update README, finished fixing eslint styling Update README, finished fixing eslint styling (look at previous commit description for info). --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 2264a12558..f0b3eaa6c6 100644 --- a/README.md +++ b/README.md @@ -1838,7 +1838,7 @@ Other Style Guides - [15.4](#comparison--moreinfo) For more information see [Truth Equality and JavaScript](https://javascriptweblog.wordpress.com/2011/02/07/truth-equality-and-javascript/#more-2108) by Angus Croll. - - [15.5](#comparison--switch-blocks) Use braces to create blocks in `case` and `default` clauses that contain lexical declarations (e.g. `let`, `const`, `function`, and `class`). eslint rules: [`no-case-declarations`](http://eslint.org/docs/rules/no-case-declarations.html) + - [15.5](#comparison--switch-blocks) Use braces to create blocks in `case` and `default` clauses that contain lexical declarations (e.g. `let`, `const`, `function`, and `class`). eslint: [`no-case-declarations`](http://eslint.org/docs/rules/no-case-declarations.html) > Why? Lexical declarations are visible in the entire `switch` block but only get initialized when assigned, which only happens when its `case` is reached. This causes problems when multiple `case` clauses attempt to define the same thing. From a206c52854ec8de387289ceb3d88fefc7ff2b030 Mon Sep 17 00:00:00 2001 From: Will Clark Date: Tue, 25 Jul 2017 11:41:34 +0200 Subject: [PATCH 206/702] [eslint config] [base] [patch] Improve Gruntfile glob pattern To cover `Gruntfile` and `Gruntfile.js` instead of just `Gruntfile`. --- packages/eslint-config-airbnb-base/rules/imports.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/eslint-config-airbnb-base/rules/imports.js b/packages/eslint-config-airbnb-base/rules/imports.js index 0150724f6b..6116c6f67c 100644 --- a/packages/eslint-config-airbnb-base/rules/imports.js +++ b/packages/eslint-config-airbnb-base/rules/imports.js @@ -82,7 +82,7 @@ module.exports = { '**/rollup.config.*.js', // rollup config '**/gulpfile.js', // gulp config '**/gulpfile.*.js', // gulp config - '**/Gruntfile', // grunt config + '**/Gruntfile{,.js}', // grunt config '**/protractor.conf.*.js', // protractor config ], optionalDependencies: false, From e4f35ac959ce531e128d97cea051ddd76dd5aa6c Mon Sep 17 00:00:00 2001 From: Chris Atkin Date: Mon, 31 Jul 2017 17:12:27 +0100 Subject: [PATCH 207/702] Removing "GitHub" from In The Wild reference This removes the word "GitHub" from an In The Wild reference link, to prevent association with the main GitHub organisation. --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index f0b3eaa6c6..408a150cb6 100644 --- a/README.md +++ b/README.md @@ -3330,7 +3330,7 @@ Other Style Guides - **React**: [facebook.github.io/react/contributing/how-to-contribute.html#style-guide](https://facebook.github.io/react/contributing/how-to-contribute.html#style-guide) - **REI**: [reidev/js-style-guide](https://github.com/rei/code-style-guides/blob/master/docs/javascript.md) - **Ripple**: [ripple/javascript-style-guide](https://github.com/ripple/javascript-style-guide) - - **Sainsbury's Supermarkets**: [github/jsainsburyplc](https://github.com/jsainsburyplc) + - **Sainsbury's Supermarkets**: [jsainsburyplc](https://github.com/jsainsburyplc) - **SeekingAlpha**: [seekingalpha/javascript-style-guide](https://github.com/seekingalpha/javascript-style-guide) - **Shutterfly**: [shutterfly/javascript](https://github.com/shutterfly/javascript) - **Sourcetoad**: [sourcetoad/javascript](https://github.com/sourcetoad/javascript) From 16faade698a185d3a84f4c2c8ef70ec4cf712936 Mon Sep 17 00:00:00 2001 From: Eric Pan Date: Mon, 31 Jul 2017 11:19:07 -0700 Subject: [PATCH 208/702] [eslint config] [*] [docs] Specify yarn-specific install instructions Attempts to clarify and address issue https://github.com/airbnb/javascript/issues/1508#issuecomment-319113807 Recommends yarn users to list peer dependencies and then install each peer dependency with specified version. Prior yarn instructions led users to install the latest version of each peer dependency which, in some cases, led to errors if the latest version of a peer dependency did not have rules that this package uses. --- packages/eslint-config-airbnb-base/README.md | 2 +- packages/eslint-config-airbnb/README.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/eslint-config-airbnb-base/README.md b/packages/eslint-config-airbnb-base/README.md index 968cec06cd..881b86b2db 100644 --- a/packages/eslint-config-airbnb-base/README.md +++ b/packages/eslint-config-airbnb-base/README.md @@ -12,7 +12,7 @@ We export two ESLint configurations for your usage. Our default export contains all of our ESLint rules, including ECMAScript 6+. It requires `eslint` and `eslint-plugin-import`. -If you use yarn, run `yarn add --dev eslint-config-airbnb-base eslint-plugin-import`, or see below for npm instructions. +If you use yarn, run `npm info "eslint-config-airbnb-base@latest" peerDependencies` to list the peer dependencies and versions, then run `yarn add --dev @` for each listed peer dependency. See below for npm instructions. 1. Install the correct versions of each package, which are listed by the command: diff --git a/packages/eslint-config-airbnb/README.md b/packages/eslint-config-airbnb/README.md index a3a7c71340..567c929a31 100644 --- a/packages/eslint-config-airbnb/README.md +++ b/packages/eslint-config-airbnb/README.md @@ -12,7 +12,7 @@ We export three ESLint configurations for your usage. Our default export contains all of our ESLint rules, including ECMAScript 6+ and React. It requires `eslint`, `eslint-plugin-import`, `eslint-plugin-react`, and `eslint-plugin-jsx-a11y`. If you don't need React, see [eslint-config-airbnb-base](https://npmjs.com/eslint-config-airbnb-base). -If you use yarn, run `yarn add --dev eslint-config-airbnb-base eslint-plugin-import eslint-plugin-react eslint-plugin-jsx-a11y`, and see below for npm instructions. +If you use yarn, run `npm info "eslint-config-airbnb@latest" peerDependencies` to list the peer dependencies and versions, then run `yarn add --dev @` for each listed peer dependency. See below for npm instructions. 1. Install the correct versions of each package, which are listed by the command: From dbdbde0b81622d2f76c3babb9ddcfdbdf880190e Mon Sep 17 00:00:00 2001 From: marhub Date: Mon, 7 Aug 2017 12:48:54 +0200 Subject: [PATCH 209/702] Remove polish translation MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Remove link to polish translation as it's outdated ( last commit from 2-3 years ago ). For example in polish translation you can read that you should use one "var" keyword to declare your vars. example: ```js // źle ( bad ) var items = getItems(); var goSportsTeam = true; var dragonball = 'z'; // dobrze ( good ) var items = getItems(), goSportsTeam = true, dragonball = 'z'; ``` --- README.md | 1 - 1 file changed, 1 deletion(-) diff --git a/README.md b/README.md index 408a150cb6..f1cfe81db2 100644 --- a/README.md +++ b/README.md @@ -3367,7 +3367,6 @@ Other Style Guides - ![it](https://raw.githubusercontent.com/gosquared/flags/master/flags/flags/shiny/24/Italy.png) **Italian**: [sinkswim/javascript-style-guide](https://github.com/sinkswim/javascript-style-guide) - ![jp](https://raw.githubusercontent.com/gosquared/flags/master/flags/flags/shiny/24/Japan.png) **Japanese**: [mitsuruog/javascript-style-guide](https://github.com/mitsuruog/javascript-style-guide) - ![kr](https://raw.githubusercontent.com/gosquared/flags/master/flags/flags/shiny/24/South-Korea.png) **Korean**: [tipjs/javascript-style-guide](https://github.com/tipjs/javascript-style-guide) - - ![pl](https://raw.githubusercontent.com/gosquared/flags/master/flags/flags/shiny/24/Poland.png) **Polish**: [mjurczyk/javascript](https://github.com/mjurczyk/javascript) - ![ru](https://raw.githubusercontent.com/gosquared/flags/master/flags/flags/shiny/24/Russia.png) **Russian**: [leonidlebedev/javascript-airbnb](https://github.com/leonidlebedev/javascript-airbnb) - ![es](https://raw.githubusercontent.com/gosquared/flags/master/flags/flags/shiny/24/Spain.png) **Spanish**: [paolocarrasco/javascript-style-guide](https://github.com/paolocarrasco/javascript-style-guide) - ![th](https://raw.githubusercontent.com/gosquared/flags/master/flags/flags/shiny/24/Thailand.png) **Thai**: [lvarayut/javascript-style-guide](https://github.com/lvarayut/javascript-style-guide) From b5e14dc5d06ddbadc0bc932b7f988f9552fb667e Mon Sep 17 00:00:00 2001 From: Jared Deckard Date: Mon, 7 Aug 2017 15:36:22 -0500 Subject: [PATCH 210/702] Explain why default exports are preferred --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index f1cfe81db2..562eebc955 100644 --- a/README.md +++ b/README.md @@ -1285,6 +1285,7 @@ Other Style Guides - [10.6](#modules--prefer-default-export) In modules with a single export, prefer default export over named export. eslint: [`import/prefer-default-export`](https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/prefer-default-export.md) + > Why? To encourage more files that only ever export one thing, which is better for readability and maintainability. ```javascript // bad From 6bd73560eea8f3c00c8185f96799f69ad4ba1fcb Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Wed, 9 Aug 2017 17:35:23 -0700 Subject: [PATCH 211/702] [eslint config] [deps] update `eslint` v4, `eslint-plugin-react`, `tape` --- packages/eslint-config-airbnb/package.json | 10 ++++----- packages/eslint-config-airbnb/rules/react.js | 23 ++++++++++++++++++-- 2 files changed, 26 insertions(+), 7 deletions(-) diff --git a/packages/eslint-config-airbnb/package.json b/packages/eslint-config-airbnb/package.json index 4f48b8fee2..41fa65abbb 100644 --- a/packages/eslint-config-airbnb/package.json +++ b/packages/eslint-config-airbnb/package.json @@ -54,21 +54,21 @@ "babel-preset-airbnb": "^2.4.0", "babel-tape-runner": "^2.0.1", "editorconfig-tools": "^0.1.1", - "eslint": "^3.19.0 || ^4.3.0", + "eslint": "^3.19.0 || ^4.4.1", "eslint-find-rules": "^3.1.1", "eslint-plugin-import": "^2.7.0", "eslint-plugin-jsx-a11y": "^5.1.1", - "eslint-plugin-react": "^7.1.0", + "eslint-plugin-react": "^7.2.0", "in-publish": "^2.0.0", "react": ">= 0.13.0", "safe-publish-latest": "^1.1.1", - "tape": "^4.7.0" + "tape": "^4.8.0" }, "peerDependencies": { - "eslint": "^3.19.0 || ^4.3.0", + "eslint": "^3.19.0 || ^4.4.1", "eslint-plugin-jsx-a11y": "^5.1.1", "eslint-plugin-import": "^2.7.0", - "eslint-plugin-react": "^7.1.0" + "eslint-plugin-react": "^7.2.0" }, "engines": { "node": ">= 4" diff --git a/packages/eslint-config-airbnb/rules/react.js b/packages/eslint-config-airbnb/rules/react.js index 96e5f4a75d..c5503a17b1 100644 --- a/packages/eslint-config-airbnb/rules/react.js +++ b/packages/eslint-config-airbnb/rules/react.js @@ -42,7 +42,7 @@ module.exports = { // Enforce boolean attributes notation in JSX // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-boolean-value.md - 'react/jsx-boolean-value': ['error', 'never'], + 'react/jsx-boolean-value': ['error', 'never', { always: [] }], // Validate closing bracket location in JSX // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-closing-bracket-location.md @@ -90,7 +90,7 @@ module.exports = { // Prevent usage of unwrapped JSX strings // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-no-literals.md - 'react/jsx-no-literals': 'off', + 'react/jsx-no-literals': ['off', { noStrings: true }], // Disallow undeclared variables in JSX // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-no-undef.md @@ -208,6 +208,8 @@ module.exports = { 'static-methods', 'lifecycle', '/^on.+$/', + 'getters', + 'setters', '/^(get|set)(?!(InitialState$|DefaultProps$|ChildContext$)).+$/', 'everything-else', '/^render.+$/', @@ -330,6 +332,23 @@ module.exports = { // https://github.com/yannickcr/eslint-plugin-react/blob/9e13ae2c51e44872b45cc15bf1ac3a72105bdd0e/docs/rules/no-redundant-should-component-update.md // TODO: enable, semver-major 'react/no-redundant-should-component-update': 'off', + + // Prevent unused state values + // https://github.com/yannickcr/eslint-plugin-react/pull/1103/files + // TODO: enable? semver-major + 'react/no-unused-state': 'off', + + // Enforces consistent naming for boolean props + // https://github.com/yannickcr/eslint-plugin-react/blob/73abadb697034b5ccb514d79fb4689836fe61f91/docs/rules/boolean-prop-naming.md + 'react/boolean-prop-naming': ['off', { + propTypeNames: ['bool', 'mutuallyExclusiveTrueProps'], + rule: '^(is|has)[A-Z]([A-Za-z0-9]?)+', + }], + + // Prevents common casing typos + // https://github.com/yannickcr/eslint-plugin-react/blob/73abadb697034b5ccb514d79fb4689836fe61f91/docs/rules/no-typos.md + // TODO: enable, semver-major + 'react/no-typos': 'off', }, settings: { From 1cddb4f2c0069000c235817069cc4449ce2ed681 Mon Sep 17 00:00:00 2001 From: Mark Larah Date: Mon, 14 Aug 2017 19:49:29 -0700 Subject: [PATCH 212/702] [eslint config] [base] [patch] Add jest.config.js to import/no-extraneous-dependencies devDeps --- packages/eslint-config-airbnb-base/rules/imports.js | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/eslint-config-airbnb-base/rules/imports.js b/packages/eslint-config-airbnb-base/rules/imports.js index 6116c6f67c..2700194efe 100644 --- a/packages/eslint-config-airbnb-base/rules/imports.js +++ b/packages/eslint-config-airbnb-base/rules/imports.js @@ -76,6 +76,7 @@ module.exports = { 'test.{js,jsx}', // repos with a single test file 'test-*.{js,jsx}', // repos with multiple top-level test files '**/*.{test,spec}.{js,jsx}', // tests where the extension denotes that it is a test + '**/jest.config.js', // jest config '**/webpack.config.js', // webpack config '**/webpack.config.*.js', // webpack config '**/rollup.config.js', // rollup config From 344c25d83a91c7a9c456e6fc9d5b40d1b924f8d3 Mon Sep 17 00:00:00 2001 From: Wooram Jun Date: Thu, 17 Aug 2017 15:35:14 +0900 Subject: [PATCH 213/702] Fix a wrong link --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 562eebc955..65309ed421 100644 --- a/README.md +++ b/README.md @@ -2658,7 +2658,7 @@ Other Style Guides })()); ``` - [Read more](https://stackoverflow.com/questions/7365172/semicolon-before-self-invoking-function/7365214%237365214). + [Read more](https://stackoverflow.com/questions/7365172/semicolon-before-self-invoking-function/7365214#7365214). **[⬆ back to top](#table-of-contents)** From 855426b3db99b07469962b4d1515757d8284dda0 Mon Sep 17 00:00:00 2001 From: Anton Vasyunin Date: Fri, 18 Aug 2017 00:05:21 +0700 Subject: [PATCH 214/702] Update section on naming conventions for acronyms - Fix array name starting with a capital - Add alternative good example --- README.md | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 65309ed421..69ff656e32 100644 --- a/README.md +++ b/README.md @@ -2928,11 +2928,16 @@ Other Style Guides // ... ]; + // also good + const httpRequests = [ + // ... + ]; + // best import TextMessageContainer from './containers/TextMessageContainer'; // best - const Requests = [ + const requests = [ // ... ]; ``` From 09988e34b4d580af8f6988b438ce492686ad2759 Mon Sep 17 00:00:00 2001 From: Max Kaplan Date: Sun, 20 Aug 2017 09:24:03 -0400 Subject: [PATCH 215/702] [inthewild] adding kaplan komputing --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 69ff656e32..b9887ff20a 100644 --- a/README.md +++ b/README.md @@ -3313,6 +3313,7 @@ Other Style Guides - **Jam3**: [Jam3/Javascript-Code-Conventions](https://github.com/Jam3/Javascript-Code-Conventions) - **JeopardyBot**: [kesne/jeopardy-bot](https://github.com/kesne/jeopardy-bot/blob/master/STYLEGUIDE.md) - **JSSolutions**: [JSSolutions/javascript](https://github.com/JSSolutions/javascript) + - **Kaplan Komputing**: [kaplankomputing/javascript](https://github.com/kaplankomputing/javascript) - **KickorStick**: [kickorstick/javascript](https://github.com/kickorstick/javascript) - **Kinetica Solutions**: [kinetica/javascript](https://github.com/kinetica/Javascript-style-guide) - **LEINWAND**: [LEINWAND/javascript](https://github.com/LEINWAND/javascript) From a79237b02090df922f54b1082515139a59f04874 Mon Sep 17 00:00:00 2001 From: Dhruvdutt Jadhav Date: Thu, 17 Aug 2017 22:54:31 +0530 Subject: [PATCH 216/702] =?UTF-8?q?[guide]=20[react]=20add=20another=20?= =?UTF-8?q?=E2=80=9Cgood=E2=80=9D=20example?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- react/README.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/react/README.md b/react/README.md index b86f743f23..b1ba2ac7a7 100644 --- a/react/README.md +++ b/react/README.md @@ -269,6 +269,9 @@