From b6c56cb070445d62717913758d4b54f1efbdac77 Mon Sep 17 00:00:00 2001 From: Remco Haszing Date: Mon, 21 Jan 2019 13:39:53 +0100 Subject: [PATCH 1/4] [eslint config] [base] [patch] Allow use of `__REDUX_DEVTOOLS_EXTENSION_COMPOSE__` This style guide disallows the use of underscores in properties. However, the Redux browser extension requires the use of a variable named `__REDUX_DEVTOOLS_EXTENSION_COMPOSE__`. Since Redux is so popular with React, it makes sense to allow this. --- 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 d288bc5a..007f2764 100644 --- a/packages/eslint-config-airbnb-base/rules/style.js +++ b/packages/eslint-config-airbnb-base/rules/style.js @@ -369,7 +369,7 @@ module.exports = { // disallow dangling underscores in identifiers // https://eslint.org/docs/rules/no-underscore-dangle 'no-underscore-dangle': ['error', { - allow: [], + allow: ['__REDUX_DEVTOOLS_EXTENSION_COMPOSE__'], allowAfterThis: false, allowAfterSuper: false, enforceInMethodNames: true, From 1439ebe78d043ed8c206367b23406da7ddb7c3ce Mon Sep 17 00:00:00 2001 From: Telmen Munkhdalai Date: Sat, 26 Jan 2019 16:55:34 +0800 Subject: [PATCH 2/4] [editorial] [react] fix typo --- react/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/react/README.md b/react/README.md index 542aa1fd..51e035db 100644 --- a/react/README.md +++ b/react/README.md @@ -28,7 +28,7 @@ This style guide is mostly based on the standards that are currently prevalent i - However, multiple [Stateless, or Pure, Components](https://facebook.github.io/react/docs/reusable-components.html#stateless-functions) are allowed per file. eslint: [`react/no-multi-comp`](https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/no-multi-comp.md#ignorestateless). - Always use JSX syntax. - Do not use `React.createElement` unless you’re initializing the app from a file that is not JSX. - - [`react/forbid-prod-types`](https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/forbid-prop-types.md) will allow `arrays` and `objects` only if it is explicitly noted what `array` and `object` contains, using `arrayOf`, `objectOf`, or `shape`. + - [`react/forbid-prop-types`](https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/forbid-prop-types.md) will allow `arrays` and `objects` only if it is explicitly noted what `array` and `object` contains, using `arrayOf`, `objectOf`, or `shape`. ## Class vs `React.createClass` vs stateless From 25f11fb31e787a055329bdfaf9c4ad572780ac99 Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Sat, 26 Jan 2019 10:12:49 -0800 Subject: [PATCH 3/4] [eslint config] [patch] extend `no-underscore-dangle` to allow for redux dev tools in the main config instead --- packages/eslint-config-airbnb-base/rules/style.js | 2 +- packages/eslint-config-airbnb/rules/react.js | 9 +++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/packages/eslint-config-airbnb-base/rules/style.js b/packages/eslint-config-airbnb-base/rules/style.js index 007f2764..d288bc5a 100644 --- a/packages/eslint-config-airbnb-base/rules/style.js +++ b/packages/eslint-config-airbnb-base/rules/style.js @@ -369,7 +369,7 @@ module.exports = { // disallow dangling underscores in identifiers // https://eslint.org/docs/rules/no-underscore-dangle 'no-underscore-dangle': ['error', { - allow: ['__REDUX_DEVTOOLS_EXTENSION_COMPOSE__'], + allow: [], allowAfterThis: false, allowAfterSuper: false, enforceInMethodNames: true, diff --git a/packages/eslint-config-airbnb/rules/react.js b/packages/eslint-config-airbnb/rules/react.js index 527274da..eb3b6482 100644 --- a/packages/eslint-config-airbnb/rules/react.js +++ b/packages/eslint-config-airbnb/rules/react.js @@ -1,3 +1,8 @@ +const assign = require('object.assign'); +const baseStyleRules = require('eslint-config-airbnb-base/rules/style').rules; + +const dangleRules = baseStyleRules['no-underscore-dangle']; + module.exports = { plugins: [ 'react', @@ -12,6 +17,10 @@ module.exports = { // View link below for react rules documentation // https://github.com/yannickcr/eslint-plugin-react#list-of-supported-rules rules: { + 'no-underscore-dangle': [dangleRules[0], assign({}, dangleRules[1], { + allow: dangleRules[1].allow.concat(['__REDUX_DEVTOOLS_EXTENSION_COMPOSE__']), + })], + // Specify whether double or single quotes should be used in JSX attributes // https://eslint.org/docs/rules/jsx-quotes 'jsx-quotes': ['error', 'prefer-double'], From d8256fc886717c758cc3830478e072d897bd68b9 Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Sun, 27 Jan 2019 13:41:14 -0800 Subject: [PATCH 4/4] [eslint config] [*] [deps] update `object.entries`, `eslint-plugin-import`, `eslint-plugin-jsx-a11y`, `eslint-plugin-react` --- packages/eslint-config-airbnb-base/package.json | 6 +++--- .../eslint-config-airbnb-base/rules/imports.js | 4 ++++ packages/eslint-config-airbnb/package.json | 14 +++++++------- 3 files changed, 14 insertions(+), 10 deletions(-) diff --git a/packages/eslint-config-airbnb-base/package.json b/packages/eslint-config-airbnb-base/package.json index 4ec14976..3ad23c44 100644 --- a/packages/eslint-config-airbnb-base/package.json +++ b/packages/eslint-config-airbnb-base/package.json @@ -58,14 +58,14 @@ "editorconfig-tools": "^0.1.1", "eslint": "^4.19.1 || ^5.3.0", "eslint-find-rules": "^3.3.1", - "eslint-plugin-import": "^2.14.0", + "eslint-plugin-import": "^2.15.0", "in-publish": "^2.0.0", "safe-publish-latest": "^1.1.2", "tape": "^4.9.1" }, "peerDependencies": { "eslint": "^4.19.1 || ^5.3.0", - "eslint-plugin-import": "^2.14.0" + "eslint-plugin-import": "^2.15.0" }, "engines": { "node": ">= 4" @@ -73,6 +73,6 @@ "dependencies": { "confusing-browser-globals": "^1.0.5", "object.assign": "^4.1.0", - "object.entries": "^1.0.4" + "object.entries": "^1.1.0" } } diff --git a/packages/eslint-config-airbnb-base/rules/imports.js b/packages/eslint-config-airbnb-base/rules/imports.js index fbeca8dc..1853ae05 100644 --- a/packages/eslint-config-airbnb-base/rules/imports.js +++ b/packages/eslint-config-airbnb-base/rules/imports.js @@ -221,6 +221,10 @@ module.exports = { // https://github.com/benmosher/eslint-plugin-import/blob/44a038c06487964394b1e15b64f3bd34e5d40cde/docs/rules/no-default-export.md 'import/no-default-export': 'off', + // Prohibit named exports. this is a terrible rule, do not use it. + // https://github.com/benmosher/eslint-plugin-import/blob/1ec80fa35fa1819e2d35a70e68fb6a149fb57c5e/docs/rules/no-named-export.md + 'import/no-named-export': 'off', + // Forbid a module from importing itself // https://github.com/benmosher/eslint-plugin-import/blob/44a038c06487964394b1e15b64f3bd34e5d40cde/docs/rules/no-self-import.md 'import/no-self-import': 'error', diff --git a/packages/eslint-config-airbnb/package.json b/packages/eslint-config-airbnb/package.json index b45487a1..d5710640 100644 --- a/packages/eslint-config-airbnb/package.json +++ b/packages/eslint-config-airbnb/package.json @@ -56,7 +56,7 @@ "dependencies": { "eslint-config-airbnb-base": "^13.1.0", "object.assign": "^4.1.0", - "object.entries": "^1.0.4" + "object.entries": "^1.1.0" }, "devDependencies": { "babel-preset-airbnb": "^2.5.3", @@ -64,9 +64,9 @@ "editorconfig-tools": "^0.1.1", "eslint": "^4.19.1 || ^5.3.0", "eslint-find-rules": "^3.3.1", - "eslint-plugin-import": "^2.14.0", - "eslint-plugin-jsx-a11y": "^6.1.1", - "eslint-plugin-react": "^7.11.0", + "eslint-plugin-import": "^2.15.0", + "eslint-plugin-jsx-a11y": "^6.2.0", + "eslint-plugin-react": "^7.12.4", "in-publish": "^2.0.0", "react": ">= 0.13.0", "safe-publish-latest": "^1.1.2", @@ -74,9 +74,9 @@ }, "peerDependencies": { "eslint": "^4.19.1 || ^5.3.0", - "eslint-plugin-import": "^2.14.0", - "eslint-plugin-jsx-a11y": "^6.1.1", - "eslint-plugin-react": "^7.11.0" + "eslint-plugin-import": "^2.15.0", + "eslint-plugin-jsx-a11y": "^6.2.0", + "eslint-plugin-react": "^7.12.4" }, "engines": { "node": ">= 4"