From 5fd7c6f08c0650ed67297fc83c8a0590c9a92cc8 Mon Sep 17 00:00:00 2001 From: Estelle Date: Mon, 23 Mar 2015 18:48:19 -0700 Subject: [PATCH 001/826] 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 646fa70f591e22d9edbd2810d5549e00efbc6dd6 Mon Sep 17 00:00:00 2001 From: Maxim Date: Mon, 8 Aug 2016 11:14:05 +0300 Subject: [PATCH 002/826] Update README.md --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 966c263eae..6b11efefc1 100644 --- a/README.md +++ b/README.md @@ -2890,6 +2890,7 @@ Other Style Guides - **Shutterfly**: [shutterfly/javascript](https://github.com/shutterfly/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) - **StudentSphere**: [studentsphere/javascript](https://github.com/studentsphere/guide-javascript) - **SysGarage**: [sysgarage/javascript-style-guide](https://github.com/sysgarage/javascript-style-guide) - **Syzygy Warsaw**: [syzygypl/javascript](https://github.com/syzygypl/javascript) From d20f33f660f36de6576e99c5397e2dbb307f012e Mon Sep 17 00:00:00 2001 From: Mitsuru Ogawa Date: Tue, 9 Aug 2016 19:06:43 +0900 Subject: [PATCH 003/826] Add link for Japanese translation --- react/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/react/README.md b/react/README.md index b216e14c72..eee0170c0d 100644 --- a/react/README.md +++ b/react/README.md @@ -575,5 +575,6 @@ - ![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) - ![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) **[⬆ back to top](#table-of-contents)** From 0b8e466397e538f3120ae92d0f5461262a7750cd Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Tue, 9 Aug 2016 09:08:49 -0700 Subject: [PATCH 004/826] [eslint config] [*] [deps] update `eslint`, `eslint-find-rules` --- packages/eslint-config-airbnb-base/package.json | 6 +++--- packages/eslint-config-airbnb/package.json | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/packages/eslint-config-airbnb-base/package.json b/packages/eslint-config-airbnb-base/package.json index a2934ca39b..bda0880ee1 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.0.0", "babel-tape-runner": "^2.0.1", - "eslint": "^3.2.0", - "eslint-find-rules": "^1.11.1", + "eslint": "^3.2.2", + "eslint-find-rules": "^1.13.0", "eslint-plugin-import": "^1.12.0", "in-publish": "^2.0.0", "safe-publish-latest": "^1.0.1", "tape": "^4.6.0" }, "peerDependencies": { - "eslint": "^3.2.0", + "eslint": "^3.2.2", "eslint-plugin-import": "^1.12.0" }, "engines": { diff --git a/packages/eslint-config-airbnb/package.json b/packages/eslint-config-airbnb/package.json index 778632f071..4a26da1cd6 100644 --- a/packages/eslint-config-airbnb/package.json +++ b/packages/eslint-config-airbnb/package.json @@ -51,12 +51,12 @@ "babel-preset-airbnb": "^2.0.0", "babel-tape-runner": "^2.0.1", "eslint": "^3.2.2", - "eslint-find-rules": "^1.11.1", + "eslint-find-rules": "^1.13.0", "eslint-plugin-import": "^1.12.0", "eslint-plugin-jsx-a11y": "^2.0.1", "eslint-plugin-react": "^6.0.0", "in-publish": "^2.0.0", - "react": ">= 0.13.0", + "react": "> 0.13.0", "safe-publish-latest": "^1.0.1", "tape": "^4.6.0" }, From fb0f03f676aa604198d9a3f8f9903fd3c1ac68e9 Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Fri, 12 Aug 2016 15:36:56 -0700 Subject: [PATCH 005/826] [eslint config] [base] [deps] update `eslint`, `eslint-plugin-import` - add temp disabled `func-call-spacing` rule - add temp disabled `no-template-curly-in-string` rule - enable `no-global-assign` and deprecate `no-native-reassign` - enable `no-unsafe-negation` and deprecate `no-negated-in-lhs` - add disabled `sort-keys` rule --- packages/eslint-config-airbnb-base/package.json | 8 ++++---- .../rules/best-practices.js | 7 ++++++- packages/eslint-config-airbnb-base/rules/errors.js | 12 +++++++++++- packages/eslint-config-airbnb-base/rules/style.js | 8 ++++++++ 4 files changed, 29 insertions(+), 6 deletions(-) diff --git a/packages/eslint-config-airbnb-base/package.json b/packages/eslint-config-airbnb-base/package.json index bda0880ee1..93aeba1ede 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.0.0", "babel-tape-runner": "^2.0.1", - "eslint": "^3.2.2", + "eslint": "^3.3.0", "eslint-find-rules": "^1.13.0", - "eslint-plugin-import": "^1.12.0", + "eslint-plugin-import": "^1.13.0", "in-publish": "^2.0.0", "safe-publish-latest": "^1.0.1", "tape": "^4.6.0" }, "peerDependencies": { - "eslint": "^3.2.2", - "eslint-plugin-import": "^1.12.0" + "eslint": "^3.3.0", + "eslint-plugin-import": "^1.13.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 838ae71368..f4c46eabef 100644 --- a/packages/eslint-config-airbnb-base/rules/best-practices.js +++ b/packages/eslint-config-airbnb-base/rules/best-practices.js @@ -89,6 +89,10 @@ module.exports = { // disallow the use of leading or trailing decimal points in numeric literals 'no-floating-decimal': 2, + // disallow reassignments of native objects or read-only globals + // http://eslint.org/docs/rules/no-global-assign + 'no-global-assign': [2, { exceptions: [] }], + // disallow implicit type conversions // http://eslint.org/docs/rules/no-implicit-coercion 'no-implicit-coercion': [0, { @@ -136,7 +140,8 @@ module.exports = { 'no-multi-str': 2, // disallow reassignments of native objects - 'no-native-reassign': 2, + // TODO: deprecated in favor of no-global-assign + 'no-native-reassign': 0, // disallow use of new operator when not part of the assignment or comparison 'no-new': 2, diff --git a/packages/eslint-config-airbnb-base/rules/errors.js b/packages/eslint-config-airbnb-base/rules/errors.js index 7221cd1647..66396cd594 100644 --- a/packages/eslint-config-airbnb-base/rules/errors.js +++ b/packages/eslint-config-airbnb-base/rules/errors.js @@ -64,7 +64,8 @@ module.exports = { 'no-irregular-whitespace': 2, // disallow negation of the left operand of an in expression - 'no-negated-in-lhs': 2, + // TODO: deprecated in favor of no-unsafe-negation + 'no-negated-in-lhs': 0, // disallow the use of object properties of the global object (Math and JSON) as functions 'no-obj-calls': 2, @@ -79,6 +80,11 @@ module.exports = { // disallow sparse arrays 'no-sparse-arrays': 2, + // Disallow template literal placeholder syntax in regular strings + // http://eslint.org/docs/rules/no-template-curly-in-string + // TODO: enable, semver-major + 'no-template-curly-in-string': 0, + // Avoid code that looks like two expressions but is actually one // http://eslint.org/docs/rules/no-unexpected-multiline 'no-unexpected-multiline': 2, @@ -90,6 +96,10 @@ module.exports = { // http://eslint.org/docs/rules/no-unsafe-finally 'no-unsafe-finally': 2, + // disallow negating the left operand of relational operators + // http://eslint.org/docs/rules/no-unsafe-negation + 'no-unsafe-negation': 2, + // disallow comparisons with the value NaN 'use-isnan': 2, diff --git a/packages/eslint-config-airbnb-base/rules/style.js b/packages/eslint-config-airbnb-base/rules/style.js index dd21a4aefb..5d8825aab9 100644 --- a/packages/eslint-config-airbnb-base/rules/style.js +++ b/packages/eslint-config-airbnb-base/rules/style.js @@ -28,6 +28,11 @@ module.exports = { // enforce newline at the end of file, with no multiple empty lines 'eol-last': 2, + // enforce spacing between functions and their invocations + // http://eslint.org/docs/rules/func-call-spacing + // TODO: enable, semver-minor + 'func-call-spacing': [0, 'never'], + // require function expressions to have a name 'func-names': 1, @@ -264,6 +269,9 @@ module.exports = { // enforce spacing before and after semicolons 'semi-spacing': [2, { before: false, after: true }], + // requires object keys to be sorted + 'sort-keys': [0, 'asc', { caseSensitive: false, natural: true }], + // sort variables within the same declaration block 'sort-vars': 0, From be6e13f7b91ede245602c9760d112905ac497dcc Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Fri, 12 Aug 2016 15:38:44 -0700 Subject: [PATCH 006/826] [eslint config] [base] v5.0.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 9baf2527b9..f26c1d9cb3 100644 --- a/packages/eslint-config-airbnb-base/CHANGELOG.md +++ b/packages/eslint-config-airbnb-base/CHANGELOG.md @@ -1,3 +1,8 @@ +5.0.2 / 2016-08-12 +================== + - [deps] update `eslint`, `eslint-find-rules`, `eslint-plugin-import` + - [tests] add `safe-publish-latest` to `prepublish` + 5.0.1 / 2016-07-29 ================== - [patch] `no-unused-expressions`: flesh out options diff --git a/packages/eslint-config-airbnb-base/package.json b/packages/eslint-config-airbnb-base/package.json index 93aeba1ede..0be10a421a 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": "5.0.1", + "version": "5.0.2", "description": "Airbnb's base JS ESLint config, following our styleguide", "main": "index.js", "scripts": { From 7d9af14ce48791775c1c39e8c28991907b1e8b40 Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Fri, 12 Aug 2016 15:49:18 -0700 Subject: [PATCH 007/826] [eslint config] [deps] update `eslint`, `eslint-plugin-jsx-a11y`, `eslint-plugin-import`, `eslint-config-airbnb-base` - add temp disabled `jsx-a11y/anchor-has-content` rule --- packages/eslint-config-airbnb/package.json | 14 +++++++------- packages/eslint-config-airbnb/rules/react-a11y.js | 5 +++++ 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/packages/eslint-config-airbnb/package.json b/packages/eslint-config-airbnb/package.json index 4a26da1cd6..7f1540f376 100644 --- a/packages/eslint-config-airbnb/package.json +++ b/packages/eslint-config-airbnb/package.json @@ -45,15 +45,15 @@ }, "homepage": "https://github.com/airbnb/javascript", "dependencies": { - "eslint-config-airbnb-base": "^5.0.1" + "eslint-config-airbnb-base": "^5.0.2" }, "devDependencies": { "babel-preset-airbnb": "^2.0.0", "babel-tape-runner": "^2.0.1", - "eslint": "^3.2.2", + "eslint": "^3.3.0", "eslint-find-rules": "^1.13.0", - "eslint-plugin-import": "^1.12.0", - "eslint-plugin-jsx-a11y": "^2.0.1", + "eslint-plugin-import": "^1.13.0", + "eslint-plugin-jsx-a11y": "^2.1.0", "eslint-plugin-react": "^6.0.0", "in-publish": "^2.0.0", "react": "> 0.13.0", @@ -61,9 +61,9 @@ "tape": "^4.6.0" }, "peerDependencies": { - "eslint": "^3.2.2", - "eslint-plugin-jsx-a11y": "^2.0.1", - "eslint-plugin-import": "^1.12.0", + "eslint": "^3.3.0", + "eslint-plugin-jsx-a11y": "^2.1.0", + "eslint-plugin-import": "^1.13.0", "eslint-plugin-react": "^6.0.0" }, "engines": { diff --git a/packages/eslint-config-airbnb/rules/react-a11y.js b/packages/eslint-config-airbnb/rules/react-a11y.js index bc2b4cff74..9e1c664449 100644 --- a/packages/eslint-config-airbnb/rules/react-a11y.js +++ b/packages/eslint-config-airbnb/rules/react-a11y.js @@ -7,6 +7,11 @@ module.exports = { jsx: true }, rules: { + // Enforce that anchors have content + // https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/anchor-has-content.md + // TODO: enable, semver-major + 'jsx-a11y/anchor-has-content': [0, ['']], + // 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': 2, From 3fb9f2ec695b80d06fb03212f1846fb7492cb8c5 Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Fri, 12 Aug 2016 15:52:10 -0700 Subject: [PATCH 008/826] [eslint config] v10.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 f353154156..bb88fb3659 100644 --- a/packages/eslint-config-airbnb/CHANGELOG.md +++ b/packages/eslint-config-airbnb/CHANGELOG.md @@ -1,3 +1,7 @@ +10.0.1 / 2016-08-12 +================== +- [deps] update `eslint`, `eslint-find-rules`, `eslint-plugin-jsx-a11y`, `eslint-plugin-import`, `eslint-config-airbnb-base` + 10.0.0 / 2016-08-01 ================== - [breaking] enable jsx-a11y rules: diff --git a/packages/eslint-config-airbnb/package.json b/packages/eslint-config-airbnb/package.json index 7f1540f376..5887859ebb 100644 --- a/packages/eslint-config-airbnb/package.json +++ b/packages/eslint-config-airbnb/package.json @@ -1,6 +1,6 @@ { "name": "eslint-config-airbnb", - "version": "10.0.0", + "version": "10.0.1", "description": "Airbnb's ESLint config, following our styleguide", "main": "index.js", "scripts": { From 424d74ec8db255b00ac68e17d33a7524f7de39b3 Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Mon, 15 Aug 2016 00:21:39 -0700 Subject: [PATCH 009/826] [eslint config] [deps] update `eslint-plugin-react` --- packages/eslint-config-airbnb/package.json | 4 ++-- packages/eslint-config-airbnb/rules/react.js | 9 +++++++++ 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/packages/eslint-config-airbnb/package.json b/packages/eslint-config-airbnb/package.json index 5887859ebb..f674595db5 100644 --- a/packages/eslint-config-airbnb/package.json +++ b/packages/eslint-config-airbnb/package.json @@ -54,7 +54,7 @@ "eslint-find-rules": "^1.13.0", "eslint-plugin-import": "^1.13.0", "eslint-plugin-jsx-a11y": "^2.1.0", - "eslint-plugin-react": "^6.0.0", + "eslint-plugin-react": "^6.1.0", "in-publish": "^2.0.0", "react": "> 0.13.0", "safe-publish-latest": "^1.0.1", @@ -64,7 +64,7 @@ "eslint": "^3.3.0", "eslint-plugin-jsx-a11y": "^2.1.0", "eslint-plugin-import": "^1.13.0", - "eslint-plugin-react": "^6.0.0" + "eslint-plugin-react": "^6.1.0" }, "engines": { "node": ">= 4" diff --git a/packages/eslint-config-airbnb/rules/react.js b/packages/eslint-config-airbnb/rules/react.js index 53961c368d..4bb15b6bd5 100644 --- a/packages/eslint-config-airbnb/rules/react.js +++ b/packages/eslint-config-airbnb/rules/react.js @@ -243,6 +243,15 @@ module.exports = { // warn against using findDOMNode() // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/no-find-dom-node.md 'react/no-find-dom-node': 2, + + // Forbid certain props on Components + // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/forbid-component-props.md + 'react/forbid-component-props': [0, { forbid: [] }], + + // Prevent problem with children and props.dangerouslySetInnerHTML + // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/no-danger-with-children.md + // TODO: enable, semver-major + 'react/no-danger-with-children': 0, }, settings: { From db2e7bdf63fd7827af0922662f408410afc916a3 Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Mon, 15 Aug 2016 23:17:04 -0700 Subject: [PATCH 010/826] [eslint config] [base] [fix] correct `import/extensions` list. From b45fdcd60f6e08f13718bc2348e8d6ea1314e91c / fixes #1013. --- 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 eb0610760f..821818909d 100644 --- a/packages/eslint-config-airbnb-base/rules/imports.js +++ b/packages/eslint-config-airbnb-base/rules/imports.js @@ -17,7 +17,8 @@ module.exports = { } }, 'import/extensions': [ - 'node_modules', + '.js', + '.jsx', ], 'import/core-modules': [ ], From e92eaef4e2aefc7bbd3576dc28e7d0c52ba63c7d Mon Sep 17 00:00:00 2001 From: Gerardo Renovales Date: Wed, 17 Aug 2016 19:46:55 -0400 Subject: [PATCH 011/826] Update README.md Add M2GEN to the list --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 6b11efefc1..851b46e16b 100644 --- a/README.md +++ b/README.md @@ -2869,6 +2869,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) + - **M2GEN**: [M2GEN/javascript](https://github.com/M2GEN/javascript) - **Mighty Spring**: [mightyspring/javascript](https://github.com/mightyspring/javascript) - **MinnPost**: [MinnPost/javascript](https://github.com/MinnPost/javascript) - **MitocGroup**: [MitocGroup/javascript](https://github.com/MitocGroup/javascript) From b1260164108fbdba88946f650f7a0ab1313bdf10 Mon Sep 17 00:00:00 2001 From: Aniruddh Agarwal Date: Wed, 17 Aug 2016 13:20:08 +0800 Subject: [PATCH 012/826] Add section on variable assignment chaining --- README.md | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/README.md b/README.md index 851b46e16b..b3975e2e9f 100644 --- a/README.md +++ b/README.md @@ -1417,6 +1417,38 @@ Other Style Guides return name; } ``` + + - [13.5](#variables--no-chain-assignment) Don't chain variable assignments. eslint: [`one-var`](http://eslint.org/docs/rules/one-var.html) + + > Why? Chaining variable assignments creates implicit global variables. + + ```javascript + // bad + (function example() { + // JavaScript interprets this as + // let a = ( b = ( c = 1 ) ); + // The let keyword only applies to variable a; variables b and c become + // global variables. + let a = b = c = 1; + }()); + + console.log(a); // undefined + console.log(b); // 1 + console.log(c); // 1 + + // good + (function example() { + let a = 1; + let b = a; + let c = a; + }()); + + console.log(a); // undefined + console.log(b); // undefined + console.log(c); // undefined + + // the same applies for `const` + ``` **[⬆ back to top](#table-of-contents)** From 3ad33681a7260608b89be41221fa22024cce4a33 Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Thu, 18 Aug 2016 00:50:37 -0700 Subject: [PATCH 013/826] [eslint config] [*] [deps] update `eslint`, `eslint-plugin-react` --- packages/eslint-config-airbnb-base/package.json | 4 ++-- packages/eslint-config-airbnb/package.json | 10 +++++----- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/packages/eslint-config-airbnb-base/package.json b/packages/eslint-config-airbnb-base/package.json index 0be10a421a..ed9014e2de 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.0.0", "babel-tape-runner": "^2.0.1", - "eslint": "^3.3.0", + "eslint": "^3.3.1", "eslint-find-rules": "^1.13.0", "eslint-plugin-import": "^1.13.0", "in-publish": "^2.0.0", @@ -55,7 +55,7 @@ "tape": "^4.6.0" }, "peerDependencies": { - "eslint": "^3.3.0", + "eslint": "^3.3.1", "eslint-plugin-import": "^1.13.0" }, "engines": { diff --git a/packages/eslint-config-airbnb/package.json b/packages/eslint-config-airbnb/package.json index f674595db5..c176f07da3 100644 --- a/packages/eslint-config-airbnb/package.json +++ b/packages/eslint-config-airbnb/package.json @@ -50,21 +50,21 @@ "devDependencies": { "babel-preset-airbnb": "^2.0.0", "babel-tape-runner": "^2.0.1", - "eslint": "^3.3.0", + "eslint": "^3.3.1", "eslint-find-rules": "^1.13.0", "eslint-plugin-import": "^1.13.0", "eslint-plugin-jsx-a11y": "^2.1.0", - "eslint-plugin-react": "^6.1.0", + "eslint-plugin-react": "^6.1.2", "in-publish": "^2.0.0", - "react": "> 0.13.0", + "react": ">= 0.13.0", "safe-publish-latest": "^1.0.1", "tape": "^4.6.0" }, "peerDependencies": { - "eslint": "^3.3.0", + "eslint": "^3.3.1", "eslint-plugin-jsx-a11y": "^2.1.0", "eslint-plugin-import": "^1.13.0", - "eslint-plugin-react": "^6.1.0" + "eslint-plugin-react": "^6.1.2" }, "engines": { "node": ">= 4" From 41623039e89296819d243e2b23004d3cb53e425f Mon Sep 17 00:00:00 2001 From: Olivier G Date: Thu, 18 Aug 2016 17:33:23 +0200 Subject: [PATCH 014/826] Typo : text link to 13.5 was not working (#1020) --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index b3975e2e9f..350aece0d7 100644 --- a/README.md +++ b/README.md @@ -1417,7 +1417,7 @@ Other Style Guides return name; } ``` - + - [13.5](#variables--no-chain-assignment) Don't chain variable assignments. eslint: [`one-var`](http://eslint.org/docs/rules/one-var.html) > Why? Chaining variable assignments creates implicit global variables. From 39d5559b9a75c818c529d7f5265b8651b96b875a Mon Sep 17 00:00:00 2001 From: Joe Lencioni Date: Thu, 18 Aug 2016 10:35:23 -0700 Subject: [PATCH 015/826] Remove misleading reference to one-var eslint rule This eslint rule does not enforce this style guide rule. I believe that referencing it here will cause people to believe that this is enforced via linting when it is not. As far as I know, there is no rule that currently enforces this, but it would be nice to add one. --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 350aece0d7..4223bf4fd3 100644 --- a/README.md +++ b/README.md @@ -1418,7 +1418,7 @@ Other Style Guides } ``` - - [13.5](#variables--no-chain-assignment) Don't chain variable assignments. eslint: [`one-var`](http://eslint.org/docs/rules/one-var.html) + - [13.5](#variables--no-chain-assignment) Don't chain variable assignments. > Why? Chaining variable assignments creates implicit global variables. From baf0fa5343caecbbcd4684a3a6446b4447b51e91 Mon Sep 17 00:00:00 2001 From: soul-wish Date: Thu, 18 Aug 2016 22:35:42 +0300 Subject: [PATCH 016/826] fix issue with eslint-config-airbnb README.md file formatting --- packages/eslint-config-airbnb/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/eslint-config-airbnb/README.md b/packages/eslint-config-airbnb/README.md index a96a9fe138..7a0b8c68b6 100644 --- a/packages/eslint-config-airbnb/README.md +++ b/packages/eslint-config-airbnb/README.md @@ -27,6 +27,7 @@ Our default export contains all of our ESLint rules, including ECMAScript 6+ and ``` 2. Add `"extends": "airbnb"` to your .eslintrc + ### eslint-config-airbnb/base This entry point is deprecated. See [eslint-config-airbnb-base](https://npmjs.com/eslint-config-airbnb-base). From f1fedfa7ca480743b9482f3befdacf7297f6773c Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Thu, 18 Aug 2016 23:08:45 -0700 Subject: [PATCH 017/826] ES2015 --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 4223bf4fd3..cb0cbac948 100644 --- a/README.md +++ b/README.md @@ -40,7 +40,7 @@ Other Style Guides 1. [Events](#events) 1. [jQuery](#jquery) 1. [ECMAScript 5 Compatibility](#ecmascript-5-compatibility) - 1. [ECMAScript 6 Styles](#ecmascript-6-styles) + 1. [ECMAScript 6+ (ES 2015+) Styles](#ecmascript-6-styles) 1. [Testing](#testing) 1. [Performance](#performance) 1. [Resources](#resources) From 2e694723bf35b5fae5961be62fd12c4536a0d945 Mon Sep 17 00:00:00 2001 From: Yang Su Date: Sat, 9 Jul 2016 10:58:45 -0700 Subject: [PATCH 018/826] Changed ESLint rule configs to use 'off', 'warn', and 'error' instead of numbers for better readability --- packages/eslint-config-airbnb-base/index.js | 2 +- packages/eslint-config-airbnb-base/legacy.js | 2 +- .../rules/best-practices.js | 130 +++++++-------- .../eslint-config-airbnb-base/rules/errors.js | 64 ++++---- .../eslint-config-airbnb-base/rules/es6.js | 58 +++---- .../rules/imports.js | 42 ++--- .../eslint-config-airbnb-base/rules/node.js | 20 +-- .../eslint-config-airbnb-base/rules/strict.js | 2 +- .../eslint-config-airbnb-base/rules/style.js | 154 +++++++++--------- .../rules/variables.js | 24 +-- .../eslint-config-airbnb/rules/react-a11y.js | 44 ++--- packages/eslint-config-airbnb/rules/react.js | 106 ++++++------ 12 files changed, 324 insertions(+), 324 deletions(-) diff --git a/packages/eslint-config-airbnb-base/index.js b/packages/eslint-config-airbnb-base/index.js index 547e8b2ac5..c89431a0c5 100644 --- a/packages/eslint-config-airbnb-base/index.js +++ b/packages/eslint-config-airbnb-base/index.js @@ -13,6 +13,6 @@ module.exports = { sourceType: 'module', }, rules: { - strict: 2, + strict: 'error', } }; diff --git a/packages/eslint-config-airbnb-base/legacy.js b/packages/eslint-config-airbnb-base/legacy.js index f3dacc4c7b..9acfb1cb4e 100644 --- a/packages/eslint-config-airbnb-base/legacy.js +++ b/packages/eslint-config-airbnb-base/legacy.js @@ -16,6 +16,6 @@ module.exports = { ecmaFeatures: {}, globals: {}, rules: { - 'comma-dangle': [2, 'never'] + 'comma-dangle': ['error', 'never'] } }; diff --git a/packages/eslint-config-airbnb-base/rules/best-practices.js b/packages/eslint-config-airbnb-base/rules/best-practices.js index f4c46eabef..26602745de 100644 --- a/packages/eslint-config-airbnb-base/rules/best-practices.js +++ b/packages/eslint-config-airbnb-base/rules/best-practices.js @@ -1,61 +1,61 @@ module.exports = { rules: { // enforces getter/setter pairs in objects - 'accessor-pairs': 0, + 'accessor-pairs': 'off', // enforces return statements in callbacks of array's methods // http://eslint.org/docs/rules/array-callback-return - 'array-callback-return': 2, + 'array-callback-return': 'error', // treat var statements as if they were block scoped - 'block-scoped-var': 2, + 'block-scoped-var': 'error', // specify the maximum cyclomatic complexity allowed in a program - complexity: [0, 11], + complexity: ['off', 11], // require return statements to either always or never specify values - 'consistent-return': 2, + 'consistent-return': 'error', // specify curly brace conventions for all control statements - curly: [2, 'multi-line'], + curly: ['error', 'multi-line'], // require default case in switch statements - 'default-case': [2, { commentPattern: '^no default$' }], + 'default-case': ['error', { commentPattern: '^no default$' }], // encourages use of dot notation whenever possible - 'dot-notation': [2, { allowKeywords: true }], + 'dot-notation': ['error', { allowKeywords: true }], // enforces consistent newlines before or after dots // http://eslint.org/docs/rules/dot-location - 'dot-location': [2, 'property'], + 'dot-location': ['error', 'property'], // require the use of === and !== // http://eslint.org/docs/rules/eqeqeq - eqeqeq: [2, 'allow-null'], + eqeqeq: ['error', 'allow-null'], // make sure for-in loops have an if statement - 'guard-for-in': 2, + 'guard-for-in': 'error', // disallow the use of alert, confirm, and prompt - 'no-alert': 1, + 'no-alert': 'warn', // disallow use of arguments.caller or arguments.callee - 'no-caller': 2, + 'no-caller': 'error', // disallow lexical declarations in case/default clauses // http://eslint.org/docs/rules/no-case-declarations.html - 'no-case-declarations': 2, + 'no-case-declarations': 'error', // disallow division operators explicitly at beginning of regular expression // http://eslint.org/docs/rules/no-div-regex - 'no-div-regex': 0, + 'no-div-regex': 'off', // disallow else after a return in an if - 'no-else-return': 2, + 'no-else-return': 'error', // disallow empty functions, except for standalone funcs/arrows // http://eslint.org/docs/rules/no-empty-function - 'no-empty-function': [2, { + 'no-empty-function': ['error', { allow: [ 'arrowFunctions', 'functions', @@ -65,37 +65,37 @@ module.exports = { // disallow empty destructuring patterns // http://eslint.org/docs/rules/no-empty-pattern - 'no-empty-pattern': 2, + 'no-empty-pattern': 'error', // disallow comparisons to null without a type-checking operator - 'no-eq-null': 0, + 'no-eq-null': 'off', // disallow use of eval() - 'no-eval': 2, + 'no-eval': 'error', // disallow adding to native types - 'no-extend-native': 2, + 'no-extend-native': 'error', // disallow unnecessary function binding - 'no-extra-bind': 2, + 'no-extra-bind': 'error', // disallow Unnecessary Labels // http://eslint.org/docs/rules/no-extra-label - 'no-extra-label': 2, + 'no-extra-label': 'error', // disallow fallthrough of case statements - 'no-fallthrough': 2, + 'no-fallthrough': 'error', // disallow the use of leading or trailing decimal points in numeric literals - 'no-floating-decimal': 2, + 'no-floating-decimal': 'error', // disallow reassignments of native objects or read-only globals // http://eslint.org/docs/rules/no-global-assign - 'no-global-assign': [2, { exceptions: [] }], + 'no-global-assign': ['error', { exceptions: [] }], // disallow implicit type conversions // http://eslint.org/docs/rules/no-implicit-coercion - 'no-implicit-coercion': [0, { + 'no-implicit-coercion': ['off', { boolean: false, number: true, string: true, @@ -104,29 +104,29 @@ module.exports = { // disallow var and named functions in global scope // http://eslint.org/docs/rules/no-implicit-globals - 'no-implicit-globals': 0, + 'no-implicit-globals': 'off', // disallow use of eval()-like methods - 'no-implied-eval': 2, + 'no-implied-eval': 'error', // disallow this keywords outside of classes or class-like objects - 'no-invalid-this': 0, + 'no-invalid-this': 'off', // disallow usage of __iterator__ property - 'no-iterator': 2, + 'no-iterator': 'error', // disallow use of labels for anything other then loops and switches - 'no-labels': [2, { allowLoop: false, allowSwitch: false }], + 'no-labels': ['error', { allowLoop: false, allowSwitch: false }], // disallow unnecessary nested blocks - 'no-lone-blocks': 2, + 'no-lone-blocks': 'error', // disallow creation of functions within loops - 'no-loop-func': 2, + 'no-loop-func': 'error', // disallow magic numbers // http://eslint.org/docs/rules/no-magic-numbers - 'no-magic-numbers': [0, { + 'no-magic-numbers': ['off', { ignore: [], ignoreArrayIndexes: true, enforceConst: true, @@ -134,107 +134,107 @@ module.exports = { }], // disallow use of multiple spaces - 'no-multi-spaces': 2, + 'no-multi-spaces': 'error', // disallow use of multiline strings - 'no-multi-str': 2, + 'no-multi-str': 'error', // disallow reassignments of native objects // TODO: deprecated in favor of no-global-assign - 'no-native-reassign': 0, + 'no-native-reassign': 'off', // disallow use of new operator when not part of the assignment or comparison - 'no-new': 2, + 'no-new': 'error', // disallow use of new operator for Function object - 'no-new-func': 2, + 'no-new-func': 'error', // disallows creating new instances of String, Number, and Boolean - 'no-new-wrappers': 2, + 'no-new-wrappers': 'error', // disallow use of (old style) octal literals - 'no-octal': 2, + 'no-octal': 'error', // disallow use of octal escape sequences in string literals, such as // var foo = 'Copyright \251'; - 'no-octal-escape': 2, + 'no-octal-escape': 'error', // disallow reassignment of function parameters // disallow parameter object manipulation // rule: http://eslint.org/docs/rules/no-param-reassign.html - 'no-param-reassign': [2, { props: true }], + 'no-param-reassign': ['error', { props: true }], // disallow usage of __proto__ property - 'no-proto': 2, + 'no-proto': 'error', // disallow declaring the same variable more then once - 'no-redeclare': 2, + 'no-redeclare': 'error', // disallow use of assignment in return statement - 'no-return-assign': 2, + 'no-return-assign': 'error', // disallow use of `javascript:` urls. - 'no-script-url': 2, + 'no-script-url': 'error', // disallow self assignment // http://eslint.org/docs/rules/no-self-assign - 'no-self-assign': 2, + 'no-self-assign': 'error', // disallow comparisons where both sides are exactly the same - 'no-self-compare': 2, + 'no-self-compare': 'error', // disallow use of comma operator - 'no-sequences': 2, + 'no-sequences': 'error', // restrict what can be thrown as an exception - 'no-throw-literal': 2, + 'no-throw-literal': 'error', // disallow unmodified conditions of loops // http://eslint.org/docs/rules/no-unmodified-loop-condition - 'no-unmodified-loop-condition': 0, + 'no-unmodified-loop-condition': 'off', // disallow usage of expressions in statement position - 'no-unused-expressions': [2, { + 'no-unused-expressions': ['error', { allowShortCircuit: false, allowTernary: false, }], // disallow unused labels // http://eslint.org/docs/rules/no-unused-labels - 'no-unused-labels': 2, + 'no-unused-labels': 'error', // disallow unnecessary .call() and .apply() - 'no-useless-call': 0, + 'no-useless-call': 'off', // disallow useless string concatenation // http://eslint.org/docs/rules/no-useless-concat - 'no-useless-concat': 2, + 'no-useless-concat': 'error', // disallow unnecessary string escaping // http://eslint.org/docs/rules/no-useless-escape - 'no-useless-escape': 2, + 'no-useless-escape': 'error', // disallow use of void operator // http://eslint.org/docs/rules/no-void - 'no-void': 2, + 'no-void': 'error', // disallow usage of configurable warning terms in comments: e.g. todo - 'no-warning-comments': [0, { terms: ['todo', 'fixme', 'xxx'], location: 'start' }], + 'no-warning-comments': ['off', { terms: ['todo', 'fixme', 'xxx'], location: 'start' }], // disallow use of the with statement - 'no-with': 2, + 'no-with': 'error', // require use of the second argument for parseInt() - radix: 2, + radix: 'error', // requires to declare all vars on top of their containing scope - 'vars-on-top': 2, + 'vars-on-top': 'error', // require immediate function invocation to be wrapped in parentheses // http://eslint.org/docs/rules/wrap-iife.html - 'wrap-iife': [2, 'outside'], + 'wrap-iife': ['error', 'outside'], // require or disallow Yoda conditions - yoda: 2 + yoda: 'error' } }; diff --git a/packages/eslint-config-airbnb-base/rules/errors.js b/packages/eslint-config-airbnb-base/rules/errors.js index 66396cd594..6c932c8dfc 100644 --- a/packages/eslint-config-airbnb-base/rules/errors.js +++ b/packages/eslint-config-airbnb-base/rules/errors.js @@ -1,113 +1,113 @@ module.exports = { rules: { // require trailing commas in multiline object literals - 'comma-dangle': [2, 'always-multiline'], + 'comma-dangle': ['error', 'always-multiline'], // disallow assignment in conditional expressions - 'no-cond-assign': [2, 'always'], + 'no-cond-assign': ['error', 'always'], // disallow use of console - 'no-console': 1, + 'no-console': 'warn', // disallow use of constant expressions in conditions - 'no-constant-condition': 1, + 'no-constant-condition': 'warn', // disallow control characters in regular expressions - 'no-control-regex': 2, + 'no-control-regex': 'error', // disallow use of debugger - 'no-debugger': 2, + 'no-debugger': 'error', // disallow duplicate arguments in functions - 'no-dupe-args': 2, + 'no-dupe-args': 'error', // disallow duplicate keys when creating object literals - 'no-dupe-keys': 2, + 'no-dupe-keys': 'error', // disallow a duplicate case label. - 'no-duplicate-case': 2, + 'no-duplicate-case': 'error', // disallow empty statements - 'no-empty': 2, + 'no-empty': 'error', // disallow the use of empty character classes in regular expressions - 'no-empty-character-class': 2, + 'no-empty-character-class': 'error', // disallow assigning to the exception in a catch block - 'no-ex-assign': 2, + 'no-ex-assign': 'error', // disallow double-negation boolean casts in a boolean context // http://eslint.org/docs/rules/no-extra-boolean-cast - 'no-extra-boolean-cast': 2, + 'no-extra-boolean-cast': 'error', // disallow unnecessary parentheses // http://eslint.org/docs/rules/no-extra-parens - 'no-extra-parens': [0, 'all', { + 'no-extra-parens': ['off', 'all', { conditionalAssign: true, nestedBinaryExpressions: false, returnAssign: false, }], // disallow unnecessary semicolons - 'no-extra-semi': 2, + 'no-extra-semi': 'error', // disallow overwriting functions written as function declarations - 'no-func-assign': 2, + 'no-func-assign': 'error', // disallow function or variable declarations in nested blocks - 'no-inner-declarations': 2, + 'no-inner-declarations': 'error', // disallow invalid regular expression strings in the RegExp constructor - 'no-invalid-regexp': 2, + 'no-invalid-regexp': 'error', // disallow irregular whitespace outside of strings and comments - 'no-irregular-whitespace': 2, + 'no-irregular-whitespace': 'error', // disallow negation of the left operand of an in expression // TODO: deprecated in favor of no-unsafe-negation - 'no-negated-in-lhs': 0, + 'no-negated-in-lhs': 'off', // disallow the use of object properties of the global object (Math and JSON) as functions - 'no-obj-calls': 2, + 'no-obj-calls': 'error', // disallow use of Object.prototypes builtins directly // http://eslint.org/docs/rules/no-prototype-builtins - 'no-prototype-builtins': 2, + 'no-prototype-builtins': 'error', // disallow multiple spaces in a regular expression literal - 'no-regex-spaces': 2, + 'no-regex-spaces': 'error', // disallow sparse arrays - 'no-sparse-arrays': 2, + 'no-sparse-arrays': 'error', // Disallow template literal placeholder syntax in regular strings // http://eslint.org/docs/rules/no-template-curly-in-string // TODO: enable, semver-major - 'no-template-curly-in-string': 0, + 'no-template-curly-in-string': 'off', // Avoid code that looks like two expressions but is actually one // http://eslint.org/docs/rules/no-unexpected-multiline - 'no-unexpected-multiline': 2, + 'no-unexpected-multiline': 'error', // disallow unreachable statements after a return, throw, continue, or break statement - 'no-unreachable': 2, + 'no-unreachable': 'error', // disallow return/throw/break/continue inside finally blocks // http://eslint.org/docs/rules/no-unsafe-finally - 'no-unsafe-finally': 2, + 'no-unsafe-finally': 'error', // disallow negating the left operand of relational operators // http://eslint.org/docs/rules/no-unsafe-negation - 'no-unsafe-negation': 2, + 'no-unsafe-negation': 'error', // disallow comparisons with the value NaN - 'use-isnan': 2, + 'use-isnan': 'error', // ensure JSDoc comments are valid // http://eslint.org/docs/rules/valid-jsdoc - 'valid-jsdoc': 0, + 'valid-jsdoc': 'off', // ensure that the results of typeof are compared against a valid string - 'valid-typeof': 2 + 'valid-typeof': 'error' } }; diff --git a/packages/eslint-config-airbnb-base/rules/es6.js b/packages/eslint-config-airbnb-base/rules/es6.js index a7754b6461..169e30be01 100644 --- a/packages/eslint-config-airbnb-base/rules/es6.js +++ b/packages/eslint-config-airbnb-base/rules/es6.js @@ -14,89 +14,89 @@ module.exports = { rules: { // enforces no braces where they can be omitted // http://eslint.org/docs/rules/arrow-body-style - 'arrow-body-style': [2, 'as-needed'], + 'arrow-body-style': ['error', 'as-needed'], // require parens in arrow function arguments - 'arrow-parens': 0, + 'arrow-parens': 'off', // require space before/after arrow function's arrow // http://eslint.org/docs/rules/arrow-spacing - 'arrow-spacing': [2, { before: true, after: true }], + 'arrow-spacing': ['error', { before: true, after: true }], // verify super() callings in constructors - 'constructor-super': 2, + 'constructor-super': 'error', // enforce the spacing around the * in generator functions // http://eslint.org/docs/rules/generator-star-spacing - 'generator-star-spacing': [2, { before: false, after: true }], + 'generator-star-spacing': ['error', { before: false, after: true }], // disallow modifying variables of class declarations // http://eslint.org/docs/rules/no-class-assign - 'no-class-assign': 2, + 'no-class-assign': 'error', // disallow arrow functions where they could be confused with comparisons // http://eslint.org/docs/rules/no-confusing-arrow - 'no-confusing-arrow': [2, { + 'no-confusing-arrow': ['error', { allowParens: true, }], // disallow modifying variables that are declared using const - 'no-const-assign': 2, + 'no-const-assign': 'error', // disallow duplicate class members // http://eslint.org/docs/rules/no-dupe-class-members - 'no-dupe-class-members': 2, + 'no-dupe-class-members': 'error', // disallow importing from the same path more than once // http://eslint.org/docs/rules/no-duplicate-imports - 'no-duplicate-imports': 2, + 'no-duplicate-imports': 'error', // disallow symbol constructor // http://eslint.org/docs/rules/no-new-symbol - 'no-new-symbol': 2, + 'no-new-symbol': 'error', // disallow specific imports // http://eslint.org/docs/rules/no-restricted-imports - 'no-restricted-imports': 0, + 'no-restricted-imports': 'off', // disallow to use this/super before super() calling in constructors. // http://eslint.org/docs/rules/no-this-before-super - 'no-this-before-super': 2, + 'no-this-before-super': 'error', // disallow useless computed property keys // http://eslint.org/docs/rules/no-useless-computed-key - 'no-useless-computed-key': 2, + 'no-useless-computed-key': 'error', // disallow unnecessary constructor // http://eslint.org/docs/rules/no-useless-constructor - 'no-useless-constructor': 2, + 'no-useless-constructor': 'error', // disallow renaming import, export, and destructured assignments to the same name // http://eslint.org/docs/rules/no-useless-rename - 'no-useless-rename': [2, { + 'no-useless-rename': ['error', { ignoreDestructuring: false, ignoreImport: false, ignoreExport: false, }], // require let or const instead of var - 'no-var': 2, + 'no-var': 'error', // require method and property shorthand syntax for object literals // http://eslint.org/docs/rules/object-shorthand - 'object-shorthand': [2, 'always', { + 'object-shorthand': ['error', 'always', { ignoreConstructors: false, avoidQuotes: true, }], // suggest using arrow functions as callbacks - 'prefer-arrow-callback': [2, { + 'prefer-arrow-callback': ['error', { allowNamedFunctions: false, allowUnboundThis: true, }], // suggest using of const declaration for variables that are never modified after declared - 'prefer-const': [2, { + 'prefer-const': ['error', { destructuring: 'any', ignoreReadBeforeAssign: true, }], @@ -104,31 +104,31 @@ module.exports = { // suggest using Reflect methods where applicable // http://eslint.org/docs/rules/prefer-reflect // TODO: enable - 'prefer-reflect': 0, + 'prefer-reflect': 'off', // use rest parameters instead of arguments // http://eslint.org/docs/rules/prefer-rest-params - 'prefer-rest-params': 2, + 'prefer-rest-params': 'error', // suggest using the spread operator instead of .apply() // http://eslint.org/docs/rules/prefer-spread - 'prefer-spread': 2, + 'prefer-spread': 'error', // suggest using template literals instead of string concatenation // http://eslint.org/docs/rules/prefer-template - 'prefer-template': 2, + 'prefer-template': 'error', // disallow generator functions that do not have yield // http://eslint.org/docs/rules/require-yield - 'require-yield': 2, + 'require-yield': 'error', // enforce spacing between object rest-spread // http://eslint.org/docs/rules/rest-spread-spacing - 'rest-spread-spacing': [2, 'never'], + 'rest-spread-spacing': ['error', 'never'], // import sorting // http://eslint.org/docs/rules/sort-imports - 'sort-imports': [0, { + 'sort-imports': ['off', { ignoreCase: false, ignoreMemberSort: false, memberSyntaxSortOrder: ['none', 'all', 'multiple', 'single'], @@ -136,10 +136,10 @@ module.exports = { // enforce usage of spacing in template strings // http://eslint.org/docs/rules/template-curly-spacing - 'template-curly-spacing': 2, + 'template-curly-spacing': 'error', // enforce spacing around the * in yield* expressions // http://eslint.org/docs/rules/yield-star-spacing - 'yield-star-spacing': [2, 'after'] + 'yield-star-spacing': ['error', 'after'] } }; diff --git a/packages/eslint-config-airbnb-base/rules/imports.js b/packages/eslint-config-airbnb-base/rules/imports.js index 821818909d..09f2397c70 100644 --- a/packages/eslint-config-airbnb-base/rules/imports.js +++ b/packages/eslint-config-airbnb-base/rules/imports.js @@ -33,101 +33,101 @@ module.exports = { // ensure imports point to files/modules that can be resolved // https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/no-unresolved.md - 'import/no-unresolved': [2, { commonjs: true }], + 'import/no-unresolved': ['error', { commonjs: true }], // ensure named imports coupled with named exports // https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/named.md#when-not-to-use-it - 'import/named': 0, + 'import/named': 'off', // ensure default import coupled with default export // https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/default.md#when-not-to-use-it - 'import/default': 0, + 'import/default': 'off', // https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/namespace.md - 'import/namespace': 0, + 'import/namespace': 'off', // Helpful warnings: // disallow invalid exports, e.g. multiple defaults // https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/export.md - 'import/export': 2, + 'import/export': 'error', // do not allow a default import name to match a named export // https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/no-named-as-default.md - 'import/no-named-as-default': 2, + 'import/no-named-as-default': 'error', // warn on accessing default export property names that are also named exports // https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/no-named-as-default-member.md - 'import/no-named-as-default-member': 2, + 'import/no-named-as-default-member': 'error', // disallow use of jsdoc-marked-deprecated imports // https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/no-deprecated.md - 'import/no-deprecated': 0, + 'import/no-deprecated': 'off', // Forbid the use of extraneous packages // https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/no-extraneous-dependencies.md - 'import/no-extraneous-dependencies': [2, { + 'import/no-extraneous-dependencies': ['error', { devDependencies: false, optionalDependencies: false, }], // Forbid mutable exports // https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/no-mutable-exports.md - 'import/no-mutable-exports': 2, + 'import/no-mutable-exports': 'error', // Module systems: // disallow require() // https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/no-commonjs.md - 'import/no-commonjs': 0, + 'import/no-commonjs': 'off', // disallow AMD require/define // https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/no-amd.md - 'import/no-amd': 2, + 'import/no-amd': 'error', // No Node.js builtin modules // https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/no-nodejs-modules.md // TODO: enable? - 'import/no-nodejs-modules': 0, + 'import/no-nodejs-modules': 'off', // Style guide: // disallow non-import statements appearing before import statements // https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/imports-first.md - 'import/imports-first': [2, 'absolute-first'], + 'import/imports-first': ['error', 'absolute-first'], // disallow duplicate imports // https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/no-duplicates.md - 'import/no-duplicates': 2, + 'import/no-duplicates': 'error', // disallow namespace imports // TODO: enable? // https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/no-namespace.md - 'import/no-namespace': 0, + 'import/no-namespace': 'off', // Ensure consistent use of file extension within the import path // https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/extensions.md // TODO: enable when https://github.com/benmosher/eslint-plugin-import/issues/390 is resolved - 'import/extensions': [0, 'never'], + 'import/extensions': ['off', 'never'], // Enforce a convention in module import order // https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/order.md // TODO: enable? - 'import/order': [0, { + 'import/order': ['off', { groups: ['builtin', 'external', 'internal', 'parent', 'sibling', 'index'], 'newlines-between': 'never', }], // Require a newline after the last import/require in a group // https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/newline-after-import.md - 'import/newline-after-import': 2, + 'import/newline-after-import': 'error', // Require modules with a single export to use a default export // https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/prefer-default-export.md - 'import/prefer-default-export': 2, + 'import/prefer-default-export': 'error', // Restrict which files can be imported in a given folder // https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/no-restricted-paths.md - 'import/no-restricted-paths': 0, + 'import/no-restricted-paths': 'off', }, }; diff --git a/packages/eslint-config-airbnb-base/rules/node.js b/packages/eslint-config-airbnb-base/rules/node.js index cbd8fc22e6..e4a71a6a5a 100644 --- a/packages/eslint-config-airbnb-base/rules/node.js +++ b/packages/eslint-config-airbnb-base/rules/node.js @@ -5,35 +5,35 @@ module.exports = { rules: { // enforce return after a callback - 'callback-return': 0, + 'callback-return': 'off', // require all requires be top-level // http://eslint.org/docs/rules/global-require - 'global-require': 2, + 'global-require': 'error', // enforces error handling in callbacks (node environment) - 'handle-callback-err': 0, + 'handle-callback-err': 'off', // disallow mixing regular variable and require declarations - 'no-mixed-requires': [0, false], + 'no-mixed-requires': ['off', false], // disallow use of new operator with the require function - 'no-new-require': 2, + 'no-new-require': 'error', // disallow string concatenation with __dirname and __filename // http://eslint.org/docs/rules/no-path-concat - 'no-path-concat': 2, + 'no-path-concat': 'error', // disallow use of process.env - 'no-process-env': 0, + 'no-process-env': 'off', // disallow process.exit() - 'no-process-exit': 0, + 'no-process-exit': 'off', // restrict usage of specified node modules - 'no-restricted-modules': 0, + 'no-restricted-modules': 'off', // disallow use of synchronous methods (off by default) - 'no-sync': 0, + 'no-sync': 'off', } }; diff --git a/packages/eslint-config-airbnb-base/rules/strict.js b/packages/eslint-config-airbnb-base/rules/strict.js index 43d7010c60..67cfd5e8a3 100644 --- a/packages/eslint-config-airbnb-base/rules/strict.js +++ b/packages/eslint-config-airbnb-base/rules/strict.js @@ -1,6 +1,6 @@ module.exports = { rules: { // babel inserts `'use strict';` for us - strict: [2, 'never'] + strict: ['error', 'never'] } }; diff --git a/packages/eslint-config-airbnb-base/rules/style.js b/packages/eslint-config-airbnb-base/rules/style.js index 5d8825aab9..e32e79869f 100644 --- a/packages/eslint-config-airbnb-base/rules/style.js +++ b/packages/eslint-config-airbnb-base/rules/style.js @@ -1,68 +1,68 @@ module.exports = { rules: { // enforce spacing inside array brackets - 'array-bracket-spacing': [2, 'never'], + 'array-bracket-spacing': ['error', 'never'], // enforce spacing inside single-line blocks // http://eslint.org/docs/rules/block-spacing - 'block-spacing': [2, 'always'], + 'block-spacing': ['error', 'always'], // enforce one true brace style - 'brace-style': [2, '1tbs', { allowSingleLine: true }], + 'brace-style': ['error', '1tbs', { allowSingleLine: true }], // require camel case names - camelcase: [2, { properties: 'never' }], + camelcase: ['error', { properties: 'never' }], // enforce spacing before and after comma - 'comma-spacing': [2, { before: false, after: true }], + 'comma-spacing': ['error', { before: false, after: true }], // enforce one true comma style - 'comma-style': [2, 'last'], + 'comma-style': ['error', 'last'], // disallow padding inside computed properties - 'computed-property-spacing': [2, 'never'], + 'computed-property-spacing': ['error', 'never'], // enforces consistent naming when capturing the current execution context - 'consistent-this': 0, + 'consistent-this': 'off', // enforce newline at the end of file, with no multiple empty lines - 'eol-last': 2, + 'eol-last': 'error', // enforce spacing between functions and their invocations // http://eslint.org/docs/rules/func-call-spacing // TODO: enable, semver-minor - 'func-call-spacing': [0, 'never'], + 'func-call-spacing': ['off', 'never'], // require function expressions to have a name - 'func-names': 1, + 'func-names': 'warn', // enforces use of function declarations or expressions - 'func-style': 0, + 'func-style': 'off', // Blacklist certain identifiers to prevent them being used // http://eslint.org/docs/rules/id-blacklist - 'id-blacklist': 0, + 'id-blacklist': 'off', // this option enforces minimum and maximum identifier lengths // (variable names, property names etc.) - 'id-length': 0, + 'id-length': 'off', // require identifiers to match the provided regular expression - 'id-match': 0, + 'id-match': 'off', // this option sets a specific tab width for your code // http://eslint.org/docs/rules/indent - indent: [2, 2, { SwitchCase: 1, VariableDeclarator: 1, outerIIFEBody: 1 }], + indent: ['error', 2, { SwitchCase: 1, VariableDeclarator: 1, outerIIFEBody: 1 }], // specify whether double or single quotes should be used in JSX attributes // http://eslint.org/docs/rules/jsx-quotes - 'jsx-quotes': [0, 'prefer-double'], + 'jsx-quotes': ['off', 'prefer-double'], // enforces spacing between keys and values in object literal properties - 'key-spacing': [2, { beforeColon: false, afterColon: true }], + 'key-spacing': ['error', { beforeColon: false, afterColon: true }], // require a space before & after certain keywords - 'keyword-spacing': [2, { + 'keyword-spacing': ['error', { before: true, after: true, overrides: { @@ -74,86 +74,86 @@ module.exports = { // disallow mixed 'LF' and 'CRLF' as linebreaks // http://eslint.org/docs/rules/linebreak-style - 'linebreak-style': [2, 'unix'], + 'linebreak-style': ['error', 'unix'], // enforces empty lines around comments - 'lines-around-comment': 0, + 'lines-around-comment': 'off', // specify the maximum depth that blocks can be nested - 'max-depth': [0, 4], + 'max-depth': ['off', 4], // specify the maximum length of a line in your program // http://eslint.org/docs/rules/max-len - 'max-len': [2, 100, 2, { + 'max-len': ['error', 100, 2, { ignoreUrls: true, ignoreComments: false }], // specify the max number of lines in a file // http://eslint.org/docs/rules/max-lines - 'max-lines': [0, { + 'max-lines': ['off', { max: 300, skipBlankLines: true, skipComments: true }], // specify the maximum depth callbacks can be nested - 'max-nested-callbacks': 0, + 'max-nested-callbacks': 'off', // limits the number of parameters that can be used in the function declaration. - 'max-params': [0, 3], + 'max-params': ['off', 3], // specify the maximum number of statement allowed in a function - 'max-statements': [0, 10], + 'max-statements': ['off', 10], // restrict the number of statements per line // http://eslint.org/docs/rules/max-statements-per-line - 'max-statements-per-line': [0, { max: 1 }], + 'max-statements-per-line': ['off', { max: 1 }], // require multiline ternary // http://eslint.org/docs/rules/multiline-ternary - 'multiline-ternary': 0, + 'multiline-ternary': 'off', // require a capital letter for constructors - 'new-cap': [2, { newIsCap: true }], + 'new-cap': ['error', { newIsCap: true }], // disallow the omission of parentheses when invoking a constructor with no arguments // http://eslint.org/docs/rules/new-parens - 'new-parens': 2, + 'new-parens': 'error', // allow/disallow an empty newline after var statement - 'newline-after-var': 0, + 'newline-after-var': 'off', // http://eslint.org/docs/rules/newline-before-return - 'newline-before-return': 0, + 'newline-before-return': 'off', // enforces new line after each method call in the chain to make it // more readable and easy to maintain // http://eslint.org/docs/rules/newline-per-chained-call - 'newline-per-chained-call': [2, { ignoreChainWithDepth: 4 }], + 'newline-per-chained-call': ['error', { ignoreChainWithDepth: 4 }], // disallow use of the Array constructor - 'no-array-constructor': 2, + 'no-array-constructor': 'error', // disallow use of bitwise operators // http://eslint.org/docs/rules/no-bitwise // TODO: enable - 'no-bitwise': 0, + 'no-bitwise': 'off', // disallow use of the continue statement // http://eslint.org/docs/rules/no-continue - 'no-continue': 2, + 'no-continue': 'error', // disallow comments inline after code - 'no-inline-comments': 0, + 'no-inline-comments': 'off', // disallow if as the only statement in an else block // http://eslint.org/docs/rules/no-lonely-if - 'no-lonely-if': 2, + 'no-lonely-if': 'error', // disallow un-paren'd mixes of different operators // http://eslint.org/docs/rules/no-mixed-operators - 'no-mixed-operators': [2, { + 'no-mixed-operators': ['error', { groups: [ ['+', '-', '*', '/', '%', '**'], ['&', '|', '^', '~', '<<', '>>', '>>>'], @@ -165,28 +165,28 @@ module.exports = { }], // disallow mixed spaces and tabs for indentation - 'no-mixed-spaces-and-tabs': 2, + 'no-mixed-spaces-and-tabs': 'error', // disallow multiple empty lines and only one newline at the end - 'no-multiple-empty-lines': [2, { max: 2, maxEOF: 1 }], + 'no-multiple-empty-lines': ['error', { max: 2, maxEOF: 1 }], // disallow negated conditions // http://eslint.org/docs/rules/no-negated-condition - 'no-negated-condition': 0, + 'no-negated-condition': 'off', // disallow nested ternary expressions - 'no-nested-ternary': 2, + 'no-nested-ternary': 'error', // disallow use of the Object constructor - 'no-new-object': 2, + 'no-new-object': 'error', // disallow use of unary operators, ++ and -- - 'no-plusplus': 0, + 'no-plusplus': 'off', // disallow certain syntax forms // http://eslint.org/docs/rules/no-restricted-syntax 'no-restricted-syntax': [ - 2, + 'error', 'DebuggerStatement', 'ForInStatement', 'LabeledStatement', @@ -194,103 +194,103 @@ module.exports = { ], // disallow space between function identifier and application - 'no-spaced-func': 2, + 'no-spaced-func': 'error', // disallow tab characters entirely // TODO: enable - 'no-tabs': 0, + 'no-tabs': 'off', // disallow the use of ternary operators - 'no-ternary': 0, + 'no-ternary': 'off', // disallow trailing whitespace at the end of lines - 'no-trailing-spaces': 2, + 'no-trailing-spaces': 'error', // disallow dangling underscores in identifiers - 'no-underscore-dangle': [2, { allowAfterThis: false }], + 'no-underscore-dangle': ['error', { allowAfterThis: false }], // disallow the use of Boolean literals in conditional expressions // also, prefer `a || b` over `a ? a : b` // http://eslint.org/docs/rules/no-unneeded-ternary - 'no-unneeded-ternary': [2, { defaultAssignment: false }], + 'no-unneeded-ternary': ['error', { defaultAssignment: false }], // disallow whitespace before properties // http://eslint.org/docs/rules/no-whitespace-before-property - 'no-whitespace-before-property': 2, + 'no-whitespace-before-property': 'error', // require padding inside curly braces - 'object-curly-spacing': [2, 'always'], + 'object-curly-spacing': ['error', 'always'], // 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 - 'object-curly-newline': [0, { + 'object-curly-newline': ['off', { ObjectExpression: { minProperties: 0, multiline: true }, ObjectPattern: { minProperties: 0, multiline: true } }], // enforce "same line" or "multiple line" on object properties. // http://eslint.org/docs/rules/object-property-newline - 'object-property-newline': [2, { + 'object-property-newline': ['error', { allowMultiplePropertiesPerLine: true, }], // allow just one var statement per function - 'one-var': [2, 'never'], + 'one-var': ['error', 'never'], // require a newline around variable declaration // http://eslint.org/docs/rules/one-var-declaration-per-line - 'one-var-declaration-per-line': [2, 'always'], + 'one-var-declaration-per-line': ['error', 'always'], // require assignment operator shorthand where possible or prohibit it entirely // http://eslint.org/docs/rules/operator-assignment - 'operator-assignment': [2, 'always'], + 'operator-assignment': ['error', 'always'], // enforce operators to be placed before or after line breaks - 'operator-linebreak': 0, + 'operator-linebreak': 'off', // enforce padding within blocks - 'padded-blocks': [2, 'never'], + 'padded-blocks': ['error', 'never'], // require quotes around object literal property names // http://eslint.org/docs/rules/quote-props.html - 'quote-props': [2, 'as-needed', { keywords: false, unnecessary: true, numbers: false }], + 'quote-props': ['error', 'as-needed', { keywords: false, unnecessary: true, numbers: false }], // specify whether double or single quotes should be used - quotes: [2, 'single', { avoidEscape: true }], + quotes: ['error', 'single', { avoidEscape: true }], // do not require jsdoc // http://eslint.org/docs/rules/require-jsdoc - 'require-jsdoc': 0, + 'require-jsdoc': 'off', // require or disallow use of semicolons instead of ASI - semi: [2, 'always'], + semi: ['error', 'always'], // enforce spacing before and after semicolons - 'semi-spacing': [2, { before: false, after: true }], + 'semi-spacing': ['error', { before: false, after: true }], // requires object keys to be sorted - 'sort-keys': [0, 'asc', { caseSensitive: false, natural: true }], + 'sort-keys': ['off', 'asc', { caseSensitive: false, natural: true }], // sort variables within the same declaration block - 'sort-vars': 0, + 'sort-vars': 'off', // require or disallow space before blocks - 'space-before-blocks': 2, + 'space-before-blocks': 'error', // require or disallow space before function opening parenthesis // http://eslint.org/docs/rules/space-before-function-paren - 'space-before-function-paren': [2, { anonymous: 'always', named: 'never' }], + 'space-before-function-paren': ['error', { anonymous: 'always', named: 'never' }], // require or disallow spaces inside parentheses - 'space-in-parens': [2, 'never'], + 'space-in-parens': ['error', 'never'], // require spaces around operators - 'space-infix-ops': 2, + 'space-infix-ops': 'error', // Require or disallow spaces before/after unary operators // http://eslint.org/docs/rules/space-unary-ops - 'space-unary-ops': [2, { + 'space-unary-ops': ['error', { words: true, nonwords: false, overrides: { @@ -298,16 +298,16 @@ module.exports = { }], // require or disallow a space immediately following the // or /* in a comment - 'spaced-comment': [2, 'always', { + 'spaced-comment': ['error', 'always', { exceptions: ['-', '+'], markers: ['=', '!'] // space here to support sprockets directives }], // require or disallow the Unicode Byte Order Mark // http://eslint.org/docs/rules/unicode-bom - 'unicode-bom': [2, 'never'], + 'unicode-bom': ['error', 'never'], // require regex literals to be wrapped in parentheses - 'wrap-regex': 0 + 'wrap-regex': 'off' } }; diff --git a/packages/eslint-config-airbnb-base/rules/variables.js b/packages/eslint-config-airbnb-base/rules/variables.js index 3abce6f8ec..312ee76813 100644 --- a/packages/eslint-config-airbnb-base/rules/variables.js +++ b/packages/eslint-config-airbnb-base/rules/variables.js @@ -1,41 +1,41 @@ module.exports = { rules: { // enforce or disallow variable initializations at definition - 'init-declarations': 0, + 'init-declarations': 'off', // disallow the catch clause parameter name being the same as a variable in the outer scope - 'no-catch-shadow': 0, + 'no-catch-shadow': 'off', // disallow deletion of variables - 'no-delete-var': 2, + 'no-delete-var': 'error', // disallow labels that share a name with a variable // http://eslint.org/docs/rules/no-label-var - 'no-label-var': 2, + 'no-label-var': 'error', // disallow specific globals - 'no-restricted-globals': 0, + 'no-restricted-globals': 'off', // disallow declaration of variables already declared in the outer scope - 'no-shadow': 2, + 'no-shadow': 'error', // disallow shadowing of names such as arguments - 'no-shadow-restricted-names': 2, + 'no-shadow-restricted-names': 'error', // disallow use of undeclared variables unless mentioned in a /*global */ block - 'no-undef': 2, + 'no-undef': 'error', // disallow use of undefined when initializing variables - 'no-undef-init': 2, + 'no-undef-init': 'error', // disallow use of undefined variable // TODO: enable? - 'no-undefined': 0, + 'no-undefined': 'off', // disallow declaration of variables that are not used in the code - 'no-unused-vars': [2, { vars: 'local', args: 'after-used' }], + 'no-unused-vars': ['error', { vars: 'local', args: 'after-used' }], // disallow use of variables before they are defined - 'no-use-before-define': 2 + 'no-use-before-define': 'error' } }; diff --git a/packages/eslint-config-airbnb/rules/react-a11y.js b/packages/eslint-config-airbnb/rules/react-a11y.js index 9e1c664449..76430261c7 100644 --- a/packages/eslint-config-airbnb/rules/react-a11y.js +++ b/packages/eslint-config-airbnb/rules/react-a11y.js @@ -10,96 +10,96 @@ module.exports = { // Enforce that anchors have content // https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/anchor-has-content.md // TODO: enable, semver-major - 'jsx-a11y/anchor-has-content': [0, ['']], + 'jsx-a11y/anchor-has-content': ['off', ['']], // 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': 2, + 'jsx-a11y/aria-role': 'error', // Enforce all aria-* props are valid. // https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/aria-props.md - 'jsx-a11y/aria-props': 2, + 'jsx-a11y/aria-props': 'error', // Enforce ARIA state and property values are valid. // https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/aria-proptypes.md - 'jsx-a11y/aria-proptypes': 2, + 'jsx-a11y/aria-proptypes': 'error', // Enforce that elements that do not support ARIA roles, states, and // properties do not have those attributes. // https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/aria-unsupported-elements.md - 'jsx-a11y/aria-unsupported-elements': 2, + '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': [2, ['a']], + 'jsx-a11y/href-no-hash': ['error', ['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': 2, + 'jsx-a11y/img-has-alt': 'error', // 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 - 'jsx-a11y/img-redundant-alt': 2, + 'jsx-a11y/img-redundant-alt': 'error', // 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': [2, ['label']], + 'jsx-a11y/label-has-for': ['error', ['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': 0, + 'jsx-a11y/mouse-events-have-key-events': 'off', // Prevent use of `accessKey` // https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/no-access-key.md - 'jsx-a11y/no-access-key': 2, + 'jsx-a11y/no-access-key': 'error', // require onBlur instead of onChange // https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/no-onchange.md - 'jsx-a11y/no-onchange': 0, + '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': 0, + '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': 0, + 'jsx-a11y/onclick-has-role': 'off', // Enforce that elements with ARIA roles must have all required attributes // for that role. // https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/role-has-required-aria-props.md - 'jsx-a11y/role-has-required-aria-props': 2, + 'jsx-a11y/role-has-required-aria-props': 'error', // Enforce that elements with explicit or implicit roles defined contain // only aria-* properties supported by that role. // https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/role-supports-aria-props.md - 'jsx-a11y/role-supports-aria-props': 2, + 'jsx-a11y/role-supports-aria-props': 'error', // Enforce tabIndex value is not greater than zero. // TODO: evaluate // https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/tabindex-no-positive.md - 'jsx-a11y/tabindex-no-positive': 0, + 'jsx-a11y/tabindex-no-positive': 'off', // 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': [2, ['']], + 'jsx-a11y/heading-has-content': ['error', ['']], // require HTML elements to have a "lang" prop // https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/html-has-lang.md - 'jsx-a11y/html-has-lang': 2, + 'jsx-a11y/html-has-lang': 'error', // require HTML element's lang prop to be valid // https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/lang.md - 'jsx-a11y/lang': 2, + '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': 2, + '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': 2, + 'jsx-a11y/scope': 'error', }, }; diff --git a/packages/eslint-config-airbnb/rules/react.js b/packages/eslint-config-airbnb/rules/react.js index 4bb15b6bd5..1552b7ea78 100644 --- a/packages/eslint-config-airbnb/rules/react.js +++ b/packages/eslint-config-airbnb/rules/react.js @@ -16,50 +16,50 @@ module.exports = { rules: { // Specify whether double or single quotes should be used in JSX attributes // http://eslint.org/docs/rules/jsx-quotes - 'jsx-quotes': [2, 'prefer-double'], + 'jsx-quotes': ['error', 'prefer-double'], // Prevent missing displayName in a React component definition // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/display-name.md - 'react/display-name': [0, { ignoreTranspilerName: false }], + 'react/display-name': ['off', { ignoreTranspilerName: false }], // Forbid certain propTypes (any, array, object) // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/forbid-prop-types.md - 'react/forbid-prop-types': [0, { forbid: ['any', 'array', 'object'] }], + 'react/forbid-prop-types': ['off', { forbid: ['any', 'array', 'object'] }], // 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': [2, 'never'], + 'react/jsx-boolean-value': ['error', 'never'], // Validate closing bracket location in JSX // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-closing-bracket-location.md - 'react/jsx-closing-bracket-location': [2, 'line-aligned'], + 'react/jsx-closing-bracket-location': ['error', 'line-aligned'], // 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': [2, 'never', { allowMultiline: true }], + 'react/jsx-curly-spacing': ['error', 'never', { allowMultiline: true }], // Enforce event handler naming conventions in JSX // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-handler-names.md - 'react/jsx-handler-names': [0, { + 'react/jsx-handler-names': ['off', { eventHandlerPrefix: 'handle', eventHandlerPropPrefix: 'on', }], // Validate props indentation in JSX // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-indent-props.md - 'react/jsx-indent-props': [2, 2], + 'react/jsx-indent-props': ['error', 2], // Validate JSX has key prop when in array or iterator // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-key.md - 'react/jsx-key': 0, + 'react/jsx-key': 'off', // 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': [0, { maximum: 1 }], + 'react/jsx-max-props-per-line': ['off', { maximum: 1 }], // Prevent usage of .bind() in JSX props // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-no-bind.md - 'react/jsx-no-bind': [2, { + 'react/jsx-no-bind': ['error', { ignoreRefs: true, allowArrowFunctions: true, allowBind: false, @@ -67,37 +67,37 @@ module.exports = { // Prevent duplicate props in JSX // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-no-duplicate-props.md - 'react/jsx-no-duplicate-props': [0, { ignoreCase: false }], + 'react/jsx-no-duplicate-props': ['off', { ignoreCase: false }], // 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': 0, + 'react/jsx-no-literals': 'off', // Disallow undeclared variables in JSX // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-no-undef.md - 'react/jsx-no-undef': 2, + 'react/jsx-no-undef': 'error', // Enforce PascalCase for user-defined JSX components // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-pascal-case.md - 'react/jsx-pascal-case': [2, { + 'react/jsx-pascal-case': ['error', { allowAllCaps: true, ignore: [], }], // Enforce propTypes declarations alphabetical sorting // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/sort-prop-types.md - 'react/sort-prop-types': [0, { + 'react/sort-prop-types': ['off', { ignoreCase: false, callbacksLast: false, requiredFirst: false, }], // Deprecated in favor of react/jsx-sort-props - 'react/jsx-sort-prop-types': 0, + 'react/jsx-sort-prop-types': 'off', // Enforce props alphabetical sorting // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-sort-props.md - 'react/jsx-sort-props': [0, { + 'react/jsx-sort-props': ['off', { ignoreCase: false, callbacksLast: false, shorthandFirst: false, @@ -106,87 +106,87 @@ module.exports = { // Prevent React to be incorrectly marked as unused // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-uses-react.md - 'react/jsx-uses-react': [2], + 'react/jsx-uses-react': ['error'], // Prevent variables used in JSX to be incorrectly marked as unused // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-uses-vars.md - 'react/jsx-uses-vars': 2, + 'react/jsx-uses-vars': 'error', // Prevent usage of dangerous JSX properties // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/no-danger.md - 'react/no-danger': 0, + 'react/no-danger': 'off', // Prevent usage of deprecated methods // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/no-deprecated.md - 'react/no-deprecated': [2], + 'react/no-deprecated': ['error'], // 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': [2], + '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': [2], + 'react/no-did-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 - 'react/no-direct-mutation-state': 0, + 'react/no-direct-mutation-state': 'off', // Prevent usage of isMounted // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/no-is-mounted.md - 'react/no-is-mounted': 2, + 'react/no-is-mounted': 'error', // Prevent multiple component definition per file // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/no-multi-comp.md - 'react/no-multi-comp': [2, { ignoreStateless: true }], + 'react/no-multi-comp': ['error', { ignoreStateless: true }], // Prevent usage of setState // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/no-set-state.md - 'react/no-set-state': 0, + 'react/no-set-state': 'off', // Prevent using string references // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/no-string-refs.md - 'react/no-string-refs': 2, + 'react/no-string-refs': 'error', // Prevent usage of unknown DOM property // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/no-unknown-property.md - 'react/no-unknown-property': 2, + 'react/no-unknown-property': 'error', // Require ES6 class declarations over React.createClass // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/prefer-es6-class.md - 'react/prefer-es6-class': [2, 'always'], + 'react/prefer-es6-class': ['error', 'always'], // 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': 2, + 'react/prefer-stateless-function': 'error', // 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': [2, { ignore: [], customValidators: [] }], + 'react/prop-types': ['error', { ignore: [], customValidators: [] }], // Prevent missing React when using JSX // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/react-in-jsx-scope.md - 'react/react-in-jsx-scope': 2, + '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 - 'react/require-extension': [2, { extensions: ['.jsx', '.js'] }], + 'react/require-extension': ['error', { 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': 2, + 'react/require-render-return': 'error', // Prevent extra closing tags for components without children // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/self-closing-comp.md - 'react/self-closing-comp': 2, + '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': [2, 'always'], + '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': [2, { + 'react/sort-comp': ['error', { order: [ 'static-methods', 'lifecycle', @@ -200,58 +200,58 @@ module.exports = { // Prevent missing parentheses around multilines JSX // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-wrap-multilines.md - 'react/jsx-wrap-multilines': [2, { + 'react/jsx-wrap-multilines': ['error', { declaration: true, assignment: true, return: true }], - 'react/wrap-multilines': 0, // deprecated version + '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': [2, 'multiline'], + 'react/jsx-first-prop-new-line': ['error', 'multiline'], // Enforce spacing around jsx equals signs // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-equals-spacing.md - 'react/jsx-equals-spacing': [2, 'never'], + 'react/jsx-equals-spacing': ['error', 'never'], // Enforce JSX indentation // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-indent.md - 'react/jsx-indent': [2, 2], + 'react/jsx-indent': ['error', 2], // Disallow target="_blank" on links // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-no-target-blank.md - 'react/jsx-no-target-blank': 2, + 'react/jsx-no-target-blank': 'error', // only .jsx files may have JSX // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-filename-extension.md - 'react/jsx-filename-extension': [2, { extensions: ['.jsx'] }], + 'react/jsx-filename-extension': ['error', { extensions: ['.jsx'] }], // 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': 2, - 'react/no-comment-textnodes': 0, // deprecated version + '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 - 'react/no-render-return-value': 2, + 'react/no-render-return-value': 'error', // require a shouldComponentUpdate method, or PureRenderMixin // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/require-optimization.md - 'react/require-optimization': [0, { allowDecorators: [] }], + 'react/require-optimization': ['off', { allowDecorators: [] }], // warn against using findDOMNode() // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/no-find-dom-node.md - 'react/no-find-dom-node': 2, + 'react/no-find-dom-node': 'error', // Forbid certain props on Components // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/forbid-component-props.md - 'react/forbid-component-props': [0, { forbid: [] }], + 'react/forbid-component-props': ['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 // TODO: enable, semver-major - 'react/no-danger-with-children': 0, + 'react/no-danger-with-children': 'off', }, settings: { From ca1124cd8d2e33addbffb3b1743849e2bf774039 Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Sun, 21 Aug 2016 23:25:19 -0700 Subject: [PATCH 019/826] [eslint config] [base] v5.0.3 --- 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 f26c1d9cb3..aa61e0f2be 100644 --- a/packages/eslint-config-airbnb-base/CHANGELOG.md +++ b/packages/eslint-config-airbnb-base/CHANGELOG.md @@ -1,3 +1,9 @@ +5.0.3 / 2016-08-21 +================== + - [fix] correct `import/extensions` list (#1013) + - [refactor] Changed ESLint rule configs to use 'off', 'warn', and 'error' instead of numbers for better readability (#946) + - [deps] update `eslint`, `eslint-plugin-react` + 5.0.2 / 2016-08-12 ================== - [deps] update `eslint`, `eslint-find-rules`, `eslint-plugin-import` diff --git a/packages/eslint-config-airbnb-base/package.json b/packages/eslint-config-airbnb-base/package.json index ed9014e2de..5a04cd263d 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": "5.0.2", + "version": "5.0.3", "description": "Airbnb's base JS ESLint config, following our styleguide", "main": "index.js", "scripts": { From 21846f6da0b9217dc3e4dde808ec240740038640 Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Tue, 23 Aug 2016 15:07:42 -0700 Subject: [PATCH 020/826] =?UTF-8?q?[guide]=20fix=20=E2=80=9Clong=20lines?= =?UTF-8?q?=E2=80=9D=20example=20to=20not=20include=20strings.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixes #1027. --- README.md | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index cb0cbac948..9d40f701d8 100644 --- a/README.md +++ b/README.md @@ -2149,20 +2149,24 @@ Other Style Guides ``` - - [18.12](#whitespace--max-len) Avoid having lines of code that are longer than 100 characters (including whitespace). eslint: [`max-len`](http://eslint.org/docs/rules/max-len.html) jscs: [`maximumLineLength`](http://jscs.info/rule/maximumLineLength) + - [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) > Why? This ensures readability and maintainability. ```javascript // bad - const foo = 'Whatever national crop flips the window. The cartoon reverts within the screw. Whatever wizard constrains a helpful ally. The counterpart ascends!'; + const foo = jsonData && jsonData.foo && jsonData.foo.bar && jsonData.foo.bar.baz && jsonData.foo.bar.baz.quux && jsonData.foo.bar.baz.quux.xyzzy; // bad $.ajax({ method: 'POST', url: 'https://airbnb.com/', data: { name: 'John' } }).done(() => console.log('Congratulations!')).fail(() => console.log('You have failed this city.')); // good - const foo = 'Whatever national crop flips the window. The cartoon reverts within the screw. ' + - 'Whatever wizard constrains a helpful ally. The counterpart ascends!'; + const foo = jsonData + && jsonData.foo + && jsonData.foo.bar + && jsonData.foo.bar.baz + && jsonData.foo.bar.baz.quux + && jsonData.foo.bar.baz.quux.xyzzy; // good $.ajax({ From 48f477db2ad9a5650e5305ed04489d5abc5b9d8c Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Tue, 23 Aug 2016 15:19:34 -0700 Subject: [PATCH 021/826] [eslint config] [base] [patch] remove redundant `DebuggerStatement` from `no-restricted-syntax` Fixes #1031. --- packages/eslint-config-airbnb-base/rules/style.js | 1 - 1 file changed, 1 deletion(-) diff --git a/packages/eslint-config-airbnb-base/rules/style.js b/packages/eslint-config-airbnb-base/rules/style.js index e32e79869f..c80beaee87 100644 --- a/packages/eslint-config-airbnb-base/rules/style.js +++ b/packages/eslint-config-airbnb-base/rules/style.js @@ -187,7 +187,6 @@ module.exports = { // http://eslint.org/docs/rules/no-restricted-syntax 'no-restricted-syntax': [ 'error', - 'DebuggerStatement', 'ForInStatement', 'LabeledStatement', 'WithStatement', From 1541503fd47626e2d4b03ff01bca76940081edeb Mon Sep 17 00:00:00 2001 From: Harrison Shoff Date: Thu, 25 Aug 2016 21:48:31 -0700 Subject: [PATCH 022/826] [7.1] add link to fn names discussion. fixes #794 --- README.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/README.md b/README.md index 9d40f701d8..86cd3cc69e 100644 --- a/README.md +++ b/README.md @@ -555,7 +555,7 @@ Other Style Guides - [7.1](#functions--declarations) Use function declarations instead of function expressions. eslint: [`func-style`](http://eslint.org/docs/rules/func-style) jscs: [`requireFunctionDeclarations`](http://jscs.info/rule/requireFunctionDeclarations) - > Why? Function declarations are named, so they're easier to identify in call stacks. Also, the whole body of a function declaration is hoisted, whereas only the reference of a function expression is hoisted. This rule makes it possible to always use [Arrow Functions](#arrow-functions) in place of function expressions. + > Why? Function declarations are named, so they're easier to identify in call stacks. Also, the whole body of a function declaration is hoisted, whereas only the reference of a function expression is hoisted. This rule makes it possible to always use [Arrow Functions](#arrow-functions) in place of function expressions. ([discussion](https://github.com/airbnb/javascript/issues/794)) ```javascript // bad @@ -2221,7 +2221,6 @@ 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) > 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](es5/README.md#commas) in legacy browsers. - ```javascript // bad - git diff without trailing comma const hero = { From 6944be009cb81de5bf7d8b525267235382452ca3 Mon Sep 17 00:00:00 2001 From: Heejong Ahn Date: Sun, 28 Aug 2016 23:09:11 +0900 Subject: [PATCH 023/826] Fix a typo in commas section Example code block following blockquote(line 2223) was broken as a line break was missing. So I just added single blank line. --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 86cd3cc69e..c7faf50d02 100644 --- a/README.md +++ b/README.md @@ -2221,6 +2221,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) > 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](es5/README.md#commas) in legacy browsers. + ```javascript // bad - git diff without trailing comma const hero = { From a43c16e330d03082f5955de90873c6f9ca7d6308 Mon Sep 17 00:00:00 2001 From: Thomas Marek Date: Sun, 21 Aug 2016 11:35:20 -0400 Subject: [PATCH 024/826] Explain why not to prefix methods with underscores --- react/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/react/README.md b/react/README.md index eee0170c0d..32e4be48ab 100644 --- a/react/README.md +++ b/react/README.md @@ -450,6 +450,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, and #490 for a more in-depth discussion. ```jsx // bad From 0e4517ea38681ea1368a522591e2aefc18b108ba Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Mon, 29 Aug 2016 00:11:52 -0700 Subject: [PATCH 025/826] [eslint config] [patch] set `ignoreCase` to `true` in disabled rules. When/if these rules are enabled, we will want to ignore case. This also helps https://github.com/pinterest-web/eslint-config-pinterest/pull/46/files#r76165293 --- packages/eslint-config-airbnb/rules/react.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/eslint-config-airbnb/rules/react.js b/packages/eslint-config-airbnb/rules/react.js index 1552b7ea78..9921526213 100644 --- a/packages/eslint-config-airbnb/rules/react.js +++ b/packages/eslint-config-airbnb/rules/react.js @@ -67,7 +67,7 @@ module.exports = { // Prevent duplicate props in JSX // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-no-duplicate-props.md - 'react/jsx-no-duplicate-props': ['off', { ignoreCase: false }], + 'react/jsx-no-duplicate-props': ['off', { ignoreCase: true }], // Prevent usage of unwrapped JSX strings // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-no-literals.md @@ -87,7 +87,7 @@ module.exports = { // Enforce propTypes declarations alphabetical sorting // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/sort-prop-types.md 'react/sort-prop-types': ['off', { - ignoreCase: false, + ignoreCase: true, callbacksLast: false, requiredFirst: false, }], @@ -98,7 +98,7 @@ module.exports = { // Enforce props alphabetical sorting // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-sort-props.md 'react/jsx-sort-props': ['off', { - ignoreCase: false, + ignoreCase: true, callbacksLast: false, shorthandFirst: false, shorthandLast: false, From 3a7210eac1d6af201e21f37c507fd584d3d11d56 Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Wed, 31 Aug 2016 21:54:51 -0700 Subject: [PATCH 026/826] [guide] remove subtle endorsement of JSDoc-style commenting. --- README.md | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index c7faf50d02..4435532cdb 100644 --- a/README.md +++ b/README.md @@ -1749,7 +1749,7 @@ Other Style Guides ## Comments - - [17.1](#comments--multiline) Use `/** ... */` for multi-line comments. Include a description, specify types and values for all parameters and return values. + - [17.1](#comments--multiline) Use `/** ... */` for multi-line comments. ```javascript // bad @@ -1768,10 +1768,7 @@ Other Style Guides // good /** * make() returns a new element - * based on the passed in tag name - * - * @param {String} tag - * @return {Element} element + * based on the passed-in tag name */ function make(tag) { From 71a2b12262e628702d98785ae3655fc655ac1551 Mon Sep 17 00:00:00 2001 From: Joe Lencioni Date: Wed, 31 Aug 2016 12:49:52 -0700 Subject: [PATCH 027/826] Add CSS-in-JavaScript section We have been writing CSS in JavaScript and have developed a set of best practices around this type of thing. I thought it would be nice to publish this document alongside our other JavaScript style guide documents. --- README.md | 3 +- css-in-javascript/README.md | 433 ++++++++++++++++++++++++++++++++++++ 2 files changed, 435 insertions(+), 1 deletion(-) create mode 100644 css-in-javascript/README.md diff --git a/README.md b/README.md index 4435532cdb..728f364780 100644 --- a/README.md +++ b/README.md @@ -9,6 +9,7 @@ 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) @@ -2218,7 +2219,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) > 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](es5/README.md#commas) in legacy browsers. - + ```javascript // bad - git diff without trailing comma const hero = { diff --git a/css-in-javascript/README.md b/css-in-javascript/README.md new file mode 100644 index 0000000000..9c44de6f21 --- /dev/null +++ b/css-in-javascript/README.md @@ -0,0 +1,433 @@ +# Airbnb CSS-in-JavaScript Style Guide + +*A mostly reasonable approach to CSS-in-JavaScript + +## Table of Contents + +1. [Naming](#naming) +1. [Ordering](#ordering) +1. [Nesting](#nesting) +1. [Inline](#inline) +1. [Themes](#themes) + +## Naming + + - 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. + + ```js + // bad + { + 'bermuda-triangle': { + display: 'none', + }, + } + + // good + { + bermudaTriangle: { + display: 'none', + }, + } + ``` + + - 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. + + ```js + // bad + { + bruceBanner: { + color: 'pink', + transition: 'color 10s', + }, + + bruceBannerTheHulk: { + color: 'green', + }, + } + + // good + { + bruceBanner: { + color: 'pink', + transition: 'color 10s', + }, + + bruceBanner_theHulk: { + color: 'green', + }, + } + ``` + + - 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. + + ```js + // bad + { + muscles: { + display: 'flex', + }, + + muscles_sadBears: { + width: '100%', + }, + } + + // good + { + muscles: { + display: 'flex', + }, + + muscles_fallback: { + width: '100%', + }, + } + ``` + + - Use a separate selector for sets of fallback styles. + + > Why? Keeping fallback styles contained in a separate object clarifies their purpose, which improves readability. + + ```js + // bad + { + muscles: { + display: 'flex', + }, + + left: { + flexGrow: 1, + display: 'inline-block', + }, + + right: { + display: 'inline-block', + }, + } + + // good + { + muscles: { + display: 'flex', + }, + + left: { + flexGrow: 1, + }, + + left_fallback: { + display: 'inline-block', + }, + + right_fallback: { + display: 'inline-block', + }, + } + ``` + + - 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. + + ```js + // bad + const breakpoints = { + desktop: '@media (min-width: 1048px)', + tablet: '@media (max-width: 1047px)', + mobile: '@media (max-width: 639px)', + }; + + // good + const breakpoints = { + large: '@media (min-width: 1048px)', + medium: '@media (max-width: 1047px)', + small: '@media (max-width: 639px)', + }; + ``` + +## Ordering + + - 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. + + ```jsx + // bad + const styles = { + container: { + display: 'inline-block', + }, + }; + + function MyComponent({ styles }) { + return ( +
+ Never doubt that a small group of thoughtful, committed citizens can + change the world. Indeed, it’s the only thing that ever has. +
+ ); + } + + export default withStyles(() => styles)(MyComponent); + + + // good + function MyComponent({ styles }) { + return ( +
+ Never doubt that a small group of thoughtful, committed citizens can + change the world. Indeed, it’s the only thing that ever has. +
+ ); + } + + export default withStyles(() => ({ + container: { + display: 'inline-block', + }, + }))(MyComponent); + ``` + +## Nesting + + - Leave a blank line between adjacent blocks at the same indentation level. + + > Why? The whitespace improves readability and reduces the likelihood of merge conflicts. + + ```js + // bad + { + bigBang: { + display: 'inline-block', + '::before': { + content: "''", + }, + }, + universe: { + border: 'none', + }, + } + + // good + { + bigBang: { + display: 'inline-block', + + '::before': { + content: "''", + }, + }, + + universe: { + border: 'none', + }, + } + ``` + +## Inline + + - 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. + + ```jsx + // bad + export default function MyComponent({ spacing }) { + return ( +
+ ); + } + + // good + function MyComponent({ styles, spacing }) { + return ( +
+ ); + } + export default withStyles(() => ({ + periodic: { + display: 'table', + }, + }))(MyComponent); + ``` + +## Themes + + - Use an abstraction layer such as [react-with-styles](https://github.com/airbnb/react-with-styles) that enables theming. + + > Why? It is useful to have a set of shared variables for styling your components. Using an abstraction layer makes this more convenient. Additionally, this can help prevent your components from being tightly coupled to any particular underlying implementation, which gives you more freedom. + + - Define colors only in themes. + + ```js + // bad + export default withStyles(() => ({ + chuckNorris: { + color: '#bada55', + }, + }))(MyComponent); + + // good + export default withStyles(({ color }) => ({ + chuckNorris: { + color: color.badass, + }, + }))(MyComponent); + ``` + + - Define fonts only in themes. + + ```js + // bad + export default withStyles(() => ({ + towerOfPisa: { + fontStyle: 'italic', + }, + }))(MyComponent); + + // good + export default withStyles(({ font }) => ({ + towerOfPisa: { + fontStyle: font.italic, + }, + }))(MyComponent); + ``` + + - Define fonts as sets of related styles. + + ```js + // bad + export default withStyles(() => ({ + towerOfPisa: { + fontFamily: 'Italiana, "Times New Roman", serif', + fontSize: '2em', + fontStyle: 'italic', + lineHeight: 1.5, + }, + }))(MyComponent); + + // good + export default withStyles(({ font }) => ({ + towerOfPisa: { + ...font.italian, + }, + }))(MyComponent); + ``` + + - Define base grid units in theme (either as a value or a function that takes a multiplier). + + ```js + // bad + export default withStyles(() => ({ + rip: { + bottom: '-6912px', // 6 feet + }, + }))(MyComponent); + + // good + export default withStyles(({ units }) => ({ + rip: { + bottom: units(864), // 6 feet, assuming our unit is 8px + }, + }))(MyComponent); + + // good + export default withStyles(({ unit }) => ({ + rip: { + bottom: 864 * unit, // 6 feet, assuming our unit is 8px + }, + }))(MyComponent); + ``` + + - Define media queries only in themes. + + ```js + // bad + export default withStyles(() => ({ + container: { + width: '100%', + + '@media (max-width: 1047px)': { + width: '50%', + }, + }, + }))(MyComponent); + + // good + export default withStyles(({ breakpoint }) => ({ + container: { + width: '100%', + + [breakpoint.medium]: { + width: '50%', + }, + }, + }))(MyComponent); + ``` + + - 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. + + ```js + // bad + export default withStyles(() => ({ + .muscles { + display: 'flex', + }, + + .muscles_fallback { + 'display ': 'table', + }, + }))(MyComponent); + + // good + export default withStyles(({ fallbacks }) => ({ + .muscles { + display: 'flex', + }, + + .muscles_fallback { + [fallbacks.display]: 'table', + }, + }))(MyComponent); + + // good + export default withStyles(({ fallback }) => ({ + .muscles { + display: 'flex', + }, + + .muscles_fallback { + [fallback('display')]: 'table', + }, + }))(MyComponent); + ``` + + - Create as few custom themes as possible. Many applications may only have one theme. + + - Namespace custom theme settings under a nested object with a unique and descriptive key. + + ```js + // bad + ThemedStyleSheet.registerTheme('mySection', { + mySectionPrimaryColor: 'green', + }); + + // good + ThemedStyleSheet.registerTheme('mySection', { + mySection: { + primaryColor: 'green', + }, + }); + ``` + +--- + +CSS puns adapted from [Saijo George](http://saijogeorge.com/css-puns/). From c74caead2a5569da4623ee4a9d613d8cde9940c2 Mon Sep 17 00:00:00 2001 From: Joe Lencioni Date: Wed, 31 Aug 2016 14:10:07 -0700 Subject: [PATCH 028/826] Re-order breakpoints in CSS-in-JS document This is more "mobile first". --- css-in-javascript/README.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/css-in-javascript/README.md b/css-in-javascript/README.md index 9c44de6f21..e310c4d407 100644 --- a/css-in-javascript/README.md +++ b/css-in-javascript/README.md @@ -138,16 +138,16 @@ ```js // bad const breakpoints = { - desktop: '@media (min-width: 1048px)', - tablet: '@media (max-width: 1047px)', mobile: '@media (max-width: 639px)', + tablet: '@media (max-width: 1047px)', + desktop: '@media (min-width: 1048px)', }; // good const breakpoints = { - large: '@media (min-width: 1048px)', - medium: '@media (max-width: 1047px)', small: '@media (max-width: 639px)', + medium: '@media (max-width: 1047px)', + large: '@media (min-width: 1048px)', }; ``` From c6406330ea3640a93de8117ad8c7a0cd1f9ed999 Mon Sep 17 00:00:00 2001 From: Joe Lencioni Date: Fri, 2 Sep 2016 07:57:33 -0700 Subject: [PATCH 029/826] Add note about where where mystery objects come from As @ljharb pointed out, we are using some functions like `css()` and `withStyles()`, but make no mention of what they are or where they come from. Since they come from react-with-styles, let's make this clear. --- css-in-javascript/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/css-in-javascript/README.md b/css-in-javascript/README.md index e310c4d407..59c1c7bcbd 100644 --- a/css-in-javascript/README.md +++ b/css-in-javascript/README.md @@ -259,7 +259,7 @@ ## Themes - - Use an abstraction layer such as [react-with-styles](https://github.com/airbnb/react-with-styles) that enables theming. + - Use an abstraction layer such as [react-with-styles](https://github.com/airbnb/react-with-styles) that enables theming. *react-with-styles gives us things like `withStyles()`, `ThemedStyleSheet`, and `css()` which are used in some of the examples in this document.* > Why? It is useful to have a set of shared variables for styling your components. Using an abstraction layer makes this more convenient. Additionally, this can help prevent your components from being tightly coupled to any particular underlying implementation, which gives you more freedom. From 086cc0035df91b34c52744ab278b778a4d3208a7 Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Tue, 6 Sep 2016 00:36:04 -0700 Subject: [PATCH 030/826] [eslint config] [base] [breaking] enable `no-template-curly-in-string` - Also, clean up rule documentation. --- .../eslint-config-airbnb-base/rules/best-practices.js | 6 ++---- packages/eslint-config-airbnb-base/rules/errors.js | 10 ++++------ packages/eslint-config-airbnb-base/rules/es6.js | 2 +- packages/eslint-config-airbnb-base/rules/variables.js | 1 + 4 files changed, 8 insertions(+), 11 deletions(-) diff --git a/packages/eslint-config-airbnb-base/rules/best-practices.js b/packages/eslint-config-airbnb-base/rules/best-practices.js index 26602745de..a6f714bcb9 100644 --- a/packages/eslint-config-airbnb-base/rules/best-practices.js +++ b/packages/eslint-config-airbnb-base/rules/best-practices.js @@ -92,6 +92,8 @@ module.exports = { // disallow reassignments of native objects or read-only globals // http://eslint.org/docs/rules/no-global-assign 'no-global-assign': ['error', { exceptions: [] }], + // deprecated in favor of no-global-assign + 'no-native-reassign': 'off', // disallow implicit type conversions // http://eslint.org/docs/rules/no-implicit-coercion @@ -139,10 +141,6 @@ module.exports = { // disallow use of multiline strings 'no-multi-str': 'error', - // disallow reassignments of native objects - // TODO: deprecated in favor of no-global-assign - 'no-native-reassign': 'off', - // disallow use of new operator when not part of the assignment or comparison 'no-new': 'error', diff --git a/packages/eslint-config-airbnb-base/rules/errors.js b/packages/eslint-config-airbnb-base/rules/errors.js index 6c932c8dfc..4dbed4f3b2 100644 --- a/packages/eslint-config-airbnb-base/rules/errors.js +++ b/packages/eslint-config-airbnb-base/rules/errors.js @@ -63,10 +63,6 @@ module.exports = { // disallow irregular whitespace outside of strings and comments 'no-irregular-whitespace': 'error', - // disallow negation of the left operand of an in expression - // TODO: deprecated in favor of no-unsafe-negation - 'no-negated-in-lhs': 'off', - // disallow the use of object properties of the global object (Math and JSON) as functions 'no-obj-calls': 'error', @@ -82,8 +78,7 @@ module.exports = { // Disallow template literal placeholder syntax in regular strings // http://eslint.org/docs/rules/no-template-curly-in-string - // TODO: enable, semver-major - 'no-template-curly-in-string': 'off', + 'no-template-curly-in-string': 'error', // Avoid code that looks like two expressions but is actually one // http://eslint.org/docs/rules/no-unexpected-multiline @@ -99,6 +94,9 @@ module.exports = { // disallow negating the left operand of relational operators // http://eslint.org/docs/rules/no-unsafe-negation 'no-unsafe-negation': 'error', + // disallow negation of the left operand of an in expression + // deprecated in favor of no-unsafe-negation + 'no-negated-in-lhs': 'off', // disallow comparisons with the value NaN 'use-isnan': 'error', diff --git a/packages/eslint-config-airbnb-base/rules/es6.js b/packages/eslint-config-airbnb-base/rules/es6.js index 169e30be01..611dbe4de0 100644 --- a/packages/eslint-config-airbnb-base/rules/es6.js +++ b/packages/eslint-config-airbnb-base/rules/es6.js @@ -103,7 +103,7 @@ module.exports = { // suggest using Reflect methods where applicable // http://eslint.org/docs/rules/prefer-reflect - // TODO: enable + // TODO: enable? 'prefer-reflect': 'off', // use rest parameters instead of arguments diff --git a/packages/eslint-config-airbnb-base/rules/variables.js b/packages/eslint-config-airbnb-base/rules/variables.js index 312ee76813..8af041c082 100644 --- a/packages/eslint-config-airbnb-base/rules/variables.js +++ b/packages/eslint-config-airbnb-base/rules/variables.js @@ -29,6 +29,7 @@ module.exports = { 'no-undef-init': 'error', // disallow use of undefined variable + // http://eslint.org/docs/rules/no-undefined // TODO: enable? 'no-undefined': 'off', From 27dcb99c6d80718946d10017144b2aa68bed8b9e Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Tue, 6 Sep 2016 01:07:16 -0700 Subject: [PATCH 031/826] [eslint config] [base] [breaking] enable `func-call-spacing` --- 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 c80beaee87..288b0ed5d5 100644 --- a/packages/eslint-config-airbnb-base/rules/style.js +++ b/packages/eslint-config-airbnb-base/rules/style.js @@ -30,8 +30,7 @@ module.exports = { // enforce spacing between functions and their invocations // http://eslint.org/docs/rules/func-call-spacing - // TODO: enable, semver-minor - 'func-call-spacing': ['off', 'never'], + 'func-call-spacing': ['error', 'never'], // require function expressions to have a name 'func-names': 'warn', From aa4e9c466ad8edc44aa744a579389d10af2e6fd7 Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Tue, 6 Sep 2016 01:07:39 -0700 Subject: [PATCH 032/826] [eslint config] [base] [breaking] enable `no-tabs` --- 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 288b0ed5d5..c3f0442fd2 100644 --- a/packages/eslint-config-airbnb-base/rules/style.js +++ b/packages/eslint-config-airbnb-base/rules/style.js @@ -195,8 +195,7 @@ module.exports = { 'no-spaced-func': 'error', // disallow tab characters entirely - // TODO: enable - 'no-tabs': 'off', + 'no-tabs': 'error', // disallow the use of ternary operators 'no-ternary': 'off', From a6d59f977e9b6d8fdc0d8cd7333667a4c6e40efa Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Tue, 6 Sep 2016 01:07:56 -0700 Subject: [PATCH 033/826] [eslint config] [base] [breaking] enable `no-bitwise` --- 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 c3f0442fd2..1d16982676 100644 --- a/packages/eslint-config-airbnb-base/rules/style.js +++ b/packages/eslint-config-airbnb-base/rules/style.js @@ -136,8 +136,7 @@ module.exports = { // disallow use of bitwise operators // http://eslint.org/docs/rules/no-bitwise - // TODO: enable - 'no-bitwise': 'off', + 'no-bitwise': 'error', // disallow use of the continue statement // http://eslint.org/docs/rules/no-continue From 3bf7035cecbdcfbbddac9092b46c50f6591c5098 Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Tue, 6 Sep 2016 10:40:31 -0700 Subject: [PATCH 034/826] [eslint config] [base] [deps] update `eslint`, `eslint-find-rules`, `eslint-plugin-import` --- packages/eslint-config-airbnb-base/package.json | 10 +++++----- .../eslint-config-airbnb-base/rules/best-practices.js | 5 +++++ packages/eslint-config-airbnb-base/rules/es6.js | 5 +++++ packages/eslint-config-airbnb-base/rules/style.js | 3 ++- 4 files changed, 17 insertions(+), 6 deletions(-) diff --git a/packages/eslint-config-airbnb-base/package.json b/packages/eslint-config-airbnb-base/package.json index 5a04cd263d..5a4ff4338b 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.0.0", "babel-tape-runner": "^2.0.1", - "eslint": "^3.3.1", - "eslint-find-rules": "^1.13.0", - "eslint-plugin-import": "^1.13.0", + "eslint": "^3.4.0", + "eslint-find-rules": "^1.13.1", + "eslint-plugin-import": "^1.14.0", "in-publish": "^2.0.0", "safe-publish-latest": "^1.0.1", "tape": "^4.6.0" }, "peerDependencies": { - "eslint": "^3.3.1", - "eslint-plugin-import": "^1.13.0" + "eslint": "^3.4.0", + "eslint-plugin-import": "^1.14.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 a6f714bcb9..17ce192179 100644 --- a/packages/eslint-config-airbnb-base/rules/best-practices.js +++ b/packages/eslint-config-airbnb-base/rules/best-practices.js @@ -13,6 +13,11 @@ module.exports = { // specify the maximum cyclomatic complexity allowed in a program complexity: ['off', 11], + // enforce that class methods use "this" + // http://eslint.org/docs/rules/class-methods-use-this + // TODO: enable + 'class-methods-use-this': 'off', + // require return statements to either always or never specify values 'consistent-return': 'error', diff --git a/packages/eslint-config-airbnb-base/rules/es6.js b/packages/eslint-config-airbnb-base/rules/es6.js index 611dbe4de0..e6506a8b07 100644 --- a/packages/eslint-config-airbnb-base/rules/es6.js +++ b/packages/eslint-config-airbnb-base/rules/es6.js @@ -134,6 +134,11 @@ module.exports = { memberSyntaxSortOrder: ['none', 'all', 'multiple', 'single'], }], + // require a Symbol description + // http://eslint.org/docs/rules/symbol-description + // TODO: enable + 'symbol-description': 'off', + // enforce usage of spacing in template strings // http://eslint.org/docs/rules/template-curly-spacing 'template-curly-spacing': 'error', diff --git a/packages/eslint-config-airbnb-base/rules/style.js b/packages/eslint-config-airbnb-base/rules/style.js index 1d16982676..f4fb7dbddf 100644 --- a/packages/eslint-config-airbnb-base/rules/style.js +++ b/packages/eslint-config-airbnb-base/rules/style.js @@ -111,7 +111,8 @@ module.exports = { // require multiline ternary // http://eslint.org/docs/rules/multiline-ternary - 'multiline-ternary': 'off', + // TODO: enable? + 'multiline-ternary': ['off', 'never'], // require a capital letter for constructors 'new-cap': ['error', { newIsCap: true }], From 2c5a775d7bec4e543b5ce3eb823e2134531a8841 Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Tue, 6 Sep 2016 10:44:00 -0700 Subject: [PATCH 035/826] [eslint config] [base] [breaking] enable `symbol-description` --- packages/eslint-config-airbnb-base/rules/es6.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/packages/eslint-config-airbnb-base/rules/es6.js b/packages/eslint-config-airbnb-base/rules/es6.js index e6506a8b07..f1e2bd026f 100644 --- a/packages/eslint-config-airbnb-base/rules/es6.js +++ b/packages/eslint-config-airbnb-base/rules/es6.js @@ -136,8 +136,7 @@ module.exports = { // require a Symbol description // http://eslint.org/docs/rules/symbol-description - // TODO: enable - 'symbol-description': 'off', + 'symbol-description': 'error', // enforce usage of spacing in template strings // http://eslint.org/docs/rules/template-curly-spacing From 06ff74801be00dfaee5077a59e883750796a3004 Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Tue, 6 Sep 2016 10:44:19 -0700 Subject: [PATCH 036/826] [eslint config] [base] [breaking] enable `class-methods-use-this` --- packages/eslint-config-airbnb-base/rules/best-practices.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/packages/eslint-config-airbnb-base/rules/best-practices.js b/packages/eslint-config-airbnb-base/rules/best-practices.js index 17ce192179..a41c1e252a 100644 --- a/packages/eslint-config-airbnb-base/rules/best-practices.js +++ b/packages/eslint-config-airbnb-base/rules/best-practices.js @@ -15,8 +15,7 @@ module.exports = { // enforce that class methods use "this" // http://eslint.org/docs/rules/class-methods-use-this - // TODO: enable - 'class-methods-use-this': 'off', + 'class-methods-use-this': 'error', // require return statements to either always or never specify values 'consistent-return': 'error', From d7d606ec0d904cd3e162aa798f0cd2e0f4d64e60 Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Tue, 6 Sep 2016 10:48:21 -0700 Subject: [PATCH 037/826] [eslint config] [base] [breaking] `valid-typeof`: enable `requireStringLiterals` option --- packages/eslint-config-airbnb-base/rules/errors.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/eslint-config-airbnb-base/rules/errors.js b/packages/eslint-config-airbnb-base/rules/errors.js index 4dbed4f3b2..de6439b5e3 100644 --- a/packages/eslint-config-airbnb-base/rules/errors.js +++ b/packages/eslint-config-airbnb-base/rules/errors.js @@ -106,6 +106,7 @@ module.exports = { 'valid-jsdoc': 'off', // ensure that the results of typeof are compared against a valid string - 'valid-typeof': 'error' + // http://eslint.org/docs/rules/valid-typeof + 'valid-typeof': ['error', { requireStringLiterals: true }], } }; From 9750f4261c11ec812ba9308b3966bd54faed272e Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Tue, 6 Sep 2016 10:50:03 -0700 Subject: [PATCH 038/826] [eslint config] [base] Update `ecmaVersion` to `2016`. --- packages/eslint-config-airbnb-base/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/eslint-config-airbnb-base/index.js b/packages/eslint-config-airbnb-base/index.js index c89431a0c5..cc13673700 100644 --- a/packages/eslint-config-airbnb-base/index.js +++ b/packages/eslint-config-airbnb-base/index.js @@ -9,7 +9,7 @@ module.exports = { './rules/imports', ].map(require.resolve), parserOptions: { - ecmaVersion: 7, + ecmaVersion: 2016, sourceType: 'module', }, rules: { From e52f41c9cc89c04eec3ddc9801df526d143b6095 Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Tue, 6 Sep 2016 10:56:02 -0700 Subject: [PATCH 039/826] [eslint config] [base] v6.0.0 --- packages/eslint-config-airbnb-base/CHANGELOG.md | 13 +++++++++++++ packages/eslint-config-airbnb-base/package.json | 2 +- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/packages/eslint-config-airbnb-base/CHANGELOG.md b/packages/eslint-config-airbnb-base/CHANGELOG.md index aa61e0f2be..9611dfc952 100644 --- a/packages/eslint-config-airbnb-base/CHANGELOG.md +++ b/packages/eslint-config-airbnb-base/CHANGELOG.md @@ -1,3 +1,16 @@ +6.0.0 / 2016-09-06 +================== + - [breaking] `valid-typeof`: enable `requireStringLiterals` option + - [breaking] enable `class-methods-use-this` + - [breaking] enable `symbol-description` + - [breaking] enable `no-bitwise` + - [breaking] enable `no-tabs` + - [breaking] enable `func-call-spacing` + - [breaking] enable `no-template-curly-in-string` + - [patch] remove redundant `DebuggerStatement` from `no-restricted-syntax` (#1031) + - [deps] update `eslint`, `eslint-find-rules`, `eslint-plugin-import` + - Update `ecmaVersion` to `2016` + 5.0.3 / 2016-08-21 ================== - [fix] correct `import/extensions` list (#1013) diff --git a/packages/eslint-config-airbnb-base/package.json b/packages/eslint-config-airbnb-base/package.json index 5a4ff4338b..be24a5d3f3 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": "5.0.3", + "version": "6.0.0", "description": "Airbnb's base JS ESLint config, following our styleguide", "main": "index.js", "scripts": { From bc3b15d4d784327e8d8713a5111db94a6a42a5ba Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Tue, 6 Sep 2016 11:40:42 -0700 Subject: [PATCH 040/826] =?UTF-8?q?[eslint=20config]=20[*]=20[docs]=20use?= =?UTF-8?q?=20=E2=80=9C#=E2=80=9D=20in=20example=20command=20rather=20than?= =?UTF-8?q?=20version=20numbers.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Closes #984. --- 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 40691b43c8..dabe3a6345 100644 --- a/packages/eslint-config-airbnb-base/README.md +++ b/packages/eslint-config-airbnb-base/README.md @@ -23,7 +23,7 @@ Our default export contains all of our ESLint rules, including ECMAScript 6+. It Which produces and runs a command like: ```sh - npm install --save-dev eslint-config-airbnb-base eslint@^3.0.1 eslint-plugin-import@^1.10.3 + npm install --save-dev eslint-config-airbnb-base eslint@^#.#.# eslint-plugin-import@^#.#.# ``` 2. Add `"extends": "airbnb-base"` to your .eslintrc diff --git a/packages/eslint-config-airbnb/README.md b/packages/eslint-config-airbnb/README.md index 7a0b8c68b6..d13133e14e 100644 --- a/packages/eslint-config-airbnb/README.md +++ b/packages/eslint-config-airbnb/README.md @@ -23,7 +23,7 @@ Our default export contains all of our ESLint rules, including ECMAScript 6+ and Which produces and runs a command like: ```sh - npm install --save-dev eslint-config-airbnb eslint@^2.9.0 eslint-plugin-jsx-a11y@^1.2.0 eslint-plugin-import@^1.7.0 eslint-plugin-react@^5.0.1 + 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 From 55d044c7c17d22fc0e4299a23481a72347c55cba Mon Sep 17 00:00:00 2001 From: scott stern Date: Sun, 14 Aug 2016 15:35:05 -0700 Subject: [PATCH 041/826] [eslint config] [base] [breaking] Add no-plusplus in style.js and added explanation in README. --- README.md | 29 +++++++++++++++++++ .../eslint-config-airbnb-base/rules/style.js | 3 +- 2 files changed, 31 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 728f364780..2ed3f9f18f 100644 --- a/README.md +++ b/README.md @@ -1278,6 +1278,35 @@ Other Style Guides } ``` + - [13.5](#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. + + ```javascript + // bad + + let array = [1, 2, 3]; + let num = 1; + let increment = num ++; + let decrement = -- num; + + for(let i = 0; i < array.length; i++){ + let value = array[i]; + ++value; + } + + // good + + let array = [1, 2, 3]; + let num = 1; + let increment = num += 1; + let decrement = num -= 1; + + array.forEach((value) => { + value += 1; + }); + ``` + **[⬆ back to top](#table-of-contents)** diff --git a/packages/eslint-config-airbnb-base/rules/style.js b/packages/eslint-config-airbnb-base/rules/style.js index f4fb7dbddf..faac007cfb 100644 --- a/packages/eslint-config-airbnb-base/rules/style.js +++ b/packages/eslint-config-airbnb-base/rules/style.js @@ -180,7 +180,8 @@ module.exports = { 'no-new-object': 'error', // disallow use of unary operators, ++ and -- - 'no-plusplus': 'off', + // http://eslint.org/docs/rules/no-plusplus + 'no-plusplus': 2, // disallow certain syntax forms // http://eslint.org/docs/rules/no-restricted-syntax From 49045060e01db75d4035835184b9554dd79adac7 Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Tue, 6 Sep 2016 12:21:22 -0700 Subject: [PATCH 042/826] [eslint config] [base] v7.0.0 --- packages/eslint-config-airbnb-base/CHANGELOG.md | 4 ++++ packages/eslint-config-airbnb-base/package.json | 2 +- packages/eslint-config-airbnb-base/rules/style.js | 2 +- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/packages/eslint-config-airbnb-base/CHANGELOG.md b/packages/eslint-config-airbnb-base/CHANGELOG.md index 9611dfc952..06075f3d70 100644 --- a/packages/eslint-config-airbnb-base/CHANGELOG.md +++ b/packages/eslint-config-airbnb-base/CHANGELOG.md @@ -1,3 +1,7 @@ +7.0.0 / 2016-09-06 +================== + - [breaking] Add no-plusplus in style.js and added explanation in README (#1012) + 6.0.0 / 2016-09-06 ================== - [breaking] `valid-typeof`: enable `requireStringLiterals` option diff --git a/packages/eslint-config-airbnb-base/package.json b/packages/eslint-config-airbnb-base/package.json index be24a5d3f3..b935962690 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": "6.0.0", + "version": "7.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 faac007cfb..c46e510a8c 100644 --- a/packages/eslint-config-airbnb-base/rules/style.js +++ b/packages/eslint-config-airbnb-base/rules/style.js @@ -181,7 +181,7 @@ module.exports = { // disallow use of unary operators, ++ and -- // http://eslint.org/docs/rules/no-plusplus - 'no-plusplus': 2, + 'no-plusplus': 'error', // disallow certain syntax forms // http://eslint.org/docs/rules/no-restricted-syntax From 9abe8789417d4fef6f4fcd490a186f0dd719aa6f Mon Sep 17 00:00:00 2001 From: cshg Date: Tue, 6 Sep 2016 13:08:55 +0200 Subject: [PATCH 043/826] Fix header link to Classes & Constructors from ECMAScript 6+ Styles --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 2ed3f9f18f..be7bb4e3b4 100644 --- a/README.md +++ b/README.md @@ -2754,7 +2754,7 @@ Other Style Guides - [27.1](#es6-styles) This is a collection of links to the various ES6 features. 1. [Arrow Functions](#arrow-functions) -1. [Classes](#constructors) +1. [Classes](#classes--constructors) 1. [Object Shorthand](#es6-object-shorthand) 1. [Object Concise](#es6-object-concise) 1. [Object Computed Properties](#es6-computed-properties) From e037760bad9c514ef183e2c9409e6d418753bbea Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Tue, 6 Sep 2016 17:10:48 -0700 Subject: [PATCH 044/826] [eslint config] [deps] update `eslint-config-airbnb-base`, `eslint`, `eslint-find-rules`, `eslint-plugin-import`, `eslint-plugin-jsx-a11y`, `eslint-plugin-react` --- packages/eslint-config-airbnb/package.json | 20 +++++++++---------- .../eslint-config-airbnb/rules/react-a11y.js | 10 ++++++++++ packages/eslint-config-airbnb/rules/react.js | 14 +++++++++++++ .../test/test-react-order.js | 2 +- 4 files changed, 35 insertions(+), 11 deletions(-) diff --git a/packages/eslint-config-airbnb/package.json b/packages/eslint-config-airbnb/package.json index c176f07da3..1ec47d7284 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": "^5.0.2" + "eslint-config-airbnb-base": "^7.0.0" }, "devDependencies": { "babel-preset-airbnb": "^2.0.0", "babel-tape-runner": "^2.0.1", - "eslint": "^3.3.1", - "eslint-find-rules": "^1.13.0", - "eslint-plugin-import": "^1.13.0", - "eslint-plugin-jsx-a11y": "^2.1.0", - "eslint-plugin-react": "^6.1.2", + "eslint": "^3.4.0", + "eslint-find-rules": "^1.13.1", + "eslint-plugin-import": "^1.14.0", + "eslint-plugin-jsx-a11y": "^2.2.1", + "eslint-plugin-react": "^6.2.0", "in-publish": "^2.0.0", "react": ">= 0.13.0", "safe-publish-latest": "^1.0.1", "tape": "^4.6.0" }, "peerDependencies": { - "eslint": "^3.3.1", - "eslint-plugin-jsx-a11y": "^2.1.0", - "eslint-plugin-import": "^1.13.0", - "eslint-plugin-react": "^6.1.2" + "eslint": "^3.4.0", + "eslint-plugin-jsx-a11y": "^2.2.1", + "eslint-plugin-import": "^1.14.0", + "eslint-plugin-react": "^6.2.0" }, "engines": { "node": ">= 4" diff --git a/packages/eslint-config-airbnb/rules/react-a11y.js b/packages/eslint-config-airbnb/rules/react-a11y.js index 76430261c7..3b7d684b5d 100644 --- a/packages/eslint-config-airbnb/rules/react-a11y.js +++ b/packages/eslint-config-airbnb/rules/react-a11y.js @@ -101,5 +101,15 @@ module.exports = { // 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', + + // 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', + + // 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 + // TODO: enable + 'jsx-a11y/no-static-element-interactions': 'off', }, }; diff --git a/packages/eslint-config-airbnb/rules/react.js b/packages/eslint-config-airbnb/rules/react.js index 9921526213..1d4eb2a493 100644 --- a/packages/eslint-config-airbnb/rules/react.js +++ b/packages/eslint-config-airbnb/rules/react.js @@ -252,6 +252,20 @@ module.exports = { // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/no-danger-with-children.md // TODO: enable, semver-major 'react/no-danger-with-children': 'off', + + // Prevent unused propType definitions + // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/no-unused-prop-types.md + // TODO: enable + 'react/no-unused-prop-types': ['off', { + customValidators: [ + ], + skipShapeProps: false, + }], + + // Require style prop value be an object or var + // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/style-prop-object.md + // TODO: enable + 'react/style-prop-object': 'off', }, settings: { diff --git a/packages/eslint-config-airbnb/test/test-react-order.js b/packages/eslint-config-airbnb/test/test-react-order.js index 37d417ca15..aa8aa192eb 100644 --- a/packages/eslint-config-airbnb/test/test-react-order.js +++ b/packages/eslint-config-airbnb/test/test-react-order.js @@ -26,7 +26,7 @@ function wrapComponent(body) { import React from 'react'; export default class MyComponent extends React.Component { -/* eslint no-empty-function: 0 */ +/* eslint no-empty-function: 0, class-methods-use-this: 0 */ ${body} } `; From 4ce30fc89135c76ad3fa7aeccd5b5ad9550fe9be Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Tue, 6 Sep 2016 22:46:52 -0700 Subject: [PATCH 045/826] [eslint config] [breaking] enable `jsx-a11y` rules: - `jsx-a11y/anchor-has-content` - `jsx-a11y/tabindex-no-positive` - `jsx-a11y/no-static-element-interactions` --- packages/eslint-config-airbnb/rules/react-a11y.js | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/packages/eslint-config-airbnb/rules/react-a11y.js b/packages/eslint-config-airbnb/rules/react-a11y.js index 3b7d684b5d..1df39103ab 100644 --- a/packages/eslint-config-airbnb/rules/react-a11y.js +++ b/packages/eslint-config-airbnb/rules/react-a11y.js @@ -9,8 +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 - // TODO: enable, semver-major - 'jsx-a11y/anchor-has-content': ['off', ['']], + 'jsx-a11y/anchor-has-content': ['error', ['']], // Require ARIA roles to be valid and non-abstract // https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/aria-role.md @@ -78,9 +77,8 @@ module.exports = { 'jsx-a11y/role-supports-aria-props': 'error', // Enforce tabIndex value is not greater than zero. - // TODO: evaluate // https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/tabindex-no-positive.md - 'jsx-a11y/tabindex-no-positive': 'off', + 'jsx-a11y/tabindex-no-positive': 'error', // 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 @@ -109,7 +107,6 @@ 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 - // TODO: enable - 'jsx-a11y/no-static-element-interactions': 'off', + 'jsx-a11y/no-static-element-interactions': 'error', }, }; From 7f12b9f04373860ad9d2e5c17f85aef95d195d30 Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Tue, 6 Sep 2016 22:53:01 -0700 Subject: [PATCH 046/826] [eslint config] [breaking] enable `react` rules: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - `react/no-danger-with-children` - `react/no-unused-prop-types` - `react/style-prop-object` - `react/forbid-prop-types` - `react/jsx-no-duplicate-props` Also sets `react/no-danger` to “warn”. --- packages/eslint-config-airbnb/rules/react.js | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/packages/eslint-config-airbnb/rules/react.js b/packages/eslint-config-airbnb/rules/react.js index 1d4eb2a493..9c0a13eb8f 100644 --- a/packages/eslint-config-airbnb/rules/react.js +++ b/packages/eslint-config-airbnb/rules/react.js @@ -24,7 +24,7 @@ module.exports = { // Forbid certain propTypes (any, array, object) // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/forbid-prop-types.md - 'react/forbid-prop-types': ['off', { forbid: ['any', 'array', 'object'] }], + 'react/forbid-prop-types': ['error', { forbid: ['any', 'array', 'object'] }], // Enforce boolean attributes notation in JSX // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-boolean-value.md @@ -67,7 +67,7 @@ module.exports = { // Prevent duplicate props in JSX // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-no-duplicate-props.md - 'react/jsx-no-duplicate-props': ['off', { ignoreCase: true }], + 'react/jsx-no-duplicate-props': ['error', { ignoreCase: true }], // Prevent usage of unwrapped JSX strings // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-no-literals.md @@ -114,7 +114,7 @@ module.exports = { // Prevent usage of dangerous JSX properties // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/no-danger.md - 'react/no-danger': 'off', + 'react/no-danger': 'warn', // Prevent usage of deprecated methods // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/no-deprecated.md @@ -250,13 +250,11 @@ module.exports = { // Prevent problem with children and props.dangerouslySetInnerHTML // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/no-danger-with-children.md - // TODO: enable, semver-major - 'react/no-danger-with-children': 'off', + 'react/no-danger-with-children': 'error', // Prevent unused propType definitions // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/no-unused-prop-types.md - // TODO: enable - 'react/no-unused-prop-types': ['off', { + 'react/no-unused-prop-types': ['error', { customValidators: [ ], skipShapeProps: false, @@ -264,8 +262,7 @@ module.exports = { // Require style prop value be an object or var // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/style-prop-object.md - // TODO: enable - 'react/style-prop-object': 'off', + 'react/style-prop-object': 'error', }, settings: { From ccd18f8b40e1718b5e75d6702ecbc2ab82d28455 Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Tue, 6 Sep 2016 23:08:36 -0700 Subject: [PATCH 047/826] [guide] Update declarations section to prefer expressions. Fixes #1008. --- README.md | 10 +++++++--- packages/eslint-config-airbnb-base/rules/style.js | 4 +++- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index be7bb4e3b4..2df5294457 100644 --- a/README.md +++ b/README.md @@ -554,18 +554,22 @@ Other Style Guides ## Functions - - [7.1](#functions--declarations) Use function declarations instead of function expressions. 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: [`requireFunctionDeclarations`](http://jscs.info/rule/requireFunctionDeclarations) - > Why? Function declarations are named, so they're easier to identify in call stacks. Also, the whole body of a function declaration is hoisted, whereas only the reference of a function expression is hoisted. This rule makes it possible to always use [Arrow Functions](#arrow-functions) in place of function expressions. ([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. ```javascript // bad const foo = function () { }; - // good + // bad function foo() { } + + // good + const foo = function bar() { + }; ``` diff --git a/packages/eslint-config-airbnb-base/rules/style.js b/packages/eslint-config-airbnb-base/rules/style.js index c46e510a8c..243d3141d0 100644 --- a/packages/eslint-config-airbnb-base/rules/style.js +++ b/packages/eslint-config-airbnb-base/rules/style.js @@ -36,7 +36,9 @@ module.exports = { 'func-names': 'warn', // enforces use of function declarations or expressions - 'func-style': 'off', + // http://eslint.org/docs/rules/func-style + // TODO: enable + 'func-style': ['off', 'expression'], // Blacklist certain identifiers to prevent them being used // http://eslint.org/docs/rules/id-blacklist From f769e35018021e2f2ee82fbb0c79290ba1c43d77 Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Thu, 8 Sep 2016 00:19:10 -0700 Subject: [PATCH 048/826] [eslint config] v11.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 bb88fb3659..f6ff29b070 100644 --- a/packages/eslint-config-airbnb/CHANGELOG.md +++ b/packages/eslint-config-airbnb/CHANGELOG.md @@ -1,3 +1,11 @@ +11.0.0 / 2016-09-08 +================== +- [breaking] enable `react` rules: `react/no-danger-with-children`, `react/no-unused-prop-types`, `react/style-prop-object`, `react/forbid-prop-types`, `react/jsx-no-duplicate-props`; set `react/no-danger` to “warn” +- [breaking] enable `jsx-a11y` rules: `jsx-a11y/anchor-has-content`, `jsx-a11y/tabindex-no-positive`, `jsx-a11y/no-static-element-interactions` +- [deps] update `eslint`, `eslint-plugin-react`, `eslint-config-airbnb-base`, `eslint-find-rules`, `eslint-plugin-import`, `eslint-plugin-jsx-a11y` +- [patch] set `ignoreCase` to `true` in disabled rules. +- [docs] use “#” in example command rather than version numbers (#984) + 10.0.1 / 2016-08-12 ================== - [deps] update `eslint`, `eslint-find-rules`, `eslint-plugin-jsx-a11y`, `eslint-plugin-import`, `eslint-config-airbnb-base` diff --git a/packages/eslint-config-airbnb/package.json b/packages/eslint-config-airbnb/package.json index 1ec47d7284..7b2cb1da50 100644 --- a/packages/eslint-config-airbnb/package.json +++ b/packages/eslint-config-airbnb/package.json @@ -1,6 +1,6 @@ { "name": "eslint-config-airbnb", - "version": "10.0.1", + "version": "11.0.0", "description": "Airbnb's ESLint config, following our styleguide", "main": "index.js", "scripts": { From e6782493f378b6f3065354e82551deb42d570697 Mon Sep 17 00:00:00 2001 From: Joe Lencioni Date: Thu, 8 Sep 2016 08:09:17 -0700 Subject: [PATCH 049/826] Update ECMAScript 6 heading to match TOC I plan to add some information to this section that applies to ES6 and everything following ES6. Since we already list this as ES6+ in the table of contents, I figured it would be a good idea to make this match. I preserved the anchor to avoid breaking links for folks. --- README.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 2df5294457..4f95692531 100644 --- a/README.md +++ b/README.md @@ -41,7 +41,7 @@ Other Style Guides 1. [Events](#events) 1. [jQuery](#jquery) 1. [ECMAScript 5 Compatibility](#ecmascript-5-compatibility) - 1. [ECMAScript 6+ (ES 2015+) Styles](#ecmascript-6-styles) + 1. [ECMAScript 6+ (ES 2015+) Styles](#ecmascript-6-es-2015-styles) 1. [Testing](#testing) 1. [Performance](#performance) 1. [Resources](#resources) @@ -2752,7 +2752,8 @@ Other Style Guides **[⬆ back to top](#table-of-contents)** -## ECMAScript 6 Styles + +## ECMAScript 6+ (ES 2015+) Styles - [27.1](#es6-styles) This is a collection of links to the various ES6 features. From 68b7aeb6dd7839f3556c612695e65a60e01ca1e7 Mon Sep 17 00:00:00 2001 From: Joe Lencioni Date: Thu, 8 Sep 2016 08:18:43 -0700 Subject: [PATCH 050/826] Add rule about TC39 proposals that haven't reached stage 3 There has been some confusion around which language features should be used and which should not be used yet. We have a pretty clear-cut rule at Airbnb about this, which is do not use any TC39 proposals that have not reached stage 3. I considered putting this at the very top of the document, but I spotted this section that seemed to fit. Addresses #1057 --- README.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/README.md b/README.md index 4f95692531..358c38be8f 100644 --- a/README.md +++ b/README.md @@ -2772,6 +2772,11 @@ Other Style Guides 1. [Iterators and Generators](#iterators-and-generators) 1. [Modules](#modules) + + - [27.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. + **[⬆ back to top](#table-of-contents)** ## Testing From 25123199dcd9bc7ffcdb6662c54d24f8f547916e Mon Sep 17 00:00:00 2001 From: Joe Lencioni Date: Thu, 8 Sep 2016 08:29:10 -0700 Subject: [PATCH 051/826] Add JavaScript Air to list of Podcasts It probably wouldn't be a bad idea for us to make a full pass on updating the resources section, but I noticed the podcasts portion was missing JS Air. --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 358c38be8f..acaff602ae 100644 --- a/README.md +++ b/README.md @@ -2893,6 +2893,7 @@ Other Style Guides **Podcasts** + - [JavaScript Air](https://javascriptair.com/) - [JavaScript Jabber](https://devchat.tv/js-jabber/) From 7d46d3c59fed7c959f20624412f0cc0e75087b0c Mon Sep 17 00:00:00 2001 From: Jordan Eldredge Date: Fri, 2 Sep 2016 22:08:25 -0700 Subject: [PATCH 052/826] Document react/require-render-return as a fully fledged rule Now that the pull request has been merged, we can reference the actual rule. --- react/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/react/README.md b/react/README.md index 32e4be48ab..c110e62c32 100644 --- a/react/README.md +++ b/react/README.md @@ -472,7 +472,7 @@ } ``` - - Be sure to return a value in your `render` methods. eslint: [`require-render-return`](https://github.com/yannickcr/eslint-plugin-react/pull/502) + - Be sure to return a value in your `render` methods. eslint: [`react/require-render-return`](https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/require-render-return.md) ```jsx // bad From ff69c8cb35a7adcb349ba35783b24b28b7917f11 Mon Sep 17 00:00:00 2001 From: Joe Lencioni Date: Thu, 8 Sep 2016 08:39:18 -0700 Subject: [PATCH 053/826] Prefer https over http I checked all of the links in the JS style guide document and converted as many as I could to use https. --- README.md | 48 ++++++++++++++++++++++++------------------------ 1 file changed, 24 insertions(+), 24 deletions(-) diff --git a/README.md b/README.md index acaff602ae..0f603dbaf0 100644 --- a/README.md +++ b/README.md @@ -1635,7 +1635,7 @@ Other Style Guides ``` - - [15.4](#comparison--moreinfo) For more information see [Truth Equality and JavaScript](http://javascriptweblog.wordpress.com/2011/02/07/truth-equality-and-javascript/#more-2108) by Angus Croll. + - [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`). @@ -2320,7 +2320,7 @@ Other Style Guides }()); ``` - [Read more](http://stackoverflow.com/questions/7365172/semicolon-before-self-invoking-function/7365214%237365214). + [Read more](https://stackoverflow.com/questions/7365172/semicolon-before-self-invoking-function/7365214%237365214). **[⬆ back to top](#table-of-contents)** @@ -2372,7 +2372,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](http://jsperf.com/coercion-vs-casting/3), leave a comment explaining why and what you're doing. + - [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. ```javascript // good @@ -2385,7 +2385,7 @@ Other Style Guides ``` - - [21.5](#coercion--bitwise) **Note:** Be careful when using bitshift operations. Numbers are represented as [64-bit values](http://es5.github.io/#x4.3.19), but bitshift operations always return a 32-bit integer ([source](http://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: + - [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 @@ -2748,7 +2748,7 @@ Other Style Guides ## ECMAScript 5 Compatibility - - [26.1](#es5-compat--kangax) Refer to [Kangax](https://twitter.com/kangax/)'s ES5 [compatibility table](http://kangax.github.io/es5-compat-table/). + - [26.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)** @@ -2804,13 +2804,13 @@ Other Style Guides ## Performance - - [On Layout & Web Performance](http://www.kellegous.com/j/2013/01/26/layout-performance/) - - [String vs Array Concat](http://jsperf.com/string-vs-array-concat/2) - - [Try/Catch Cost In a Loop](http://jsperf.com/try-catch-in-loop-cost) - - [Bang Function](http://jsperf.com/bang-function) - - [jQuery Find vs Context, Selector](http://jsperf.com/jquery-find-vs-context-sel/13) - - [innerHTML vs textContent for script text](http://jsperf.com/innerhtml-vs-textcontent-for-script-text) - - [Long String Concatenation](http://jsperf.com/ya-string-concat) + - [On Layout & Web Performance](https://www.kellegous.com/j/2013/01/26/layout-performance/) + - [String vs Array Concat](https://jsperf.com/string-vs-array-concat/2) + - [Try/Catch Cost In a Loop](https://jsperf.com/try-catch-in-loop-cost) + - [Bang Function](https://jsperf.com/bang-function) + - [jQuery Find vs Context, Selector](https://jsperf.com/jquery-find-vs-context-sel/13) + - [innerHTML vs textContent for script text](https://jsperf.com/innerhtml-vs-textcontent-for-script-text) + - [Long String Concatenation](https://jsperf.com/ya-string-concat) - [Are Javascript functions like `map()`, `reduce()`, and `filter()` optimized for traversing arrays?](https://www.quora.com/JavaScript-programming-language-Are-Javascript-functions-like-map-reduce-and-filter-already-optimized-for-traversing-array/answer/Quildreen-Motta) - Loading... @@ -2840,7 +2840,7 @@ Other Style Guides **Other Style Guides** - [Google JavaScript Style Guide](https://google.github.io/styleguide/javascriptguide.xml) - - [jQuery Core Style Guidelines](http://contribute.jquery.org/style-guide/js/) + - [jQuery Core Style Guidelines](https://contribute.jquery.org/style-guide/js/) - [Principles of Writing Consistent, Idiomatic JavaScript](https://github.com/rwaldron/idiomatic.js) **Other Styles** @@ -2852,7 +2852,7 @@ Other Style Guides **Further Reading** - - [Understanding JavaScript Closures](http://javascriptweblog.wordpress.com/2010/10/25/understanding-javascript-closures/) - Angus Croll + - [Understanding JavaScript Closures](https://javascriptweblog.wordpress.com/2010/10/25/understanding-javascript-closures/) - Angus Croll - [Basic JavaScript for the impatient programmer](http://www.2ality.com/2013/06/basic-javascript.html) - Dr. Axel Rauschmayer - [You Might Not Need jQuery](http://youmightnotneedjquery.com/) - Zack Bloom & Adam Schwartz - [ES6 Features](https://github.com/lukehoban/es6features) - Luke Hoban @@ -2860,15 +2860,15 @@ Other Style Guides **Books** - - [JavaScript: The Good Parts](http://www.amazon.com/JavaScript-Good-Parts-Douglas-Crockford/dp/0596517742) - Douglas Crockford - - [JavaScript Patterns](http://www.amazon.com/JavaScript-Patterns-Stoyan-Stefanov/dp/0596806752) - Stoyan Stefanov - - [Pro JavaScript Design Patterns](http://www.amazon.com/JavaScript-Design-Patterns-Recipes-Problem-Solution/dp/159059908X) - Ross Harmes and Dustin Diaz - - [High Performance Web Sites: Essential Knowledge for Front-End Engineers](http://www.amazon.com/High-Performance-Web-Sites-Essential/dp/0596529309) - Steve Souders - - [Maintainable JavaScript](http://www.amazon.com/Maintainable-JavaScript-Nicholas-C-Zakas/dp/1449327680) - Nicholas C. Zakas - - [JavaScript Web Applications](http://www.amazon.com/JavaScript-Web-Applications-Alex-MacCaw/dp/144930351X) - Alex MacCaw - - [Pro JavaScript Techniques](http://www.amazon.com/Pro-JavaScript-Techniques-John-Resig/dp/1590597273) - John Resig - - [Smashing Node.js: JavaScript Everywhere](http://www.amazon.com/Smashing-Node-js-JavaScript-Everywhere-Magazine/dp/1119962595) - Guillermo Rauch - - [Secrets of the JavaScript Ninja](http://www.amazon.com/Secrets-JavaScript-Ninja-John-Resig/dp/193398869X) - John Resig and Bear Bibeault + - [JavaScript: The Good Parts](https://www.amazon.com/JavaScript-Good-Parts-Douglas-Crockford/dp/0596517742) - Douglas Crockford + - [JavaScript Patterns](https://www.amazon.com/JavaScript-Patterns-Stoyan-Stefanov/dp/0596806752) - Stoyan Stefanov + - [Pro JavaScript Design Patterns](https://www.amazon.com/JavaScript-Design-Patterns-Recipes-Problem-Solution/dp/159059908X) - Ross Harmes and Dustin Diaz + - [High Performance Web Sites: Essential Knowledge for Front-End Engineers](https://www.amazon.com/High-Performance-Web-Sites-Essential/dp/0596529309) - Steve Souders + - [Maintainable JavaScript](https://www.amazon.com/Maintainable-JavaScript-Nicholas-C-Zakas/dp/1449327680) - Nicholas C. Zakas + - [JavaScript Web Applications](https://www.amazon.com/JavaScript-Web-Applications-Alex-MacCaw/dp/144930351X) - Alex MacCaw + - [Pro JavaScript Techniques](https://www.amazon.com/Pro-JavaScript-Techniques-John-Resig/dp/1590597273) - John Resig + - [Smashing Node.js: JavaScript Everywhere](https://www.amazon.com/Smashing-Node-js-JavaScript-Everywhere-Magazine/dp/1119962595) - Guillermo Rauch + - [Secrets of the JavaScript Ninja](https://www.amazon.com/Secrets-JavaScript-Ninja-John-Resig/dp/193398869X) - John Resig and Bear Bibeault - [Human JavaScript](http://humanjavascript.com/) - Henrik Joreteg - [Superhero.js](http://superherojs.com/) - Kim Joar Bekkelund, Mads Mobæk, & Olav Bjorkoy - [JSBooks](http://jsbooks.revolunet.com/) - Julien Bouquillon @@ -2881,7 +2881,7 @@ Other Style Guides - [DailyJS](http://dailyjs.com/) - [JavaScript Weekly](http://javascriptweekly.com/) - - [JavaScript, JavaScript...](http://javascriptweblog.wordpress.com/) + - [JavaScript, JavaScript...](https://javascriptweblog.wordpress.com/) - [Bocoup Weblog](https://bocoup.com/weblog) - [Adequately Good](http://www.adequatelygood.com/) - [NCZOnline](https://www.nczonline.net/) From 7412641af9964d3c8ac3e8adf3fb48af6b88be27 Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Sat, 10 Sep 2016 14:28:26 -0700 Subject: [PATCH 054/826] [eslint config] [base] [deps] update to `eslint` `v3.5.0`. --- packages/eslint-config-airbnb-base/legacy.js | 3 ++- packages/eslint-config-airbnb-base/package.json | 4 ++-- packages/eslint-config-airbnb-base/rules/es6.js | 16 ++++++++++++++-- .../eslint-config-airbnb-base/rules/node.js | 9 +++++++++ .../eslint-config-airbnb-base/rules/style.js | 17 +++++++++++++++++ 5 files changed, 44 insertions(+), 5 deletions(-) diff --git a/packages/eslint-config-airbnb-base/legacy.js b/packages/eslint-config-airbnb-base/legacy.js index 9acfb1cb4e..3de97acd21 100644 --- a/packages/eslint-config-airbnb-base/legacy.js +++ b/packages/eslint-config-airbnb-base/legacy.js @@ -16,6 +16,7 @@ module.exports = { ecmaFeatures: {}, globals: {}, rules: { - 'comma-dangle': ['error', 'never'] + 'comma-dangle': ['error', 'never'], + 'prefer-numeric-literals': 'off', } }; diff --git a/packages/eslint-config-airbnb-base/package.json b/packages/eslint-config-airbnb-base/package.json index b935962690..f2a786b89c 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.0.0", "babel-tape-runner": "^2.0.1", - "eslint": "^3.4.0", + "eslint": "^3.5.0", "eslint-find-rules": "^1.13.1", "eslint-plugin-import": "^1.14.0", "in-publish": "^2.0.0", @@ -55,7 +55,7 @@ "tape": "^4.6.0" }, "peerDependencies": { - "eslint": "^3.4.0", + "eslint": "^3.5.0", "eslint-plugin-import": "^1.14.0" }, "engines": { diff --git a/packages/eslint-config-airbnb-base/rules/es6.js b/packages/eslint-config-airbnb-base/rules/es6.js index f1e2bd026f..11433ca3dd 100644 --- a/packages/eslint-config-airbnb-base/rules/es6.js +++ b/packages/eslint-config-airbnb-base/rules/es6.js @@ -14,10 +14,17 @@ module.exports = { rules: { // enforces no braces where they can be omitted // http://eslint.org/docs/rules/arrow-body-style - 'arrow-body-style': ['error', 'as-needed'], + // TODO: enable requireReturnForObjectLiteral? + 'arrow-body-style': ['error', 'as-needed', { + requireReturnForObjectLiteral: false, + }], // require parens in arrow function arguments - 'arrow-parens': 'off', + // http://eslint.org/docs/rules/arrow-parens + // TODO: enable, semver-minor + 'arrow-parens': ['off', 'as-needed', { + requireForBlockBody: true, + }], // require space before/after arrow function's arrow // http://eslint.org/docs/rules/arrow-spacing @@ -101,6 +108,11 @@ module.exports = { ignoreReadBeforeAssign: true, }], + // disallow parseInt() in favor of binary, octal, and hexadecimal literals + // http://eslint.org/docs/rules/prefer-numeric-literals + // TODO: enable, semver-major + 'prefer-numeric-literals': 'off', + // suggest using Reflect methods where applicable // http://eslint.org/docs/rules/prefer-reflect // TODO: enable? diff --git a/packages/eslint-config-airbnb-base/rules/node.js b/packages/eslint-config-airbnb-base/rules/node.js index e4a71a6a5a..28c37127ab 100644 --- a/packages/eslint-config-airbnb-base/rules/node.js +++ b/packages/eslint-config-airbnb-base/rules/node.js @@ -33,6 +33,15 @@ module.exports = { // restrict usage of specified node modules 'no-restricted-modules': 'off', + // disallow certain object properties + // http://eslint.org/docs/rules/no-restricted-properties + // TODO: enable, semver-major + 'no-restricted-properties': ['off', { + object: 'arguments', + property: 'callee', + message: 'arguments.callee is deprecated,' + }], + // disallow use of synchronous methods (off by default) 'no-sync': 'off', } diff --git a/packages/eslint-config-airbnb-base/rules/style.js b/packages/eslint-config-airbnb-base/rules/style.js index 243d3141d0..764fef5465 100644 --- a/packages/eslint-config-airbnb-base/rules/style.js +++ b/packages/eslint-config-airbnb-base/rules/style.js @@ -73,6 +73,15 @@ module.exports = { } }], + // enforce position of line comments + // http://eslint.org/docs/rules/line-comment-position + // TODO: enable? + 'line-comment-position': ['off', { + position: 'above', + ignorePattern: '', + applyDefaultPatterns: true, + }], + // disallow mixed 'LF' and 'CRLF' as linebreaks // http://eslint.org/docs/rules/linebreak-style 'linebreak-style': ['error', 'unix'], @@ -80,6 +89,14 @@ module.exports = { // enforces empty lines around comments 'lines-around-comment': 'off', + // require or disallow newlines around directives + // http://eslint.org/docs/rules/lines-around-directive + // TODO: enable, semver-major + 'lines-around-directive': ['off', { + before: 'always', + after: 'always', + }], + // specify the maximum depth that blocks can be nested 'max-depth': ['off', 4], From 38f679e9f90b8d9699477f4dc4c2914691b5f247 Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Sat, 10 Sep 2016 14:29:35 -0700 Subject: [PATCH 055/826] [eslint config] [base] [patch] loosen `max-len` by ignoring strings Per https://github.com/eslint/eslint/pull/7049 / https://github.com/eslint/eslint/issues/5805 --- packages/eslint-config-airbnb-base/rules/style.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/packages/eslint-config-airbnb-base/rules/style.js b/packages/eslint-config-airbnb-base/rules/style.js index 764fef5465..181bd02ff5 100644 --- a/packages/eslint-config-airbnb-base/rules/style.js +++ b/packages/eslint-config-airbnb-base/rules/style.js @@ -104,7 +104,9 @@ module.exports = { // http://eslint.org/docs/rules/max-len 'max-len': ['error', 100, 2, { ignoreUrls: true, - ignoreComments: false + ignoreComments: false, + ignoreStrings: true, + ignoreTemplateLiterals: true, }], // specify the max number of lines in a file From dbdd56ccb5ee4a98394fa3d76467b12b93c01de4 Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Sat, 10 Sep 2016 14:35:57 -0700 Subject: [PATCH 056/826] [eslint config] [base] v7.0.1 --- packages/eslint-config-airbnb-base/CHANGELOG.md | 5 +++++ packages/eslint-config-airbnb-base/package.json | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/packages/eslint-config-airbnb-base/CHANGELOG.md b/packages/eslint-config-airbnb-base/CHANGELOG.md index 06075f3d70..240597feff 100644 --- a/packages/eslint-config-airbnb-base/CHANGELOG.md +++ b/packages/eslint-config-airbnb-base/CHANGELOG.md @@ -1,3 +1,8 @@ +7.0.1 / 2016-09-10 +================== + - [patch] loosen `max-len` by ignoring strings + - [deps] update to `eslint` `v3.5.0` + 7.0.0 / 2016-09-06 ================== - [breaking] Add no-plusplus in style.js and added explanation in README (#1012) diff --git a/packages/eslint-config-airbnb-base/package.json b/packages/eslint-config-airbnb-base/package.json index f2a786b89c..ff2c2908b8 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": "7.0.0", + "version": "7.0.1", "description": "Airbnb's base JS ESLint config, following our styleguide", "main": "index.js", "scripts": { From 6a72781121b2fd6709649d6d14b6a47ef0ad6042 Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Sat, 10 Sep 2016 14:47:01 -0700 Subject: [PATCH 057/826] [eslint config] [base] [minor] enable `arrow-parens` rule MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This will cause new failures for some, but only for those not following our style guide already - hence, it’s not semver-major. --- packages/eslint-config-airbnb-base/rules/es6.js | 3 +-- packages/eslint-config-airbnb-base/test/test-base.js | 6 +++--- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/packages/eslint-config-airbnb-base/rules/es6.js b/packages/eslint-config-airbnb-base/rules/es6.js index 11433ca3dd..efd5a15b33 100644 --- a/packages/eslint-config-airbnb-base/rules/es6.js +++ b/packages/eslint-config-airbnb-base/rules/es6.js @@ -21,8 +21,7 @@ module.exports = { // require parens in arrow function arguments // http://eslint.org/docs/rules/arrow-parens - // TODO: enable, semver-minor - 'arrow-parens': ['off', 'as-needed', { + 'arrow-parens': ['error', 'as-needed', { requireForBlockBody: true, }], diff --git a/packages/eslint-config-airbnb-base/test/test-base.js b/packages/eslint-config-airbnb-base/test/test-base.js index 8e7dc8cd2d..3d500bebfc 100644 --- a/packages/eslint-config-airbnb-base/test/test-base.js +++ b/packages/eslint-config-airbnb-base/test/test-base.js @@ -6,14 +6,14 @@ import index from '../'; const files = { index }; -fs.readdirSync(path.join(__dirname, '../rules')).forEach(name => { +fs.readdirSync(path.join(__dirname, '../rules')).forEach((name) => { files[name] = require(`../rules/${name}`); // eslint-disable-line global-require }); -Object.keys(files).forEach(name => { +Object.keys(files).forEach((name) => { const config = files[name]; - test(`${name}: does not reference react`, t => { + test(`${name}: does not reference react`, (t) => { t.plan(2); // scan plugins for react and fail if it is found From 715dea65985321154d0b6d3cc2a5b331ed1c0335 Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Sun, 11 Sep 2016 14:06:19 -0700 Subject: [PATCH 058/826] [eslint config] [base] v7.1.0 --- packages/eslint-config-airbnb-base/CHANGELOG.md | 4 ++++ packages/eslint-config-airbnb-base/package.json | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/packages/eslint-config-airbnb-base/CHANGELOG.md b/packages/eslint-config-airbnb-base/CHANGELOG.md index 240597feff..1bc559086a 100644 --- a/packages/eslint-config-airbnb-base/CHANGELOG.md +++ b/packages/eslint-config-airbnb-base/CHANGELOG.md @@ -1,3 +1,7 @@ +7.1.0 / 2016-09-11 +================== + - [minor] enable `arrow-parens` rule + 7.0.1 / 2016-09-10 ================== - [patch] loosen `max-len` by ignoring strings diff --git a/packages/eslint-config-airbnb-base/package.json b/packages/eslint-config-airbnb-base/package.json index ff2c2908b8..ab06ae72af 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": "7.0.1", + "version": "7.1.0", "description": "Airbnb's base JS ESLint config, following our styleguide", "main": "index.js", "scripts": { From 3fc37b3a26e5f7f0a6ab93c23c0a5157cdd06378 Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Sun, 11 Sep 2016 15:05:43 -0700 Subject: [PATCH 059/826] [eslint config] [deps] update `eslint-config-airbnb-base`, `eslint` --- packages/eslint-config-airbnb/package.json | 6 +++--- packages/eslint-config-airbnb/test/test-base.js | 6 +++--- packages/eslint-config-airbnb/test/test-react-order.js | 4 ++-- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/packages/eslint-config-airbnb/package.json b/packages/eslint-config-airbnb/package.json index 7b2cb1da50..e9bfb19382 100644 --- a/packages/eslint-config-airbnb/package.json +++ b/packages/eslint-config-airbnb/package.json @@ -45,12 +45,12 @@ }, "homepage": "https://github.com/airbnb/javascript", "dependencies": { - "eslint-config-airbnb-base": "^7.0.0" + "eslint-config-airbnb-base": "^7.1.0" }, "devDependencies": { "babel-preset-airbnb": "^2.0.0", "babel-tape-runner": "^2.0.1", - "eslint": "^3.4.0", + "eslint": "^3.5.0", "eslint-find-rules": "^1.13.1", "eslint-plugin-import": "^1.14.0", "eslint-plugin-jsx-a11y": "^2.2.1", @@ -61,7 +61,7 @@ "tape": "^4.6.0" }, "peerDependencies": { - "eslint": "^3.4.0", + "eslint": "^3.5.0", "eslint-plugin-jsx-a11y": "^2.2.1", "eslint-plugin-import": "^1.14.0", "eslint-plugin-react": "^6.2.0" diff --git a/packages/eslint-config-airbnb/test/test-base.js b/packages/eslint-config-airbnb/test/test-base.js index 9457e2ef42..6f7a55ab7c 100644 --- a/packages/eslint-config-airbnb/test/test-base.js +++ b/packages/eslint-config-airbnb/test/test-base.js @@ -6,7 +6,7 @@ const base = require('../base'); const files = { base }; -fs.readdirSync(path.join(__dirname, '../rules')).forEach(name => { +fs.readdirSync(path.join(__dirname, '../rules')).forEach((name) => { if (name === 'react.js' || name === 'react-a11y.js') { return; } @@ -14,10 +14,10 @@ fs.readdirSync(path.join(__dirname, '../rules')).forEach(name => { files[name] = require(`../rules/${name}`); // eslint-disable-line global-require }); -Object.keys(files).forEach(name => { +Object.keys(files).forEach((name) => { const config = files[name]; - test(`${name}: does not reference react`, t => { + test(`${name}: does not reference react`, (t) => { t.plan(2); // scan plugins for react and fail if it is found diff --git a/packages/eslint-config-airbnb/test/test-react-order.js b/packages/eslint-config-airbnb/test/test-react-order.js index aa8aa192eb..0257a40a92 100644 --- a/packages/eslint-config-airbnb/test/test-react-order.js +++ b/packages/eslint-config-airbnb/test/test-react-order.js @@ -57,7 +57,7 @@ test('validate react prop order', (t) => { t.deepEquals(result.messages, [], 'no messages in results'); }); - t.test('order: when random method is first', t => { + t.test('order: when random method is first', (t) => { t.plan(2); const result = lint(wrapComponent(` someMethod() {} @@ -74,7 +74,7 @@ test('validate react prop order', (t) => { t.equal(result.messages[0].ruleId, 'react/sort-comp', 'fails due to sort'); }); - t.test('order: when random method after lifecycle methods', t => { + t.test('order: when random method after lifecycle methods', (t) => { t.plan(2); const result = lint(wrapComponent(` componentWillMount() {} From e59376f625a4278f53494074c1c905de296cd8aa Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Sun, 11 Sep 2016 15:51:58 -0700 Subject: [PATCH 060/826] [eslint config] v11.1.0 --- packages/eslint-config-airbnb/CHANGELOG.md | 4 ++++ packages/eslint-config-airbnb/package.json | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/packages/eslint-config-airbnb/CHANGELOG.md b/packages/eslint-config-airbnb/CHANGELOG.md index f6ff29b070..2ac3efbd8d 100644 --- a/packages/eslint-config-airbnb/CHANGELOG.md +++ b/packages/eslint-config-airbnb/CHANGELOG.md @@ -1,3 +1,7 @@ +11.1.0 / 2016-09-11 +================== +- [deps] update `eslint-config-airbnb-base`, `eslint` + 11.0.0 / 2016-09-08 ================== - [breaking] enable `react` rules: `react/no-danger-with-children`, `react/no-unused-prop-types`, `react/style-prop-object`, `react/forbid-prop-types`, `react/jsx-no-duplicate-props`; set `react/no-danger` to “warn” diff --git a/packages/eslint-config-airbnb/package.json b/packages/eslint-config-airbnb/package.json index e9bfb19382..d576e030f6 100644 --- a/packages/eslint-config-airbnb/package.json +++ b/packages/eslint-config-airbnb/package.json @@ -1,6 +1,6 @@ { "name": "eslint-config-airbnb", - "version": "11.0.0", + "version": "11.1.0", "description": "Airbnb's ESLint config, following our styleguide", "main": "index.js", "scripts": { From 7da28d43ad4b73264420663ebbfb83fdff2b9249 Mon Sep 17 00:00:00 2001 From: Guillaume Verbal Date: Mon, 12 Sep 2016 12:18:59 +0800 Subject: [PATCH 061/826] [Docs] update 8.3 to fix conflict with 6.2 (fixes #1058) --- README.md | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 0f603dbaf0..ce0de3fd3e 100644 --- a/README.md +++ b/README.md @@ -849,15 +849,18 @@ Other Style Guides ```js // bad - [1, 2, 3].map(number => 'As time went by, the string containing the ' + - `${number} became much longer. So we needed to break it over multiple ` + - 'lines.' + ['get', 'post', 'put'].map(number => Object.prototype.hasOwnProperty.call( + httpMagicObjectWithAVeryLongName, + httpMethod + ) ); // good - [1, 2, 3].map(number => ( - `As time went by, the string containing the ${number} became much ` + - 'longer. So we needed to break it over multiple lines.' + ['get', 'post', 'put'].map(number => ( + Object.prototype.hasOwnProperty.call( + httpMagicObjectWithAVeryLongName, + httpMethod + ) )); ``` From 2a28b9c82f04a05462cfef025b6c791538472232 Mon Sep 17 00:00:00 2001 From: Alexey Raspopov Date: Mon, 12 Sep 2016 10:06:15 +0300 Subject: [PATCH 062/826] move #variables--unary-increment-decrement to correct section --- README.md | 59 ++++++++++++++++++++++++++++--------------------------- 1 file changed, 30 insertions(+), 29 deletions(-) diff --git a/README.md b/README.md index ce0de3fd3e..0c99262f5a 100644 --- a/README.md +++ b/README.md @@ -1285,35 +1285,6 @@ Other Style Guides } ``` - - [13.5](#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. - - ```javascript - // bad - - let array = [1, 2, 3]; - let num = 1; - let increment = num ++; - let decrement = -- num; - - for(let i = 0; i < array.length; i++){ - let value = array[i]; - ++value; - } - - // good - - let array = [1, 2, 3]; - let num = 1; - let increment = num += 1; - let decrement = num -= 1; - - array.forEach((value) => { - value += 1; - }); - ``` - **[⬆ back to top](#table-of-contents)** @@ -1487,6 +1458,36 @@ Other Style Guides // the same applies for `const` ``` + + - [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. + + ```javascript + // bad + + let array = [1, 2, 3]; + let num = 1; + let increment = num ++; + let decrement = -- num; + + for(let i = 0; i < array.length; i++){ + let value = array[i]; + ++value; + } + + // good + + let array = [1, 2, 3]; + let num = 1; + let increment = num += 1; + let decrement = num -= 1; + + array.forEach((value) => { + value += 1; + }); + ``` + **[⬆ back to top](#table-of-contents)** From 6cdda0737e25b92cd0805a4490b20b7df3f9e8e5 Mon Sep 17 00:00:00 2001 From: Guillaume Verbal Date: Mon, 12 Sep 2016 19:08:10 +0800 Subject: [PATCH 063/826] [guide] Fix typo from #1058 --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 0c99262f5a..d1a0ab4af0 100644 --- a/README.md +++ b/README.md @@ -849,14 +849,14 @@ Other Style Guides ```js // bad - ['get', 'post', 'put'].map(number => Object.prototype.hasOwnProperty.call( + ['get', 'post', 'put'].map(httpMethod => Object.prototype.hasOwnProperty.call( httpMagicObjectWithAVeryLongName, httpMethod ) ); // good - ['get', 'post', 'put'].map(number => ( + ['get', 'post', 'put'].map(httpMethod => ( Object.prototype.hasOwnProperty.call( httpMagicObjectWithAVeryLongName, httpMethod From e9141f46308f3622ef7dd204e8c54f336db1011b Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Mon, 12 Sep 2016 11:02:12 -0700 Subject: [PATCH 064/826] [eslint config] [base] [patch] fix category of `no-restricted-properties` Per https://github.com/eslint/eslint/issues/7112 / https://github.com/eslint/eslint/issues/7118 --- .../eslint-config-airbnb-base/rules/best-practices.js | 9 +++++++++ packages/eslint-config-airbnb-base/rules/node.js | 9 --------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/packages/eslint-config-airbnb-base/rules/best-practices.js b/packages/eslint-config-airbnb-base/rules/best-practices.js index a41c1e252a..1da565f692 100644 --- a/packages/eslint-config-airbnb-base/rules/best-practices.js +++ b/packages/eslint-config-airbnb-base/rules/best-practices.js @@ -172,6 +172,15 @@ module.exports = { // disallow declaring the same variable more then once 'no-redeclare': 'error', + // disallow certain object properties + // http://eslint.org/docs/rules/no-restricted-properties + // TODO: enable, semver-major + 'no-restricted-properties': ['off', { + object: 'arguments', + property: 'callee', + message: 'arguments.callee is deprecated,' + }], + // disallow use of assignment in return statement 'no-return-assign': 'error', diff --git a/packages/eslint-config-airbnb-base/rules/node.js b/packages/eslint-config-airbnb-base/rules/node.js index 28c37127ab..e4a71a6a5a 100644 --- a/packages/eslint-config-airbnb-base/rules/node.js +++ b/packages/eslint-config-airbnb-base/rules/node.js @@ -33,15 +33,6 @@ module.exports = { // restrict usage of specified node modules 'no-restricted-modules': 'off', - // disallow certain object properties - // http://eslint.org/docs/rules/no-restricted-properties - // TODO: enable, semver-major - 'no-restricted-properties': ['off', { - object: 'arguments', - property: 'callee', - message: 'arguments.callee is deprecated,' - }], - // disallow use of synchronous methods (off by default) 'no-sync': 'off', } From bd5505b7273cd2c80815c880b3c7709c02ec73c0 Mon Sep 17 00:00:00 2001 From: Harrison Shoff Date: Thu, 25 Aug 2016 21:33:51 -0700 Subject: [PATCH 065/826] [commas] fix traling comma link --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index d1a0ab4af0..572efb257c 100644 --- a/README.md +++ b/README.md @@ -2255,7 +2255,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) - > 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](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. ```javascript // bad - git diff without trailing comma From 286b01c6759a8dea957db7e78517ba675cd1a8c1 Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Wed, 14 Sep 2016 12:54:45 -0700 Subject: [PATCH 066/826] [eslint config] [*] [deps] update `eslint-plugin-import` --- packages/eslint-config-airbnb-base/package.json | 4 ++-- packages/eslint-config-airbnb-base/rules/imports.js | 9 +++++++++ packages/eslint-config-airbnb/package.json | 4 ++-- 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/packages/eslint-config-airbnb-base/package.json b/packages/eslint-config-airbnb-base/package.json index ab06ae72af..3d8429df6f 100644 --- a/packages/eslint-config-airbnb-base/package.json +++ b/packages/eslint-config-airbnb-base/package.json @@ -49,14 +49,14 @@ "babel-tape-runner": "^2.0.1", "eslint": "^3.5.0", "eslint-find-rules": "^1.13.1", - "eslint-plugin-import": "^1.14.0", + "eslint-plugin-import": "^1.15.0", "in-publish": "^2.0.0", "safe-publish-latest": "^1.0.1", "tape": "^4.6.0" }, "peerDependencies": { "eslint": "^3.5.0", - "eslint-plugin-import": "^1.14.0" + "eslint-plugin-import": "^1.15.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 09f2397c70..1f5c67a749 100644 --- a/packages/eslint-config-airbnb-base/rules/imports.js +++ b/packages/eslint-config-airbnb-base/rules/imports.js @@ -129,5 +129,14 @@ module.exports = { // Restrict which files can be imported in a given folder // https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/no-restricted-paths.md 'import/no-restricted-paths': 'off', + + // Forbid modules to have too many dependencies + // https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/max-dependencies.md + 'import/max-dependencies': ['off', { max: 10 }], + + // Forbid import of modules using absolute paths + // https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/no-absolute-path.md + // TODO: enable, semver-major + 'import/no-absolute-path': ['off'], }, }; diff --git a/packages/eslint-config-airbnb/package.json b/packages/eslint-config-airbnb/package.json index d576e030f6..ed3cace477 100644 --- a/packages/eslint-config-airbnb/package.json +++ b/packages/eslint-config-airbnb/package.json @@ -52,7 +52,7 @@ "babel-tape-runner": "^2.0.1", "eslint": "^3.5.0", "eslint-find-rules": "^1.13.1", - "eslint-plugin-import": "^1.14.0", + "eslint-plugin-import": "^1.15.0", "eslint-plugin-jsx-a11y": "^2.2.1", "eslint-plugin-react": "^6.2.0", "in-publish": "^2.0.0", @@ -63,7 +63,7 @@ "peerDependencies": { "eslint": "^3.5.0", "eslint-plugin-jsx-a11y": "^2.2.1", - "eslint-plugin-import": "^1.14.0", + "eslint-plugin-import": "^1.15.0", "eslint-plugin-react": "^6.2.0" }, "engines": { From a2a35a8dbadc229c402b9752412d22ce5c42f33b Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Wed, 14 Sep 2016 12:55:24 -0700 Subject: [PATCH 067/826] [eslint config] [deps] update `eslint-plugin-jsx-a11y`, `eslint-plugin-react` --- 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 ed3cace477..aaa19aa068 100644 --- a/packages/eslint-config-airbnb/package.json +++ b/packages/eslint-config-airbnb/package.json @@ -53,8 +53,8 @@ "eslint": "^3.5.0", "eslint-find-rules": "^1.13.1", "eslint-plugin-import": "^1.15.0", - "eslint-plugin-jsx-a11y": "^2.2.1", - "eslint-plugin-react": "^6.2.0", + "eslint-plugin-jsx-a11y": "^2.2.2", + "eslint-plugin-react": "^6.2.1", "in-publish": "^2.0.0", "react": ">= 0.13.0", "safe-publish-latest": "^1.0.1", @@ -62,9 +62,9 @@ }, "peerDependencies": { "eslint": "^3.5.0", - "eslint-plugin-jsx-a11y": "^2.2.1", + "eslint-plugin-jsx-a11y": "^2.2.2", "eslint-plugin-import": "^1.15.0", - "eslint-plugin-react": "^6.2.0" + "eslint-plugin-react": "^6.2.1" }, "engines": { "node": ">= 4" From 11b9adff01597361f080588196a268e1d6f64d86 Mon Sep 17 00:00:00 2001 From: Kazuki Yamada Date: Fri, 16 Sep 2016 02:39:35 +0900 Subject: [PATCH 068/826] Fix japanese translation link --- react/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/react/README.md b/react/README.md index c110e62c32..d672e56b16 100644 --- a/react/README.md +++ b/react/README.md @@ -576,6 +576,6 @@ - ![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) - ![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) + - ![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) **[⬆ back to top](#table-of-contents)** From a86d546c618f596003a7c6dbe0ee3d6ca61fe120 Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Fri, 16 Sep 2016 16:12:06 -0700 Subject: [PATCH 069/826] [Docs] remove yet another wrapped-string "good" example --- README.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/README.md b/README.md index 572efb257c..5ede48ef97 100644 --- a/README.md +++ b/README.md @@ -878,8 +878,7 @@ Other Style Guides // good [1, 2, 3].map(number => ( - `A long string with the ${number}. It’s so long that we’ve broken it ` + - 'over multiple lines!' + `A long string with the ${number}. It’s so long that we don’t want it to take up space on the .map line!` )); // bad From a599bca47492035fa5b9fdd9d1ba23743877a44f Mon Sep 17 00:00:00 2001 From: Joe Lencioni Date: Mon, 19 Sep 2016 11:42:12 -0700 Subject: [PATCH 070/826] Add rule to avoid misusing DOM component prop names 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. --- react/README.md | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/react/README.md b/react/README.md index d672e56b16..9d4d9da3e3 100644 --- a/react/README.md +++ b/react/README.md @@ -127,6 +127,19 @@ return WithFoo; } ``` + + - **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. + + ```jsx + // bad + + + // good + + ``` + ## Declaration - Do not use `displayName` for naming components. Instead, name the component by reference. From 386a7b1d158f262f3c19f268d1bdb980098a9b0d Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Tue, 20 Sep 2016 00:03:08 -0700 Subject: [PATCH 071/826] [eslint config] [*] [deps] update `eslint-find-rules`, `safe-publish-latest` --- 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 3d8429df6f..37944d16b7 100644 --- a/packages/eslint-config-airbnb-base/package.json +++ b/packages/eslint-config-airbnb-base/package.json @@ -48,10 +48,10 @@ "babel-preset-airbnb": "^2.0.0", "babel-tape-runner": "^2.0.1", "eslint": "^3.5.0", - "eslint-find-rules": "^1.13.1", + "eslint-find-rules": "^1.13.2", "eslint-plugin-import": "^1.15.0", "in-publish": "^2.0.0", - "safe-publish-latest": "^1.0.1", + "safe-publish-latest": "^1.1.0", "tape": "^4.6.0" }, "peerDependencies": { diff --git a/packages/eslint-config-airbnb/package.json b/packages/eslint-config-airbnb/package.json index aaa19aa068..9d44748dc7 100644 --- a/packages/eslint-config-airbnb/package.json +++ b/packages/eslint-config-airbnb/package.json @@ -51,13 +51,13 @@ "babel-preset-airbnb": "^2.0.0", "babel-tape-runner": "^2.0.1", "eslint": "^3.5.0", - "eslint-find-rules": "^1.13.1", + "eslint-find-rules": "^1.13.2", "eslint-plugin-import": "^1.15.0", "eslint-plugin-jsx-a11y": "^2.2.2", "eslint-plugin-react": "^6.2.1", "in-publish": "^2.0.0", "react": ">= 0.13.0", - "safe-publish-latest": "^1.0.1", + "safe-publish-latest": "^1.1.0", "tape": "^4.6.0" }, "peerDependencies": { From 4c598664fbef7c16a5f1e3b648635b4c83d6527b Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Tue, 20 Sep 2016 00:13:37 -0700 Subject: [PATCH 072/826] [eslint config] [deps] update `eslint-plugin-react` --- packages/eslint-config-airbnb/package.json | 4 ++-- packages/eslint-config-airbnb/rules/react.js | 10 ++++++++++ 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/packages/eslint-config-airbnb/package.json b/packages/eslint-config-airbnb/package.json index 9d44748dc7..a69217c450 100644 --- a/packages/eslint-config-airbnb/package.json +++ b/packages/eslint-config-airbnb/package.json @@ -54,7 +54,7 @@ "eslint-find-rules": "^1.13.2", "eslint-plugin-import": "^1.15.0", "eslint-plugin-jsx-a11y": "^2.2.2", - "eslint-plugin-react": "^6.2.1", + "eslint-plugin-react": "^6.3.0", "in-publish": "^2.0.0", "react": ">= 0.13.0", "safe-publish-latest": "^1.1.0", @@ -64,7 +64,7 @@ "eslint": "^3.5.0", "eslint-plugin-jsx-a11y": "^2.2.2", "eslint-plugin-import": "^1.15.0", - "eslint-plugin-react": "^6.2.1" + "eslint-plugin-react": "^6.3.0" }, "engines": { "node": ">= 4" diff --git a/packages/eslint-config-airbnb/rules/react.js b/packages/eslint-config-airbnb/rules/react.js index 9c0a13eb8f..e8ead07943 100644 --- a/packages/eslint-config-airbnb/rules/react.js +++ b/packages/eslint-config-airbnb/rules/react.js @@ -263,6 +263,16 @@ module.exports = { // Require style prop value be an object or var // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/style-prop-object.md 'react/style-prop-object': 'error', + + // Prevent invalid characters from appearing in markup + // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/no-unescaped-entities.md + // TODO: enable, semver-major + 'react/no-unescaped-entities': 'off', + + // Prevent passing of children as props + // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/no-children-prop.md + // TODO: enable, semver-major + 'react/no-children-prop': 'off' }, settings: { From e5f4eb57b4733d0b338f120842e719f6df51c035 Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Fri, 23 Sep 2016 15:29:36 -0700 Subject: [PATCH 073/826] [eslint config] [*] [deps] update `eslint-plugin-import`, `eslint` to 3.6 --- packages/eslint-config-airbnb-base/package.json | 8 ++++---- .../eslint-config-airbnb-base/rules/best-practices.js | 10 +++++++++- packages/eslint-config-airbnb-base/rules/imports.js | 11 +++++++++++ packages/eslint-config-airbnb-base/rules/style.js | 2 +- packages/eslint-config-airbnb/package.json | 8 ++++---- 5 files changed, 29 insertions(+), 10 deletions(-) diff --git a/packages/eslint-config-airbnb-base/package.json b/packages/eslint-config-airbnb-base/package.json index 37944d16b7..c4ba9ead0e 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.0.0", "babel-tape-runner": "^2.0.1", - "eslint": "^3.5.0", + "eslint": "^3.6.0", "eslint-find-rules": "^1.13.2", - "eslint-plugin-import": "^1.15.0", + "eslint-plugin-import": "^1.16.0", "in-publish": "^2.0.0", "safe-publish-latest": "^1.1.0", "tape": "^4.6.0" }, "peerDependencies": { - "eslint": "^3.5.0", - "eslint-plugin-import": "^1.15.0" + "eslint": "^3.6.0", + "eslint-plugin-import": "^1.16.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 1da565f692..d8d10b3398 100644 --- a/packages/eslint-config-airbnb-base/rules/best-practices.js +++ b/packages/eslint-config-airbnb-base/rules/best-practices.js @@ -15,7 +15,9 @@ module.exports = { // enforce that class methods use "this" // http://eslint.org/docs/rules/class-methods-use-this - 'class-methods-use-this': 'error', + 'class-methods-use-this': ['error', { + exceptMethods: [], + }], // require return statements to either always or never specify values 'consistent-return': 'error', @@ -179,6 +181,12 @@ module.exports = { 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.', }], // disallow use of assignment in return statement diff --git a/packages/eslint-config-airbnb-base/rules/imports.js b/packages/eslint-config-airbnb-base/rules/imports.js index 1f5c67a749..b7065dd3bd 100644 --- a/packages/eslint-config-airbnb-base/rules/imports.js +++ b/packages/eslint-config-airbnb-base/rules/imports.js @@ -138,5 +138,16 @@ module.exports = { // https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/no-absolute-path.md // TODO: enable, semver-major 'import/no-absolute-path': ['off'], + + // Forbid require() calls with expressions + // https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/no-dynamic-require.md + // TODO: enable, semver-major + 'import/no-dynamic-require': ['off'], + + // prevent importing the submodules of other modules + // https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/no-internal-modules.md + 'import/no-internal-modules': ['off', { + allow: [], + }], }, }; diff --git a/packages/eslint-config-airbnb-base/rules/style.js b/packages/eslint-config-airbnb-base/rules/style.js index 181bd02ff5..4349e1352b 100644 --- a/packages/eslint-config-airbnb-base/rules/style.js +++ b/packages/eslint-config-airbnb-base/rules/style.js @@ -26,7 +26,7 @@ module.exports = { 'consistent-this': 'off', // enforce newline at the end of file, with no multiple empty lines - 'eol-last': 'error', + 'eol-last': ['error', 'always'], // enforce spacing between functions and their invocations // http://eslint.org/docs/rules/func-call-spacing diff --git a/packages/eslint-config-airbnb/package.json b/packages/eslint-config-airbnb/package.json index a69217c450..e320fdf0d4 100644 --- a/packages/eslint-config-airbnb/package.json +++ b/packages/eslint-config-airbnb/package.json @@ -50,9 +50,9 @@ "devDependencies": { "babel-preset-airbnb": "^2.0.0", "babel-tape-runner": "^2.0.1", - "eslint": "^3.5.0", + "eslint": "^3.6.0", "eslint-find-rules": "^1.13.2", - "eslint-plugin-import": "^1.15.0", + "eslint-plugin-import": "^1.16.0", "eslint-plugin-jsx-a11y": "^2.2.2", "eslint-plugin-react": "^6.3.0", "in-publish": "^2.0.0", @@ -61,9 +61,9 @@ "tape": "^4.6.0" }, "peerDependencies": { - "eslint": "^3.5.0", + "eslint": "^3.6.0", "eslint-plugin-jsx-a11y": "^2.2.2", - "eslint-plugin-import": "^1.15.0", + "eslint-plugin-import": "^1.16.0", "eslint-plugin-react": "^6.3.0" }, "engines": { From e8b51b278520142b5d025fd2df993d4e25d46434 Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Wed, 21 Sep 2016 17:17:27 -0700 Subject: [PATCH 074/826] [eslint config] [*] [new] set `ecmaVersion` to 2017; enable object rest/spread; update `babel-preset-airbnb` --- README.md | 20 +++++++++++++++++++ packages/eslint-config-airbnb-base/.eslintrc | 2 +- packages/eslint-config-airbnb-base/index.js | 7 +++++-- .../eslint-config-airbnb-base/package.json | 2 +- .../rules/best-practices.js | 4 ++++ .../eslint-config-airbnb-base/test/.eslintrc | 3 +-- .../test/test-base.js | 6 ++++-- packages/eslint-config-airbnb/package.json | 2 +- 8 files changed, 37 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index 5ede48ef97..705f44d582 100644 --- a/README.md +++ b/README.md @@ -293,6 +293,26 @@ Other Style Guides console.log(has.call(object, key)); ``` + + - [3.10](#objects--rest-spread) Prefer the object spread operator over `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 + + // 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 } + + const { a, ...noA } = copy; // noA => { b: 2, c: 3 } + ``` + **[⬆ back to top](#table-of-contents)** ## Arrays diff --git a/packages/eslint-config-airbnb-base/.eslintrc b/packages/eslint-config-airbnb-base/.eslintrc index 6c8556be3b..224149fda6 100644 --- a/packages/eslint-config-airbnb-base/.eslintrc +++ b/packages/eslint-config-airbnb-base/.eslintrc @@ -4,5 +4,5 @@ // disable requiring trailing commas because it might be nice to revert to // being JSON at some point, and I don't want to make big changes now. "comma-dangle": 0 - } + }, } diff --git a/packages/eslint-config-airbnb-base/index.js b/packages/eslint-config-airbnb-base/index.js index cc13673700..4de657b075 100644 --- a/packages/eslint-config-airbnb-base/index.js +++ b/packages/eslint-config-airbnb-base/index.js @@ -9,10 +9,13 @@ module.exports = { './rules/imports', ].map(require.resolve), parserOptions: { - ecmaVersion: 2016, + ecmaVersion: 2017, sourceType: 'module', + ecmaFeatures: { + experimentalObjectRestSpread: true, + }, }, rules: { strict: 'error', - } + }, }; diff --git a/packages/eslint-config-airbnb-base/package.json b/packages/eslint-config-airbnb-base/package.json index c4ba9ead0e..6c6302050b 100644 --- a/packages/eslint-config-airbnb-base/package.json +++ b/packages/eslint-config-airbnb-base/package.json @@ -45,7 +45,7 @@ }, "homepage": "https://github.com/airbnb/javascript", "devDependencies": { - "babel-preset-airbnb": "^2.0.0", + "babel-preset-airbnb": "^2.1.0", "babel-tape-runner": "^2.0.1", "eslint": "^3.6.0", "eslint-find-rules": "^1.13.2", diff --git a/packages/eslint-config-airbnb-base/rules/best-practices.js b/packages/eslint-config-airbnb-base/rules/best-practices.js index d8d10b3398..46fefab83f 100644 --- a/packages/eslint-config-airbnb-base/rules/best-practices.js +++ b/packages/eslint-config-airbnb-base/rules/best-practices.js @@ -187,6 +187,10 @@ module.exports = { }, { property: '__defineSetter__', message: 'Please use Object.defineProperty instead.', + }, { + object: 'Object', + property: 'assign', + message: 'Please use the object spread operator (...) instead.', }], // disallow use of assignment in return statement diff --git a/packages/eslint-config-airbnb-base/test/.eslintrc b/packages/eslint-config-airbnb-base/test/.eslintrc index 7e22f26a09..02ab3c48bb 100644 --- a/packages/eslint-config-airbnb-base/test/.eslintrc +++ b/packages/eslint-config-airbnb-base/test/.eslintrc @@ -1,7 +1,6 @@ { "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"]}], diff --git a/packages/eslint-config-airbnb-base/test/test-base.js b/packages/eslint-config-airbnb-base/test/test-base.js index 3d500bebfc..7544a0639c 100644 --- a/packages/eslint-config-airbnb-base/test/test-base.js +++ b/packages/eslint-config-airbnb-base/test/test-base.js @@ -4,13 +4,15 @@ import test from 'tape'; import index from '../'; -const files = { index }; +const files = { ...{ index } }; // object spread is to test parsing fs.readdirSync(path.join(__dirname, '../rules')).forEach((name) => { files[name] = require(`../rules/${name}`); // eslint-disable-line global-require }); -Object.keys(files).forEach((name) => { +Object.keys(files).forEach(( + name, // trailing function comma is to test parsing +) => { const config = files[name]; test(`${name}: does not reference react`, (t) => { diff --git a/packages/eslint-config-airbnb/package.json b/packages/eslint-config-airbnb/package.json index e320fdf0d4..a5ede6ffcb 100644 --- a/packages/eslint-config-airbnb/package.json +++ b/packages/eslint-config-airbnb/package.json @@ -48,7 +48,7 @@ "eslint-config-airbnb-base": "^7.1.0" }, "devDependencies": { - "babel-preset-airbnb": "^2.0.0", + "babel-preset-airbnb": "^2.1.0", "babel-tape-runner": "^2.0.1", "eslint": "^3.6.0", "eslint-find-rules": "^1.13.2", From ec2c4393d2b6accf832607082b3a7a5842347fa6 Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Fri, 23 Sep 2016 16:00:11 -0700 Subject: [PATCH 075/826] [eslint config] [base] v7.2.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 1bc559086a..1346a8b9ac 100644 --- a/packages/eslint-config-airbnb-base/CHANGELOG.md +++ b/packages/eslint-config-airbnb-base/CHANGELOG.md @@ -1,3 +1,9 @@ +7.2.0 / 2016-09-23 +================== + - [new] set `ecmaVersion` to 2017; enable object rest/spread; update `babel-preset-airbnb` + - [patch] fix category of `no-restricted-properties` + - [deps] update `eslint`, `eslint-plugin-import`, `eslint-find-rules`, `safe-publish-latest` + 7.1.0 / 2016-09-11 ================== - [minor] enable `arrow-parens` rule diff --git a/packages/eslint-config-airbnb-base/package.json b/packages/eslint-config-airbnb-base/package.json index 6c6302050b..528510914d 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": "7.1.0", + "version": "7.2.0", "description": "Airbnb's base JS ESLint config, following our styleguide", "main": "index.js", "scripts": { From 62cac3eea120dc0eb74a152e05004e0e962e9706 Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Fri, 23 Sep 2016 22:42:53 -0700 Subject: [PATCH 076/826] [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 a5ede6ffcb..c36188c4ea 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": "^7.1.0" + "eslint-config-airbnb-base": "^7.2.0" }, "devDependencies": { "babel-preset-airbnb": "^2.1.0", From 173cba3cc6987daf0d018633313ae277c290dcde Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Fri, 23 Sep 2016 22:45:47 -0700 Subject: [PATCH 077/826] [eslint config] v11.2.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 2ac3efbd8d..2f4f803406 100644 --- a/packages/eslint-config-airbnb/CHANGELOG.md +++ b/packages/eslint-config-airbnb/CHANGELOG.md @@ -1,3 +1,8 @@ +11.2.0 / 2016-09-23 +================== +- [new] set `ecmaVersion` to 2017; enable object rest/spread; update `babel-preset-airbnb` +- [deps] update `eslint`, `eslint-config-airbnb-base`, `eslint-plugin-import`, `eslint-plugin-jsx-a11y`, `eslint-plugin-react`, `eslint-find-rules`, `safe-publish-latest` + 11.1.0 / 2016-09-11 ================== - [deps] update `eslint-config-airbnb-base`, `eslint` diff --git a/packages/eslint-config-airbnb/package.json b/packages/eslint-config-airbnb/package.json index c36188c4ea..94299c25e6 100644 --- a/packages/eslint-config-airbnb/package.json +++ b/packages/eslint-config-airbnb/package.json @@ -1,6 +1,6 @@ { "name": "eslint-config-airbnb", - "version": "11.1.0", + "version": "11.2.0", "description": "Airbnb's ESLint config, following our styleguide", "main": "index.js", "scripts": { From f6dab799b8fa1346f1cc3fdfdbe9c9fbeef7baf6 Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Sat, 24 Sep 2016 12:30:58 -0700 Subject: [PATCH 078/826] [eslint config] [base] [breaking] enable rules: - `no-restricted-properties` - `prefer-numeric-literals` - `lines-around-directive` - `import/extensions` - `import/no-absolute-path` - `import/no-dynamic-require` --- .../rules/best-practices.js | 7 +------ packages/eslint-config-airbnb-base/rules/es6.js | 3 +-- packages/eslint-config-airbnb-base/rules/imports.js | 12 ++++++------ packages/eslint-config-airbnb-base/rules/style.js | 3 +-- packages/eslint-config-airbnb-base/test/test-base.js | 1 + 5 files changed, 10 insertions(+), 16 deletions(-) diff --git a/packages/eslint-config-airbnb-base/rules/best-practices.js b/packages/eslint-config-airbnb-base/rules/best-practices.js index 46fefab83f..fa97fb68e3 100644 --- a/packages/eslint-config-airbnb-base/rules/best-practices.js +++ b/packages/eslint-config-airbnb-base/rules/best-practices.js @@ -176,8 +176,7 @@ module.exports = { // disallow certain object properties // http://eslint.org/docs/rules/no-restricted-properties - // TODO: enable, semver-major - 'no-restricted-properties': ['off', { + 'no-restricted-properties': ['error', { object: 'arguments', property: 'callee', message: 'arguments.callee is deprecated,' @@ -187,10 +186,6 @@ module.exports = { }, { property: '__defineSetter__', message: 'Please use Object.defineProperty instead.', - }, { - object: 'Object', - property: 'assign', - message: 'Please use the object spread operator (...) instead.', }], // disallow use of assignment in return statement diff --git a/packages/eslint-config-airbnb-base/rules/es6.js b/packages/eslint-config-airbnb-base/rules/es6.js index efd5a15b33..063ee2cfa5 100644 --- a/packages/eslint-config-airbnb-base/rules/es6.js +++ b/packages/eslint-config-airbnb-base/rules/es6.js @@ -109,8 +109,7 @@ module.exports = { // disallow parseInt() in favor of binary, octal, and hexadecimal literals // http://eslint.org/docs/rules/prefer-numeric-literals - // TODO: enable, semver-major - 'prefer-numeric-literals': 'off', + 'prefer-numeric-literals': 'error', // suggest using Reflect methods where applicable // http://eslint.org/docs/rules/prefer-reflect diff --git a/packages/eslint-config-airbnb-base/rules/imports.js b/packages/eslint-config-airbnb-base/rules/imports.js index b7065dd3bd..c4b350fc66 100644 --- a/packages/eslint-config-airbnb-base/rules/imports.js +++ b/packages/eslint-config-airbnb-base/rules/imports.js @@ -107,8 +107,10 @@ module.exports = { // Ensure consistent use of file extension within the import path // https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/extensions.md - // TODO: enable when https://github.com/benmosher/eslint-plugin-import/issues/390 is resolved - 'import/extensions': ['off', 'never'], + 'import/extensions': ['error', 'always', { + js: 'never', + jsx: 'never', + }], // Enforce a convention in module import order // https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/order.md @@ -136,13 +138,11 @@ module.exports = { // Forbid import of modules using absolute paths // https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/no-absolute-path.md - // TODO: enable, semver-major - 'import/no-absolute-path': ['off'], + 'import/no-absolute-path': 'error', // Forbid require() calls with expressions // https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/no-dynamic-require.md - // TODO: enable, semver-major - 'import/no-dynamic-require': ['off'], + 'import/no-dynamic-require': 'error', // prevent importing the submodules of other modules // https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/no-internal-modules.md diff --git a/packages/eslint-config-airbnb-base/rules/style.js b/packages/eslint-config-airbnb-base/rules/style.js index 4349e1352b..a661712984 100644 --- a/packages/eslint-config-airbnb-base/rules/style.js +++ b/packages/eslint-config-airbnb-base/rules/style.js @@ -91,8 +91,7 @@ module.exports = { // require or disallow newlines around directives // http://eslint.org/docs/rules/lines-around-directive - // TODO: enable, semver-major - 'lines-around-directive': ['off', { + 'lines-around-directive': ['error', { before: 'always', after: 'always', }], diff --git a/packages/eslint-config-airbnb-base/test/test-base.js b/packages/eslint-config-airbnb-base/test/test-base.js index 7544a0639c..810c8000b0 100644 --- a/packages/eslint-config-airbnb-base/test/test-base.js +++ b/packages/eslint-config-airbnb-base/test/test-base.js @@ -7,6 +7,7 @@ import index from '../'; const files = { ...{ index } }; // object spread is to test parsing fs.readdirSync(path.join(__dirname, '../rules')).forEach((name) => { + // eslint-disable-next-line import/no-dynamic-require files[name] = require(`../rules/${name}`); // eslint-disable-line global-require }); From 0157e69a0df8ee8fa568d2c0ed53c087e4910c80 Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Sat, 24 Sep 2016 12:31:53 -0700 Subject: [PATCH 079/826] [eslint config] [base] v8.0.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 1346a8b9ac..7919002249 100644 --- a/packages/eslint-config-airbnb-base/CHANGELOG.md +++ b/packages/eslint-config-airbnb-base/CHANGELOG.md @@ -1,3 +1,7 @@ +8.0.0 / 2016-09-24 +================== + - [breaking] enable rules: `no-restricted-properties`, `prefer-numeric-literals`, `lines-around-directive`, `import/extensions`, `import/no-absolute-path`, `import/no-dynamic-require` + 7.2.0 / 2016-09-23 ================== - [new] set `ecmaVersion` to 2017; enable object rest/spread; update `babel-preset-airbnb` diff --git a/packages/eslint-config-airbnb-base/package.json b/packages/eslint-config-airbnb-base/package.json index 528510914d..adb4fd9981 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": "7.2.0", + "version": "8.0.0", "description": "Airbnb's base JS ESLint config, following our styleguide", "main": "index.js", "scripts": { From 0faabe054d0026806e12386f81c508f3ea3386fe Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Sat, 24 Sep 2016 14:30:57 -0700 Subject: [PATCH 080/826] [eslint config] [breaking] [deps] update `eslint-config-airbnb-base` --- packages/eslint-config-airbnb/package.json | 2 +- packages/eslint-config-airbnb/test/test-base.js | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/eslint-config-airbnb/package.json b/packages/eslint-config-airbnb/package.json index 94299c25e6..c536f4ce0b 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": "^7.2.0" + "eslint-config-airbnb-base": "^8.0.0" }, "devDependencies": { "babel-preset-airbnb": "^2.1.0", diff --git a/packages/eslint-config-airbnb/test/test-base.js b/packages/eslint-config-airbnb/test/test-base.js index 6f7a55ab7c..2b946a462c 100644 --- a/packages/eslint-config-airbnb/test/test-base.js +++ b/packages/eslint-config-airbnb/test/test-base.js @@ -11,6 +11,7 @@ fs.readdirSync(path.join(__dirname, '../rules')).forEach((name) => { return; } + // eslint-disable-next-line import/no-dynamic-require files[name] = require(`../rules/${name}`); // eslint-disable-line global-require }); From 0dae56a8e164cb6371328759bd02c5ab3fe2d185 Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Sat, 24 Sep 2016 14:34:52 -0700 Subject: [PATCH 081/826] [eslint config] [patch] disable deprecated and redundant `react/require-extension` rule Fixes #978. --- packages/eslint-config-airbnb/rules/react.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/eslint-config-airbnb/rules/react.js b/packages/eslint-config-airbnb/rules/react.js index e8ead07943..c696bf0d6b 100644 --- a/packages/eslint-config-airbnb/rules/react.js +++ b/packages/eslint-config-airbnb/rules/react.js @@ -170,7 +170,8 @@ module.exports = { // Restrict file extensions that may be required // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/require-extension.md - 'react/require-extension': ['error', { extensions: ['.jsx', '.js'] }], + // 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 From 976845e9305e33cc366b104569145a05354078bd Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Sat, 24 Sep 2016 14:38:54 -0700 Subject: [PATCH 082/826] [eslint config] [breaking] Enable react rules: - `react/no-unescaped-entities` - `react/no-children-prop` --- 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 c696bf0d6b..7736020599 100644 --- a/packages/eslint-config-airbnb/rules/react.js +++ b/packages/eslint-config-airbnb/rules/react.js @@ -267,13 +267,11 @@ module.exports = { // Prevent invalid characters from appearing in markup // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/no-unescaped-entities.md - // TODO: enable, semver-major - 'react/no-unescaped-entities': 'off', + 'react/no-unescaped-entities': 'error', // Prevent passing of children as props // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/no-children-prop.md - // TODO: enable, semver-major - 'react/no-children-prop': 'off' + 'react/no-children-prop': 'error' }, settings: { From 39d7c73ef10f0c2c45681722159f5a8897b99cf9 Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Sat, 24 Sep 2016 20:03:58 -0700 Subject: [PATCH 083/826] [eslint config] [patch] `class-methods-use-this`: exempt React lifecycle methods --- packages/eslint-config-airbnb/rules/react.js | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/packages/eslint-config-airbnb/rules/react.js b/packages/eslint-config-airbnb/rules/react.js index 7736020599..11f2825a5a 100644 --- a/packages/eslint-config-airbnb/rules/react.js +++ b/packages/eslint-config-airbnb/rules/react.js @@ -1,6 +1,6 @@ module.exports = { plugins: [ - 'react' + 'react', ], parserOptions: { ecmaFeatures: { @@ -8,7 +8,7 @@ module.exports = { }, }, ecmaFeatures: { - jsx: true + jsx: true, }, // View link below for react rules documentation @@ -18,6 +18,21 @@ module.exports = { // http://eslint.org/docs/rules/jsx-quotes 'jsx-quotes': ['error', 'prefer-double'], + 'class-methods-use-this': ['error', { + exceptMethods: [ + 'render', + 'getInitialState', + 'getDefaultProps', + 'componentWillMount', + 'componentDidMount', + 'componentWillReceiveProps', + 'shouldComponentUpdate', + 'componentWillUpdate', + 'componentDidUpdate', + 'componentWillUnmount', + ], + }], + // Prevent missing displayName in a React component definition // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/display-name.md 'react/display-name': ['off', { ignoreTranspilerName: false }], From a1c84eee150da374381193799b3a89aa8f0fa2e5 Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Sat, 24 Sep 2016 15:06:10 -0700 Subject: [PATCH 084/826] [eslint config] v12.0.0 --- packages/eslint-config-airbnb/CHANGELOG.md | 6 ++++++ packages/eslint-config-airbnb/package.json | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/packages/eslint-config-airbnb/CHANGELOG.md b/packages/eslint-config-airbnb/CHANGELOG.md index 2f4f803406..4dde06abe3 100644 --- a/packages/eslint-config-airbnb/CHANGELOG.md +++ b/packages/eslint-config-airbnb/CHANGELOG.md @@ -1,3 +1,9 @@ +12.0.0 / 2016-09-24 +================== +- [breaking] Enable react rules: `react/no-unescaped-entities`, `react/no-children-prop` +- [breaking] [deps] update `eslint-config-airbnb-base` +- [patch] disable deprecated and redundant `react/require-extension` rule (#978) + 11.2.0 / 2016-09-23 ================== - [new] set `ecmaVersion` to 2017; enable object rest/spread; update `babel-preset-airbnb` diff --git a/packages/eslint-config-airbnb/package.json b/packages/eslint-config-airbnb/package.json index c536f4ce0b..04f566e532 100644 --- a/packages/eslint-config-airbnb/package.json +++ b/packages/eslint-config-airbnb/package.json @@ -1,6 +1,6 @@ { "name": "eslint-config-airbnb", - "version": "11.2.0", + "version": "12.0.0", "description": "Airbnb's ESLint config, following our styleguide", "main": "index.js", "scripts": { From 59db4aab157d98bf98c216c119e9ff848eea9505 Mon Sep 17 00:00:00 2001 From: Jonas Enlund Date: Sun, 25 Sep 2016 11:56:54 +0300 Subject: [PATCH 085/826] [eslint config] [base] [patch] `new-cap`: add immutable.js exceptions --- packages/eslint-config-airbnb-base/rules/style.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/packages/eslint-config-airbnb-base/rules/style.js b/packages/eslint-config-airbnb-base/rules/style.js index a661712984..5da9f34f79 100644 --- a/packages/eslint-config-airbnb-base/rules/style.js +++ b/packages/eslint-config-airbnb-base/rules/style.js @@ -135,7 +135,12 @@ module.exports = { 'multiline-ternary': ['off', 'never'], // require a capital letter for constructors - 'new-cap': ['error', { newIsCap: true }], + 'new-cap': ['error', { + newIsCap: true, + newIsCapExceptions: [], + capIsNew: false, + capIsNewExceptions: ['Immutable.Map', 'Immutable.Set', 'Immutable.List'], + }], // disallow the omission of parentheses when invoking a constructor with no arguments // http://eslint.org/docs/rules/new-parens From 24223ee444409087f1105be0c80f759d0d75d06f Mon Sep 17 00:00:00 2001 From: Tim van der Horst Date: Tue, 27 Sep 2016 18:07:56 +1000 Subject: [PATCH 086/826] [eslint config] [patch] `class-methods-use-this`: exempt React `getChildContext` Added `getChildContext` to the exceptions list for `class-methods-use-this` --- packages/eslint-config-airbnb/rules/react.js | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/eslint-config-airbnb/rules/react.js b/packages/eslint-config-airbnb/rules/react.js index 11f2825a5a..5f81e40c86 100644 --- a/packages/eslint-config-airbnb/rules/react.js +++ b/packages/eslint-config-airbnb/rules/react.js @@ -23,6 +23,7 @@ module.exports = { 'render', 'getInitialState', 'getDefaultProps', + 'getChildContext', 'componentWillMount', 'componentDidMount', 'componentWillReceiveProps', From 8468ed842314a5d66816927ba6c35f018035cffc Mon Sep 17 00:00:00 2001 From: jcreamer898 Date: Tue, 27 Sep 2016 09:13:20 -0500 Subject: [PATCH 087/826] Lonely Planet Add Lonely Planet to the "In the Wild" list. --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 705f44d582..f3b4559d3e 100644 --- a/README.md +++ b/README.md @@ -2966,6 +2966,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) + - **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) - **MinnPost**: [MinnPost/javascript](https://github.com/MinnPost/javascript) From e2de71efb79bed5acf6d7f33fbd3b857a0a4b42c Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Mon, 3 Oct 2016 16:15:31 -0700 Subject: [PATCH 088/826] [eslint config] [*] update `babel-preset-airbnb`, `eslint`, `eslint-find-rules`, `tape` --- packages/eslint-config-airbnb-base/package.json | 10 +++++----- packages/eslint-config-airbnb/package.json | 10 +++++----- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/packages/eslint-config-airbnb-base/package.json b/packages/eslint-config-airbnb-base/package.json index adb4fd9981..e8fff45fb6 100644 --- a/packages/eslint-config-airbnb-base/package.json +++ b/packages/eslint-config-airbnb-base/package.json @@ -45,17 +45,17 @@ }, "homepage": "https://github.com/airbnb/javascript", "devDependencies": { - "babel-preset-airbnb": "^2.1.0", + "babel-preset-airbnb": "^2.1.1", "babel-tape-runner": "^2.0.1", - "eslint": "^3.6.0", - "eslint-find-rules": "^1.13.2", + "eslint": "^3.7.1", + "eslint-find-rules": "^1.14.0", "eslint-plugin-import": "^1.16.0", "in-publish": "^2.0.0", "safe-publish-latest": "^1.1.0", - "tape": "^4.6.0" + "tape": "^4.6.2" }, "peerDependencies": { - "eslint": "^3.6.0", + "eslint": "^3.7.1", "eslint-plugin-import": "^1.16.0" }, "engines": { diff --git a/packages/eslint-config-airbnb/package.json b/packages/eslint-config-airbnb/package.json index 04f566e532..df09c07df8 100644 --- a/packages/eslint-config-airbnb/package.json +++ b/packages/eslint-config-airbnb/package.json @@ -48,20 +48,20 @@ "eslint-config-airbnb-base": "^8.0.0" }, "devDependencies": { - "babel-preset-airbnb": "^2.1.0", + "babel-preset-airbnb": "^2.1.1", "babel-tape-runner": "^2.0.1", - "eslint": "^3.6.0", - "eslint-find-rules": "^1.13.2", + "eslint": "^3.7.1", + "eslint-find-rules": "^1.14.0", "eslint-plugin-import": "^1.16.0", "eslint-plugin-jsx-a11y": "^2.2.2", "eslint-plugin-react": "^6.3.0", "in-publish": "^2.0.0", "react": ">= 0.13.0", "safe-publish-latest": "^1.1.0", - "tape": "^4.6.0" + "tape": "^4.6.2" }, "peerDependencies": { - "eslint": "^3.6.0", + "eslint": "^3.7.1", "eslint-plugin-jsx-a11y": "^2.2.2", "eslint-plugin-import": "^1.16.0", "eslint-plugin-react": "^6.3.0" From 6ad315c090208aca03dfcd761c3b84663a5ac1e2 Mon Sep 17 00:00:00 2001 From: Karan Thakkar Date: Thu, 6 Oct 2016 14:54:53 +0530 Subject: [PATCH 089/826] Add section on multi-line imports. Fixes #1051 --- README.md | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/README.md b/README.md index f3b4559d3e..5bb6080d6a 100644 --- a/README.md +++ b/README.md @@ -1223,6 +1223,25 @@ Other Style Guides foo.init(); ``` + + - [10.8](#modules--multiline-imports-over-newlines) Multi-line imports should be preferred over single line + + > Why? The curly braces follow the same indentation rules as every other curly brace block in the style guide, as do the trailing commas. + + ```javascript + // bad + import {longNameA, longNameB, longNameC, longNameD, longNameE} from 'path'; + + // good + import { + longNameA, + longNameB, + longNameC, + longNameD, + longNameE + } from 'path'; + ``` + **[⬆ back to top](#table-of-contents)** ## Iterators and Generators From 098894efee58242c066644919ac4f75ff2ac17db Mon Sep 17 00:00:00 2001 From: Karan Thakkar Date: Fri, 7 Oct 2016 12:16:21 +0530 Subject: [PATCH 090/826] Remove legacy anchor link. Add dangling comma --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 5bb6080d6a..0312fb1cd1 100644 --- a/README.md +++ b/README.md @@ -1223,7 +1223,7 @@ Other Style Guides foo.init(); ``` - + - [10.8](#modules--multiline-imports-over-newlines) Multi-line imports should be preferred over single line > Why? The curly braces follow the same indentation rules as every other curly brace block in the style guide, as do the trailing commas. @@ -1238,7 +1238,7 @@ Other Style Guides longNameB, longNameC, longNameD, - longNameE + longNameE, } from 'path'; ``` From b72bd520b63622477ce40c9b5a52c3514920ab81 Mon Sep 17 00:00:00 2001 From: Karan Thakkar Date: Fri, 7 Oct 2016 12:34:36 +0530 Subject: [PATCH 091/826] Fix rule description --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 0312fb1cd1..0cbf24c7a0 100644 --- a/README.md +++ b/README.md @@ -1224,7 +1224,7 @@ Other Style Guides ``` - - [10.8](#modules--multiline-imports-over-newlines) Multi-line imports should be preferred over single line + - [10.8](#modules--multiline-imports-over-newlines) Multiline imports should be indented just like multiline array and object literals. > Why? The curly braces follow the same indentation rules as every other curly brace block in the style guide, as do the trailing commas. From d0d260095b593e7956010df869295387fb7a8111 Mon Sep 17 00:00:00 2001 From: "Randall Reed, Jr" Date: Tue, 4 Oct 2016 13:56:38 -0400 Subject: [PATCH 092/826] Make section numbering consistent * Renumber items where numbers were skipped --- README.md | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index 0cbf24c7a0..56580fee44 100644 --- a/README.md +++ b/README.md @@ -155,7 +155,7 @@ Other Style Guides ``` - - [3.4](#es6-computed-properties) Use computed property names when creating objects with dynamic property names. + - [3.2](#es6-computed-properties) Use computed property names when creating objects with dynamic property names. > Why? They allow you to define all the properties of an object in one place. @@ -181,7 +181,7 @@ Other Style Guides ``` - - [3.5](#es6-object-shorthand) Use object method shorthand. eslint: [`object-shorthand`](http://eslint.org/docs/rules/object-shorthand.html) jscs: [`requireEnhancedObjectLiterals`](http://jscs.info/rule/requireEnhancedObjectLiterals) + - [3.3](#es6-object-shorthand) Use object method shorthand. eslint: [`object-shorthand`](http://eslint.org/docs/rules/object-shorthand.html) jscs: [`requireEnhancedObjectLiterals`](http://jscs.info/rule/requireEnhancedObjectLiterals) ```javascript // bad @@ -204,7 +204,7 @@ Other Style Guides ``` - - [3.6](#es6-object-concise) Use property value shorthand. eslint: [`object-shorthand`](http://eslint.org/docs/rules/object-shorthand.html) jscs: [`requireEnhancedObjectLiterals`](http://jscs.info/rule/requireEnhancedObjectLiterals) + - [3.4](#es6-object-concise) Use property value shorthand. eslint: [`object-shorthand`](http://eslint.org/docs/rules/object-shorthand.html) jscs: [`requireEnhancedObjectLiterals`](http://jscs.info/rule/requireEnhancedObjectLiterals) > Why? It is shorter to write and descriptive. @@ -223,7 +223,7 @@ Other Style Guides ``` - - [3.7](#objects--grouped-shorthand) Group your shorthand properties at the beginning of your object declaration. + - [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. @@ -253,7 +253,7 @@ Other Style Guides ``` - - [3.8](#objects--quoted-props) Only quote properties that are invalid identifiers. eslint: [`quote-props`](http://eslint.org/docs/rules/quote-props.html) jscs: [`disallowQuotedKeysInObjects`](http://jscs.info/rule/disallowQuotedKeysInObjects) + - [3.6](#objects--quoted-props) Only quote properties that are invalid identifiers. eslint: [`quote-props`](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. @@ -274,7 +274,7 @@ Other Style Guides ``` - - [3.9](#objects--prototype-builtins) Do not call `Object.prototype` methods directly, such as `hasOwnProperty`, `propertyIsEnumerable`, and `isPrototypeOf`. + - [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)`). @@ -294,7 +294,7 @@ Other Style Guides ``` - - [3.10](#objects--rest-spread) Prefer the object spread operator over `Object.assign` to shallow-copy objects. Use the object rest operator to get a new object with certain properties omitted. + - [3.8](#objects--rest-spread) Prefer the object spread operator over `Object.assign` to shallow-copy objects. Use the object rest operator to get a new object with certain properties omitted. ```javascript // very bad @@ -525,7 +525,7 @@ Other Style Guides ``` - - [6.4](#es6-template-literals) When programmatically building up strings, use template strings instead of concatenation. eslint: [`prefer-template`](http://eslint.org/docs/rules/prefer-template.html) [`template-curly-spacing`](http://eslint.org/docs/rules/template-curly-spacing) jscs: [`requireTemplateStrings`](http://jscs.info/rule/requireTemplateStrings) + - [6.3](#es6-template-literals) When programmatically building up strings, use template strings instead of concatenation. eslint: [`prefer-template`](http://eslint.org/docs/rules/prefer-template.html) [`template-curly-spacing`](http://eslint.org/docs/rules/template-curly-spacing) jscs: [`requireTemplateStrings`](http://jscs.info/rule/requireTemplateStrings) > Why? Template strings give you a readable, concise syntax with proper newlines and string interpolation features. @@ -552,10 +552,10 @@ Other Style Guides ``` - - [6.5](#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. - - [6.6](#strings--escaping) Do not unnecessarily escape characters in strings. eslint: [`no-useless-escape`](http://eslint.org/docs/rules/no-useless-escape) + - [6.5](#strings--escaping) Do not unnecessarily escape characters in strings. eslint: [`no-useless-escape`](http://eslint.org/docs/rules/no-useless-escape) > Why? Backslashes harm readability, thus they should only be present when necessary. From b7492ffe60483edd5f30819ceaa0f3f4b6e84886 Mon Sep 17 00:00:00 2001 From: "Randall Reed, Jr" Date: Sat, 8 Oct 2016 16:41:45 -0400 Subject: [PATCH 093/826] Update comparison recommendation * Use shortcuts for boolean comparisons * Use explicit comparisons for strings and numbers --- README.md | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 56580fee44..60621cca7d 100644 --- a/README.md +++ b/README.md @@ -1652,28 +1652,38 @@ Other Style Guides ``` - - [15.3](#comparison--shortcuts) Use shortcuts. + - [15.3](#comparison--shortcuts) Use shortcuts for booleans, but explicit comparisons for strings and numbers. ```javascript // bad - if (name !== '') { + if (isValid === true) { // ...stuff... } // good - if (name) { + if (isValid) { // ...stuff... } // bad - if (collection.length > 0) { + if (name) { // ...stuff... } // good + if (name !== '') { + // ...stuff... + } + + // bad if (collection.length) { // ...stuff... } + + // good + if (collection.length > 0) { + // ...stuff... + } ``` From 148329289344c965f306f1f38931e317328cec3a Mon Sep 17 00:00:00 2001 From: Chester How Date: Mon, 10 Oct 2016 11:21:18 +0800 Subject: [PATCH 094/826] Fix naming typo --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 60621cca7d..26fa46e035 100644 --- a/README.md +++ b/README.md @@ -1148,7 +1148,7 @@ Other Style Guides ```javascript // bad // filename es6.js - export { es6 as default } from './airbnbStyleGuide'; + export { es6 as default } from './AirbnbStyleGuide'; // good // filename es6.js From 781f186f908d064d7fe66bbca0a80a7d3656278e Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Sun, 9 Oct 2016 20:33:06 -0700 Subject: [PATCH 095/826] [eslint config] [*] [deps] update `safe-publish-latest`, `eslint-plugin-jsx-a11y`, `eslint-plugin-react` --- packages/eslint-config-airbnb-base/package.json | 2 +- packages/eslint-config-airbnb/package.json | 10 +++++----- 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 e8fff45fb6..d146054ed1 100644 --- a/packages/eslint-config-airbnb-base/package.json +++ b/packages/eslint-config-airbnb-base/package.json @@ -51,7 +51,7 @@ "eslint-find-rules": "^1.14.0", "eslint-plugin-import": "^1.16.0", "in-publish": "^2.0.0", - "safe-publish-latest": "^1.1.0", + "safe-publish-latest": "^1.1.1", "tape": "^4.6.2" }, "peerDependencies": { diff --git a/packages/eslint-config-airbnb/package.json b/packages/eslint-config-airbnb/package.json index df09c07df8..39478f88c4 100644 --- a/packages/eslint-config-airbnb/package.json +++ b/packages/eslint-config-airbnb/package.json @@ -53,18 +53,18 @@ "eslint": "^3.7.1", "eslint-find-rules": "^1.14.0", "eslint-plugin-import": "^1.16.0", - "eslint-plugin-jsx-a11y": "^2.2.2", - "eslint-plugin-react": "^6.3.0", + "eslint-plugin-jsx-a11y": "^2.2.3", + "eslint-plugin-react": "^6.4.0", "in-publish": "^2.0.0", "react": ">= 0.13.0", - "safe-publish-latest": "^1.1.0", + "safe-publish-latest": "^1.1.1", "tape": "^4.6.2" }, "peerDependencies": { "eslint": "^3.7.1", - "eslint-plugin-jsx-a11y": "^2.2.2", + "eslint-plugin-jsx-a11y": "^2.2.3", "eslint-plugin-import": "^1.16.0", - "eslint-plugin-react": "^6.3.0" + "eslint-plugin-react": "^6.4.0" }, "engines": { "node": ">= 4" From 357cc46da083518498e329584795dccc0f575253 Mon Sep 17 00:00:00 2001 From: Miles Burton Date: Tue, 11 Oct 2016 08:44:43 +0100 Subject: [PATCH 096/826] Update README.md Minor oversight generating map object. Need square brackets to generate dynamic key. --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 26fa46e035..c7c39d9ab4 100644 --- a/README.md +++ b/README.md @@ -858,7 +858,7 @@ Other Style Guides // good [1, 2, 3].map((number, index) => ({ - index: number + [index]: number })); ``` From b599b7c2d56e2bc4ca264729b0b177e21a4c3139 Mon Sep 17 00:00:00 2001 From: Simen Bekkhus Date: Sun, 2 Oct 2016 08:43:05 +0200 Subject: [PATCH 097/826] Upgrade to import plugin v2 --- .../eslint-config-airbnb-base/package.json | 4 ++-- .../rules/imports.js | 22 +++++++++++++++++-- 2 files changed, 22 insertions(+), 4 deletions(-) diff --git a/packages/eslint-config-airbnb-base/package.json b/packages/eslint-config-airbnb-base/package.json index d146054ed1..44d49524ba 100644 --- a/packages/eslint-config-airbnb-base/package.json +++ b/packages/eslint-config-airbnb-base/package.json @@ -49,14 +49,14 @@ "babel-tape-runner": "^2.0.1", "eslint": "^3.7.1", "eslint-find-rules": "^1.14.0", - "eslint-plugin-import": "^1.16.0", + "eslint-plugin-import": "^2.0.1", "in-publish": "^2.0.0", "safe-publish-latest": "^1.1.1", "tape": "^4.6.2" }, "peerDependencies": { "eslint": "^3.7.1", - "eslint-plugin-import": "^1.16.0" + "eslint-plugin-import": "^2.0.1" }, "engines": { "node": ">= 4" diff --git a/packages/eslint-config-airbnb-base/rules/imports.js b/packages/eslint-config-airbnb-base/rules/imports.js index c4b350fc66..5306e3cd4c 100644 --- a/packages/eslint-config-airbnb-base/rules/imports.js +++ b/packages/eslint-config-airbnb-base/rules/imports.js @@ -33,7 +33,7 @@ module.exports = { // ensure imports point to files/modules that can be resolved // https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/no-unresolved.md - 'import/no-unresolved': ['error', { commonjs: true }], + 'import/no-unresolved': ['error', { commonjs: true, caseSensitive: true }], // ensure named imports coupled with named exports // https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/named.md#when-not-to-use-it @@ -92,9 +92,14 @@ module.exports = { // Style guide: + // disallow non-import statements appearing before import statements + // https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/first.md + 'import/first': ['error', 'absolute-first'], + // disallow non-import statements appearing before import statements // https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/imports-first.md - 'import/imports-first': ['error', 'absolute-first'], + // deprecated: use `import/first` + 'import/imports-first': 'off', // disallow duplicate imports // https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/no-duplicates.md @@ -149,5 +154,18 @@ module.exports = { 'import/no-internal-modules': ['off', { allow: [], }], + + // Warn if a module could be mistakenly parsed as a script by a consumer leveraging Unambiguous + // JavaScript Grammar + // https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/unambiguous.md + 'import/unambiguous': 'off', + + // Forbid Webpack loader syntax in imports + // https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/no-webpack-loader-syntax.md + 'import/no-webpack-loader-syntax': 'off', + + // Prevent unassigned imports + // https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/no-unassigned-import.md + 'import/no-unassigned-import': 'off', }, }; From eb9927fb58e89ae87a8e03a5c834f50f9ab1e1b7 Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Wed, 12 Oct 2016 23:50:56 -0700 Subject: [PATCH 098/826] [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 39478f88c4..2c7a9df7f1 100644 --- a/packages/eslint-config-airbnb/package.json +++ b/packages/eslint-config-airbnb/package.json @@ -54,7 +54,7 @@ "eslint-find-rules": "^1.14.0", "eslint-plugin-import": "^1.16.0", "eslint-plugin-jsx-a11y": "^2.2.3", - "eslint-plugin-react": "^6.4.0", + "eslint-plugin-react": "^6.4.1", "in-publish": "^2.0.0", "react": ">= 0.13.0", "safe-publish-latest": "^1.1.1", @@ -64,7 +64,7 @@ "eslint": "^3.7.1", "eslint-plugin-jsx-a11y": "^2.2.3", "eslint-plugin-import": "^1.16.0", - "eslint-plugin-react": "^6.4.0" + "eslint-plugin-react": "^6.4.1" }, "engines": { "node": ">= 4" From b59bfffac3812aef551a29720302a1ba977b3149 Mon Sep 17 00:00:00 2001 From: Simen Bekkhus Date: Thu, 13 Oct 2016 09:00:23 +0200 Subject: [PATCH 099/826] Enable `import/no-webpack-loader-syntax` rule --- README.md | 15 +++++++++++++++ .../eslint-config-airbnb-base/rules/imports.js | 2 +- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index c7c39d9ab4..c7f1c98d0f 100644 --- a/README.md +++ b/README.md @@ -1242,6 +1242,21 @@ Other Style Guides } from 'path'; ``` + + - [10.9](#modules--no-webpack-loader-syntax) Disallow Webpack loader syntax in module import statements. + eslint: [`import/no-webpack-loader-syntax`](https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/no-webpack-loader-syntax.md) + > Why? Since using Webpack syntax in the imports couples the code to a module bundler. Prefer using the loader syntax in `webpack.config.js`. + + ```javascript + // bad + import fooSass from 'css!sass!foo.scss'; + import barCss from 'style!css!bar.css'; + + // good + import fooSass from 'foo.scss'; + import barCss from 'bar.css'; + ``` + **[⬆ back to top](#table-of-contents)** ## Iterators and Generators diff --git a/packages/eslint-config-airbnb-base/rules/imports.js b/packages/eslint-config-airbnb-base/rules/imports.js index 5306e3cd4c..a02ef93030 100644 --- a/packages/eslint-config-airbnb-base/rules/imports.js +++ b/packages/eslint-config-airbnb-base/rules/imports.js @@ -162,7 +162,7 @@ module.exports = { // Forbid Webpack loader syntax in imports // https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/no-webpack-loader-syntax.md - 'import/no-webpack-loader-syntax': 'off', + 'import/no-webpack-loader-syntax': 'error', // Prevent unassigned imports // https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/no-unassigned-import.md From 8d0fda975c1b52dd6696d8f70219a00f9703871d Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Thu, 13 Oct 2016 00:33:29 -0700 Subject: [PATCH 100/826] [eslint config] [base] Add comments on new import rules. --- packages/eslint-config-airbnb-base/rules/imports.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/packages/eslint-config-airbnb-base/rules/imports.js b/packages/eslint-config-airbnb-base/rules/imports.js index a02ef93030..a8f4269cbd 100644 --- a/packages/eslint-config-airbnb-base/rules/imports.js +++ b/packages/eslint-config-airbnb-base/rules/imports.js @@ -155,9 +155,11 @@ module.exports = { allow: [], }], - // Warn if a module could be mistakenly parsed as a script by a consumer leveraging Unambiguous - // JavaScript Grammar + // Warn if a module could be mistakenly parsed as a script by a consumer + // leveraging Unambiguous JavaScript Grammar // https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/unambiguous.md + // this should not be enabled until this proposal has at least been *presented* to TC39. + // At the moment, it's not a thing. 'import/unambiguous': 'off', // Forbid Webpack loader syntax in imports @@ -166,6 +168,7 @@ module.exports = { // Prevent unassigned imports // 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', }, }; From baa831b4a997ca6318ec311f8ef4576f9a9d7991 Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Thu, 13 Oct 2016 10:26:31 -0700 Subject: [PATCH 101/826] [eslint config] [*] [docs] ensure latest version of config is installed Fixes #1121. --- 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 dabe3a6345..d293a8ad90 100644 --- a/packages/eslint-config-airbnb-base/README.md +++ b/packages/eslint-config-airbnb-base/README.md @@ -16,7 +16,7 @@ Our default export contains all of our ESLint rules, including ECMAScript 6+. It ```sh ( export PKG=eslint-config-airbnb-base; - npm info "$PKG" peerDependencies --json | command sed 's/[\{\},]//g ; s/: /@/g' | xargs npm install --save-dev "$PKG" + npm info "$PKG@latest" peerDependencies --json | command sed 's/[\{\},]//g ; s/: /@/g' | xargs npm install --save-dev "$PKG@latest" ) ``` diff --git a/packages/eslint-config-airbnb/README.md b/packages/eslint-config-airbnb/README.md index d13133e14e..5014173d27 100644 --- a/packages/eslint-config-airbnb/README.md +++ b/packages/eslint-config-airbnb/README.md @@ -16,7 +16,7 @@ Our default export contains all of our ESLint rules, including ECMAScript 6+ and ```sh ( export PKG=eslint-config-airbnb; - npm info "$PKG" peerDependencies --json | command sed 's/[\{\},]//g ; s/: /@/g' | xargs npm install --save-dev "$PKG" + npm info "$PKG@latest" peerDependencies --json | command sed 's/[\{\},]//g ; s/: /@/g' | xargs npm install --save-dev "$PKG@latest" ) ``` From a75efdfdb0484f3e09112c2d5c381d0513f06040 Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Fri, 14 Oct 2016 22:37:14 -0700 Subject: [PATCH 102/826] [guide] improve ++/-- example. Fixes #1130. --- README.md | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index c7f1c98d0f..6396a48847 100644 --- a/README.md +++ b/README.md @@ -1521,24 +1521,28 @@ Other Style Guides let array = [1, 2, 3]; let num = 1; - let increment = num ++; - let decrement = -- num; + num ++; + -- num; + let sum = 0; + let truthyCount = 0; for(let i = 0; i < array.length; i++){ let value = array[i]; - ++value; + sum += value; + if (value) { + truthyCount++; + } } // good let array = [1, 2, 3]; let num = 1; - let increment = num += 1; - let decrement = num -= 1; + num += 1; + num -= 1; - array.forEach((value) => { - value += 1; - }); + const sum = array.reduce((a, b) => a + b, 0); + const truthyCount = array.filter(Boolean).length; ``` **[⬆ back to top](#table-of-contents)** From 978c0eecc236860a23ee91e0ab3f415f45acef28 Mon Sep 17 00:00:00 2001 From: Mikael Finstad Date: Sun, 16 Oct 2016 16:59:23 +0200 Subject: [PATCH 103/826] Use import instead of require Don't recommend the use of require (See 10.1) --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 6396a48847..ad08a61bb4 100644 --- a/README.md +++ b/README.md @@ -288,7 +288,7 @@ Other Style Guides // best const has = Object.prototype.hasOwnProperty; // cache the lookup once, in module scope. /* or */ - const has = require('has'); + import has from 'has'; … console.log(has.call(object, key)); ``` From 9c5afe58090ba014434fe3130e7c3e551b31359a Mon Sep 17 00:00:00 2001 From: Simen Bekkhus Date: Sun, 16 Oct 2016 10:02:54 +0200 Subject: [PATCH 104/826] Update eslint to 3.8.0 New rule called `func-name-matching` added --- packages/eslint-config-airbnb-base/package.json | 4 ++-- .../rules/best-practices.js | 2 +- packages/eslint-config-airbnb-base/rules/style.js | 12 +++++++++++- packages/eslint-config-airbnb/package.json | 4 ++-- 4 files changed, 16 insertions(+), 6 deletions(-) diff --git a/packages/eslint-config-airbnb-base/package.json b/packages/eslint-config-airbnb-base/package.json index 44d49524ba..b971eb2b4a 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.7.1", + "eslint": "^3.8.0", "eslint-find-rules": "^1.14.0", "eslint-plugin-import": "^2.0.1", "in-publish": "^2.0.0", @@ -55,7 +55,7 @@ "tape": "^4.6.2" }, "peerDependencies": { - "eslint": "^3.7.1", + "eslint": "^3.8.0", "eslint-plugin-import": "^2.0.1" }, "engines": { diff --git a/packages/eslint-config-airbnb-base/rules/best-practices.js b/packages/eslint-config-airbnb-base/rules/best-practices.js index fa97fb68e3..31d06c60e0 100644 --- a/packages/eslint-config-airbnb-base/rules/best-practices.js +++ b/packages/eslint-config-airbnb-base/rules/best-practices.js @@ -250,7 +250,7 @@ module.exports = { // require immediate function invocation to be wrapped in parentheses // http://eslint.org/docs/rules/wrap-iife.html - 'wrap-iife': ['error', 'outside'], + 'wrap-iife': ['error', 'outside', { functionPrototypeMethods: false }], // require or disallow Yoda conditions yoda: 'error' diff --git a/packages/eslint-config-airbnb-base/rules/style.js b/packages/eslint-config-airbnb-base/rules/style.js index 5da9f34f79..5d13066512 100644 --- a/packages/eslint-config-airbnb-base/rules/style.js +++ b/packages/eslint-config-airbnb-base/rules/style.js @@ -32,7 +32,13 @@ module.exports = { // http://eslint.org/docs/rules/func-call-spacing 'func-call-spacing': ['error', 'never'], + // requires function names to match the name of the variable or property to which they are + // assigned + // http://eslint.org/docs/rules/func-name-matching + 'func-name-matching': ['off', { includeCommonJSModuleExports: false }], + // require function expressions to have a name + // http://eslint.org/docs/rules/func-names 'func-names': 'warn', // enforces use of function declarations or expressions @@ -303,7 +309,11 @@ module.exports = { // require or disallow space before function opening parenthesis // http://eslint.org/docs/rules/space-before-function-paren - 'space-before-function-paren': ['error', { anonymous: 'always', named: 'never' }], + 'space-before-function-paren': ['error', { + anonymous: 'always', + named: 'never', + asyncArrow: 'always' + }], // require or disallow spaces inside parentheses 'space-in-parens': ['error', 'never'], diff --git a/packages/eslint-config-airbnb/package.json b/packages/eslint-config-airbnb/package.json index 2c7a9df7f1..9cd7dec0ab 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.7.1", + "eslint": "^3.8.0", "eslint-find-rules": "^1.14.0", "eslint-plugin-import": "^1.16.0", "eslint-plugin-jsx-a11y": "^2.2.3", @@ -61,7 +61,7 @@ "tape": "^4.6.2" }, "peerDependencies": { - "eslint": "^3.7.1", + "eslint": "^3.8.0", "eslint-plugin-jsx-a11y": "^2.2.3", "eslint-plugin-import": "^1.16.0", "eslint-plugin-react": "^6.4.1" From a1ca49b34c4e83ac70a583c1f64143f520d771f6 Mon Sep 17 00:00:00 2001 From: Simen Bekkhus Date: Mon, 17 Oct 2016 08:04:38 +0200 Subject: [PATCH 105/826] Add `ForOfStatement` to `no-restricted-syntax` Fixes #1122 --- packages/eslint-config-airbnb-base/rules/style.js | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/eslint-config-airbnb-base/rules/style.js b/packages/eslint-config-airbnb-base/rules/style.js index 5d13066512..53c76aef71 100644 --- a/packages/eslint-config-airbnb-base/rules/style.js +++ b/packages/eslint-config-airbnb-base/rules/style.js @@ -219,6 +219,7 @@ module.exports = { 'no-restricted-syntax': [ 'error', 'ForInStatement', + 'ForOfStatement', 'LabeledStatement', 'WithStatement', ], From d7d50bcbd0780803f00290729123a51788eb1f14 Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Sun, 16 Oct 2016 23:16:28 -0700 Subject: [PATCH 106/826] [eslint config] [base] v9.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 7919002249..17f218bd65 100644 --- a/packages/eslint-config-airbnb-base/CHANGELOG.md +++ b/packages/eslint-config-airbnb-base/CHANGELOG.md @@ -1,3 +1,13 @@ +9.0.0 / 2016-10-16 +================== + - [breaking] Add `ForOfStatement` to `no-restricted-syntax` (#1122, #1134) + - [breaking] enable `import/no-webpack-loader-syntax` (#1123) + - [breaking] [deps] update `eslint` to `v3.8.0` (#1132) + - [breaking] [deps] update `eslint-plugin-import` to v2 (#1101) + - [patch] `new-cap`: add immutable.js exceptions + - [docs] ensure latest version of config is installed + - [dev deps] update `babel-preset-airbnb`, `eslint`, `eslint-find-rules`, `tape`, `safe-publish-latest` + 8.0.0 / 2016-09-24 ================== - [breaking] enable rules: `no-restricted-properties`, `prefer-numeric-literals`, `lines-around-directive`, `import/extensions`, `import/no-absolute-path`, `import/no-dynamic-require` diff --git a/packages/eslint-config-airbnb-base/package.json b/packages/eslint-config-airbnb-base/package.json index b971eb2b4a..6acd4435a9 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": "8.0.0", + "version": "9.0.0", "description": "Airbnb's base JS ESLint config, following our styleguide", "main": "index.js", "scripts": { From 0bb3eb541203aee1b134bef06940557cf7a30007 Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Sun, 16 Oct 2016 23:20:02 -0700 Subject: [PATCH 107/826] [eslint config] [deps] [breaking] update `eslint-config-airbnb-base`, `eslint-plugin-import` --- 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 9cd7dec0ab..678a82b2a1 100644 --- a/packages/eslint-config-airbnb/package.json +++ b/packages/eslint-config-airbnb/package.json @@ -45,14 +45,14 @@ }, "homepage": "https://github.com/airbnb/javascript", "dependencies": { - "eslint-config-airbnb-base": "^8.0.0" + "eslint-config-airbnb-base": "^9.0.0" }, "devDependencies": { "babel-preset-airbnb": "^2.1.1", "babel-tape-runner": "^2.0.1", "eslint": "^3.8.0", "eslint-find-rules": "^1.14.0", - "eslint-plugin-import": "^1.16.0", + "eslint-plugin-import": "^2.0.1", "eslint-plugin-jsx-a11y": "^2.2.3", "eslint-plugin-react": "^6.4.1", "in-publish": "^2.0.0", @@ -63,7 +63,7 @@ "peerDependencies": { "eslint": "^3.8.0", "eslint-plugin-jsx-a11y": "^2.2.3", - "eslint-plugin-import": "^1.16.0", + "eslint-plugin-import": "^2.0.1", "eslint-plugin-react": "^6.4.1" }, "engines": { From a06831d52c412147bd1bd590095482df49bcbea9 Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Sat, 22 Oct 2016 01:03:16 -0700 Subject: [PATCH 108/826] =?UTF-8?q?[eslint=20config]=20[patch]=20set=20`re?= =?UTF-8?q?act/no-unused-prop-types`=20to=20=E2=80=9Cwarn=E2=80=9D,=20pend?= =?UTF-8?q?ing=20bugfixes.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Closes #1099. --- packages/eslint-config-airbnb/rules/react.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/eslint-config-airbnb/rules/react.js b/packages/eslint-config-airbnb/rules/react.js index 5f81e40c86..38b7dc25df 100644 --- a/packages/eslint-config-airbnb/rules/react.js +++ b/packages/eslint-config-airbnb/rules/react.js @@ -271,10 +271,10 @@ 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': ['error', { + 'react/no-unused-prop-types': ['warn', { customValidators: [ ], - skipShapeProps: false, + skipShapeProps: true, }], // Require style prop value be an object or var From 70428bdc37723167bb09792fcf013d63e2aecf37 Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Sat, 22 Oct 2016 01:04:16 -0700 Subject: [PATCH 109/826] [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 6acd4435a9..71069c6c1f 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.8.0", + "eslint": "^3.8.1", "eslint-find-rules": "^1.14.0", "eslint-plugin-import": "^2.0.1", "in-publish": "^2.0.0", @@ -55,7 +55,7 @@ "tape": "^4.6.2" }, "peerDependencies": { - "eslint": "^3.8.0", + "eslint": "^3.8.1", "eslint-plugin-import": "^2.0.1" }, "engines": { diff --git a/packages/eslint-config-airbnb/package.json b/packages/eslint-config-airbnb/package.json index 678a82b2a1..fa987a56f0 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.8.0", + "eslint": "^3.8.1", "eslint-find-rules": "^1.14.0", "eslint-plugin-import": "^2.0.1", "eslint-plugin-jsx-a11y": "^2.2.3", @@ -61,7 +61,7 @@ "tape": "^4.6.2" }, "peerDependencies": { - "eslint": "^3.8.0", + "eslint": "^3.8.1", "eslint-plugin-jsx-a11y": "^2.2.3", "eslint-plugin-import": "^2.0.1", "eslint-plugin-react": "^6.4.1" From 0e2b74a263594d258337a424bddb49f60ec0c368 Mon Sep 17 00:00:00 2001 From: SpenUK Date: Wed, 26 Oct 2016 15:50:49 +1100 Subject: [PATCH 110/826] Add links to mentioned github issues --- react/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/react/README.md b/react/README.md index 9d4d9da3e3..5ba21051f9 100644 --- a/react/README.md +++ b/react/README.md @@ -463,7 +463,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, and #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 adc782343eb862f313ef40849e11c7385a31da22 Mon Sep 17 00:00:00 2001 From: Pete Pirasis <1pete@users.noreply.github.com> Date: Thu, 27 Oct 2016 01:58:42 +0700 Subject: [PATCH 111/826] [react] add rule references in section *Spacing* --- react/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/react/README.md b/react/README.md index 5ba21051f9..7d8a32ebf1 100644 --- a/react/README.md +++ b/react/README.md @@ -206,7 +206,7 @@ ## Spacing - - Always include a single space in your self-closing tag. + - 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) ```jsx // bad From 05d06346270fae870537a10960166f60ea8a3bf8 Mon Sep 17 00:00:00 2001 From: Pete Pirasis <1pete@users.noreply.github.com> Date: Thu, 27 Oct 2016 03:31:58 +0700 Subject: [PATCH 112/826] Add reference for `Object.assign` --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index ad08a61bb4..a81d3a0380 100644 --- a/README.md +++ b/README.md @@ -294,7 +294,7 @@ Other Style Guides ``` - - [3.8](#objects--rest-spread) Prefer the object spread operator over `Object.assign` to shallow-copy objects. Use the object rest operator to get a new object with certain properties omitted. + - [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 From a23a3efba9d1661e52cfa6894d620cee965ac090 Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Mon, 31 Oct 2016 01:36:15 -0700 Subject: [PATCH 113/826] [eslint config] [base] [deps] [breaking] update `eslint` - enable `no-useless-return` - tighten up `indent` - loosen `max-len` with `ignoreRegExpLiterals` option --- .../eslint-config-airbnb-base/package.json | 4 ++-- .../rules/best-practices.js | 4 ++++ .../eslint-config-airbnb-base/rules/style.js | 24 +++++++++++++++++-- 3 files changed, 28 insertions(+), 4 deletions(-) diff --git a/packages/eslint-config-airbnb-base/package.json b/packages/eslint-config-airbnb-base/package.json index 71069c6c1f..f993986d99 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.8.1", + "eslint": "^3.9.0", "eslint-find-rules": "^1.14.0", "eslint-plugin-import": "^2.0.1", "in-publish": "^2.0.0", @@ -55,7 +55,7 @@ "tape": "^4.6.2" }, "peerDependencies": { - "eslint": "^3.8.1", + "eslint": "^3.9.0", "eslint-plugin-import": "^2.0.1" }, "engines": { diff --git a/packages/eslint-config-airbnb-base/rules/best-practices.js b/packages/eslint-config-airbnb-base/rules/best-practices.js index 31d06c60e0..e2dd67dd57 100644 --- a/packages/eslint-config-airbnb-base/rules/best-practices.js +++ b/packages/eslint-config-airbnb-base/rules/best-practices.js @@ -232,6 +232,10 @@ module.exports = { // http://eslint.org/docs/rules/no-useless-escape 'no-useless-escape': 'error', + // disallow redundant return; keywords + // http://eslint.org/docs/rules/no-useless-return + 'no-useless-return': 'error', + // disallow use of void operator // http://eslint.org/docs/rules/no-void 'no-void': 'error', diff --git a/packages/eslint-config-airbnb-base/rules/style.js b/packages/eslint-config-airbnb-base/rules/style.js index 53c76aef71..f201d1ca8b 100644 --- a/packages/eslint-config-airbnb-base/rules/style.js +++ b/packages/eslint-config-airbnb-base/rules/style.js @@ -35,7 +35,10 @@ module.exports = { // requires function names to match the name of the variable or property to which they are // assigned // http://eslint.org/docs/rules/func-name-matching - 'func-name-matching': ['off', { includeCommonJSModuleExports: false }], + 'func-name-matching': ['off', { + includeCommonJSModuleExports: false, + nameMatches: 'always' + }], // require function expressions to have a name // http://eslint.org/docs/rules/func-names @@ -59,7 +62,23 @@ module.exports = { // this option sets a specific tab width for your code // http://eslint.org/docs/rules/indent - indent: ['error', 2, { SwitchCase: 1, VariableDeclarator: 1, outerIIFEBody: 1 }], + indent: ['error', 2, { + SwitchCase: 1, + VariableDeclarator: 1, + outerIIFEBody: 1, + // MemberExpression: null, + // CallExpression: { + // parameters: null, + // }, + FunctionDeclaration: { + parameters: 1, + body: 1 + }, + FunctionExpression: { + parameters: 1, + body: 1 + } + }], // specify whether double or single quotes should be used in JSX attributes // http://eslint.org/docs/rules/jsx-quotes @@ -110,6 +129,7 @@ module.exports = { 'max-len': ['error', 100, 2, { ignoreUrls: true, ignoreComments: false, + ignoreRegExpLiterals: true, ignoreStrings: true, ignoreTemplateLiterals: true, }], From 9b649c843f85509fe9d1cb3e1da894d7a29e8e1f Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Mon, 31 Oct 2016 01:37:23 -0700 Subject: [PATCH 114/826] [eslint config] [*] [dev deps] update `eslint-find-rules` --- packages/eslint-config-airbnb-base/package.json | 2 +- packages/eslint-config-airbnb/package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/eslint-config-airbnb-base/package.json b/packages/eslint-config-airbnb-base/package.json index f993986d99..783eaa5c85 100644 --- a/packages/eslint-config-airbnb-base/package.json +++ b/packages/eslint-config-airbnb-base/package.json @@ -48,7 +48,7 @@ "babel-preset-airbnb": "^2.1.1", "babel-tape-runner": "^2.0.1", "eslint": "^3.9.0", - "eslint-find-rules": "^1.14.0", + "eslint-find-rules": "^1.14.3", "eslint-plugin-import": "^2.0.1", "in-publish": "^2.0.0", "safe-publish-latest": "^1.1.1", diff --git a/packages/eslint-config-airbnb/package.json b/packages/eslint-config-airbnb/package.json index fa987a56f0..17d511c20d 100644 --- a/packages/eslint-config-airbnb/package.json +++ b/packages/eslint-config-airbnb/package.json @@ -51,7 +51,7 @@ "babel-preset-airbnb": "^2.1.1", "babel-tape-runner": "^2.0.1", "eslint": "^3.8.1", - "eslint-find-rules": "^1.14.0", + "eslint-find-rules": "^1.14.3", "eslint-plugin-import": "^2.0.1", "eslint-plugin-jsx-a11y": "^2.2.3", "eslint-plugin-react": "^6.4.1", From 5da6fac8ccfacae8e28f4ee5d5cc74225e3da8d7 Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Mon, 31 Oct 2016 02:01:37 -0700 Subject: [PATCH 115/826] [eslint config] [base] correct typo from a23a3efba9d1661e52cfa6894d620cee965ac090 --- packages/eslint-config-airbnb-base/rules/best-practices.js | 2 +- packages/eslint-config-airbnb-base/rules/style.js | 5 ++--- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/packages/eslint-config-airbnb-base/rules/best-practices.js b/packages/eslint-config-airbnb-base/rules/best-practices.js index e2dd67dd57..b7e3f60630 100644 --- a/packages/eslint-config-airbnb-base/rules/best-practices.js +++ b/packages/eslint-config-airbnb-base/rules/best-practices.js @@ -179,7 +179,7 @@ module.exports = { 'no-restricted-properties': ['error', { object: 'arguments', property: 'callee', - message: 'arguments.callee is deprecated,' + message: 'arguments.callee is deprecated', }, { property: '__defineGetter__', message: 'Please use Object.defineProperty instead.', diff --git a/packages/eslint-config-airbnb-base/rules/style.js b/packages/eslint-config-airbnb-base/rules/style.js index f201d1ca8b..b3b0d6236d 100644 --- a/packages/eslint-config-airbnb-base/rules/style.js +++ b/packages/eslint-config-airbnb-base/rules/style.js @@ -35,9 +35,8 @@ module.exports = { // requires function names to match the name of the variable or property to which they are // assigned // http://eslint.org/docs/rules/func-name-matching - 'func-name-matching': ['off', { - includeCommonJSModuleExports: false, - nameMatches: 'always' + 'func-name-matching': ['off', 'always', { + includeCommonJSModuleExports: false }], // require function expressions to have a name From f3878876d2733930b049c2e566b450c64fcb3fc7 Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Mon, 31 Oct 2016 02:09:09 -0700 Subject: [PATCH 116/826] [eslint config] [deps] update `eslint` --- 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 17d511c20d..12c23441f6 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.8.1", + "eslint": "^3.9.0", "eslint-find-rules": "^1.14.3", "eslint-plugin-import": "^2.0.1", "eslint-plugin-jsx-a11y": "^2.2.3", @@ -61,7 +61,7 @@ "tape": "^4.6.2" }, "peerDependencies": { - "eslint": "^3.8.1", + "eslint": "^3.9.0", "eslint-plugin-jsx-a11y": "^2.2.3", "eslint-plugin-import": "^2.0.1", "eslint-plugin-react": "^6.4.1" From 5aec2c6691532b210fa7f5e45151e304a31fc8a8 Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Mon, 31 Oct 2016 02:22:30 -0700 Subject: [PATCH 117/826] [eslint config] [base] correct another typo from a23a3efba9d1661e52cfa6894d620cee965ac090 --- packages/eslint-config-airbnb-base/rules/style.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/eslint-config-airbnb-base/rules/style.js b/packages/eslint-config-airbnb-base/rules/style.js index b3b0d6236d..7d86567a1d 100644 --- a/packages/eslint-config-airbnb-base/rules/style.js +++ b/packages/eslint-config-airbnb-base/rules/style.js @@ -36,8 +36,8 @@ module.exports = { // assigned // http://eslint.org/docs/rules/func-name-matching 'func-name-matching': ['off', 'always', { - includeCommonJSModuleExports: false - }], + includeCommonJSModuleExports: false + }], // require function expressions to have a name // http://eslint.org/docs/rules/func-names From 4acb48b09a48bc8b0365cb4096f076d14dcb0873 Mon Sep 17 00:00:00 2001 From: dan-h-ch Date: Mon, 31 Oct 2016 12:22:40 -0700 Subject: [PATCH 118/826] Updated README.md - Corrected capitalize on GitHub --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index a81d3a0380..a105d6ee4c 100644 --- a/README.md +++ b/README.md @@ -2918,7 +2918,7 @@ Other Style Guides - [Naming this in nested functions](https://gist.github.com/cjohansen/4135065) - Christian Johansen - [Conditional Callbacks](https://github.com/airbnb/javascript/issues/52) - Ross Allen - - [Popular JavaScript Coding Conventions on Github](http://sideeffect.kr/popularconvention/#javascript) - JeongHoon Byun + - [Popular JavaScript Coding Conventions on GitHub](http://sideeffect.kr/popularconvention/#javascript) - JeongHoon Byun - [Multiple var statements in JavaScript, not superfluous](http://benalman.com/news/2012/05/multiple-var-statements-javascript/) - Ben Alman **Further Reading** From fbfe8812eeadc52a8b6a7eefbba49a45f520c7f5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gianfranc=C3=B8=20Palumbo?= Date: Mon, 31 Oct 2016 23:55:24 +0000 Subject: [PATCH 119/826] DailyJS is not longer being published --- README.md | 1 - 1 file changed, 1 deletion(-) diff --git a/README.md b/README.md index a105d6ee4c..7a6c4a78c1 100644 --- a/README.md +++ b/README.md @@ -2950,7 +2950,6 @@ Other Style Guides **Blogs** - - [DailyJS](http://dailyjs.com/) - [JavaScript Weekly](http://javascriptweekly.com/) - [JavaScript, JavaScript...](https://javascriptweblog.wordpress.com/) - [Bocoup Weblog](https://bocoup.com/weblog) From 9cbda0f0e73a17a6a63719e44b198b25c751b73d Mon Sep 17 00:00:00 2001 From: Nischay Venkatram Date: Mon, 31 Oct 2016 18:38:36 -0500 Subject: [PATCH 120/826] Updated README - Added sub-section for spaces in comments --- README.md | 42 +++++++++++++++++++++++++++++++++++++++--- 1 file changed, 39 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 7a6c4a78c1..8f3fad84a1 100644 --- a/README.md +++ b/README.md @@ -1922,11 +1922,47 @@ Other Style Guides } ``` + - [17.3](#comments--spaces) Start all comments with a space to make it easier to read. + + ```javascript + // bad + //is current tab + const active = true; + + // good + // is current tab + const active = true; + + // bad + /** + *make() returns a new element + *based on the passed-in tag name + */ + function make(tag) { + + // ...stuff... + + return element; + } + + // good + /** + * make() returns a new element + * based on the passed-in tag name + */ + function make(tag) { + + // ...stuff... + + return element; + } + ``` + - - [17.3](#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.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.4](#comments--fixme) Use `// FIXME:` to annotate problems. + - [17.5](#comments--fixme) Use `// FIXME:` to annotate problems. ```javascript class Calculator extends Abacus { @@ -1940,7 +1976,7 @@ Other Style Guides ``` - - [17.5](#comments--todo) Use `// TODO:` to annotate solutions to problems. + - [17.6](#comments--todo) Use `// TODO:` to annotate solutions to problems. ```javascript class Calculator extends Abacus { From 017dfa81fa2ffbb191ddb28240aa6098837b8d1b Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Mon, 31 Oct 2016 21:36:28 -0700 Subject: [PATCH 121/826] [Docs] add reference to spaced-comment rule; flesh out options --- README.md | 2 +- packages/eslint-config-airbnb-base/rules/style.js | 13 +++++++++++-- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 8f3fad84a1..29ba881063 100644 --- a/README.md +++ b/README.md @@ -1922,7 +1922,7 @@ Other Style Guides } ``` - - [17.3](#comments--spaces) Start all comments with a space to make it easier to read. + - [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) ```javascript // bad diff --git a/packages/eslint-config-airbnb-base/rules/style.js b/packages/eslint-config-airbnb-base/rules/style.js index 7d86567a1d..c9e7c0f7a9 100644 --- a/packages/eslint-config-airbnb-base/rules/style.js +++ b/packages/eslint-config-airbnb-base/rules/style.js @@ -351,9 +351,18 @@ 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', { - exceptions: ['-', '+'], - markers: ['=', '!'] // space here to support sprockets directives + line: { + exceptions: ['-', '+'], + markers: ['=', '!'], // space here to support sprockets directives + }, + block: { + exceptions: ['-', '+'], + markers: ['=', '!'], // space here to support sprockets directives + balanced: false, + } }], // require or disallow the Unicode Byte Order Mark From f9a5dd4919c30d575944ded3d9e33b233041ffe4 Mon Sep 17 00:00:00 2001 From: Kevin Grandon Date: Tue, 1 Nov 2016 13:54:07 -0700 Subject: [PATCH 122/826] Update JSX quote style rationale. Based on https://github.com/airbnb/javascript/issues/629#issuecomment-166384924. --- react/README.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/react/README.md b/react/README.md index 7d8a32ebf1..dbf3b0a0a2 100644 --- a/react/README.md +++ b/react/README.md @@ -187,8 +187,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? JSX attributes [can't contain escaped quotes](http://eslint.org/docs/rules/jsx-quotes), so double quotes make contractions like `"don't"` easier to type. - > 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 From c51251d17b8e38f1e8975a5e4eb13d7986229410 Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Wed, 2 Nov 2016 00:48:11 -0700 Subject: [PATCH 123/826] [guide] add section on multiline function signatures/invocations --- README.md | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/README.md b/README.md index 29ba881063..11f6d04d97 100644 --- a/README.md +++ b/README.md @@ -810,6 +810,39 @@ Other Style Guides new Date(...[2016, 08, 05]); ``` + + - [7.15](#functions--signature-invocation-indentation) Functions with multiline signatures, or invocations, should be indented just like every other multiline list in this guide: with each item on a line by itself, with a trailing comma on the last item. + + ```javascript + // bad + function foo(bar, + baz, + quux) { + // body + } + + // good + function foo( + bar, + baz, + quux, + ) { + // body + } + + // bad + console.log(foo, + bar, + baz); + + // good + console.log( + foo, + bar, + baz, + ); + ``` + **[⬆ back to top](#table-of-contents)** ## Arrow Functions From 788208295469e19b806c06e01095dc8ba1b6cdc9 Mon Sep 17 00:00:00 2001 From: Thomas Grainger Date: Tue, 1 Nov 2016 19:06:39 +0000 Subject: [PATCH 124/826] [eslint config] [base] [breaking] `comma-dangle`: require trailing commas for functions --- README.md | 54 ++++++++++++++++++- .../eslint-config-airbnb-base/rules/errors.js | 8 ++- 2 files changed, 59 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 11f6d04d97..1ed011d564 100644 --- a/README.md +++ b/README.md @@ -816,8 +816,8 @@ Other Style Guides ```javascript // bad function foo(bar, - baz, - quux) { + baz, + quux) { // body } @@ -2430,6 +2430,56 @@ Other Style Guides 'Batman', 'Superman', ]; + + // bad + function createHero( + firstName, + lastName, + inventorOf + ) { + // does nothing + } + + // good + function createHero( + firstName, + lastName, + inventorOf, + ) { + // does nothing + } + + // good (note that a comma must not appear after a "rest" element) + function createHero( + firstName, + lastName, + inventorOf, + ...heroArgs + ) { + // does nothing + } + + // bad + createHero( + firstName, + lastName, + inventorOf + ); + + // good + createHero( + firstName, + lastName, + inventorOf, + ); + + // good (note that a comma must not appear after a "rest" element) + createHero( + firstName, + lastName, + inventorOf, + ...heroArgs + ) ``` **[⬆ back to top](#table-of-contents)** diff --git a/packages/eslint-config-airbnb-base/rules/errors.js b/packages/eslint-config-airbnb-base/rules/errors.js index de6439b5e3..1849e8db4d 100644 --- a/packages/eslint-config-airbnb-base/rules/errors.js +++ b/packages/eslint-config-airbnb-base/rules/errors.js @@ -1,7 +1,13 @@ module.exports = { rules: { // require trailing commas in multiline object literals - 'comma-dangle': ['error', 'always-multiline'], + 'comma-dangle': ['error', { + arrays: 'always-multiline', + objects: 'always-multiline', + imports: 'always-multiline', + exports: 'always-multiline', + functions: 'always-multiline', + }], // disallow assignment in conditional expressions 'no-cond-assign': ['error', 'always'], From 86f52012cda6d9383f4afaf72aa3857ecaa0ce7d Mon Sep 17 00:00:00 2001 From: Ryan Busby Date: Tue, 1 Nov 2016 18:42:11 -0700 Subject: [PATCH 125/826] [guide] quotes: corrected casing Updated case to read the same in multiple spots. Added single quote example --- react/README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/react/README.md b/react/README.md index dbf3b0a0a2..714eea947a 100644 --- a/react/README.md +++ b/react/README.md @@ -185,7 +185,7 @@ ## Quotes - - Always use double quotes (`"`) for JSX attributes, but single quotes for all other JS. eslint: [`jsx-quotes`](http://eslint.org/docs/rules/jsx-quotes) + - Always use double quotes (`"`) for JSX attributes, but single quotes (`'`) for all other JS. eslint: [`jsx-quotes`](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. @@ -514,7 +514,7 @@ 1. `componentWillUnmount` 1. *clickHandlers or eventHandlers* like `onClickSubmit()` or `onChangeDescription()` 1. *getter methods for `render`* like `getSelectReason()` or `getFooterContent()` - 1. *Optional render methods* like `renderNavigation()` or `renderProfilePicture()` + 1. *optional render methods* like `renderNavigation()` or `renderProfilePicture()` 1. `render` - How to define `propTypes`, `defaultProps`, `contextTypes`, etc... @@ -569,7 +569,7 @@ 1. `componentWillUnmount` 1. *clickHandlers or eventHandlers* like `onClickSubmit()` or `onChangeDescription()` 1. *getter methods for `render`* like `getSelectReason()` or `getFooterContent()` - 1. *Optional render methods* like `renderNavigation()` or `renderProfilePicture()` + 1. *optional render methods* like `renderNavigation()` or `renderProfilePicture()` 1. `render` ## `isMounted` From 556846745cee3b2c9630ce69722c60986ea0c800 Mon Sep 17 00:00:00 2001 From: Mark Miyashita Date: Sun, 6 Nov 2016 05:19:22 -0800 Subject: [PATCH 126/826] [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 127/826] [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 128/826] 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 129/826] [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 130/826] [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 131/826] [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 132/826] [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 133/826] [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 134/826] [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 135/826] [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 136/826] [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 137/826] [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 138/826] [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 139/826] [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 140/826] 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 141/826] [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 142/826] [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 143/826] [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 144/826] [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 145/826] [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 146/826] [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 147/826] [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 148/826] [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 149/826] [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 150/826] [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 151/826] [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 152/826] 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 153/826] =?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 154/826] [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 155/826] [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 156/826] [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 157/826] [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 158/826] 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 159/826] [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 160/826] [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 161/826] [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 162/826] [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 163/826] [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 164/826] [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 165/826] [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 166/826] [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 167/826] 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 168/826] [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 169/826] [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 170/826] [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 171/826] [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 172/826] [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 173/826] 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 174/826] [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 175/826] [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 176/826] [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 177/826] [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 178/826] [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 179/826] [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 180/826] [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 181/826] [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 182/826] 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 183/826] [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 184/826] 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 185/826] 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 186/826] 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 187/826] 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 188/826] [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 189/826] [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 190/826] [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 191/826] [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 192/826] [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 193/826] [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 194/826] [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 195/826] [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 196/826] [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 197/826] [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 198/826] [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 199/826] [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 200/826] [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 201/826] [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 202/826] 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 203/826] 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 204/826] [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 205/826] [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 206/826] [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 207/826] [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 208/826] [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 209/826] [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 210/826] [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 211/826] [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 212/826] [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 213/826] [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 214/826] [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 215/826] 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 216/826] 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 217/826] 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 218/826] [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 219/826] 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 220/826] [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 221/826] 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 222/826] [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 223/826] 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 224/826] 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 225/826] [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 226/826] 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 227/826] [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 228/826] [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 229/826] [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 230/826] [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 231/826] [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 232/826] [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 233/826] [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 234/826] 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 235/826] 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 236/826] [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 237/826] [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 238/826] [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 239/826] [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 240/826] [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 241/826] [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 242/826] 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 243/826] 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 244/826] 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 245/826] 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 246/826] [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 247/826] [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 248/826] 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 249/826] 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 250/826] 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 251/826] 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 252/826] 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 253/826] [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 254/826] 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 255/826] [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 256/826] 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 257/826] [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 258/826] [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 259/826] [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 260/826] [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 261/826] [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 262/826] [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 263/826] [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 264/826] [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 265/826] [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 266/826] [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 267/826] [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 268/826] [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 269/826] [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 270/826] [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 271/826] [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 272/826] [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 273/826] [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 274/826] [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 275/826] [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 276/826] [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 277/826] [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 278/826] 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 279/826] [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 280/826] [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 281/826] [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 282/826] [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 283/826] [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 284/826] 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 285/826] 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 286/826] 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 287/826] [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 288/826] [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 289/826] [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 290/826] 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 291/826] [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 292/826] [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 293/826] [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 294/826] [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 295/826] [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 296/826] [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 297/826] [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 298/826] [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 299/826] [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 300/826] [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 301/826] 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 302/826] [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 303/826] [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 304/826] [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 305/826] [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 306/826] [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 307/826] [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 308/826] [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 309/826] [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 310/826] [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 311/826] [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 312/826] [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 313/826] [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 314/826] 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 315/826] [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 316/826] [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 317/826] [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 318/826] [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 319/826] [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 320/826] [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 321/826] [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 322/826] [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 323/826] [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 324/826] [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 325/826] [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 326/826] [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 327/826] 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 328/826] 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 329/826] 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 330/826] [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 331/826] 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 332/826] [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 333/826] 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 334/826] 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 335/826] [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 336/826] [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 337/826] 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 338/826] 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 339/826] [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 340/826] =?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 @@