From 711aeb650db14c3b8cc329511ac508ee05bc1af6 Mon Sep 17 00:00:00 2001 From: kimhanui <30483337+kimhanui@users.noreply.github.com> Date: Thu, 18 Mar 2021 08:43:41 +0900 Subject: [PATCH 001/122] [editorial] Complete 19.6 example code (cut in the middle) Fixes #2403 --- README.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/README.md b/README.md index 284ca26e7f..f7e0823c55 100644 --- a/README.md +++ b/README.md @@ -2618,6 +2618,10 @@ Other Style Guides // good const leds = stage.selectAll('.led').data(data); + const svg = leds.enter().append('svg:svg'); + svg.classed('led', true).attr(width', (radius + margin) * 2); + const g = svg.append('svg:g'); + g.attr('transform', `translate(${radius + margin},${radius + margin})`).call(tron.led); ``` From 1b540ba14ea15c28f4028e4216373d0eeb96dde0 Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Wed, 24 Mar 2021 23:32:41 -0700 Subject: [PATCH 002/122] [*] [dev deps] update `tape` --- 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 b86a415362..10a35679e0 100644 --- a/packages/eslint-config-airbnb-base/package.json +++ b/packages/eslint-config-airbnb-base/package.json @@ -62,7 +62,7 @@ "eslint-plugin-import": "^2.22.1", "in-publish": "^2.0.1", "safe-publish-latest": "^1.1.4", - "tape": "^5.1.0" + "tape": "^5.2.2" }, "peerDependencies": { "eslint": "^5.16.0 || ^6.8.0 || ^7.2.0", diff --git a/packages/eslint-config-airbnb/package.json b/packages/eslint-config-airbnb/package.json index f3a9057e5c..22e0b639cb 100644 --- a/packages/eslint-config-airbnb/package.json +++ b/packages/eslint-config-airbnb/package.json @@ -72,7 +72,7 @@ "in-publish": "^2.0.1", "react": ">= 0.13.0", "safe-publish-latest": "^1.1.4", - "tape": "^5.1.0" + "tape": "^5.2.2" }, "peerDependencies": { "eslint": "^5.16.0 || ^6.8.0 || ^7.2.0", From 4d837646b7ae2a37780f91423479e65949863570 Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Wed, 24 Mar 2021 23:33:38 -0700 Subject: [PATCH 003/122] [eslint config] [deps] update `eslint-plugin-react` --- packages/eslint-config-airbnb/package.json | 6 +++--- packages/eslint-config-airbnb/rules/react.js | 5 +++++ 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/packages/eslint-config-airbnb/package.json b/packages/eslint-config-airbnb/package.json index 22e0b639cb..641c731139 100644 --- a/packages/eslint-config-airbnb/package.json +++ b/packages/eslint-config-airbnb/package.json @@ -59,7 +59,7 @@ "object.entries": "^1.1.3" }, "devDependencies": { - "@babel/runtime": "^7.12.5", + "@babel/runtime": "^7.13.10", "babel-preset-airbnb": "^4.5.0", "babel-tape-runner": "^3.0.0", "eclint": "^2.8.1", @@ -67,7 +67,7 @@ "eslint-find-rules": "^3.6.1", "eslint-plugin-import": "^2.22.1", "eslint-plugin-jsx-a11y": "^6.4.1", - "eslint-plugin-react": "^7.22.0", + "eslint-plugin-react": "^7.23.1", "eslint-plugin-react-hooks": "^4 || ^3 || ^2.3.0 || ^1.7.0", "in-publish": "^2.0.1", "react": ">= 0.13.0", @@ -78,7 +78,7 @@ "eslint": "^5.16.0 || ^6.8.0 || ^7.2.0", "eslint-plugin-import": "^2.22.1", "eslint-plugin-jsx-a11y": "^6.4.1", - "eslint-plugin-react": "^7.22.0", + "eslint-plugin-react": "^7.23.1", "eslint-plugin-react-hooks": "^4 || ^3 || ^2.3.0 || ^1.7.0" }, "engines": { diff --git a/packages/eslint-config-airbnb/rules/react.js b/packages/eslint-config-airbnb/rules/react.js index 24d9fffaa5..a077e4c113 100644 --- a/packages/eslint-config-airbnb/rules/react.js +++ b/packages/eslint-config-airbnb/rules/react.js @@ -540,6 +540,11 @@ module.exports = { // https://github.com/yannickcr/eslint-plugin-react/blob/e2eaadae316f9506d163812a09424eb42698470a/docs/rules/jsx-no-constructed-context-values.md // TODO: enable, semver-minor 'react/jsx-no-constructed-context-values': 'off', + + // Prevent creating unstable components inside components + // https://github.com/yannickcr/eslint-plugin-react/blob/c2a790a3472eea0f6de984bdc3ee2a62197417fb/docs/rules/no-unstable-nested-components.md + // TODO: enable, semver-major + 'react/no-unstable-nested-components': 'off', }, settings: { From 730b74927432d5931f9047322e925fb7e1c07be6 Mon Sep 17 00:00:00 2001 From: Diane Ko Date: Wed, 24 Mar 2021 18:38:08 -0700 Subject: [PATCH 004/122] [eslint config] [patch] Alphabetize the rules for react-a11y.js The ordering of the rules are currently not alphabetical, which can make it hard to tell whether there are rules missing or what's set for each rule from eslint-plugin-jsx-a11y. This change alphabetizes the list so it's easier to compare to the [list of supported rules](https://github.com/jsx-eslint/eslint-plugin-jsx-a11y#supported-rules) --- .../eslint-config-airbnb/rules/react-a11y.js | 260 +++++++++--------- 1 file changed, 132 insertions(+), 128 deletions(-) diff --git a/packages/eslint-config-airbnb/rules/react-a11y.js b/packages/eslint-config-airbnb/rules/react-a11y.js index 5898ca9eb3..f7bf7c79e6 100644 --- a/packages/eslint-config-airbnb/rules/react-a11y.js +++ b/packages/eslint-config-airbnb/rules/react-a11y.js @@ -11,13 +11,36 @@ module.exports = { }, rules: { + // ensure emoji are accessible + // https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/accessible-emoji.md + // disabled; rule is deprecated + 'jsx-a11y/accessible-emoji': 'off', + + // 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"]': [], + }], + // 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: [] }], - // 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', { ignoreNonDOM: false }], + // ensure tags are valid + // https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/0745af376cdc8686d85a361ce36952b1fb1ccf6e/docs/rules/anchor-is-valid.md + 'jsx-a11y/anchor-is-valid': ['error', { + components: ['Link'], + specialLink: ['to'], + aspects: ['noHref', 'invalidHref', 'preferButton'], + }], + + // 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', // Enforce all aria-* props are valid. // https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/aria-props.md @@ -27,45 +50,24 @@ module.exports = { // https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/aria-proptypes.md 'jsx-a11y/aria-proptypes': '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 + 'jsx-a11y/aria-role': ['error', { ignoreNonDOM: false }], + // 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': '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 - '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 - // deprecated: replaced by `label-has-associated-control` rule - 'jsx-a11y/label-has-for': ['off', { - components: [], - required: { - every: ['nesting', 'id'], - }, - allowChildren: false, + // Ensure the autocomplete attribute is correct and suitable for the form field it is used with + // https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/blob/29c68596b15c4ff0a40daae6d4a2670e36e37d35/docs/rules/autocomplete-valid.md + 'jsx-a11y/autocomplete-valid': ['off', { + inputComponents: [], }], - // Enforce that a label tag has a text label and an associated control. - // https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/b800f40a2a69ad48015ae9226fbe879f946757ed/docs/rules/label-has-associated-control.md - 'jsx-a11y/label-has-associated-control': ['error', { - labelComponents: [], - labelAttributes: [], - controlComponents: [], - assert: 'both', - depth: 25 - }], + // require 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 + 'jsx-a11y/click-events-have-key-events': 'error', // Enforce that a control (an interactive element) has a text label. // https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/control-has-associated-label.md @@ -96,47 +98,59 @@ module.exports = { depth: 5, }], - // require that mouseover/out come with focus/blur, for keyboard-only users - // https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/mouse-events-have-key-events.md - 'jsx-a11y/mouse-events-have-key-events': 'error', + // 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', { components: [''] }], - // 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': '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': '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': 'off', + // 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', + + // 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': 'error', // 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. - // 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': 'error', + // Enforce that a label tag has a text label and an associated control. + // https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/b800f40a2a69ad48015ae9226fbe879f946757ed/docs/rules/label-has-associated-control.md + 'jsx-a11y/label-has-associated-control': ['error', { + labelComponents: [], + labelAttributes: [], + controlComponents: [], + assert: 'both', + depth: 25 + }], - // 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': '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': 'error', - // Enforce tabIndex value is not greater than zero. - // https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/tabindex-no-positive.md - 'jsx-a11y/tabindex-no-positive': '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: [], + }], - // 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', { components: [''] }], + // require that mouseover/out come with focus/blur, for keyboard-only users + // https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/mouse-events-have-key-events.md + 'jsx-a11y/mouse-events-have-key-events': 'error', - // 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': 'error', + // 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': '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': 'error', + // prohibit autoFocus prop + // https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/no-autofocus.md + 'jsx-a11y/no-autofocus': ['error', { ignoreNonDOM: true }], // prevent distracting elements, like and // https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/no-distracting-elements.md @@ -144,25 +158,10 @@ module.exports = { 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', - - // 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 - '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 - 'jsx-a11y/no-static-element-interactions': ['error', { - handlers: [ - 'onClick', - 'onMouseDown', - 'onMouseUp', - 'onKeyPress', - 'onKeyDown', - 'onKeyUp', - ] + // 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'], }], // A non-interactive element does not support event handlers (mouse and key handlers) @@ -178,41 +177,6 @@ module.exports = { ] }], - // ensure emoji are accessible - // https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/accessible-emoji.md - // disabled; rule is deprecated - 'jsx-a11y/accessible-emoji': 'off', - - // 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', { 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', { @@ -230,18 +194,58 @@ module.exports = { roles: ['tabpanel'], }], - // ensure tags are valid - // https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/0745af376cdc8686d85a361ce36952b1fb1ccf6e/docs/rules/anchor-is-valid.md - 'jsx-a11y/anchor-is-valid': ['error', { - components: ['Link'], - specialLink: ['to'], - aspects: ['noHref', 'invalidHref', 'preferButton'], + // require onBlur instead of onChange + // https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/no-onchange.md + 'jsx-a11y/no-onchange': 'off', + + // 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', + + // 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', { + handlers: [ + 'onClick', + 'onMouseDown', + 'onMouseUp', + 'onKeyPress', + 'onKeyDown', + 'onKeyUp', + ] }], - // Ensure the autocomplete attribute is correct and suitable for the form field it is used with - // https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/blob/29c68596b15c4ff0a40daae6d4a2670e36e37d35/docs/rules/autocomplete-valid.md - 'jsx-a11y/autocomplete-valid': ['off', { - inputComponents: [], + // 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': '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': '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', + + // Enforce tabIndex value is not greater than zero. + // https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/tabindex-no-positive.md + 'jsx-a11y/tabindex-no-positive': 'error', + + // ---------------------------------------------------- + // Rules that no longer exist in eslint-plugin-jsx-a11y + // ---------------------------------------------------- + + // require that JSX labels use "htmlFor" + // https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/label-has-for.md + // deprecated: replaced by `label-has-associated-control` rule + 'jsx-a11y/label-has-for': ['off', { + components: [], + required: { + every: ['nesting', 'id'], + }, + allowChildren: false, }], }, }; From 0cf78acab0fff90e9591dedd8783b62a72ffc118 Mon Sep 17 00:00:00 2001 From: Cong Zhang Date: Wed, 24 Mar 2021 18:17:15 +0800 Subject: [PATCH 005/122] [guide] Fix 19.6 example code --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index f7e0823c55..c4d803e303 100644 --- a/README.md +++ b/README.md @@ -2619,7 +2619,7 @@ Other Style Guides // good const leds = stage.selectAll('.led').data(data); const svg = leds.enter().append('svg:svg'); - svg.classed('led', true).attr(width', (radius + margin) * 2); + svg.classed('led', true).attr('width', (radius + margin) * 2); const g = svg.append('svg:g'); g.attr('transform', `translate(${radius + margin},${radius + margin})`).call(tron.led); ``` From 1eadb93e377da1e56c3f91f26610e5d0a00738a9 Mon Sep 17 00:00:00 2001 From: Mackenzie Morgan Date: Thu, 17 Dec 2020 00:18:29 -0500 Subject: [PATCH 006/122] [eslint config] [fix] bump eslint-plugin-react-hooks peer dependency version Fixes #2355 --- 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 641c731139..be32b6e667 100644 --- a/packages/eslint-config-airbnb/package.json +++ b/packages/eslint-config-airbnb/package.json @@ -68,7 +68,7 @@ "eslint-plugin-import": "^2.22.1", "eslint-plugin-jsx-a11y": "^6.4.1", "eslint-plugin-react": "^7.23.1", - "eslint-plugin-react-hooks": "^4 || ^3 || ^2.3.0 || ^1.7.0", + "eslint-plugin-react-hooks": "^4.0.1 || ^3 || ^2.3.0 || ^1.7.0", "in-publish": "^2.0.1", "react": ">= 0.13.0", "safe-publish-latest": "^1.1.4", @@ -79,7 +79,7 @@ "eslint-plugin-import": "^2.22.1", "eslint-plugin-jsx-a11y": "^6.4.1", "eslint-plugin-react": "^7.23.1", - "eslint-plugin-react-hooks": "^4 || ^3 || ^2.3.0 || ^1.7.0" + "eslint-plugin-react-hooks": "^4.0.1 || ^3 || ^2.3.0 || ^1.7.0" }, "engines": { "node": ">= 6" From dc3af3a90ebf56a5e9df2d4c7b40d6518200bb87 Mon Sep 17 00:00:00 2001 From: Kiran S <18kirans@gmail.com> Date: Mon, 3 May 2021 21:39:00 +0530 Subject: [PATCH 007/122] [eslint config] [base] update default value for complexity --- 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 e3420416ef..0587e8f496 100644 --- a/packages/eslint-config-airbnb-base/rules/best-practices.js +++ b/packages/eslint-config-airbnb-base/rules/best-practices.js @@ -11,7 +11,7 @@ module.exports = { 'block-scoped-var': 'error', // specify the maximum cyclomatic complexity allowed in a program - complexity: ['off', 11], + complexity: ['off', 20], // enforce that class methods use "this" // https://eslint.org/docs/rules/class-methods-use-this From 5641278fa1df75ba3b6af2959a553bd682c0ad42 Mon Sep 17 00:00:00 2001 From: Kushang Shah Date: Fri, 23 Apr 2021 09:12:07 +0530 Subject: [PATCH 008/122] [editorial] add `var` info to `let`/`const` section --- README.md | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index c4d803e303..08d5af1922 100644 --- a/README.md +++ b/README.md @@ -139,18 +139,22 @@ Other Style Guides ``` - - [2.3](#references--block-scope) Note that both `let` and `const` are block-scoped. + - [2.3](#references--block-scope) Note that both `let` and `const` are block-scoped, whereas `var` is function-scoped. ```javascript // const and let only exist in the blocks they are defined in. { let a = 1; const b = 1; + var c = 1; } console.log(a); // ReferenceError console.log(b); // ReferenceError + console.log(c); // Prints 1 ``` + In the above code, you can see that referencing `a` and `b` will produce a ReferenceError, while `c` contains the number. This is because `a` and `b` are block scoped, while `c` is scoped to the containing function. + **[⬆ back to top](#table-of-contents)** ## Objects From 1fb4592122ef94029b3ff2f361408f0681751253 Mon Sep 17 00:00:00 2001 From: Kiran S <18kirans@gmail.com> Date: Tue, 4 May 2021 21:15:46 +0530 Subject: [PATCH 009/122] [guide] add references for eslint rules --- .../rules/best-practices.js | 48 ++++++++++++++++++- 1 file changed, 47 insertions(+), 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 0587e8f496..deb91cfb01 100644 --- a/packages/eslint-config-airbnb-base/rules/best-practices.js +++ b/packages/eslint-config-airbnb-base/rules/best-practices.js @@ -1,6 +1,7 @@ module.exports = { rules: { // enforces getter/setter pairs in objects + // https://eslint.org/docs/rules/accessor-pairs 'accessor-pairs': 'off', // enforces return statements in callbacks of array's methods @@ -8,9 +9,11 @@ module.exports = { 'array-callback-return': ['error', { allowImplicit: true }], // treat var statements as if they were block scoped + // https://eslint.org/docs/rules/block-scoped-var 'block-scoped-var': 'error', // specify the maximum cyclomatic complexity allowed in a program + // https://eslint.org/docs/rules/complexity complexity: ['off', 20], // enforce that class methods use "this" @@ -20,12 +23,15 @@ module.exports = { }], // require return statements to either always or never specify values + // https://eslint.org/docs/rules/consistent-return 'consistent-return': 'error', // specify curly brace conventions for all control statements + // https://eslint.org/docs/rules/curly curly: ['error', 'multi-line'], // multiline // require default case in switch statements + // https://eslint.org/docs/rules/default-case 'default-case': ['error', { commentPattern: '^no default$' }], // Enforce default clauses in switch statements to be last @@ -38,6 +44,7 @@ module.exports = { 'default-param-last': 'off', // encourages use of dot notation whenever possible + // https://eslint.org/docs/rules/dot-notation 'dot-notation': ['error', { allowKeywords: true }], // enforces consistent newlines before or after dots @@ -54,6 +61,7 @@ module.exports = { 'grouped-accessor-pairs': 'off', // make sure for-in loops have an if statement + // https://eslint.org/docs/rules/guard-for-in 'guard-for-in': 'error', // enforce a maximum number of classes per file @@ -61,13 +69,15 @@ module.exports = { 'max-classes-per-file': ['error', 1], // disallow the use of alert, confirm, and prompt + // https://eslint.org/docs/rules/no-alert 'no-alert': 'warn', // disallow use of arguments.caller or arguments.callee + // https://eslint.org/docs/rules/no-caller 'no-caller': 'error', // disallow lexical declarations in case/default clauses - // https://eslint.org/docs/rules/no-case-declarations.html + // https://eslint.org/docs/rules/no-case-declarations 'no-case-declarations': 'error', // Disallow returning value in constructor @@ -98,15 +108,19 @@ module.exports = { 'no-empty-pattern': 'error', // disallow comparisons to null without a type-checking operator + // https://eslint.org/docs/rules/no-eq-null 'no-eq-null': 'off', // disallow use of eval() + // https://eslint.org/docs/rules/no-eval 'no-eval': 'error', // disallow adding to native types + // https://eslint.org/docs/rules/no-extend-native 'no-extend-native': 'error', // disallow unnecessary function binding + // https://eslint.org/docs/rules/no-extra-bind 'no-extra-bind': 'error', // disallow Unnecessary Labels @@ -114,15 +128,19 @@ module.exports = { 'no-extra-label': 'error', // disallow fallthrough of case statements + // https://eslint.org/docs/rules/no-fallthrough 'no-fallthrough': 'error', // disallow the use of leading or trailing decimal points in numeric literals + // https://eslint.org/docs/rules/no-floating-decimal 'no-floating-decimal': 'error', // disallow reassignments of native objects or read-only globals // https://eslint.org/docs/rules/no-global-assign 'no-global-assign': ['error', { exceptions: [] }], + // deprecated in favor of no-global-assign + // https://eslint.org/docs/rules/no-native-reassign 'no-native-reassign': 'off', // disallow implicit type conversions @@ -139,21 +157,27 @@ module.exports = { 'no-implicit-globals': 'off', // disallow use of eval()-like methods + // https://eslint.org/docs/rules/no-implied-eval 'no-implied-eval': 'error', // disallow this keywords outside of classes or class-like objects + // https://eslint.org/docs/rules/no-invalid-this 'no-invalid-this': 'off', // disallow usage of __iterator__ property + // https://eslint.org/docs/rules/no-iterator 'no-iterator': 'error', // disallow use of labels for anything other than loops and switches + // https://eslint.org/docs/rules/no-labels 'no-labels': ['error', { allowLoop: false, allowSwitch: false }], // disallow unnecessary nested blocks + // https://eslint.org/docs/rules/no-lone-blocks 'no-lone-blocks': 'error', // disallow creation of functions within loops + // https://eslint.org/docs/rules/no-loop-func 'no-loop-func': 'error', // disallow magic numbers @@ -166,20 +190,25 @@ module.exports = { }], // disallow use of multiple spaces + // https://eslint.org/docs/rules/no-multi-spaces 'no-multi-spaces': ['error', { ignoreEOLComments: false, }], // disallow use of multiline strings + // https://eslint.org/docs/rules/no-multi-str 'no-multi-str': 'error', // disallow use of new operator when not part of the assignment or comparison + // https://eslint.org/docs/rules/no-new 'no-new': 'error', // disallow use of new operator for Function object + // https://eslint.org/docs/rules/no-new-func 'no-new-func': 'error', // disallows creating new instances of String, Number, and Boolean + // https://eslint.org/docs/rules/no-new-wrappers 'no-new-wrappers': 'error', // Disallow \8 and \9 escape sequences in string literals @@ -188,10 +217,12 @@ module.exports = { 'no-nonoctal-decimal-escape': 'off', // disallow use of (old style) octal literals + // https://eslint.org/docs/rules/no-octal 'no-octal': 'error', // disallow use of octal escape sequences in string literals, such as // var foo = 'Copyright \251'; + // https://eslint.org/docs/rules/no-octal-escape 'no-octal-escape': 'error', // disallow reassignment of function parameters @@ -215,9 +246,11 @@ module.exports = { }], // disallow usage of __proto__ property + // https://eslint.org/docs/rules/no-proto 'no-proto': 'error', // disallow declaring the same variable more than once + // https://eslint.org/docs/rules/no-redeclare 'no-redeclare': 'error', // disallow certain object properties @@ -263,12 +296,15 @@ module.exports = { }], // disallow use of assignment in return statement + // https://eslint.org/docs/rules/no-return-assign 'no-return-assign': ['error', 'always'], // disallow redundant `return await` + // https://eslint.org/docs/rules/no-return-await 'no-return-await': 'error', // disallow use of `javascript:` urls. + // https://eslint.org/docs/rules/no-script-url 'no-script-url': 'error', // disallow self assignment @@ -278,12 +314,15 @@ module.exports = { }], // disallow comparisons where both sides are exactly the same + // https://eslint.org/docs/rules/no-self-compare 'no-self-compare': 'error', // disallow use of comma operator + // https://eslint.org/docs/rules/no-sequences 'no-sequences': 'error', // restrict what can be thrown as an exception + // https://eslint.org/docs/rules/no-throw-literal 'no-throw-literal': 'error', // disallow unmodified conditions of loops @@ -291,6 +330,7 @@ module.exports = { 'no-unmodified-loop-condition': 'off', // disallow usage of expressions in statement position + // https://eslint.org/docs/rules/no-unused-expressions 'no-unused-expressions': ['error', { allowShortCircuit: false, allowTernary: false, @@ -302,6 +342,7 @@ module.exports = { 'no-unused-labels': 'error', // disallow unnecessary .call() and .apply() + // https://eslint.org/docs/rules/no-useless-call 'no-useless-call': 'off', // Disallow unnecessary catch clauses @@ -325,9 +366,11 @@ module.exports = { 'no-void': 'error', // disallow usage of configurable warning terms in comments: e.g. todo + // https://eslint.org/docs/rules/no-warning-comments 'no-warning-comments': ['off', { terms: ['todo', 'fixme', 'xxx'], location: 'start' }], // disallow use of the with statement + // https://eslint.org/docs/rules/no-with 'no-with': 'error', // require using Error objects as Promise rejection reasons @@ -343,6 +386,7 @@ module.exports = { 'prefer-regex-literals': 'off', // require use of the second argument for parseInt() + // https://eslint.org/docs/rules/radix radix: 'error', // require `await` in `async function` (note: this is a horrible rule that should never be used) @@ -354,6 +398,7 @@ module.exports = { 'require-unicode-regexp': 'off', // requires to declare all vars on top of their containing scope + // https://eslint.org/docs/rules/vars-on-top 'vars-on-top': 'error', // require immediate function invocation to be wrapped in parentheses @@ -361,6 +406,7 @@ module.exports = { 'wrap-iife': ['error', 'outside', { functionPrototypeMethods: false }], // require or disallow Yoda conditions + // https://eslint.org/docs/rules/yoda yoda: 'error' } }; From 35914b14025cd52f53cd2ae2f353cdc7384087c0 Mon Sep 17 00:00:00 2001 From: Asher Hwang Date: Tue, 11 May 2021 09:08:23 +0900 Subject: [PATCH 010/122] [guide] Spread operator => Spread syntax --- README.md | 4 ++-- packages/eslint-config-airbnb-base/rules/es6.js | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 08d5af1922..c90eba926b 100644 --- a/README.md +++ b/README.md @@ -310,7 +310,7 @@ Other Style Guides ``` - - [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. eslint: [`prefer-object-spread`](https://eslint.org/docs/rules/prefer-object-spread) + - [3.8](#objects--rest-spread) Prefer the object spread syntax 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. eslint: [`prefer-object-spread`](https://eslint.org/docs/rules/prefer-object-spread) ```javascript // very bad @@ -875,7 +875,7 @@ Other Style Guides ``` - - [7.14](#functions--spread-vs-apply) Prefer the use of the spread operator `...` to call variadic functions. eslint: [`prefer-spread`](https://eslint.org/docs/rules/prefer-spread) + - [7.14](#functions--spread-vs-apply) Prefer the use of the spread syntax `...` to call variadic functions. eslint: [`prefer-spread`](https://eslint.org/docs/rules/prefer-spread) > Why? It’s cleaner, you don’t need to supply a context, and you can not easily compose `new` with `apply`. diff --git a/packages/eslint-config-airbnb-base/rules/es6.js b/packages/eslint-config-airbnb-base/rules/es6.js index 02c616dad5..835afdd319 100644 --- a/packages/eslint-config-airbnb-base/rules/es6.js +++ b/packages/eslint-config-airbnb-base/rules/es6.js @@ -146,7 +146,7 @@ module.exports = { // https://eslint.org/docs/rules/prefer-rest-params 'prefer-rest-params': 'error', - // suggest using the spread operator instead of .apply() + // suggest using the spread syntax instead of .apply() // https://eslint.org/docs/rules/prefer-spread 'prefer-spread': 'error', From d5d406a849f03b8ce1bc8848acb7ef1690d29c85 Mon Sep 17 00:00:00 2001 From: amirvatani Date: Sun, 9 May 2021 00:10:31 -0700 Subject: [PATCH 011/122] [readme] add AloPeyk to "in the wild" --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index c90eba926b..cf0be8e37c 100644 --- a/README.md +++ b/README.md @@ -3846,6 +3846,7 @@ Other Style Guides - **4Catalyzer**: [4Catalyzer/javascript](https://github.com/4Catalyzer/javascript) - **Aan Zee**: [AanZee/javascript](https://github.com/AanZee/javascript) - **Airbnb**: [airbnb/javascript](https://github.com/airbnb/javascript) + - **AloPeyk**: [AloPeyk](https://github.com/AloPeyk) - **AltSchool**: [AltSchool/javascript](https://github.com/AltSchool/javascript) - **Apartmint**: [apartmint/javascript](https://github.com/apartmint/javascript) - **Ascribe**: [ascribe/javascript](https://github.com/ascribe/javascript) From af8bdf17ddf7752021ef6cbfe5c23ac8fb307f26 Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Tue, 29 Jun 2021 09:56:18 -0700 Subject: [PATCH 012/122] [*] [deps] update `object.entries` --- 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 10a35679e0..bc9ad248a0 100644 --- a/packages/eslint-config-airbnb-base/package.json +++ b/packages/eslint-config-airbnb-base/package.json @@ -74,6 +74,6 @@ "dependencies": { "confusing-browser-globals": "^1.0.10", "object.assign": "^4.1.2", - "object.entries": "^1.1.3" + "object.entries": "^1.1.4" } } diff --git a/packages/eslint-config-airbnb/package.json b/packages/eslint-config-airbnb/package.json index be32b6e667..c16dde4a4e 100644 --- a/packages/eslint-config-airbnb/package.json +++ b/packages/eslint-config-airbnb/package.json @@ -56,7 +56,7 @@ "dependencies": { "eslint-config-airbnb-base": "^14.2.1", "object.assign": "^4.1.2", - "object.entries": "^1.1.3" + "object.entries": "^1.1.4" }, "devDependencies": { "@babel/runtime": "^7.13.10", From 428c9ddb7e27466c74fb3b02d20d427d8500f7c9 Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Tue, 29 Jun 2021 10:03:15 -0700 Subject: [PATCH 013/122] [*] [deps] update `@babel/runtime`, `eslint-plugin-import`, `eslint-plugin-react` --- packages/eslint-config-airbnb-base/.eslintrc | 2 ++ packages/eslint-config-airbnb-base/package.json | 6 +++--- packages/eslint-config-airbnb-base/rules/imports.js | 12 ++++++++++++ packages/eslint-config-airbnb/package.json | 6 +++--- 4 files changed, 20 insertions(+), 6 deletions(-) diff --git a/packages/eslint-config-airbnb-base/.eslintrc b/packages/eslint-config-airbnb-base/.eslintrc index ab2c306fd9..7606a50a46 100644 --- a/packages/eslint-config-airbnb-base/.eslintrc +++ b/packages/eslint-config-airbnb-base/.eslintrc @@ -4,5 +4,7 @@ // 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, + + "max-len": 0, }, } diff --git a/packages/eslint-config-airbnb-base/package.json b/packages/eslint-config-airbnb-base/package.json index bc9ad248a0..4da8fcd9bc 100644 --- a/packages/eslint-config-airbnb-base/package.json +++ b/packages/eslint-config-airbnb-base/package.json @@ -53,20 +53,20 @@ }, "homepage": "https://github.com/airbnb/javascript", "devDependencies": { - "@babel/runtime": "^7.12.5", + "@babel/runtime": "^7.14.6", "babel-preset-airbnb": "^4.5.0", "babel-tape-runner": "^3.0.0", "eclint": "^2.8.1", "eslint": "^5.16.0 || ^6.8.0 || ^7.2.0", "eslint-find-rules": "^3.6.1", - "eslint-plugin-import": "^2.22.1", + "eslint-plugin-import": "^2.23.4", "in-publish": "^2.0.1", "safe-publish-latest": "^1.1.4", "tape": "^5.2.2" }, "peerDependencies": { "eslint": "^5.16.0 || ^6.8.0 || ^7.2.0", - "eslint-plugin-import": "^2.22.1" + "eslint-plugin-import": "^2.23.4" }, "engines": { "node": ">= 6" diff --git a/packages/eslint-config-airbnb-base/rules/imports.js b/packages/eslint-config-airbnb-base/rules/imports.js index ca91e9fc93..f3a477b4b5 100644 --- a/packages/eslint-config-airbnb-base/rules/imports.js +++ b/packages/eslint-config-airbnb-base/rules/imports.js @@ -259,5 +259,17 @@ module.exports = { missingExports: true, unusedExports: true, }], + + // Reports the use of import declarations with CommonJS exports in any module except for the main module. + // https://github.com/benmosher/eslint-plugin-import/blob/1012eb951767279ce3b540a4ec4f29236104bb5b/docs/rules/no-import-module-exports.md + // TODO: enable, semver-major + 'import/no-import-module-exports': ['off', { + exceptions: [], + }], + + // Use this rule to prevent importing packages through relative paths. + // https://github.com/benmosher/eslint-plugin-import/blob/1012eb951767279ce3b540a4ec4f29236104bb5b/docs/rules/no-relative-packages.md + // TODO: enable, semver-major + 'import/no-relative-packages': 'off', }, }; diff --git a/packages/eslint-config-airbnb/package.json b/packages/eslint-config-airbnb/package.json index c16dde4a4e..941fff4869 100644 --- a/packages/eslint-config-airbnb/package.json +++ b/packages/eslint-config-airbnb/package.json @@ -59,15 +59,15 @@ "object.entries": "^1.1.4" }, "devDependencies": { - "@babel/runtime": "^7.13.10", + "@babel/runtime": "^7.14.6", "babel-preset-airbnb": "^4.5.0", "babel-tape-runner": "^3.0.0", "eclint": "^2.8.1", "eslint": "^5.16.0 || ^6.8.0 || ^7.2.0", "eslint-find-rules": "^3.6.1", - "eslint-plugin-import": "^2.22.1", + "eslint-plugin-import": "^2.23.4", "eslint-plugin-jsx-a11y": "^6.4.1", - "eslint-plugin-react": "^7.23.1", + "eslint-plugin-react": "^7.24.0", "eslint-plugin-react-hooks": "^4.0.1 || ^3 || ^2.3.0 || ^1.7.0", "in-publish": "^2.0.1", "react": ">= 0.13.0", From f5c14cae2ff58000cead98290b8ec4b54dda2f14 Mon Sep 17 00:00:00 2001 From: Luke Ingalls Date: Fri, 18 Jun 2021 19:49:13 -0600 Subject: [PATCH 014/122] [readme] fixed typo and removed redundancy --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index cf0be8e37c..b4e9d4f7a4 100644 --- a/README.md +++ b/README.md @@ -1260,7 +1260,7 @@ Other Style Guides ``` - - [9.7](#classes--methods-use-this) Class methods should use `this` or be made into a static method unless an external library or framework requires to use specific non-static methods. Being an instance method should indicate that it behaves differently based on properties of the receiver. eslint: [`class-methods-use-this`](https://eslint.org/docs/rules/class-methods-use-this) + - [9.7](#classes--methods-use-this) Class methods should use `this` or be made into a static method unless an external library or framework requires using specific non-static methods. Being an instance method should indicate that it behaves differently based on properties of the receiver. eslint: [`class-methods-use-this`](https://eslint.org/docs/rules/class-methods-use-this) ```javascript // bad @@ -3102,7 +3102,7 @@ Other Style Guides - [21.1](#semicolons--required) **Yup.** eslint: [`semi`](https://eslint.org/docs/rules/semi.html) - > Why? When JavaScript encounters a line break without a semicolon, it uses a set of rules called [Automatic Semicolon Insertion](https://tc39.github.io/ecma262/#sec-automatic-semicolon-insertion) to determine whether or not it should regard that line break as the end of a statement, and (as the name implies) place a semicolon into your code before the line break if it thinks so. ASI contains a few eccentric behaviors, though, and your code will break if JavaScript misinterprets your line break. These rules will become more complicated as new features become a part of JavaScript. Explicitly terminating your statements and configuring your linter to catch missing semicolons will help prevent you from encountering issues. + > Why? When JavaScript encounters a line break without a semicolon, it uses a set of rules called [Automatic Semicolon Insertion](https://tc39.github.io/ecma262/#sec-automatic-semicolon-insertion) to determine whether it should regard that line break as the end of a statement, and (as the name implies) place a semicolon into your code before the line break if it thinks so. ASI contains a few eccentric behaviors, though, and your code will break if JavaScript misinterprets your line break. These rules will become more complicated as new features become a part of JavaScript. Explicitly terminating your statements and configuring your linter to catch missing semicolons will help prevent you from encountering issues. ```javascript // bad - raises exception From 30927d25036805a36d15ca71742f5a17bc6a1642 Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Tue, 28 Sep 2021 21:41:06 -0700 Subject: [PATCH 015/122] [*] [deps] update `@babel/runtime`, `eslint-plugin-import`, `tape` --- packages/eslint-config-airbnb-base/package.json | 8 ++++---- packages/eslint-config-airbnb/package.json | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/packages/eslint-config-airbnb-base/package.json b/packages/eslint-config-airbnb-base/package.json index 4da8fcd9bc..4a914cd441 100644 --- a/packages/eslint-config-airbnb-base/package.json +++ b/packages/eslint-config-airbnb-base/package.json @@ -53,20 +53,20 @@ }, "homepage": "https://github.com/airbnb/javascript", "devDependencies": { - "@babel/runtime": "^7.14.6", + "@babel/runtime": "^7.15.4", "babel-preset-airbnb": "^4.5.0", "babel-tape-runner": "^3.0.0", "eclint": "^2.8.1", "eslint": "^5.16.0 || ^6.8.0 || ^7.2.0", "eslint-find-rules": "^3.6.1", - "eslint-plugin-import": "^2.23.4", + "eslint-plugin-import": "^2.24.2", "in-publish": "^2.0.1", "safe-publish-latest": "^1.1.4", - "tape": "^5.2.2" + "tape": "^5.3.1" }, "peerDependencies": { "eslint": "^5.16.0 || ^6.8.0 || ^7.2.0", - "eslint-plugin-import": "^2.23.4" + "eslint-plugin-import": "^2.24.2" }, "engines": { "node": ">= 6" diff --git a/packages/eslint-config-airbnb/package.json b/packages/eslint-config-airbnb/package.json index 941fff4869..28c3346c6b 100644 --- a/packages/eslint-config-airbnb/package.json +++ b/packages/eslint-config-airbnb/package.json @@ -59,24 +59,24 @@ "object.entries": "^1.1.4" }, "devDependencies": { - "@babel/runtime": "^7.14.6", + "@babel/runtime": "^7.15.4", "babel-preset-airbnb": "^4.5.0", "babel-tape-runner": "^3.0.0", "eclint": "^2.8.1", "eslint": "^5.16.0 || ^6.8.0 || ^7.2.0", "eslint-find-rules": "^3.6.1", - "eslint-plugin-import": "^2.23.4", + "eslint-plugin-import": "^2.24.2", "eslint-plugin-jsx-a11y": "^6.4.1", "eslint-plugin-react": "^7.24.0", "eslint-plugin-react-hooks": "^4.0.1 || ^3 || ^2.3.0 || ^1.7.0", "in-publish": "^2.0.1", "react": ">= 0.13.0", "safe-publish-latest": "^1.1.4", - "tape": "^5.2.2" + "tape": "^5.3.1" }, "peerDependencies": { "eslint": "^5.16.0 || ^6.8.0 || ^7.2.0", - "eslint-plugin-import": "^2.22.1", + "eslint-plugin-import": "^2.24.2", "eslint-plugin-jsx-a11y": "^6.4.1", "eslint-plugin-react": "^7.23.1", "eslint-plugin-react-hooks": "^4.0.1 || ^3 || ^2.3.0 || ^1.7.0" From 7fbed3b55c9815251d1a9790f42ce7b278687a47 Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Tue, 28 Sep 2021 21:44:21 -0700 Subject: [PATCH 016/122] [eslint-config-airbnb] [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 28c3346c6b..eb19d6aac8 100644 --- a/packages/eslint-config-airbnb/package.json +++ b/packages/eslint-config-airbnb/package.json @@ -67,7 +67,7 @@ "eslint-find-rules": "^3.6.1", "eslint-plugin-import": "^2.24.2", "eslint-plugin-jsx-a11y": "^6.4.1", - "eslint-plugin-react": "^7.24.0", + "eslint-plugin-react": "^7.26.0", "eslint-plugin-react-hooks": "^4.0.1 || ^3 || ^2.3.0 || ^1.7.0", "in-publish": "^2.0.1", "react": ">= 0.13.0", @@ -78,7 +78,7 @@ "eslint": "^5.16.0 || ^6.8.0 || ^7.2.0", "eslint-plugin-import": "^2.24.2", "eslint-plugin-jsx-a11y": "^6.4.1", - "eslint-plugin-react": "^7.23.1", + "eslint-plugin-react": "^7.26.0", "eslint-plugin-react-hooks": "^4.0.1 || ^3 || ^2.3.0 || ^1.7.0" }, "engines": { diff --git a/packages/eslint-config-airbnb/rules/react.js b/packages/eslint-config-airbnb/rules/react.js index a077e4c113..b72387afa5 100644 --- a/packages/eslint-config-airbnb/rules/react.js +++ b/packages/eslint-config-airbnb/rules/react.js @@ -545,6 +545,16 @@ module.exports = { // https://github.com/yannickcr/eslint-plugin-react/blob/c2a790a3472eea0f6de984bdc3ee2a62197417fb/docs/rules/no-unstable-nested-components.md // TODO: enable, semver-major 'react/no-unstable-nested-components': 'off', + + // Enforce that namespaces are not used in React elements + // https://github.com/yannickcr/eslint-plugin-react/blob/8785c169c25b09b33c95655bf508cf46263bc53f/docs/rules/no-namespace.md + // TODO: enable, semver-minor + 'react/no-namespace': 'off', + + // Prefer exact proptype definitions + // https://github.com/yannickcr/eslint-plugin-react/blob/8785c169c25b09b33c95655bf508cf46263bc53f/docs/rules/prefer-exact-props.md + // TODO: enable, semver-major, just in case + 'react/prefer-exact-props': 'off', }, settings: { From 4ee732639396362c6981b1aa4730934c3baa7919 Mon Sep 17 00:00:00 2001 From: Marko Schulz Date: Fri, 24 Sep 2021 11:26:03 +0200 Subject: [PATCH 017/122] [eslint-config-airbnb] [patch] Explain why `react/jsx-key` is turned off --- 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 b72387afa5..ca16948432 100644 --- a/packages/eslint-config-airbnb/rules/react.js +++ b/packages/eslint-config-airbnb/rules/react.js @@ -91,6 +91,7 @@ module.exports = { // Validate JSX has key prop when in array or iterator // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-key.md + // Turned off because it has too many false positives 'react/jsx-key': 'off', // Limit maximum of props on a single line in JSX From 122788230acdc416e3168e07f7d0bf89a744dd94 Mon Sep 17 00:00:00 2001 From: Mustafa Haddara Date: Fri, 15 Oct 2021 17:00:15 -0400 Subject: [PATCH 018/122] [eslint config] clarify hooks requirement --- packages/eslint-config-airbnb/README.md | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/packages/eslint-config-airbnb/README.md b/packages/eslint-config-airbnb/README.md index 9cb0270467..854f45a309 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`, `eslint-plugin-react-hooks`, and `eslint-plugin-jsx-a11y`. If you don't need React, see [eslint-config-airbnb-base](https://npmjs.com/eslint-config-airbnb-base). +Our default export contains most of our ESLint rules, including ECMAScript 6+ and React. It requires `eslint`, `eslint-plugin-import`, `eslint-plugin-react`, `eslint-plugin-react-hooks`, and `eslint-plugin-jsx-a11y`. Note that it does not enable our React Hooks rules. To enable those, see the [`eslint-config-airbnb/hooks` section](#eslint-config-airbnbhooks). + +If you don't need React, see [eslint-config-airbnb-base](https://npmjs.com/eslint-config-airbnb-base). 1. Install the correct versions of each package, which are listed by the command: @@ -58,7 +60,7 @@ Our default export contains all of our ESLint rules, including ECMAScript 6+ and ### eslint-config-airbnb/hooks -This entry point enables the linting rules for React hooks (requires v16.8+). To use, add `"extends": ["airbnb", "airbnb/hooks"]` to your `.eslintrc` +This entry point enables the linting rules for React hooks (requires v16.8+). To use, add `"extends": ["airbnb", "airbnb/hooks"]` to your `.eslintrc`. ### eslint-config-airbnb/whitespace From 82dbec3c995687fd6e08151c6d97768f6d970d56 Mon Sep 17 00:00:00 2001 From: Johnwesley R Date: Sun, 17 Oct 2021 14:27:43 -0400 Subject: [PATCH 019/122] [guide] Fix 14.1 Temporal Dead Zones link --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index b4e9d4f7a4..bab7f334b5 100644 --- a/README.md +++ b/README.md @@ -1863,7 +1863,7 @@ Other Style Guides ## Hoisting - - [14.1](#hoisting--about) `var` declarations get hoisted to the top of their closest enclosing function scope, their assignment does not. `const` and `let` declarations are blessed with a new concept called [Temporal Dead Zones (TDZ)](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/let#Temporal_dead_zone). It’s important to know why [typeof is no longer safe](https://web.archive.org/web/20200121061528/http://es-discourse.com/t/why-typeof-is-no-longer-safe/15). + - [14.1](#hoisting--about) `var` declarations get hoisted to the top of their closest enclosing function scope, their assignment does not. `const` and `let` declarations are blessed with a new concept called [Temporal Dead Zones (TDZ)](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/let#temporal_dead_zone_tdz). It’s important to know why [typeof is no longer safe](https://web.archive.org/web/20200121061528/http://es-discourse.com/t/why-typeof-is-no-longer-safe/15). ```javascript // we know this wouldn’t work (assuming there From 2a6bec1132c937c3f512da083c759bbd7da4ce90 Mon Sep 17 00:00:00 2001 From: Augustus Buonviri Date: Tue, 14 Sep 2021 22:12:31 -0400 Subject: [PATCH 020/122] [eslint config] [base] [patch] Improve `function-paren-newline` with `multiline-arguments` option Related to #1731 Co-authored-by: Augustus Buonviri Co-authored-by: Jordan Harband --- packages/eslint-config-airbnb-base/package.json | 3 ++- packages/eslint-config-airbnb-base/rules/style.js | 7 +++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/packages/eslint-config-airbnb-base/package.json b/packages/eslint-config-airbnb-base/package.json index 4a914cd441..27145b2d5a 100644 --- a/packages/eslint-config-airbnb-base/package.json +++ b/packages/eslint-config-airbnb-base/package.json @@ -74,6 +74,7 @@ "dependencies": { "confusing-browser-globals": "^1.0.10", "object.assign": "^4.1.2", - "object.entries": "^1.1.4" + "object.entries": "^1.1.4", + "semver": "^6.3.0" } } diff --git a/packages/eslint-config-airbnb-base/rules/style.js b/packages/eslint-config-airbnb-base/rules/style.js index c988fe5f3a..d73ddefb1d 100644 --- a/packages/eslint-config-airbnb-base/rules/style.js +++ b/packages/eslint-config-airbnb-base/rules/style.js @@ -1,3 +1,6 @@ +const semver = require('semver'); +const eslintPkg = require('eslint/package.json'); + module.exports = { rules: { // enforce line breaks after opening and before closing array brackets @@ -101,9 +104,9 @@ module.exports = { // TODO: enable 'func-style': ['off', 'expression'], - // enforce consistent line breaks inside function parentheses + // require line breaks inside function parentheses if there are line breaks between parameters // https://eslint.org/docs/rules/function-paren-newline - 'function-paren-newline': ['error', 'consistent'], + 'function-paren-newline': ['error', semver.satisfies(eslintPkg.version, '>= 6') ? 'multiline-arguments' : 'consistent'], // Blacklist certain identifiers to prevent them being used // https://eslint.org/docs/rules/id-blacklist From ea5b991a4f67264a7d3a2d783de67b29450f2779 Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Thu, 4 Nov 2021 23:05:04 -0700 Subject: [PATCH 021/122] [Tests] migrate tests to Github Actions --- .github/workflows/node-pretest.yml | 26 ++++ .github/workflows/node.yml | 155 ++++++++++++++++++++++ .github/workflows/rebase.yml | 15 +++ .github/workflows/require-allow-edits.yml | 12 ++ .travis.yml | 108 --------------- 5 files changed, 208 insertions(+), 108 deletions(-) create mode 100644 .github/workflows/node-pretest.yml create mode 100644 .github/workflows/node.yml create mode 100644 .github/workflows/rebase.yml create mode 100644 .github/workflows/require-allow-edits.yml delete mode 100644 .travis.yml diff --git a/.github/workflows/node-pretest.yml b/.github/workflows/node-pretest.yml new file mode 100644 index 0000000000..48c68f5955 --- /dev/null +++ b/.github/workflows/node-pretest.yml @@ -0,0 +1,26 @@ +name: 'Tests: pretest/posttest' + +on: [pull_request, push] + +jobs: + pretest: + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + package: + - '..' + - eslint-config-airbnb + - eslint-config-airbnb-base + + defaults: + run: + working-directory: "packages/${{ matrix.package }}" + + steps: + - uses: actions/checkout@v2 + - uses: ljharb/actions/node/install@main + name: 'nvm install lts/* && npm install' + with: + node-version: 'lts/*' + - run: npm run pretest diff --git a/.github/workflows/node.yml b/.github/workflows/node.yml new file mode 100644 index 0000000000..1a1e5e5216 --- /dev/null +++ b/.github/workflows/node.yml @@ -0,0 +1,155 @@ +name: 'Tests: node.js' + +on: [pull_request, push] + +jobs: + matrix: + runs-on: ubuntu-latest + outputs: + latest: ${{ steps.set-matrix.outputs.requireds }} + steps: + - uses: ljharb/actions/node/matrix@main + id: set-matrix + with: + versionsAsRoot: true + type: 'majors' + preset: '^10 || ^12 || ^14 || ^16 || >= 17' + + base: + needs: [matrix] + name: 'base config' + runs-on: ubuntu-latest + + strategy: + fail-fast: false + matrix: + node-version: ${{ fromJson(needs.matrix.outputs.latest) }} + eslint: + - 7 + - 6 + - 5 + package: + - eslint-config-airbnb-base + + defaults: + run: + working-directory: "packages/${{ matrix.package }}" + + steps: + - uses: actions/checkout@v2 + - uses: ljharb/actions/node/install@main + name: 'nvm install ${{ matrix.node-version }} && npm install' + with: + node-version: ${{ matrix.node-version }} + - run: npm run travis + - uses: codecov/codecov-action@v2 + + react: + needs: [matrix] + name: 'react config' + runs-on: ubuntu-latest + + strategy: + fail-fast: false + matrix: + node-version: ${{ fromJson(needs.matrix.outputs.latest) }} + eslint: + - 7 + - 6 + - 5 + package: + - eslint-config-airbnb + react-hooks: + - '' + - 3 + - 2.3 + - 1.7 + + defaults: + run: + working-directory: "packages/${{ matrix.package }}" + + steps: + - uses: actions/checkout@v2 + - uses: ljharb/actions/node/install@main + name: 'nvm install ${{ matrix.node-version }} && npm install' + with: + node-version: ${{ matrix.node-version }} + after_install: | + npm install --no-save "eslint@${{ matrix.eslint }}" + - run: npm install --no-save "eslint-plugin-react-hooks@${{ matrix.react-hooks }}" + if: ${{ matrix.react-hooks > 0}} + - run: npm run travis + - uses: codecov/codecov-action@v2 + + prepublish-base: + name: 'prepublish tests (base config)' + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + eslint: + - 7 + - 6 + - 5 + package: + - eslint-config-airbnb-base + + defaults: + run: + working-directory: "packages/${{ matrix.package }}" + + steps: + - uses: actions/checkout@v2 + - uses: ljharb/actions/node/install@main + name: 'nvm install ${{ matrix.node-version }} && npm install' + with: + node-version: lts/* + after_install: | + npm install --no-save "eslint@${{ matrix.eslint }}" + - run: npm run pretravis + - run: npm run prepublish + - run: npm run posttravis + + prepublish-react: + name: 'prepublish tests (react config)' + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + eslint: + - 7 + - 6 + - 5 + package: + - eslint-config-airbnb + react-hooks: + - '' + - 3 + - 2.3 + - 1.7 + + defaults: + run: + working-directory: "packages/${{ matrix.package }}" + + steps: + - uses: actions/checkout@v2 + - uses: ljharb/actions/node/install@main + name: 'nvm install ${{ matrix.node-version }} && npm install' + with: + node-version: lts/* + after_install: | + npm install --no-save "eslint@${{ matrix.eslint }}" + - run: npm install --no-save "eslint-plugin-react-hooks@${{ matrix.react-hooks }}" + if: ${{ matrix.react-hooks > 0}} + - run: npm run pretravis + - run: npm run prepublish + - run: npm run posttravis + + node: + name: 'node 10+' + needs: [base, prepublish-base, react, prepublish-react] + runs-on: ubuntu-latest + steps: + - run: 'echo tests completed' diff --git a/.github/workflows/rebase.yml b/.github/workflows/rebase.yml new file mode 100644 index 0000000000..027aed0797 --- /dev/null +++ b/.github/workflows/rebase.yml @@ -0,0 +1,15 @@ +name: Automatic Rebase + +on: [pull_request_target] + +jobs: + _: + name: "Automatic Rebase" + + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v2 + - uses: ljharb/rebase@master + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/require-allow-edits.yml b/.github/workflows/require-allow-edits.yml new file mode 100644 index 0000000000..549d7b4823 --- /dev/null +++ b/.github/workflows/require-allow-edits.yml @@ -0,0 +1,12 @@ +name: Require “Allow Edits” + +on: [pull_request_target] + +jobs: + _: + name: "Require “Allow Edits”" + + runs-on: ubuntu-latest + + steps: + - uses: ljharb/require-allow-edits@main diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index b7eb96d7ae..0000000000 --- a/.travis.yml +++ /dev/null @@ -1,108 +0,0 @@ -language: node_js -node_js: - - "14" - - "12" - - "10" -before_install: - - 'nvm install-latest-npm' -install: - - 'if [ -n "${PACKAGE-}" ]; then cd "packages/${PACKAGE}"; fi' - - 'if [ "${TRAVIS_NODE_VERSION}" = "0.6" ] || [ "${TRAVIS_NODE_VERSION}" = "0.9" ]; then nvm install --latest-npm 0.8 && npm install && nvm use "${TRAVIS_NODE_VERSION}"; else npm install; fi;' - - 'if [ -n "${ESLINT}" ]; then npm install --no-save "eslint@${ESLINT}"; fi' - - 'if [ -n "${REACT_HOOKS}" ]; then npm install --no-save "eslint-plugin-react-hooks@${REACT_HOOKS}"; fi' -script: - - 'if [ -n "${PREPUBLISH-}" ]; then npm run pretravis && npm run prepublish && npm run posttravis; elif [ -n "${LINT-}" ]; then npm run lint; else npm run travis; fi' -sudo: false -env: - matrix: - - 'TEST=true ESLINT=7 PACKAGE=eslint-config-airbnb-base' - - 'TEST=true ESLINT=7 PACKAGE=eslint-config-airbnb' - - 'TEST=true ESLINT=7 REACT_HOOKS=3 PACKAGE=eslint-config-airbnb' - - 'TEST=true ESLINT=7 REACT_HOOKS=2.3 PACKAGE=eslint-config-airbnb' - - 'TEST=true ESLINT=7 REACT_HOOKS=1.7 PACKAGE=eslint-config-airbnb' - - 'TEST=true ESLINT=6 PACKAGE=eslint-config-airbnb-base' - - 'TEST=true ESLINT=6 PACKAGE=eslint-config-airbnb' - - 'TEST=true ESLINT=6 REACT_HOOKS=3 PACKAGE=eslint-config-airbnb' - - 'TEST=true ESLINT=6 REACT_HOOKS=2.3 PACKAGE=eslint-config-airbnb' - - 'TEST=true ESLINT=6 REACT_HOOKS=1.7 PACKAGE=eslint-config-airbnb' - - 'TEST=true ESLINT=5 PACKAGE=eslint-config-airbnb-base' - - 'TEST=true ESLINT=5 PACKAGE=eslint-config-airbnb' - - 'TEST=true ESLINT=5 REACT_HOOKS=3 PACKAGE=eslint-config-airbnb' - - 'TEST=true ESLINT=5 REACT_HOOKS=2.3 PACKAGE=eslint-config-airbnb' - - 'TEST=true ESLINT=5 REACT_HOOKS=1.7 PACKAGE=eslint-config-airbnb' -matrix: - fast_finish: true - include: - - node_js: "lts/*" - env: PREPUBLISH=true ESLINT=7 PACKAGE=eslint-config-airbnb-base - - node_js: "lts/*" - env: PREPUBLISH=true ESLINT=7 PACKAGE=eslint-config-airbnb - - node_js: "lts/*" - env: PREPUBLISH=true ESLINT=7 REACT_HOOKS=3 PACKAGE=eslint-config-airbnb - - node_js: "lts/*" - env: PREPUBLISH=true ESLINT=7 REACT_HOOKS=2.3 PACKAGE=eslint-config-airbnb - - node_js: "lts/*" - env: PREPUBLISH=true ESLINT=7 REACT_HOOKS=1.7 PACKAGE=eslint-config-airbnb - - node_js: "lts/*" - - node_js: "lts/*" - env: PREPUBLISH=true ESLINT=6 PACKAGE=eslint-config-airbnb-base - - node_js: "lts/*" - env: PREPUBLISH=true ESLINT=6 PACKAGE=eslint-config-airbnb - - node_js: "lts/*" - env: PREPUBLISH=true ESLINT=6 REACT_HOOKS=3 PACKAGE=eslint-config-airbnb - - node_js: "lts/*" - env: PREPUBLISH=true ESLINT=6 REACT_HOOKS=2.3 PACKAGE=eslint-config-airbnb - - node_js: "lts/*" - env: PREPUBLISH=true ESLINT=6 REACT_HOOKS=1.7 PACKAGE=eslint-config-airbnb - - node_js: "lts/*" - env: PREPUBLISH=true ESLINT=5 PACKAGE=eslint-config-airbnb-base - - node_js: "lts/*" - env: PREPUBLISH=true ESLINT=5 PACKAGE=eslint-config-airbnb - - node_js: "lts/*" - env: PREPUBLISH=true ESLINT=5 REACT_HOOKS=3 PACKAGE=eslint-config-airbnb - - node_js: "lts/*" - env: PREPUBLISH=true ESLINT=5 REACT_HOOKS=2.3 PACKAGE=eslint-config-airbnb - - node_js: "lts/*" - env: PREPUBLISH=true ESLINT=5 REACT_HOOKS=1.7 PACKAGE=eslint-config-airbnb - - node_js: "lts/*" - env: LINT=true - - node_js: "lts/*" - env: LINT=true PACKAGE=eslint-config-airbnb - - node_js: "lts/*" - env: LINT=true PACKAGE=eslint-config-airbnb-base - - node_js: "8" - env: TEST=true ESLINT=6 PACKAGE=eslint-config-airbnb-base - - node_js: "8" - env: TEST=true ESLINT=6 PACKAGE=eslint-config-airbnb - - node_js: "8" - env: TEST=true ESLINT=6 REACT_HOOKS=3 PACKAGE=eslint-config-airbnb - - node_js: "8" - env: TEST=true ESLINT=6 REACT_HOOKS=2.3 PACKAGE=eslint-config-airbnb - - node_js: "8" - env: TEST=true ESLINT=6 REACT_HOOKS=1.7 PACKAGE=eslint-config-airbnb - - node_js: "8" - env: TEST=true ESLINT=5 PACKAGE=eslint-config-airbnb-base - - node_js: "8" - env: TEST=true ESLINT=5 PACKAGE=eslint-config-airbnb - - node_js: "8" - env: TEST=true ESLINT=5 REACT_HOOKS=3 PACKAGE=eslint-config-airbnb - - node_js: "8" - env: TEST=true ESLINT=5 REACT_HOOKS=2.3 PACKAGE=eslint-config-airbnb - - node_js: "8" - env: TEST=true ESLINT=5 REACT_HOOKS=1.7 PACKAGE=eslint-config-airbnb - - node_js: "6" - env: TEST=true ESLINT=5 PACKAGE=eslint-config-airbnb-base - - node_js: "6" - env: TEST=true ESLINT=5 PACKAGE=eslint-config-airbnb - - node_js: "6" - env: TEST=true ESLINT=5 REACT_HOOKS=3 PACKAGE=eslint-config-airbnb - - node_js: "6" - env: TEST=true ESLINT=5 REACT_HOOKS=2.3 PACKAGE=eslint-config-airbnb - - node_js: "6" - env: TEST=true ESLINT=5 REACT_HOOKS=1.7 PACKAGE=eslint-config-airbnb - exclude: - allow_failures: - - env: PREPUBLISH=true ESLINT=6 PACKAGE=eslint-config-airbnb-base - - env: PREPUBLISH=true ESLINT=6 PACKAGE=eslint-config-airbnb - - env: PREPUBLISH=true ESLINT=5 PACKAGE=eslint-config-airbnb-base - - env: PREPUBLISH=true ESLINT=5 PACKAGE=eslint-config-airbnb From fdc812a0a5773449274f7c4d473e0841eca89614 Mon Sep 17 00:00:00 2001 From: Kai Date: Thu, 4 Nov 2021 00:24:41 +0100 Subject: [PATCH 022/122] [Docs] HTTP => HTTPS --- README.md | 32 +++++++++---------- .../SublimeLinter.sublime-settings | 2 +- packages/eslint-config-airbnb-base/README.md | 2 +- packages/eslint-config-airbnb/README.md | 2 +- 4 files changed, 19 insertions(+), 19 deletions(-) diff --git a/README.md b/README.md index bab7f334b5..3fcade31f4 100644 --- a/README.md +++ b/README.md @@ -1955,7 +1955,7 @@ Other Style Guides } ``` - - For more information refer to [JavaScript Scoping & Hoisting](http://www.adequatelygood.com/2010/2/JavaScript-Scoping-and-Hoisting/) by [Ben Cherry](http://www.adequatelygood.com/). + - For more information refer to [JavaScript Scoping & Hoisting](https://www.adequatelygood.com/2010/2/JavaScript-Scoping-and-Hoisting/) by [Ben Cherry](https://www.adequatelygood.com/). **[⬆ back to top](#table-of-contents)** @@ -3622,7 +3622,7 @@ Other Style Guides ``` - - [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) + - [26.3](#jquery--queries) For DOM queries use Cascading `$('.sidebar ul')` or parent > child `$('.sidebar > ul')`. [jsPerf](https://jsperf.com/jquery-find-vs-context-sel/16) - [26.4](#jquery--find) Use `find` with scoped jQuery object queries. @@ -3762,19 +3762,19 @@ Other Style Guides **Learning ES6+** - [Latest ECMA spec](https://tc39.github.io/ecma262/) - - [ExploringJS](http://exploringjs.com/) + - [ExploringJS](https://exploringjs.com/) - [ES6 Compatibility Table](https://kangax.github.io/compat-table/es6/) - [Comprehensive Overview of ES6 Features](http://es6-features.org/) **Read This** - - [Standard ECMA-262](http://www.ecma-international.org/ecma-262/6.0/index.html) + - [Standard ECMA-262](https://www.ecma-international.org/ecma-262/6.0/index.html) **Tools** - Code Style Linters - [ESlint](https://eslint.org/) - [Airbnb Style .eslintrc](https://github.com/airbnb/javascript/blob/master/linters/.eslintrc) - - [JSHint](http://jshint.com/) - [Airbnb Style .jshintrc](https://github.com/airbnb/javascript/blob/master/linters/.jshintrc) + - [JSHint](https://jshint.com/) - [Airbnb Style .jshintrc](https://github.com/airbnb/javascript/blob/master/linters/.jshintrc) - Neutrino Preset - [@neutrinojs/airbnb](https://neutrinojs.org/packages/airbnb/) **Other Style Guides** @@ -3790,13 +3790,13 @@ 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 - - [Multiple var statements in JavaScript, not superfluous](http://benalman.com/news/2012/05/multiple-var-statements-javascript/) - Ben Alman + - [Multiple var statements in JavaScript, not superfluous](https://benalman.com/news/2012/05/multiple-var-statements-javascript/) - Ben Alman **Further Reading** - [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 + - [Basic JavaScript for the impatient programmer](https://www.2ality.com/2013/06/basic-javascript.html) - Dr. Axel Rauschmayer + - [You Might Not Need jQuery](https://youmightnotneedjquery.com/) - Zack Bloom & Adam Schwartz - [ES6 Features](https://github.com/lukehoban/es6features) - Luke Hoban - [Frontend Guidelines](https://github.com/bendc/frontend-guidelines) - Benjamin De Cock @@ -3813,23 +3813,23 @@ Other Style Guides - [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 + - [JSBooks](https://jsbooks.revolunet.com/) - Julien Bouquillon - [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 + - [Effective JavaScript: 68 Specific Ways to Harness the Power of JavaScript](https://amzn.com/0321812182) - David Herman + - [Eloquent JavaScript](https://eloquentjavascript.net/) - Marijn Haverbeke + - [You Don’t Know JS: ES6 & Beyond](https://shop.oreilly.com/product/0636920033769.do) - Kyle Simpson **Blogs** - - [JavaScript Weekly](http://javascriptweekly.com/) + - [JavaScript Weekly](https://javascriptweekly.com/) - [JavaScript, JavaScript...](https://javascriptweblog.wordpress.com/) - [Bocoup Weblog](https://bocoup.com/weblog) - - [Adequately Good](http://www.adequatelygood.com/) + - [Adequately Good](https://www.adequatelygood.com/) - [NCZOnline](https://www.nczonline.net/) - [Perfection Kills](http://perfectionkills.com/) - - [Ben Alman](http://benalman.com/) + - [Ben Alman](https://benalman.com/) - [Dmitry Baranovskiy](http://dmitry.baranovskiy.com/) - - [nettuts](http://code.tutsplus.com/?s=javascript) + - [nettuts](https://code.tutsplus.com/?s=javascript) **Podcasts** diff --git a/linters/SublimeLinter/SublimeLinter.sublime-settings b/linters/SublimeLinter/SublimeLinter.sublime-settings index 259dbaff6a..7ce44c9821 100644 --- a/linters/SublimeLinter/SublimeLinter.sublime-settings +++ b/linters/SublimeLinter/SublimeLinter.sublime-settings @@ -9,7 +9,7 @@ * * @version 0.3.0 * @see https://github.com/SublimeLinter/SublimeLinter - * @see http://www.jshint.com/docs/ + * @see https://www.jshint.com/docs/ */ { "jshint_options": diff --git a/packages/eslint-config-airbnb-base/README.md b/packages/eslint-config-airbnb-base/README.md index 685e50060b..0339618ca3 100644 --- a/packages/eslint-config-airbnb-base/README.md +++ b/packages/eslint-config-airbnb-base/README.md @@ -1,6 +1,6 @@ # eslint-config-airbnb-base -[![npm version](https://badge.fury.io/js/eslint-config-airbnb-base.svg)](http://badge.fury.io/js/eslint-config-airbnb-base) +[![npm version](https://badge.fury.io/js/eslint-config-airbnb-base.svg)](https://badge.fury.io/js/eslint-config-airbnb-base) This package provides Airbnb's base JS .eslintrc (without React plugins) as an extensible shared config. diff --git a/packages/eslint-config-airbnb/README.md b/packages/eslint-config-airbnb/README.md index 854f45a309..3b3f43196d 100644 --- a/packages/eslint-config-airbnb/README.md +++ b/packages/eslint-config-airbnb/README.md @@ -1,6 +1,6 @@ # eslint-config-airbnb -[![npm version](https://badge.fury.io/js/eslint-config-airbnb.svg)](http://badge.fury.io/js/eslint-config-airbnb) +[![npm version](https://badge.fury.io/js/eslint-config-airbnb.svg)](https://badge.fury.io/js/eslint-config-airbnb) This package provides Airbnb's .eslintrc as an extensible shared config. From 6734b7891176ce5d2601e16f62b5c37a8479e6ae Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Mon, 8 Nov 2021 16:00:07 -0800 Subject: [PATCH 023/122] [eslint config] [*] [deps] update `eslint-plugin-import`, `object.entries` --- packages/eslint-config-airbnb-base/package.json | 6 +++--- packages/eslint-config-airbnb/package.json | 6 +++--- 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 27145b2d5a..d3c711e5d2 100644 --- a/packages/eslint-config-airbnb-base/package.json +++ b/packages/eslint-config-airbnb-base/package.json @@ -59,14 +59,14 @@ "eclint": "^2.8.1", "eslint": "^5.16.0 || ^6.8.0 || ^7.2.0", "eslint-find-rules": "^3.6.1", - "eslint-plugin-import": "^2.24.2", + "eslint-plugin-import": "^2.25.2", "in-publish": "^2.0.1", "safe-publish-latest": "^1.1.4", "tape": "^5.3.1" }, "peerDependencies": { "eslint": "^5.16.0 || ^6.8.0 || ^7.2.0", - "eslint-plugin-import": "^2.24.2" + "eslint-plugin-import": "^2.25.2" }, "engines": { "node": ">= 6" @@ -74,7 +74,7 @@ "dependencies": { "confusing-browser-globals": "^1.0.10", "object.assign": "^4.1.2", - "object.entries": "^1.1.4", + "object.entries": "^1.1.5", "semver": "^6.3.0" } } diff --git a/packages/eslint-config-airbnb/package.json b/packages/eslint-config-airbnb/package.json index eb19d6aac8..be64da1a86 100644 --- a/packages/eslint-config-airbnb/package.json +++ b/packages/eslint-config-airbnb/package.json @@ -56,7 +56,7 @@ "dependencies": { "eslint-config-airbnb-base": "^14.2.1", "object.assign": "^4.1.2", - "object.entries": "^1.1.4" + "object.entries": "^1.1.5" }, "devDependencies": { "@babel/runtime": "^7.15.4", @@ -65,7 +65,7 @@ "eclint": "^2.8.1", "eslint": "^5.16.0 || ^6.8.0 || ^7.2.0", "eslint-find-rules": "^3.6.1", - "eslint-plugin-import": "^2.24.2", + "eslint-plugin-import": "^2.25.2", "eslint-plugin-jsx-a11y": "^6.4.1", "eslint-plugin-react": "^7.26.0", "eslint-plugin-react-hooks": "^4.0.1 || ^3 || ^2.3.0 || ^1.7.0", @@ -76,7 +76,7 @@ }, "peerDependencies": { "eslint": "^5.16.0 || ^6.8.0 || ^7.2.0", - "eslint-plugin-import": "^2.24.2", + "eslint-plugin-import": "^2.25.2", "eslint-plugin-jsx-a11y": "^6.4.1", "eslint-plugin-react": "^7.26.0", "eslint-plugin-react-hooks": "^4.0.1 || ^3 || ^2.3.0 || ^1.7.0" From ef6c478a2b2b97ccc996ed6169f3f97bff2e5395 Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Mon, 8 Nov 2021 18:06:45 -0800 Subject: [PATCH 024/122] [eslint config] [*] [dev deps] update `@babel/runtime` --- 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 d3c711e5d2..91ba5473b6 100644 --- a/packages/eslint-config-airbnb-base/package.json +++ b/packages/eslint-config-airbnb-base/package.json @@ -53,7 +53,7 @@ }, "homepage": "https://github.com/airbnb/javascript", "devDependencies": { - "@babel/runtime": "^7.15.4", + "@babel/runtime": "^7.16.0", "babel-preset-airbnb": "^4.5.0", "babel-tape-runner": "^3.0.0", "eclint": "^2.8.1", diff --git a/packages/eslint-config-airbnb/package.json b/packages/eslint-config-airbnb/package.json index be64da1a86..ec4efd07b0 100644 --- a/packages/eslint-config-airbnb/package.json +++ b/packages/eslint-config-airbnb/package.json @@ -59,7 +59,7 @@ "object.entries": "^1.1.5" }, "devDependencies": { - "@babel/runtime": "^7.15.4", + "@babel/runtime": "^7.16.0", "babel-preset-airbnb": "^4.5.0", "babel-tape-runner": "^3.0.0", "eclint": "^2.8.1", From 10a6d02c665f35826114d66ee8f37bda1d89f59e Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Mon, 8 Nov 2021 21:21:58 -0800 Subject: [PATCH 025/122] [meta] use `prepublishOnly` script for npm 7+ --- packages/eslint-config-airbnb-base/package.json | 3 ++- packages/eslint-config-airbnb/package.json | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/packages/eslint-config-airbnb-base/package.json b/packages/eslint-config-airbnb-base/package.json index 91ba5473b6..a5cb181d37 100644 --- a/packages/eslint-config-airbnb-base/package.json +++ b/packages/eslint-config-airbnb-base/package.json @@ -8,7 +8,8 @@ "lint": "eslint --report-unused-disable-directives .", "pretests-only": "node ./test/requires", "tests-only": "babel-tape-runner ./test/test-*.js", - "prepublish": "(in-install || eslint-find-rules --unused) && (not-in-publish || npm test) && safe-publish-latest", + "prepublishOnly": "eslint-find-rules --unused && npm test && safe-publish-latest", + "prepublish": "not-in-publish || npm run prepublishOnly", "pretest": "npm run --silent lint", "test": "npm run --silent tests-only", "pretravis": ":", diff --git a/packages/eslint-config-airbnb/package.json b/packages/eslint-config-airbnb/package.json index ec4efd07b0..dd5a214145 100644 --- a/packages/eslint-config-airbnb/package.json +++ b/packages/eslint-config-airbnb/package.json @@ -8,7 +8,8 @@ "lint": "eslint .", "pretests-only": "node ./test/requires", "tests-only": "babel-tape-runner ./test/test-*.js", - "prepublish": "(in-install || eslint-find-rules --unused) && (not-in-publish || npm test) && safe-publish-latest", + "prepublishOnly": "eslint-find-rules --unused && npm test && safe-publish-latest", + "prepublish": "not-in-publish || npm run prepublishOnly", "pretest": "npm run --silent lint", "test": "npm run --silent tests-only", "link:eslint": "cd node_modules/eslint && npm link --production && cd -", From c12a08c479ba139718bf8ab7eb21a3a5d0c520d7 Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Mon, 8 Nov 2021 18:27:29 -0800 Subject: [PATCH 026/122] [actions] fix action working directories --- .github/workflows/node.yml | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/.github/workflows/node.yml b/.github/workflows/node.yml index 1a1e5e5216..9a570e7741 100644 --- a/.github/workflows/node.yml +++ b/.github/workflows/node.yml @@ -40,7 +40,12 @@ jobs: - uses: ljharb/actions/node/install@main name: 'nvm install ${{ matrix.node-version }} && npm install' with: + before_install: cd "packages/${{ matrix.package }}" node-version: ${{ matrix.node-version }} + after_install: | + npm install --no-save "eslint@${{ matrix.eslint }}" + - run: node -pe "require('eslint/package.json').version" + name: 'eslint version' - run: npm run travis - uses: codecov/codecov-action@v2 @@ -74,9 +79,12 @@ jobs: - uses: ljharb/actions/node/install@main name: 'nvm install ${{ matrix.node-version }} && npm install' with: + before_install: cd "packages/${{ matrix.package }}" node-version: ${{ matrix.node-version }} after_install: | npm install --no-save "eslint@${{ matrix.eslint }}" + - run: node -pe "require('eslint/package.json').version" + name: 'eslint version' - run: npm install --no-save "eslint-plugin-react-hooks@${{ matrix.react-hooks }}" if: ${{ matrix.react-hooks > 0}} - run: npm run travis @@ -102,11 +110,14 @@ jobs: steps: - uses: actions/checkout@v2 - uses: ljharb/actions/node/install@main - name: 'nvm install ${{ matrix.node-version }} && npm install' + name: 'nvm install lts/* && npm install' with: + before_install: cd "packages/${{ matrix.package }}" node-version: lts/* after_install: | npm install --no-save "eslint@${{ matrix.eslint }}" + - run: node -pe "require('eslint/package.json').version" + name: 'eslint version' - run: npm run pretravis - run: npm run prepublish - run: npm run posttravis @@ -136,13 +147,16 @@ jobs: steps: - uses: actions/checkout@v2 - uses: ljharb/actions/node/install@main - name: 'nvm install ${{ matrix.node-version }} && npm install' + name: 'nvm install lts/* && npm install' with: + before_install: cd "packages/${{ matrix.package }}" node-version: lts/* after_install: | npm install --no-save "eslint@${{ matrix.eslint }}" - run: npm install --no-save "eslint-plugin-react-hooks@${{ matrix.react-hooks }}" if: ${{ matrix.react-hooks > 0}} + - run: node -pe "require('eslint/package.json').version" + name: 'eslint version' - run: npm run pretravis - run: npm run prepublish - run: npm run posttravis From 96f11d8c810de5712ba4f80adaa402057565a3be Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Mon, 8 Nov 2021 22:25:39 -0800 Subject: [PATCH 027/122] [actions] run prepublishOnly in prepublish tests --- .github/workflows/node.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/node.yml b/.github/workflows/node.yml index 9a570e7741..78fd3e5a3c 100644 --- a/.github/workflows/node.yml +++ b/.github/workflows/node.yml @@ -119,7 +119,7 @@ jobs: - run: node -pe "require('eslint/package.json').version" name: 'eslint version' - run: npm run pretravis - - run: npm run prepublish + - run: npm run prepublishOnly - run: npm run posttravis prepublish-react: @@ -158,7 +158,7 @@ jobs: - run: node -pe "require('eslint/package.json').version" name: 'eslint version' - run: npm run pretravis - - run: npm run prepublish + - run: npm run prepublishOnly - run: npm run posttravis node: From 4fc997b97e39359c3699aa95c80586277ea565ca Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Mon, 8 Nov 2021 18:42:02 -0800 Subject: [PATCH 028/122] [readme] some updates --- packages/eslint-config-airbnb-base/README.md | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/packages/eslint-config-airbnb-base/README.md b/packages/eslint-config-airbnb-base/README.md index 0339618ca3..6ddc34dac1 100644 --- a/packages/eslint-config-airbnb-base/README.md +++ b/packages/eslint-config-airbnb-base/README.md @@ -1,6 +1,10 @@ -# eslint-config-airbnb-base +# eslint-config-airbnb-base [![Version Badge][npm-version-svg]][package-url] -[![npm version](https://badge.fury.io/js/eslint-config-airbnb-base.svg)](https://badge.fury.io/js/eslint-config-airbnb-base) +[![npm version](https://badge.fury.io/js/eslint-config-airbnb-base.svg)][package-url] + +[![github actions][actions-image]][actions-url] +[![License][license-image]][license-url] +[![Downloads][downloads-image]][downloads-url] This package provides Airbnb's base JS .eslintrc (without React plugins) as an extensible shared config. @@ -79,7 +83,7 @@ Lints ES5 and below. Requires `eslint` and `eslint-plugin-import`. 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/legacy"` to your .eslintrc @@ -97,3 +101,12 @@ Consider adding test cases if you're making complicated rules changes, like anyt You can run tests with `npm test`. You can make sure this module lints with itself using `npm run lint`. + +[package-url]: https://npmjs.org/package/eslint-config-airbnb-base +[npm-version-svg]: https://versionbadg.es/airbnb/javascript.svg +[license-image]: https://img.shields.io/npm/l/eslint-config-airbnb-base.svg +[license-url]: LICENSE.md +[downloads-image]: https://img.shields.io/npm/dm/eslint-config-airbnb-base.svg +[downloads-url]: https://npm-stat.com/charts.html?package=eslint-config-airbnb-base +[actions-image]: https://img.shields.io/endpoint?url=https://github-actions-badge-u3jn4tfpocch.runkit.sh/airbnb/javascript +[actions-url]: https://github.com/airbnb/javascript/actions From be6966b2514c53097b98e218afb52e813859dfe1 Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Mon, 8 Nov 2021 22:33:12 -0800 Subject: [PATCH 029/122] [eslint-config] [meta] add `--no-save` to link scripts --- 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 dd5a214145..929110f7e7 100644 --- a/packages/eslint-config-airbnb/package.json +++ b/packages/eslint-config-airbnb/package.json @@ -13,7 +13,7 @@ "pretest": "npm run --silent lint", "test": "npm run --silent tests-only", "link:eslint": "cd node_modules/eslint && npm link --production && cd -", - "pretravis": "npm run link:eslint && cd ../eslint-config-airbnb-base && npm link eslint && npm install && npm link && cd - && npm link --no-save eslint-config-airbnb-base", + "pretravis": "npm run link:eslint && cd ../eslint-config-airbnb-base && npm link --no-save eslint && npm install && npm link && cd - && npm link --no-save eslint-config-airbnb-base", "travis": "npm run --silent tests-only", "posttravis": "npm unlink --no-save eslint-config-airbnb-base eslint >/dev/null &" }, From eac8cc605b0ee7acf32b9b3c7fa62fa66cd35de0 Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Mon, 8 Nov 2021 18:48:04 -0800 Subject: [PATCH 030/122] [eslint config] [base] [breaking] add `exports` --- packages/eslint-config-airbnb-base/package.json | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/packages/eslint-config-airbnb-base/package.json b/packages/eslint-config-airbnb-base/package.json index a5cb181d37..fdfc405fab 100644 --- a/packages/eslint-config-airbnb-base/package.json +++ b/packages/eslint-config-airbnb-base/package.json @@ -3,6 +3,20 @@ "version": "14.2.1", "description": "Airbnb's base JS ESLint config, following our styleguide", "main": "index.js", + "exports": { + ".": "./index.js", + "./legacy": "./legacy.js", + "./whitespace": "./whitespace.js", + "./rules/best-practices": "./rules/best-practices.js", + "./rules/es6": "./rules/es6.js", + "./rules/node": "./rules/node.js", + "./rules/style": "./rules/style.js", + "./rules/errors": "./rules/errors.js", + "./rules/imports": "./rules/imports.js", + "./rules/strict": "./rules/strict.js", + "./rules/variables": "./rules/variables.js", + "./package.json": "./package.json" + }, "scripts": { "prelint": "eclint check * rules/* test/*", "lint": "eslint --report-unused-disable-directives .", From f3d3a075cda2acc02011e71991c10bb5b4a15278 Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Mon, 8 Nov 2021 18:27:29 -0800 Subject: [PATCH 031/122] [eslint config] [base] [breaking] drop eslint < 7, add eslint 8 --- .github/workflows/node.yml | 32 ++-- .../eslint-config-airbnb-base/package.json | 10 +- .../rules/best-practices.js | 20 +- .../eslint-config-airbnb-base/rules/errors.js | 29 ++- .../eslint-config-airbnb-base/rules/es6.js | 5 +- .../rules/imports.js | 8 +- .../eslint-config-airbnb-base/rules/style.js | 11 +- .../whitespace-async.js | 96 ++++++++++ .../eslint-config-airbnb-base/whitespace.js | 171 ++++++++++-------- 9 files changed, 237 insertions(+), 145 deletions(-) create mode 100755 packages/eslint-config-airbnb-base/whitespace-async.js diff --git a/.github/workflows/node.yml b/.github/workflows/node.yml index 78fd3e5a3c..8337d1da57 100644 --- a/.github/workflows/node.yml +++ b/.github/workflows/node.yml @@ -13,7 +13,7 @@ jobs: with: versionsAsRoot: true type: 'majors' - preset: '^10 || ^12 || ^14 || ^16 || >= 17' + preset: '^12 || ^14 || ^16 || >= 17' base: needs: [matrix] @@ -25,11 +25,14 @@ jobs: matrix: node-version: ${{ fromJson(needs.matrix.outputs.latest) }} eslint: + - 8 - 7 - - 6 - - 5 package: - eslint-config-airbnb-base + exclude: + - node-version: 10 + eslint: 8 + package: eslint-config-airbnb-base defaults: run: @@ -60,15 +63,15 @@ jobs: node-version: ${{ fromJson(needs.matrix.outputs.latest) }} eslint: - 7 - - 6 - - 5 + # - 6 + # - 5 package: - eslint-config-airbnb react-hooks: - '' - - 3 - - 2.3 - - 1.7 + # - 3 # TODO: re-enable these once the react config uses eslint 8 + # - 2.3 + # - 1.7 defaults: run: @@ -97,9 +100,8 @@ jobs: fail-fast: false matrix: eslint: + - 8 - 7 - - 6 - - 5 package: - eslint-config-airbnb-base @@ -130,15 +132,15 @@ jobs: matrix: eslint: - 7 - - 6 - - 5 + # - 6 + # - 5 package: - eslint-config-airbnb react-hooks: - '' - - 3 - - 2.3 - - 1.7 + # - 3 # TODO: re-enable these once the react config uses eslint 8 + # - 2.3 + # - 1.7 defaults: run: diff --git a/packages/eslint-config-airbnb-base/package.json b/packages/eslint-config-airbnb-base/package.json index fdfc405fab..ef11845cae 100644 --- a/packages/eslint-config-airbnb-base/package.json +++ b/packages/eslint-config-airbnb-base/package.json @@ -72,19 +72,19 @@ "babel-preset-airbnb": "^4.5.0", "babel-tape-runner": "^3.0.0", "eclint": "^2.8.1", - "eslint": "^5.16.0 || ^6.8.0 || ^7.2.0", - "eslint-find-rules": "^3.6.1", + "eslint": "^7.32.0 || ^8.2.0", + "eslint-find-rules": "^4.0.0", "eslint-plugin-import": "^2.25.2", "in-publish": "^2.0.1", - "safe-publish-latest": "^1.1.4", + "safe-publish-latest": "^2.0.0", "tape": "^5.3.1" }, "peerDependencies": { - "eslint": "^5.16.0 || ^6.8.0 || ^7.2.0", + "eslint": "^7.32.0 || ^8.2.0", "eslint-plugin-import": "^2.25.2" }, "engines": { - "node": ">= 6" + "node": "^10.12.0 || >=12.0.0" }, "dependencies": { "confusing-browser-globals": "^1.0.10", diff --git a/packages/eslint-config-airbnb-base/rules/best-practices.js b/packages/eslint-config-airbnb-base/rules/best-practices.js index deb91cfb01..b91133de0a 100644 --- a/packages/eslint-config-airbnb-base/rules/best-practices.js +++ b/packages/eslint-config-airbnb-base/rules/best-practices.js @@ -36,12 +36,10 @@ module.exports = { // Enforce default clauses in switch statements to be last // https://eslint.org/docs/rules/default-case-last - // TODO: enable, semver-minor, when eslint v7 is required (which is a major) - 'default-case-last': 'off', + 'default-case-last': 'error', // https://eslint.org/docs/rules/default-param-last - // TODO: enable, semver-minor, when eslint v6.4 is required (which is a major) - 'default-param-last': 'off', + 'default-param-last': 'error', // encourages use of dot notation whenever possible // https://eslint.org/docs/rules/dot-notation @@ -57,8 +55,7 @@ module.exports = { // Require grouped accessor pairs in object literals and classes // https://eslint.org/docs/rules/grouped-accessor-pairs - // TODO: enable in next major, altho the guide forbids getters/setters anyways - 'grouped-accessor-pairs': 'off', + 'grouped-accessor-pairs': 'error', // make sure for-in loops have an if statement // https://eslint.org/docs/rules/guard-for-in @@ -82,8 +79,7 @@ module.exports = { // Disallow returning value in constructor // https://eslint.org/docs/rules/no-constructor-return - // TODO: enable, semver-major - 'no-constructor-return': 'off', + 'no-constructor-return': 'error', // disallow division operators explicitly at beginning of regular expression // https://eslint.org/docs/rules/no-div-regex @@ -213,8 +209,7 @@ module.exports = { // Disallow \8 and \9 escape sequences in string literals // https://eslint.org/docs/rules/no-nonoctal-decimal-escape - // todo: semver-major: enable when v7.14 is required - 'no-nonoctal-decimal-escape': 'off', + 'no-nonoctal-decimal-escape': 'error', // disallow use of (old style) octal literals // https://eslint.org/docs/rules/no-octal @@ -382,8 +377,9 @@ module.exports = { 'prefer-named-capture-group': 'off', // https://eslint.org/docs/rules/prefer-regex-literals - // TODO; enable, semver-minor, once eslint v6.4 is required (which is a major) - 'prefer-regex-literals': 'off', + 'prefer-regex-literals': ['error', { + disallowRedundantWrapping: true, + }], // require use of the second argument for parseInt() // https://eslint.org/docs/rules/radix diff --git a/packages/eslint-config-airbnb-base/rules/errors.js b/packages/eslint-config-airbnb-base/rules/errors.js index 71ebcdecc6..cdc8c26eb7 100644 --- a/packages/eslint-config-airbnb-base/rules/errors.js +++ b/packages/eslint-config-airbnb-base/rules/errors.js @@ -40,8 +40,7 @@ module.exports = { // Disallow duplicate conditions in if-else-if chains // https://eslint.org/docs/rules/no-dupe-else-if - // TODO: enable, semver-major - 'no-dupe-else-if': 'off', + 'no-dupe-else-if': 'error', // disallow duplicate keys when creating object literals 'no-dupe-keys': 'error', @@ -79,8 +78,7 @@ module.exports = { 'no-func-assign': 'error', // https://eslint.org/docs/rules/no-import-assign - // TODO: enable, semver-minor, once eslint v6.4 is required (which is a major) - 'no-import-assign': 'off', + 'no-import-assign': 'error', // disallow function or variable declarations in nested blocks 'no-inner-declarations': 'error', @@ -93,8 +91,7 @@ module.exports = { // Disallow Number Literals That Lose Precision // https://eslint.org/docs/rules/no-loss-of-precision - // TODO: enable, semver-minor, once eslint v7.1 is required (which is major) - 'no-loss-of-precision': 'off', + 'no-loss-of-precision': 'error', // Disallow characters which are made with multiple code points in character class syntax // https://eslint.org/docs/rules/no-misleading-character-class @@ -105,8 +102,7 @@ module.exports = { // Disallow returning values from Promise executor functions // https://eslint.org/docs/rules/no-promise-executor-return - // TODO: enable, semver-minor, once eslint v7.3 is required (which is major) - 'no-promise-executor-return': 'off', + 'no-promise-executor-return': 'error', // disallow use of Object.prototypes builtins directly // https://eslint.org/docs/rules/no-prototype-builtins @@ -117,8 +113,7 @@ module.exports = { // Disallow returning values from setters // https://eslint.org/docs/rules/no-setter-return - // TODO: enable, semver-major (altho the guide forbids getters/setters already) - 'no-setter-return': 'off', + 'no-setter-return': 'error', // disallow sparse arrays 'no-sparse-arrays': 'error', @@ -136,8 +131,7 @@ module.exports = { // Disallow loops with a body that allows only one iteration // https://eslint.org/docs/rules/no-unreachable-loop - // TODO: enable, semver-minor, once eslint v7.3 is required (which is major) - 'no-unreachable-loop': ['off', { + 'no-unreachable-loop': ['error', { ignore: [], // WhileStatement, DoWhileStatement, ForStatement, ForInStatement, ForOfStatement }], @@ -151,13 +145,16 @@ module.exports = { // disallow use of optional chaining in contexts where the undefined value is not allowed // https://eslint.org/docs/rules/no-unsafe-optional-chaining - // TODO: enable, semver-minor, once eslint v7.15 is required (which is major) - 'no-unsafe-optional-chaining': ['off', { disallowArithmeticOperators: true }], + 'no-unsafe-optional-chaining': ['error', { disallowArithmeticOperators: true }], + + // Disallow Unused Private Class Members + // https://eslint.org/docs/rules/no-unused-private-class-members + // TODO: enable once eslint 7 is dropped (which is semver-major) + 'no-unused-private-class-members': 'off', // Disallow useless backreferences in regular expressions // https://eslint.org/docs/rules/no-useless-backreference - // TODO: enable, semver-minor, once eslint v7 is required (which is major) - 'no-useless-backreference': 'off', + 'no-useless-backreference': 'error', // disallow negation of the left operand of an in expression // deprecated in favor of no-unsafe-negation diff --git a/packages/eslint-config-airbnb-base/rules/es6.js b/packages/eslint-config-airbnb-base/rules/es6.js index 835afdd319..79a4cdcc25 100644 --- a/packages/eslint-config-airbnb-base/rules/es6.js +++ b/packages/eslint-config-airbnb-base/rules/es6.js @@ -62,11 +62,10 @@ module.exports = { // Disallow specified names in exports // https://eslint.org/docs/rules/no-restricted-exports - // TODO enable, semver-minor, once eslint v7 is required (which is major) - 'no-restricted-exports': ['off', { + 'no-restricted-exports': ['error', { restrictedNamedExports: [ 'default', // use `export default` to provide a default export - 'then', // this will cause tons of confusion when your module is dynamically `import()`ed + 'then', // this will cause tons of confusion when your module is dynamically `import()`ed, and will break in most node ESM versions ], }], diff --git a/packages/eslint-config-airbnb-base/rules/imports.js b/packages/eslint-config-airbnb-base/rules/imports.js index f3a477b4b5..5f7f1bd470 100644 --- a/packages/eslint-config-airbnb-base/rules/imports.js +++ b/packages/eslint-config-airbnb-base/rules/imports.js @@ -253,7 +253,7 @@ module.exports = { // Reports modules without any exports, or with unused exports // https://github.com/benmosher/eslint-plugin-import/blob/f63dd261809de6883b13b6b5b960e6d7f42a7813/docs/rules/no-unused-modules.md - // TODO: enable, semver-major + // TODO: enable once it supports CJS 'import/no-unused-modules': ['off', { ignoreExports: [], missingExports: true, @@ -262,14 +262,12 @@ module.exports = { // Reports the use of import declarations with CommonJS exports in any module except for the main module. // https://github.com/benmosher/eslint-plugin-import/blob/1012eb951767279ce3b540a4ec4f29236104bb5b/docs/rules/no-import-module-exports.md - // TODO: enable, semver-major - 'import/no-import-module-exports': ['off', { + 'import/no-import-module-exports': ['error', { exceptions: [], }], // Use this rule to prevent importing packages through relative paths. // https://github.com/benmosher/eslint-plugin-import/blob/1012eb951767279ce3b540a4ec4f29236104bb5b/docs/rules/no-relative-packages.md - // TODO: enable, semver-major - 'import/no-relative-packages': 'off', + 'import/no-relative-packages': 'error', }, }; diff --git a/packages/eslint-config-airbnb-base/rules/style.js b/packages/eslint-config-airbnb-base/rules/style.js index d73ddefb1d..2973b258ac 100644 --- a/packages/eslint-config-airbnb-base/rules/style.js +++ b/packages/eslint-config-airbnb-base/rules/style.js @@ -80,8 +80,7 @@ module.exports = { 'eol-last': ['error', 'always'], // https://eslint.org/docs/rules/function-call-argument-newline - // TODO: enable, semver-minor, once eslint v6.2 is required (which is a major) - 'function-call-argument-newline': ['off', 'consistent'], + 'function-call-argument-newline': ['error', 'consistent'], // enforce spacing between functions and their invocations // https://eslint.org/docs/rules/func-call-spacing @@ -108,11 +107,6 @@ module.exports = { // https://eslint.org/docs/rules/function-paren-newline 'function-paren-newline': ['error', semver.satisfies(eslintPkg.version, '>= 6') ? 'multiline-arguments' : 'consistent'], - // Blacklist certain identifiers to prevent them being used - // https://eslint.org/docs/rules/id-blacklist - // TODO: semver-major, remove once eslint v7.4+ is required - 'id-blacklist': 'off', - // disallow specified identifiers // https://eslint.org/docs/rules/id-denylist 'id-denylist': 'off', @@ -444,8 +438,7 @@ module.exports = { // Disallow the use of Math.pow in favor of the ** operator // https://eslint.org/docs/rules/prefer-exponentiation-operator - // TODO: enable, semver-major when eslint 5 is dropped - 'prefer-exponentiation-operator': 'off', + 'prefer-exponentiation-operator': 'error', // Prefer use of an object spread over Object.assign // https://eslint.org/docs/rules/prefer-object-spread diff --git a/packages/eslint-config-airbnb-base/whitespace-async.js b/packages/eslint-config-airbnb-base/whitespace-async.js new file mode 100755 index 0000000000..ee7e8b4034 --- /dev/null +++ b/packages/eslint-config-airbnb-base/whitespace-async.js @@ -0,0 +1,96 @@ +#!/usr/bin/env node + +const assign = require('object.assign'); +const entries = require('object.entries'); +const { ESLint } = require('eslint'); + +const baseConfig = require('.'); + +const severities = ['off', 'warn', 'error']; + +function getSeverity(ruleConfig) { + if (Array.isArray(ruleConfig)) { + return getSeverity(ruleConfig[0]); + } + if (typeof ruleConfig === 'number') { + return severities[ruleConfig]; + } + return ruleConfig; +} + +async function onlyErrorOnRules(rulesToError, config) { + const errorsOnly = assign({}, config); + const cli = new ESLint({ + useEslintrc: false, + baseConfig: config + }); + const baseRules = (await cli.calculateConfigForFile(require.resolve('./'))).rules; + + entries(baseRules).forEach((rule) => { + const ruleName = rule[0]; + const ruleConfig = rule[1]; + const severity = getSeverity(ruleConfig); + + if (rulesToError.indexOf(ruleName) === -1 && severity === 'error') { + if (Array.isArray(ruleConfig)) { + errorsOnly.rules[ruleName] = ['warn'].concat(ruleConfig.slice(1)); + } else if (typeof ruleConfig === 'number') { + errorsOnly.rules[ruleName] = 1; + } else { + errorsOnly.rules[ruleName] = 'warn'; + } + } + }); + + return errorsOnly; +} + +onlyErrorOnRules([ + 'array-bracket-newline', + 'array-bracket-spacing', + 'array-element-newline', + 'arrow-spacing', + 'block-spacing', + 'comma-spacing', + 'computed-property-spacing', + 'dot-location', + 'eol-last', + 'func-call-spacing', + 'function-paren-newline', + 'generator-star-spacing', + 'implicit-arrow-linebreak', + 'indent', + 'key-spacing', + 'keyword-spacing', + 'line-comment-position', + 'linebreak-style', + 'multiline-ternary', + 'newline-per-chained-call', + 'no-irregular-whitespace', + 'no-mixed-spaces-and-tabs', + 'no-multi-spaces', + 'no-regex-spaces', + 'no-spaced-func', + 'no-trailing-spaces', + 'no-whitespace-before-property', + 'nonblock-statement-body-position', + 'object-curly-newline', + 'object-curly-spacing', + 'object-property-newline', + 'one-var-declaration-per-line', + 'operator-linebreak', + 'padded-blocks', + 'padding-line-between-statements', + 'rest-spread-spacing', + 'semi-spacing', + 'semi-style', + 'space-before-blocks', + 'space-before-function-paren', + 'space-in-parens', + 'space-infix-ops', + 'space-unary-ops', + 'spaced-comment', + 'switch-colon-spacing', + 'template-tag-spacing', + 'import/newline-after-import', +], baseConfig).then((config) => console.log(JSON.stringify(config))); diff --git a/packages/eslint-config-airbnb-base/whitespace.js b/packages/eslint-config-airbnb-base/whitespace.js index 0b7bda8f6f..e60f7a7918 100644 --- a/packages/eslint-config-airbnb-base/whitespace.js +++ b/packages/eslint-config-airbnb-base/whitespace.js @@ -1,91 +1,102 @@ -const assign = require('object.assign'); -const entries = require('object.entries'); +/* eslint global-require: 0 */ + const { CLIEngine } = require('eslint'); -const baseConfig = require('.'); +if (CLIEngine) { + /* eslint no-inner-declarations: 0 */ + const assign = require('object.assign'); + const entries = require('object.entries'); -const severities = ['off', 'warn', 'error']; + const baseConfig = require('.'); -function getSeverity(ruleConfig) { - if (Array.isArray(ruleConfig)) { - return getSeverity(ruleConfig[0]); - } - if (typeof ruleConfig === 'number') { - return severities[ruleConfig]; + const severities = ['off', 'warn', 'error']; + + function getSeverity(ruleConfig) { + if (Array.isArray(ruleConfig)) { + return getSeverity(ruleConfig[0]); + } + if (typeof ruleConfig === 'number') { + return severities[ruleConfig]; + } + return ruleConfig; } - return ruleConfig; -} -function onlyErrorOnRules(rulesToError, config) { - const errorsOnly = assign({}, config); - const cli = new CLIEngine({ baseConfig: config, useEslintrc: false }); - const baseRules = cli.getConfigForFile(require.resolve('./')).rules; + function onlyErrorOnRules(rulesToError, config) { + const errorsOnly = assign({}, config); + const cli = new CLIEngine({ baseConfig: config, useEslintrc: false }); + const baseRules = cli.getConfigForFile(require.resolve('./')).rules; - entries(baseRules).forEach((rule) => { - const ruleName = rule[0]; - const ruleConfig = rule[1]; - const severity = getSeverity(ruleConfig); + entries(baseRules).forEach((rule) => { + const ruleName = rule[0]; + const ruleConfig = rule[1]; + const severity = getSeverity(ruleConfig); - if (rulesToError.indexOf(ruleName) === -1 && severity === 'error') { - if (Array.isArray(ruleConfig)) { - errorsOnly.rules[ruleName] = ['warn'].concat(ruleConfig.slice(1)); - } else if (typeof ruleConfig === 'number') { - errorsOnly.rules[ruleName] = 1; - } else { - errorsOnly.rules[ruleName] = 'warn'; + if (rulesToError.indexOf(ruleName) === -1 && severity === 'error') { + if (Array.isArray(ruleConfig)) { + errorsOnly.rules[ruleName] = ['warn'].concat(ruleConfig.slice(1)); + } else if (typeof ruleConfig === 'number') { + errorsOnly.rules[ruleName] = 1; + } else { + errorsOnly.rules[ruleName] = 'warn'; + } } - } - }); + }); - return errorsOnly; -} + return errorsOnly; + } -module.exports = onlyErrorOnRules([ - 'array-bracket-newline', - 'array-bracket-spacing', - 'array-element-newline', - 'arrow-spacing', - 'block-spacing', - 'comma-spacing', - 'computed-property-spacing', - 'dot-location', - 'eol-last', - 'func-call-spacing', - 'function-paren-newline', - 'generator-star-spacing', - 'implicit-arrow-linebreak', - 'indent', - 'key-spacing', - 'keyword-spacing', - 'line-comment-position', - 'linebreak-style', - 'multiline-ternary', - 'newline-per-chained-call', - 'no-irregular-whitespace', - 'no-mixed-spaces-and-tabs', - 'no-multi-spaces', - 'no-regex-spaces', - 'no-spaced-func', - 'no-trailing-spaces', - 'no-whitespace-before-property', - 'nonblock-statement-body-position', - 'object-curly-newline', - 'object-curly-spacing', - 'object-property-newline', - 'one-var-declaration-per-line', - 'operator-linebreak', - 'padded-blocks', - 'padding-line-between-statements', - 'rest-spread-spacing', - 'semi-spacing', - 'semi-style', - 'space-before-blocks', - 'space-before-function-paren', - 'space-in-parens', - 'space-infix-ops', - 'space-unary-ops', - 'spaced-comment', - 'switch-colon-spacing', - 'template-tag-spacing', - 'import/newline-after-import', -], baseConfig); + module.exports = onlyErrorOnRules([ + 'array-bracket-newline', + 'array-bracket-spacing', + 'array-element-newline', + 'arrow-spacing', + 'block-spacing', + 'comma-spacing', + 'computed-property-spacing', + 'dot-location', + 'eol-last', + 'func-call-spacing', + 'function-paren-newline', + 'generator-star-spacing', + 'implicit-arrow-linebreak', + 'indent', + 'key-spacing', + 'keyword-spacing', + 'line-comment-position', + 'linebreak-style', + 'multiline-ternary', + 'newline-per-chained-call', + 'no-irregular-whitespace', + 'no-mixed-spaces-and-tabs', + 'no-multi-spaces', + 'no-regex-spaces', + 'no-spaced-func', + 'no-trailing-spaces', + 'no-whitespace-before-property', + 'nonblock-statement-body-position', + 'object-curly-newline', + 'object-curly-spacing', + 'object-property-newline', + 'one-var-declaration-per-line', + 'operator-linebreak', + 'padded-blocks', + 'padding-line-between-statements', + 'rest-spread-spacing', + 'semi-spacing', + 'semi-style', + 'space-before-blocks', + 'space-before-function-paren', + 'space-in-parens', + 'space-infix-ops', + 'space-unary-ops', + 'spaced-comment', + 'switch-colon-spacing', + 'template-tag-spacing', + 'import/newline-after-import', + ], baseConfig); +} else { + const path = require('path'); + const { execSync } = require('child_process'); + + module.exports = JSON.parse(String(execSync(path.join(__dirname, 'whitespace-async.js')))); +} From 366bfa66380c08304101c6add46355696e90b348 Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Mon, 8 Nov 2021 22:59:44 -0800 Subject: [PATCH 032/122] [eslint config] [base] v15.0.0 --- .../eslint-config-airbnb-base/CHANGELOG.md | 19 +++++++++++++++++++ .../eslint-config-airbnb-base/package.json | 2 +- 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/packages/eslint-config-airbnb-base/CHANGELOG.md b/packages/eslint-config-airbnb-base/CHANGELOG.md index 5f8dddf100..dcc6551f4f 100644 --- a/packages/eslint-config-airbnb-base/CHANGELOG.md +++ b/packages/eslint-config-airbnb-base/CHANGELOG.md @@ -1,3 +1,22 @@ +15.0.0 / 2021-11-08 +================== + - [breaking] drop eslint < 7, add eslint 8 (#2495) + - [breaking] add `exports` + - [patch] Improve `function-paren-newline` with `multiline-arguments` option (#2471) + - [patch] update default value for complexity (#2420) + - [patch] add disabled `no-unsafe-optional-chaining` rule + - [patch] arthmetic -> arithmetic (#2341) + - [patch] fix spelling of "than" (#2333) + - [patch] add `no-nonoctal-decimal-escape` rule + - [patch] `import/no-extraneous-dependencies`: Add .eslintrc.js to devDeps (#2329) + - [guide] Spread operator => Spread syntax (#2423) + - [guide] add references for eslint rules (#2419) + - [Docs] HTTP => HTTPS (#2489) + - [readme] some updates + - [meta] use `prepublishOnly` script for npm 7+ + - [deps] update `eslint-plugin-import`, `eslint-plugin-react`, `object.entries` + - [dev deps] update `@babel/runtime`, ``tape` + 14.2.1 / 2020-11-06 ================== - [base] `no-restricted-globals`: add better messages (#2320) diff --git a/packages/eslint-config-airbnb-base/package.json b/packages/eslint-config-airbnb-base/package.json index ef11845cae..ff6a8764a7 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": "14.2.1", + "version": "15.0.0", "description": "Airbnb's base JS ESLint config, following our styleguide", "main": "index.js", "exports": { From 930a6f2e4c98df904ec748a6a2bd4928ef6218b1 Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Wed, 10 Nov 2021 00:01:04 -0800 Subject: [PATCH 033/122] [eslint config] [*] update `@babel/runtime`, `eslint-plugin-import` --- packages/eslint-config-airbnb-base/package.json | 6 +++--- packages/eslint-config-airbnb/package.json | 6 +++--- 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 ff6a8764a7..196f78c2e1 100644 --- a/packages/eslint-config-airbnb-base/package.json +++ b/packages/eslint-config-airbnb-base/package.json @@ -68,20 +68,20 @@ }, "homepage": "https://github.com/airbnb/javascript", "devDependencies": { - "@babel/runtime": "^7.16.0", + "@babel/runtime": "^7.16.3", "babel-preset-airbnb": "^4.5.0", "babel-tape-runner": "^3.0.0", "eclint": "^2.8.1", "eslint": "^7.32.0 || ^8.2.0", "eslint-find-rules": "^4.0.0", - "eslint-plugin-import": "^2.25.2", + "eslint-plugin-import": "^2.25.3", "in-publish": "^2.0.1", "safe-publish-latest": "^2.0.0", "tape": "^5.3.1" }, "peerDependencies": { "eslint": "^7.32.0 || ^8.2.0", - "eslint-plugin-import": "^2.25.2" + "eslint-plugin-import": "^2.25.3" }, "engines": { "node": "^10.12.0 || >=12.0.0" diff --git a/packages/eslint-config-airbnb/package.json b/packages/eslint-config-airbnb/package.json index 929110f7e7..8870bb2320 100644 --- a/packages/eslint-config-airbnb/package.json +++ b/packages/eslint-config-airbnb/package.json @@ -60,13 +60,13 @@ "object.entries": "^1.1.5" }, "devDependencies": { - "@babel/runtime": "^7.16.0", + "@babel/runtime": "^7.16.3", "babel-preset-airbnb": "^4.5.0", "babel-tape-runner": "^3.0.0", "eclint": "^2.8.1", "eslint": "^5.16.0 || ^6.8.0 || ^7.2.0", "eslint-find-rules": "^3.6.1", - "eslint-plugin-import": "^2.25.2", + "eslint-plugin-import": "^2.25.3", "eslint-plugin-jsx-a11y": "^6.4.1", "eslint-plugin-react": "^7.26.0", "eslint-plugin-react-hooks": "^4.0.1 || ^3 || ^2.3.0 || ^1.7.0", @@ -77,7 +77,7 @@ }, "peerDependencies": { "eslint": "^5.16.0 || ^6.8.0 || ^7.2.0", - "eslint-plugin-import": "^2.25.2", + "eslint-plugin-import": "^2.25.3", "eslint-plugin-jsx-a11y": "^6.4.1", "eslint-plugin-react": "^7.26.0", "eslint-plugin-react-hooks": "^4.0.1 || ^3 || ^2.3.0 || ^1.7.0" From 37ebbba44cb1a7cf994c43f4b8e900b9fe7e6d22 Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Wed, 10 Nov 2021 00:04:12 -0800 Subject: [PATCH 034/122] [eslint config] [deps] update `eslint-config-airbnb-base`, `eslint-plugin-jsx-a11y`, `eslint-plugin-react`, `eslint-plugin-react-hooks`, `safe-publish-latest` --- packages/eslint-config-airbnb/package.json | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/packages/eslint-config-airbnb/package.json b/packages/eslint-config-airbnb/package.json index 8870bb2320..f2eb5d073d 100644 --- a/packages/eslint-config-airbnb/package.json +++ b/packages/eslint-config-airbnb/package.json @@ -55,7 +55,7 @@ }, "homepage": "https://github.com/airbnb/javascript", "dependencies": { - "eslint-config-airbnb-base": "^14.2.1", + "eslint-config-airbnb-base": "^15.0.0", "object.assign": "^4.1.2", "object.entries": "^1.1.5" }, @@ -67,20 +67,20 @@ "eslint": "^5.16.0 || ^6.8.0 || ^7.2.0", "eslint-find-rules": "^3.6.1", "eslint-plugin-import": "^2.25.3", - "eslint-plugin-jsx-a11y": "^6.4.1", - "eslint-plugin-react": "^7.26.0", - "eslint-plugin-react-hooks": "^4.0.1 || ^3 || ^2.3.0 || ^1.7.0", + "eslint-plugin-jsx-a11y": "^6.5.1", + "eslint-plugin-react": "^7.27.0", + "eslint-plugin-react-hooks": "^4.3.0 || ^3 || ^2.3.0 || ^1.7.0", "in-publish": "^2.0.1", "react": ">= 0.13.0", - "safe-publish-latest": "^1.1.4", + "safe-publish-latest": "^2.0.0", "tape": "^5.3.1" }, "peerDependencies": { "eslint": "^5.16.0 || ^6.8.0 || ^7.2.0", "eslint-plugin-import": "^2.25.3", - "eslint-plugin-jsx-a11y": "^6.4.1", - "eslint-plugin-react": "^7.26.0", - "eslint-plugin-react-hooks": "^4.0.1 || ^3 || ^2.3.0 || ^1.7.0" + "eslint-plugin-jsx-a11y": "^6.5.1", + "eslint-plugin-react": "^7.27.0", + "eslint-plugin-react-hooks": "^4.3.0 || ^3 || ^2.3.0 || ^1.7.0" }, "engines": { "node": ">= 6" From 1bc8cabd447ef9ce69d27ae70e67eb47daeffc21 Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Wed, 10 Nov 2021 11:31:18 -0800 Subject: [PATCH 035/122] [eslint config] [breaking] support `eslint` 8; drop `eslint` < 7 --- packages/eslint-config-airbnb/package.json | 23 +++++++++---- packages/eslint-config-airbnb/rules/react.js | 33 +++++++++++-------- .../test/test-react-order.js | 2 ++ 3 files changed, 38 insertions(+), 20 deletions(-) diff --git a/packages/eslint-config-airbnb/package.json b/packages/eslint-config-airbnb/package.json index f2eb5d073d..eba28173ea 100644 --- a/packages/eslint-config-airbnb/package.json +++ b/packages/eslint-config-airbnb/package.json @@ -3,6 +3,17 @@ "version": "18.2.1", "description": "Airbnb's ESLint config, following our styleguide", "main": "index.js", + "exports": { + ".": "./index.js", + "./base": "./base.js", + "./hooks": "./hooks.js", + "./legacy": "./legacy.js", + "./whitespace": "./whitespace.js", + "./rules/react": "./rules/react.js", + "./rules/react-a11y": "./rules/react-a11y.js", + "./rules/react-hooks": "./rules/react-hook.js", + "./package.json": "./package.json" + }, "scripts": { "prelint": "eclint check * rules/* test/*", "lint": "eslint .", @@ -64,25 +75,25 @@ "babel-preset-airbnb": "^4.5.0", "babel-tape-runner": "^3.0.0", "eclint": "^2.8.1", - "eslint": "^5.16.0 || ^6.8.0 || ^7.2.0", - "eslint-find-rules": "^3.6.1", + "eslint": "^7.32.0 || ^8.2.0", + "eslint-find-rules": "^4.0.0", "eslint-plugin-import": "^2.25.3", "eslint-plugin-jsx-a11y": "^6.5.1", "eslint-plugin-react": "^7.27.0", - "eslint-plugin-react-hooks": "^4.3.0 || ^3 || ^2.3.0 || ^1.7.0", + "eslint-plugin-react-hooks": "^4.3.0", "in-publish": "^2.0.1", "react": ">= 0.13.0", "safe-publish-latest": "^2.0.0", "tape": "^5.3.1" }, "peerDependencies": { - "eslint": "^5.16.0 || ^6.8.0 || ^7.2.0", + "eslint": "^7.32.0 || ^8.2.0", "eslint-plugin-import": "^2.25.3", "eslint-plugin-jsx-a11y": "^6.5.1", "eslint-plugin-react": "^7.27.0", - "eslint-plugin-react-hooks": "^4.3.0 || ^3 || ^2.3.0 || ^1.7.0" + "eslint-plugin-react-hooks": "^4.3.0" }, "engines": { - "node": ">= 6" + "node": "^10.12.0 || ^12.22.0 || ^14.17.0 || >=16.0.0" } } diff --git a/packages/eslint-config-airbnb/rules/react.js b/packages/eslint-config-airbnb/rules/react.js index ca16948432..71230fac71 100644 --- a/packages/eslint-config-airbnb/rules/react.js +++ b/packages/eslint-config-airbnb/rules/react.js @@ -506,8 +506,7 @@ module.exports = { // Prevent usage of `javascript:` URLs // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-no-script-url.md - // TODO: enable, semver-major - 'react/jsx-no-script-url': ['off', [ + 'react/jsx-no-script-url': ['error', [ { name: 'Link', props: ['to'], @@ -516,8 +515,7 @@ module.exports = { // Disallow unnecessary fragments // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-no-useless-fragment.md - // TODO: enable, semver-major - 'react/jsx-no-useless-fragment': 'off', + 'react/jsx-no-useless-fragment': 'error', // Prevent adjacent inline elements not separated by whitespace // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/no-adjacent-inline-elements.md @@ -526,9 +524,8 @@ module.exports = { // Enforce a specific function type for function components // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/function-component-definition.md - // TODO: enable! semver-minor, but do it in a major to be safe // TODO: investigate if setting namedComponents to expression vs declaration is problematic - 'react/function-component-definition': ['off', { + 'react/function-component-definition': ['error', { namedComponents: 'function-expression', unnamedComponents: 'function-expression', }], @@ -539,23 +536,31 @@ module.exports = { // Prevent react contexts from taking non-stable values // https://github.com/yannickcr/eslint-plugin-react/blob/e2eaadae316f9506d163812a09424eb42698470a/docs/rules/jsx-no-constructed-context-values.md - // TODO: enable, semver-minor - 'react/jsx-no-constructed-context-values': 'off', + 'react/jsx-no-constructed-context-values': 'error', // Prevent creating unstable components inside components // https://github.com/yannickcr/eslint-plugin-react/blob/c2a790a3472eea0f6de984bdc3ee2a62197417fb/docs/rules/no-unstable-nested-components.md - // TODO: enable, semver-major - 'react/no-unstable-nested-components': 'off', + 'react/no-unstable-nested-components': 'error', // Enforce that namespaces are not used in React elements // https://github.com/yannickcr/eslint-plugin-react/blob/8785c169c25b09b33c95655bf508cf46263bc53f/docs/rules/no-namespace.md - // TODO: enable, semver-minor - 'react/no-namespace': 'off', + 'react/no-namespace': 'error', // Prefer exact proptype definitions // https://github.com/yannickcr/eslint-plugin-react/blob/8785c169c25b09b33c95655bf508cf46263bc53f/docs/rules/prefer-exact-props.md - // TODO: enable, semver-major, just in case - 'react/prefer-exact-props': 'off', + 'react/prefer-exact-props': 'error', + + // Lifecycle methods should be methods on the prototype, not class fields + // https://github.com/yannickcr/eslint-plugin-react/blob/21e01b61af7a38fc86d94f27eb66cda8054582ed/docs/rules/no-arrow-function-lifecycle.md + 'react/no-arrow-function-lifecycle': 'error', + + // Prevent usage of invalid attributes + // https://github.com/yannickcr/eslint-plugin-react/blob/21e01b61af7a38fc86d94f27eb66cda8054582ed/docs/rules/no-invalid-html-attribute.md + 'react/no-invalid-html-attribute': 'error', + + // Prevent declaring unused methods of component class + // https://github.com/yannickcr/eslint-plugin-react/blob/21e01b61af7a38fc86d94f27eb66cda8054582ed/docs/rules/no-unused-class-component-methods.md + 'react/no-unused-class-component-methods': 'error', }, settings: { diff --git a/packages/eslint-config-airbnb/test/test-react-order.js b/packages/eslint-config-airbnb/test/test-react-order.js index a394fe1c3c..dca8b73e8a 100644 --- a/packages/eslint-config-airbnb/test/test-react-order.js +++ b/packages/eslint-config-airbnb/test/test-react-order.js @@ -13,6 +13,8 @@ const cli = new (CLIEngine || ESLint)({ 'import/no-extraneous-dependencies': [2, { devDependencies: true }], // this doesn't matter for tests 'lines-between-class-members': 0, + // otherwise we need some junk in our fixture code + 'react/no-unused-class-component-methods': 0, }, }); From 52e710c14ec0197cfefe131061e1fe41c966f93b Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Wed, 10 Nov 2021 12:25:30 -0800 Subject: [PATCH 036/122] [eslint config] v19.0.0 --- packages/eslint-config-airbnb/CHANGELOG.md | 13 +++++++++++++ packages/eslint-config-airbnb/package.json | 2 +- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/packages/eslint-config-airbnb/CHANGELOG.md b/packages/eslint-config-airbnb/CHANGELOG.md index 745b541d58..52ce158263 100644 --- a/packages/eslint-config-airbnb/CHANGELOG.md +++ b/packages/eslint-config-airbnb/CHANGELOG.md @@ -1,3 +1,16 @@ +19.0.0 / 2021-11-10 +================== + - [breaking] support `eslint` 8; drop `eslint` < 7 + - [patch] Explain why `react/jsx-key` is turned off (#2474) + - [fix] bump eslint-plugin-react-hooks peer dependency version (#2356) + - [patch] Alphabetize the rules for react-a11y.js (#2407) + - [Docs] HTTP => HTTPS (#2489) + - [readme] clarify hooks requirement (#2482) + - [deps] update `eslint-config-airbnb-base`, `eslint-plugin-jsx-a11y`, `eslint-plugin-react`, `eslint-plugin-react-hooks`, `safe-publish-latest`, `eslint-plugin-import`, `object.entries` + - [meta] add `--no-save` to link scripts + - [meta] use `prepublishOnly` script for npm 7+ + - [dev deps] update `@babel/runtime`, `tape` + 18.2.1 / 2020-11-06 ================== - [patch] remove deprecated `jsx-a11y/accessible-emoji` rule (#2322) diff --git a/packages/eslint-config-airbnb/package.json b/packages/eslint-config-airbnb/package.json index eba28173ea..0a72d75fef 100644 --- a/packages/eslint-config-airbnb/package.json +++ b/packages/eslint-config-airbnb/package.json @@ -1,6 +1,6 @@ { "name": "eslint-config-airbnb", - "version": "18.2.1", + "version": "19.0.0", "description": "Airbnb's ESLint config, following our styleguide", "main": "index.js", "exports": { From d8cb404da74c302506f91e5928f30cc75109e74d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=8D=8E?= Date: Thu, 11 Nov 2021 23:36:01 +0800 Subject: [PATCH 037/122] [eslint config] [base] remove unneeded eslint version check --- packages/eslint-config-airbnb-base/package.json | 3 +-- packages/eslint-config-airbnb-base/rules/style.js | 5 +---- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/packages/eslint-config-airbnb-base/package.json b/packages/eslint-config-airbnb-base/package.json index 196f78c2e1..ba2af920da 100644 --- a/packages/eslint-config-airbnb-base/package.json +++ b/packages/eslint-config-airbnb-base/package.json @@ -89,7 +89,6 @@ "dependencies": { "confusing-browser-globals": "^1.0.10", "object.assign": "^4.1.2", - "object.entries": "^1.1.5", - "semver": "^6.3.0" + "object.entries": "^1.1.5" } } diff --git a/packages/eslint-config-airbnb-base/rules/style.js b/packages/eslint-config-airbnb-base/rules/style.js index 2973b258ac..4fad26be00 100644 --- a/packages/eslint-config-airbnb-base/rules/style.js +++ b/packages/eslint-config-airbnb-base/rules/style.js @@ -1,6 +1,3 @@ -const semver = require('semver'); -const eslintPkg = require('eslint/package.json'); - module.exports = { rules: { // enforce line breaks after opening and before closing array brackets @@ -105,7 +102,7 @@ module.exports = { // require line breaks inside function parentheses if there are line breaks between parameters // https://eslint.org/docs/rules/function-paren-newline - 'function-paren-newline': ['error', semver.satisfies(eslintPkg.version, '>= 6') ? 'multiline-arguments' : 'consistent'], + 'function-paren-newline': ['error', 'multiline-arguments'], // disallow specified identifiers // https://eslint.org/docs/rules/id-denylist From 91cab81f69d7b8258846e1256d06a11e544c0870 Mon Sep 17 00:00:00 2001 From: Yatin Date: Wed, 17 Nov 2021 00:14:08 +0530 Subject: [PATCH 038/122] [readme] operator => parameter syntax --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 3fcade31f4..b97db7cc7e 100644 --- a/README.md +++ b/README.md @@ -310,7 +310,7 @@ Other Style Guides ``` - - [3.8](#objects--rest-spread) Prefer the object spread syntax 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. eslint: [`prefer-object-spread`](https://eslint.org/docs/rules/prefer-object-spread) + - [3.8](#objects--rest-spread) Prefer the object spread syntax over [`Object.assign`](https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/Object/assign) to shallow-copy objects. Use the object rest parameter syntax to get a new object with certain properties omitted. eslint: [`prefer-object-spread`](https://eslint.org/docs/rules/prefer-object-spread) ```javascript // very bad From 31c6f21878a4aeb13e6d3547252a88aece6002b0 Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Mon, 22 Nov 2021 11:06:19 -0800 Subject: [PATCH 039/122] [eslint config] [base] [refactor] make a single source of truth for whitespace rule names --- .../whitespace-async.js | 51 +------------------ .../eslint-config-airbnb-base/whitespace.js | 51 +------------------ .../whitespaceRules.js | 49 ++++++++++++++++++ 3 files changed, 53 insertions(+), 98 deletions(-) create mode 100644 packages/eslint-config-airbnb-base/whitespaceRules.js diff --git a/packages/eslint-config-airbnb-base/whitespace-async.js b/packages/eslint-config-airbnb-base/whitespace-async.js index ee7e8b4034..55c5161235 100755 --- a/packages/eslint-config-airbnb-base/whitespace-async.js +++ b/packages/eslint-config-airbnb-base/whitespace-async.js @@ -5,6 +5,7 @@ const entries = require('object.entries'); const { ESLint } = require('eslint'); const baseConfig = require('.'); +const whitespaceRules = require('./whitespaceRules'); const severities = ['off', 'warn', 'error']; @@ -45,52 +46,4 @@ async function onlyErrorOnRules(rulesToError, config) { return errorsOnly; } -onlyErrorOnRules([ - 'array-bracket-newline', - 'array-bracket-spacing', - 'array-element-newline', - 'arrow-spacing', - 'block-spacing', - 'comma-spacing', - 'computed-property-spacing', - 'dot-location', - 'eol-last', - 'func-call-spacing', - 'function-paren-newline', - 'generator-star-spacing', - 'implicit-arrow-linebreak', - 'indent', - 'key-spacing', - 'keyword-spacing', - 'line-comment-position', - 'linebreak-style', - 'multiline-ternary', - 'newline-per-chained-call', - 'no-irregular-whitespace', - 'no-mixed-spaces-and-tabs', - 'no-multi-spaces', - 'no-regex-spaces', - 'no-spaced-func', - 'no-trailing-spaces', - 'no-whitespace-before-property', - 'nonblock-statement-body-position', - 'object-curly-newline', - 'object-curly-spacing', - 'object-property-newline', - 'one-var-declaration-per-line', - 'operator-linebreak', - 'padded-blocks', - 'padding-line-between-statements', - 'rest-spread-spacing', - 'semi-spacing', - 'semi-style', - 'space-before-blocks', - 'space-before-function-paren', - 'space-in-parens', - 'space-infix-ops', - 'space-unary-ops', - 'spaced-comment', - 'switch-colon-spacing', - 'template-tag-spacing', - 'import/newline-after-import', -], baseConfig).then((config) => console.log(JSON.stringify(config))); +onlyErrorOnRules(whitespaceRules, baseConfig).then((config) => console.log(JSON.stringify(config))); diff --git a/packages/eslint-config-airbnb-base/whitespace.js b/packages/eslint-config-airbnb-base/whitespace.js index e60f7a7918..dfdf95a18e 100644 --- a/packages/eslint-config-airbnb-base/whitespace.js +++ b/packages/eslint-config-airbnb-base/whitespace.js @@ -6,6 +6,7 @@ if (CLIEngine) { /* eslint no-inner-declarations: 0 */ const assign = require('object.assign'); const entries = require('object.entries'); + const whitespaceRules = require('./whitespaceRules'); const baseConfig = require('.'); @@ -45,55 +46,7 @@ if (CLIEngine) { return errorsOnly; } - module.exports = onlyErrorOnRules([ - 'array-bracket-newline', - 'array-bracket-spacing', - 'array-element-newline', - 'arrow-spacing', - 'block-spacing', - 'comma-spacing', - 'computed-property-spacing', - 'dot-location', - 'eol-last', - 'func-call-spacing', - 'function-paren-newline', - 'generator-star-spacing', - 'implicit-arrow-linebreak', - 'indent', - 'key-spacing', - 'keyword-spacing', - 'line-comment-position', - 'linebreak-style', - 'multiline-ternary', - 'newline-per-chained-call', - 'no-irregular-whitespace', - 'no-mixed-spaces-and-tabs', - 'no-multi-spaces', - 'no-regex-spaces', - 'no-spaced-func', - 'no-trailing-spaces', - 'no-whitespace-before-property', - 'nonblock-statement-body-position', - 'object-curly-newline', - 'object-curly-spacing', - 'object-property-newline', - 'one-var-declaration-per-line', - 'operator-linebreak', - 'padded-blocks', - 'padding-line-between-statements', - 'rest-spread-spacing', - 'semi-spacing', - 'semi-style', - 'space-before-blocks', - 'space-before-function-paren', - 'space-in-parens', - 'space-infix-ops', - 'space-unary-ops', - 'spaced-comment', - 'switch-colon-spacing', - 'template-tag-spacing', - 'import/newline-after-import', - ], baseConfig); + module.exports = onlyErrorOnRules(whitespaceRules, baseConfig); } else { const path = require('path'); const { execSync } = require('child_process'); diff --git a/packages/eslint-config-airbnb-base/whitespaceRules.js b/packages/eslint-config-airbnb-base/whitespaceRules.js new file mode 100644 index 0000000000..6b0d3bfec7 --- /dev/null +++ b/packages/eslint-config-airbnb-base/whitespaceRules.js @@ -0,0 +1,49 @@ +module.exports = [ + 'array-bracket-newline', + 'array-bracket-spacing', + 'array-element-newline', + 'arrow-spacing', + 'block-spacing', + 'comma-spacing', + 'computed-property-spacing', + 'dot-location', + 'eol-last', + 'func-call-spacing', + 'function-paren-newline', + 'generator-star-spacing', + 'implicit-arrow-linebreak', + 'indent', + 'key-spacing', + 'keyword-spacing', + 'line-comment-position', + 'linebreak-style', + 'multiline-ternary', + 'newline-per-chained-call', + 'no-irregular-whitespace', + 'no-mixed-spaces-and-tabs', + 'no-multi-spaces', + 'no-regex-spaces', + 'no-spaced-func', + 'no-trailing-spaces', + 'no-whitespace-before-property', + 'nonblock-statement-body-position', + 'object-curly-newline', + 'object-curly-spacing', + 'object-property-newline', + 'one-var-declaration-per-line', + 'operator-linebreak', + 'padded-blocks', + 'padding-line-between-statements', + 'rest-spread-spacing', + 'semi-spacing', + 'semi-style', + 'space-before-blocks', + 'space-before-function-paren', + 'space-in-parens', + 'space-infix-ops', + 'space-unary-ops', + 'spaced-comment', + 'switch-colon-spacing', + 'template-tag-spacing', + 'import/newline-after-import' +]; From c4000b932a452a5d33663310b28ce7d11ea88f33 Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Mon, 22 Nov 2021 11:07:00 -0800 Subject: [PATCH 040/122] [eslint config] [fix] `whitespace`: udpate to support eslint 8 Fixes #2517 --- .../eslint-config-airbnb/whitespace-async.js | 49 ++++++ packages/eslint-config-airbnb/whitespace.js | 140 ++++++------------ .../eslint-config-airbnb/whitespaceRules.js | 64 ++++++++ 3 files changed, 158 insertions(+), 95 deletions(-) create mode 100755 packages/eslint-config-airbnb/whitespace-async.js create mode 100644 packages/eslint-config-airbnb/whitespaceRules.js diff --git a/packages/eslint-config-airbnb/whitespace-async.js b/packages/eslint-config-airbnb/whitespace-async.js new file mode 100755 index 0000000000..55c5161235 --- /dev/null +++ b/packages/eslint-config-airbnb/whitespace-async.js @@ -0,0 +1,49 @@ +#!/usr/bin/env node + +const assign = require('object.assign'); +const entries = require('object.entries'); +const { ESLint } = require('eslint'); + +const baseConfig = require('.'); +const whitespaceRules = require('./whitespaceRules'); + +const severities = ['off', 'warn', 'error']; + +function getSeverity(ruleConfig) { + if (Array.isArray(ruleConfig)) { + return getSeverity(ruleConfig[0]); + } + if (typeof ruleConfig === 'number') { + return severities[ruleConfig]; + } + return ruleConfig; +} + +async function onlyErrorOnRules(rulesToError, config) { + const errorsOnly = assign({}, config); + const cli = new ESLint({ + useEslintrc: false, + baseConfig: config + }); + const baseRules = (await cli.calculateConfigForFile(require.resolve('./'))).rules; + + entries(baseRules).forEach((rule) => { + const ruleName = rule[0]; + const ruleConfig = rule[1]; + const severity = getSeverity(ruleConfig); + + if (rulesToError.indexOf(ruleName) === -1 && severity === 'error') { + if (Array.isArray(ruleConfig)) { + errorsOnly.rules[ruleName] = ['warn'].concat(ruleConfig.slice(1)); + } else if (typeof ruleConfig === 'number') { + errorsOnly.rules[ruleName] = 1; + } else { + errorsOnly.rules[ruleName] = 'warn'; + } + } + }); + + return errorsOnly; +} + +onlyErrorOnRules(whitespaceRules, baseConfig).then((config) => console.log(JSON.stringify(config))); diff --git a/packages/eslint-config-airbnb/whitespace.js b/packages/eslint-config-airbnb/whitespace.js index 48445ada24..dfdf95a18e 100644 --- a/packages/eslint-config-airbnb/whitespace.js +++ b/packages/eslint-config-airbnb/whitespace.js @@ -1,105 +1,55 @@ -const assign = require('object.assign'); -const entries = require('object.entries'); +/* eslint global-require: 0 */ + const { CLIEngine } = require('eslint'); -const baseConfig = require('.'); +if (CLIEngine) { + /* eslint no-inner-declarations: 0 */ + const assign = require('object.assign'); + const entries = require('object.entries'); + const whitespaceRules = require('./whitespaceRules'); -const severities = ['off', 'warn', 'error']; + const baseConfig = require('.'); -function getSeverity(ruleConfig) { - if (Array.isArray(ruleConfig)) { - return getSeverity(ruleConfig[0]); - } - if (typeof ruleConfig === 'number') { - return severities[ruleConfig]; + const severities = ['off', 'warn', 'error']; + + function getSeverity(ruleConfig) { + if (Array.isArray(ruleConfig)) { + return getSeverity(ruleConfig[0]); + } + if (typeof ruleConfig === 'number') { + return severities[ruleConfig]; + } + return ruleConfig; } - return ruleConfig; -} -function onlyErrorOnRules(rulesToError, config) { - const errorsOnly = assign({}, config); - const cli = new CLIEngine({ baseConfig: config, useEslintrc: false }); - const baseRules = cli.getConfigForFile(require.resolve('./')).rules; + function onlyErrorOnRules(rulesToError, config) { + const errorsOnly = assign({}, config); + const cli = new CLIEngine({ baseConfig: config, useEslintrc: false }); + const baseRules = cli.getConfigForFile(require.resolve('./')).rules; + + entries(baseRules).forEach((rule) => { + const ruleName = rule[0]; + const ruleConfig = rule[1]; + const severity = getSeverity(ruleConfig); + + if (rulesToError.indexOf(ruleName) === -1 && severity === 'error') { + if (Array.isArray(ruleConfig)) { + errorsOnly.rules[ruleName] = ['warn'].concat(ruleConfig.slice(1)); + } else if (typeof ruleConfig === 'number') { + errorsOnly.rules[ruleName] = 1; + } else { + errorsOnly.rules[ruleName] = 'warn'; + } + } + }); - entries(baseRules).forEach((rule) => { - const ruleName = rule[0]; - const ruleConfig = rule[1]; - const severity = getSeverity(ruleConfig); + return errorsOnly; + } - if (rulesToError.indexOf(ruleName) === -1 && severity === 'error') { - if (Array.isArray(ruleConfig)) { - errorsOnly.rules[ruleName] = ['warn'].concat(ruleConfig.slice(1)); - } else if (typeof ruleConfig === 'number') { - errorsOnly.rules[ruleName] = 1; - } else { - errorsOnly.rules[ruleName] = 'warn'; - } - } - }); + module.exports = onlyErrorOnRules(whitespaceRules, baseConfig); +} else { + const path = require('path'); + const { execSync } = require('child_process'); - return errorsOnly; + module.exports = JSON.parse(String(execSync(path.join(__dirname, 'whitespace-async.js')))); } - -module.exports = onlyErrorOnRules([ - 'array-bracket-newline', - 'array-bracket-spacing', - 'array-element-newline', - 'arrow-spacing', - 'block-spacing', - 'comma-spacing', - 'computed-property-spacing', - 'dot-location', - 'eol-last', - 'func-call-spacing', - 'function-paren-newline', - 'generator-star-spacing', - 'implicit-arrow-linebreak', - 'indent', - 'key-spacing', - 'keyword-spacing', - 'line-comment-position', - 'linebreak-style', - 'multiline-ternary', - 'newline-per-chained-call', - 'no-irregular-whitespace', - 'no-mixed-spaces-and-tabs', - 'no-multi-spaces', - 'no-regex-spaces', - 'no-spaced-func', - 'no-trailing-spaces', - 'no-whitespace-before-property', - 'nonblock-statement-body-position', - 'object-curly-newline', - 'object-curly-spacing', - 'object-property-newline', - 'one-var-declaration-per-line', - 'operator-linebreak', - 'padded-blocks', - 'padding-line-between-statements', - 'rest-spread-spacing', - 'semi-spacing', - 'semi-style', - 'space-before-blocks', - 'space-before-function-paren', - 'space-in-parens', - 'space-infix-ops', - 'space-unary-ops', - 'spaced-comment', - 'switch-colon-spacing', - 'template-tag-spacing', - 'import/newline-after-import', - // eslint-plugin-react rules - 'react/jsx-child-element-spacing', - 'react/jsx-closing-bracket-location', - 'react/jsx-closing-tag-location', - 'react/jsx-curly-spacing', - 'react/jsx-equals-spacing', - 'react/jsx-first-prop-newline', - 'react/jsx-indent', - 'react/jsx-indent-props', - 'react/jsx-max-props-per-line', - 'react/jsx-one-expression-per-line', - 'react/jsx-space-before-closing', - 'react/jsx-tag-spacing', - 'react/jsx-wrap-multilines', -], baseConfig); diff --git a/packages/eslint-config-airbnb/whitespaceRules.js b/packages/eslint-config-airbnb/whitespaceRules.js new file mode 100644 index 0000000000..7c4cf691c3 --- /dev/null +++ b/packages/eslint-config-airbnb/whitespaceRules.js @@ -0,0 +1,64 @@ +module.exports = [ + 'array-bracket-newline', + 'array-bracket-spacing', + 'array-element-newline', + 'arrow-spacing', + 'block-spacing', + 'comma-spacing', + 'computed-property-spacing', + 'dot-location', + 'eol-last', + 'func-call-spacing', + 'function-paren-newline', + 'generator-star-spacing', + 'implicit-arrow-linebreak', + 'indent', + 'key-spacing', + 'keyword-spacing', + 'line-comment-position', + 'linebreak-style', + 'multiline-ternary', + 'newline-per-chained-call', + 'no-irregular-whitespace', + 'no-mixed-spaces-and-tabs', + 'no-multi-spaces', + 'no-regex-spaces', + 'no-spaced-func', + 'no-trailing-spaces', + 'no-whitespace-before-property', + 'nonblock-statement-body-position', + 'object-curly-newline', + 'object-curly-spacing', + 'object-property-newline', + 'one-var-declaration-per-line', + 'operator-linebreak', + 'padded-blocks', + 'padding-line-between-statements', + 'rest-spread-spacing', + 'semi-spacing', + 'semi-style', + 'space-before-blocks', + 'space-before-function-paren', + 'space-in-parens', + 'space-infix-ops', + 'space-unary-ops', + 'spaced-comment', + 'switch-colon-spacing', + 'template-tag-spacing', + 'import/newline-after-import', + + // eslint-plugin-react rules + 'react/jsx-child-element-spacing', + 'react/jsx-closing-bracket-location', + 'react/jsx-closing-tag-location', + 'react/jsx-curly-spacing', + 'react/jsx-equals-spacing', + 'react/jsx-first-prop-newline', + 'react/jsx-indent', + 'react/jsx-indent-props', + 'react/jsx-max-props-per-line', + 'react/jsx-one-expression-per-line', + 'react/jsx-space-before-closing', + 'react/jsx-tag-spacing', + 'react/jsx-wrap-multilines', +]; From e0bb39351941fa06978dcf90ea57cf3923c19143 Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Mon, 22 Nov 2021 11:12:26 -0800 Subject: [PATCH 041/122] [eslint config] [*] [dev deps] update `tape` --- 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 ba2af920da..2534488c92 100644 --- a/packages/eslint-config-airbnb-base/package.json +++ b/packages/eslint-config-airbnb-base/package.json @@ -77,7 +77,7 @@ "eslint-plugin-import": "^2.25.3", "in-publish": "^2.0.1", "safe-publish-latest": "^2.0.0", - "tape": "^5.3.1" + "tape": "^5.3.2" }, "peerDependencies": { "eslint": "^7.32.0 || ^8.2.0", diff --git a/packages/eslint-config-airbnb/package.json b/packages/eslint-config-airbnb/package.json index 0a72d75fef..17e3643010 100644 --- a/packages/eslint-config-airbnb/package.json +++ b/packages/eslint-config-airbnb/package.json @@ -84,7 +84,7 @@ "in-publish": "^2.0.1", "react": ">= 0.13.0", "safe-publish-latest": "^2.0.0", - "tape": "^5.3.1" + "tape": "^5.3.2" }, "peerDependencies": { "eslint": "^7.32.0 || ^8.2.0", From 97a3238020ddf3d9ae8d7e0d46d542c960cfe93b Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Mon, 22 Nov 2021 11:12:36 -0800 Subject: [PATCH 042/122] [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 17e3643010..0d2e9165fe 100644 --- a/packages/eslint-config-airbnb/package.json +++ b/packages/eslint-config-airbnb/package.json @@ -79,7 +79,7 @@ "eslint-find-rules": "^4.0.0", "eslint-plugin-import": "^2.25.3", "eslint-plugin-jsx-a11y": "^6.5.1", - "eslint-plugin-react": "^7.27.0", + "eslint-plugin-react": "^7.27.1", "eslint-plugin-react-hooks": "^4.3.0", "in-publish": "^2.0.1", "react": ">= 0.13.0", @@ -90,7 +90,7 @@ "eslint": "^7.32.0 || ^8.2.0", "eslint-plugin-import": "^2.25.3", "eslint-plugin-jsx-a11y": "^6.5.1", - "eslint-plugin-react": "^7.27.0", + "eslint-plugin-react": "^7.27.1", "eslint-plugin-react-hooks": "^4.3.0" }, "engines": { From c05ffb2417908650ec789aa442020e34669ad824 Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Mon, 22 Nov 2021 13:32:11 -0800 Subject: [PATCH 043/122] [eslint config] v19.0.1 --- 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 52ce158263..3d06242f65 100644 --- a/packages/eslint-config-airbnb/CHANGELOG.md +++ b/packages/eslint-config-airbnb/CHANGELOG.md @@ -1,3 +1,9 @@ +19.0.1 / 2021-11-22 +================== + - [fix] `whitespace`: update to support eslint 8 (#2517) + - [deps] update `eslint-plugin-react` + - [dev deps] update `tape` + 19.0.0 / 2021-11-10 ================== - [breaking] support `eslint` 8; drop `eslint` < 7 diff --git a/packages/eslint-config-airbnb/package.json b/packages/eslint-config-airbnb/package.json index 0d2e9165fe..4fd8af70c8 100644 --- a/packages/eslint-config-airbnb/package.json +++ b/packages/eslint-config-airbnb/package.json @@ -1,6 +1,6 @@ { "name": "eslint-config-airbnb", - "version": "19.0.0", + "version": "19.0.1", "description": "Airbnb's ESLint config, following our styleguide", "main": "index.js", "exports": { From 371537f393da4862c624bdd90ae823bda0e251ec Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Mon, 22 Nov 2021 13:44:36 -0800 Subject: [PATCH 044/122] [Tests] re-enable tests disabled for the eslint 8 upgrade --- .github/workflows/node.yml | 16 ++---- .../test/test-react-order.js | 54 +++++++++---------- 2 files changed, 28 insertions(+), 42 deletions(-) diff --git a/.github/workflows/node.yml b/.github/workflows/node.yml index 8337d1da57..6fc77ea08d 100644 --- a/.github/workflows/node.yml +++ b/.github/workflows/node.yml @@ -62,16 +62,12 @@ jobs: matrix: node-version: ${{ fromJson(needs.matrix.outputs.latest) }} eslint: + - 8 - 7 - # - 6 - # - 5 package: - eslint-config-airbnb react-hooks: - - '' - # - 3 # TODO: re-enable these once the react config uses eslint 8 - # - 2.3 - # - 1.7 + - 4 defaults: run: @@ -131,16 +127,12 @@ jobs: fail-fast: false matrix: eslint: + - 8 - 7 - # - 6 - # - 5 package: - eslint-config-airbnb react-hooks: - - '' - # - 3 # TODO: re-enable these once the react config uses eslint 8 - # - 2.3 - # - 1.7 + - 4 defaults: run: diff --git a/packages/eslint-config-airbnb/test/test-react-order.js b/packages/eslint-config-airbnb/test/test-react-order.js index dca8b73e8a..0ab4f937f7 100644 --- a/packages/eslint-config-airbnb/test/test-react-order.js +++ b/packages/eslint-config-airbnb/test/test-react-order.js @@ -4,25 +4,25 @@ import eslintrc from '..'; import reactRules from '../rules/react'; import reactA11yRules from '../rules/react-a11y'; +const rules = { + // It is okay to import devDependencies in tests. + 'import/no-extraneous-dependencies': [2, { devDependencies: true }], + // this doesn't matter for tests + 'lines-between-class-members': 0, + // otherwise we need some junk in our fixture code + 'react/no-unused-class-component-methods': 0, +}; const cli = new (CLIEngine || ESLint)({ useEslintrc: false, baseConfig: eslintrc, - - rules: { - // It is okay to import devDependencies in tests. - 'import/no-extraneous-dependencies': [2, { devDependencies: true }], - // this doesn't matter for tests - 'lines-between-class-members': 0, - // otherwise we need some junk in our fixture code - 'react/no-unused-class-component-methods': 0, - }, + ...(CLIEngine ? { rules } : { overrideConfig: { rules } }), }); -function lint(text) { +async function lint(text) { // @see https://eslint.org/docs/developer-guide/nodejs-api.html#executeonfiles // @see https://eslint.org/docs/developer-guide/nodejs-api.html#executeontext - const linter = CLIEngine ? cli.executeOnText(text) : cli.lintText(text); - return linter.results[0]; + const linter = CLIEngine ? cli.executeOnText(text) : await cli.lintText(text); + return (CLIEngine ? linter.results : linter)[0]; } function wrapComponent(body) { @@ -42,9 +42,8 @@ test('validate react methods order', (t) => { t.deepEqual(reactA11yRules.plugins, ['jsx-a11y', 'react']); }); - t.test('passes a good component', (t) => { - t.plan(3); - const result = lint(wrapComponent(` + t.test('passes a good component', async (t) => { + const result = await lint(wrapComponent(` componentDidMount() {} handleSubmit() {} onButtonAClick() {} @@ -61,9 +60,8 @@ test('validate react methods order', (t) => { t.notOk(result.errorCount, 'no errors'); }); - t.test('order: when random method is first', (t) => { - t.plan(2); - const result = lint(wrapComponent(` + t.test('order: when random method is first', async (t) => { + const result = await lint(wrapComponent(` someMethod() {} componentDidMount() {} setFoo() {} @@ -77,9 +75,8 @@ test('validate react methods order', (t) => { t.deepEqual(result.messages.map((msg) => msg.ruleId), ['react/sort-comp'], 'fails due to sort'); }); - t.test('order: when random method after lifecycle methods', (t) => { - t.plan(2); - const result = lint(wrapComponent(` + t.test('order: when random method after lifecycle methods', async (t) => { + const result = await lint(wrapComponent(` componentDidMount() {} someMethod() {} setFoo() {} @@ -93,9 +90,8 @@ test('validate react methods order', (t) => { t.deepEqual(result.messages.map((msg) => msg.ruleId), ['react/sort-comp'], 'fails due to sort'); }); - t.test('order: when handler method with `handle` prefix after method with `on` prefix', (t) => { - t.plan(2); - const result = lint(wrapComponent(` + t.test('order: when handler method with `handle` prefix after method with `on` prefix', async (t) => { + const result = await lint(wrapComponent(` componentDidMount() {} onButtonAClick() {} handleSubmit() {} @@ -108,9 +104,8 @@ test('validate react methods order', (t) => { t.deepEqual(result.messages.map((msg) => msg.ruleId), ['react/sort-comp'], 'fails due to sort'); }); - t.test('order: when lifecycle methods after event handler methods', (t) => { - t.plan(2); - const result = lint(wrapComponent(` + t.test('order: when lifecycle methods after event handler methods', async (t) => { + const result = await lint(wrapComponent(` handleSubmit() {} componentDidMount() {} setFoo() {} @@ -122,9 +117,8 @@ test('validate react methods order', (t) => { t.deepEqual(result.messages.map((msg) => msg.ruleId), ['react/sort-comp'], 'fails due to sort'); }); - t.test('order: when event handler methods after getters and setters', (t) => { - t.plan(2); - const result = lint(wrapComponent(` + t.test('order: when event handler methods after getters and setters', async (t) => { + const result = await lint(wrapComponent(` componentDidMount() {} setFoo() {} getFoo() {} From afc2cc34327459dcda12ce0d0656a0ffecf100a0 Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Thu, 2 Dec 2021 10:04:51 -0800 Subject: [PATCH 045/122] [eslint config] [meta] fix "exports" path Fixes #2524 --- 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 4fd8af70c8..c7565b53a1 100644 --- a/packages/eslint-config-airbnb/package.json +++ b/packages/eslint-config-airbnb/package.json @@ -11,7 +11,7 @@ "./whitespace": "./whitespace.js", "./rules/react": "./rules/react.js", "./rules/react-a11y": "./rules/react-a11y.js", - "./rules/react-hooks": "./rules/react-hook.js", + "./rules/react-hooks": "./rules/react-hooks.js", "./package.json": "./package.json" }, "scripts": { From 152bd5e85a9ba941d6a3f38643317bbfb6e1fbb3 Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Thu, 2 Dec 2021 10:34:58 -0800 Subject: [PATCH 046/122] [eslint config] v19.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 3d06242f65..590cc8e704 100644 --- a/packages/eslint-config-airbnb/CHANGELOG.md +++ b/packages/eslint-config-airbnb/CHANGELOG.md @@ -1,3 +1,8 @@ +19.0.2 / 2021-12-02 +================== + - [meta] fix "exports" path (#2525) + - [Tests] re-enable tests disabled for the eslint 8 upgrade + 19.0.1 / 2021-11-22 ================== - [fix] `whitespace`: update to support eslint 8 (#2517) diff --git a/packages/eslint-config-airbnb/package.json b/packages/eslint-config-airbnb/package.json index c7565b53a1..46fd4b6bbf 100644 --- a/packages/eslint-config-airbnb/package.json +++ b/packages/eslint-config-airbnb/package.json @@ -1,6 +1,6 @@ { "name": "eslint-config-airbnb", - "version": "19.0.1", + "version": "19.0.2", "description": "Airbnb's ESLint config, following our styleguide", "main": "index.js", "exports": { From 445322db64f0dbba35616ee68366f9d929970a3e Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Wed, 22 Dec 2021 15:09:25 -0800 Subject: [PATCH 047/122] [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 46fd4b6bbf..d882d4cb4f 100644 --- a/packages/eslint-config-airbnb/package.json +++ b/packages/eslint-config-airbnb/package.json @@ -79,7 +79,7 @@ "eslint-find-rules": "^4.0.0", "eslint-plugin-import": "^2.25.3", "eslint-plugin-jsx-a11y": "^6.5.1", - "eslint-plugin-react": "^7.27.1", + "eslint-plugin-react": "^7.28.0", "eslint-plugin-react-hooks": "^4.3.0", "in-publish": "^2.0.1", "react": ">= 0.13.0", @@ -90,7 +90,7 @@ "eslint": "^7.32.0 || ^8.2.0", "eslint-plugin-import": "^2.25.3", "eslint-plugin-jsx-a11y": "^6.5.1", - "eslint-plugin-react": "^7.27.1", + "eslint-plugin-react": "^7.28.0", "eslint-plugin-react-hooks": "^4.3.0" }, "engines": { From 38bc026fe46f807627967bed1e5e7415182cba20 Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Wed, 22 Dec 2021 15:12:04 -0800 Subject: [PATCH 048/122] [eslint config] [base] add disabled `prefer-object-has-own` rule --- packages/eslint-config-airbnb-base/rules/best-practices.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/packages/eslint-config-airbnb-base/rules/best-practices.js b/packages/eslint-config-airbnb-base/rules/best-practices.js index b91133de0a..31f74b51c0 100644 --- a/packages/eslint-config-airbnb-base/rules/best-practices.js +++ b/packages/eslint-config-airbnb-base/rules/best-practices.js @@ -376,6 +376,11 @@ module.exports = { // https://eslint.org/docs/rules/prefer-named-capture-group 'prefer-named-capture-group': 'off', + // Prefer Object.hasOwn() over Object.prototype.hasOwnProperty.call() + // https://eslint.org/docs/rules/prefer-object-has-own + // TODO: semver-major: enable thus rule, once eslint v8.5.0 is required + 'prefer-object-has-own': 'off', + // https://eslint.org/docs/rules/prefer-regex-literals 'prefer-regex-literals': ['error', { disallowRedundantWrapping: true, From 274c8d570155a05b016980294d4204c5711bce86 Mon Sep 17 00:00:00 2001 From: David Petersen Date: Wed, 10 Nov 2021 17:05:21 -0600 Subject: [PATCH 049/122] [eslint config] [patch] set `namedComponents` option to match style guide Change the `namedComponents` option to `function-declaration` to match what the style guide requires. https://github.com/airbnb/javascript/commit/019e0f7e07477e85249e1d584f22773120c41b91#r60060792 --- packages/eslint-config-airbnb/rules/react.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/packages/eslint-config-airbnb/rules/react.js b/packages/eslint-config-airbnb/rules/react.js index 71230fac71..4ece5a342c 100644 --- a/packages/eslint-config-airbnb/rules/react.js +++ b/packages/eslint-config-airbnb/rules/react.js @@ -524,9 +524,8 @@ module.exports = { // Enforce a specific function type for function components // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/function-component-definition.md - // TODO: investigate if setting namedComponents to expression vs declaration is problematic 'react/function-component-definition': ['error', { - namedComponents: 'function-expression', + namedComponents: ['function-declaration', 'function-expression'], unnamedComponents: 'function-expression', }], From baaa5e8d26f869c2520f991b34e701f220a66313 Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Fri, 24 Dec 2021 12:27:19 -0800 Subject: [PATCH 050/122] [eslint config] v19.0.3 --- 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 590cc8e704..e2adecc9dd 100644 --- a/packages/eslint-config-airbnb/CHANGELOG.md +++ b/packages/eslint-config-airbnb/CHANGELOG.md @@ -1,3 +1,8 @@ +19.0.3 / 2021-12-24 +================== + - [patch] set `namedComponents` option to match style guide + - [deps] update `eslint-plugin-react` + 19.0.2 / 2021-12-02 ================== - [meta] fix "exports" path (#2525) diff --git a/packages/eslint-config-airbnb/package.json b/packages/eslint-config-airbnb/package.json index d882d4cb4f..095c9fc03f 100644 --- a/packages/eslint-config-airbnb/package.json +++ b/packages/eslint-config-airbnb/package.json @@ -1,6 +1,6 @@ { "name": "eslint-config-airbnb", - "version": "19.0.2", + "version": "19.0.3", "description": "Airbnb's ESLint config, following our styleguide", "main": "index.js", "exports": { From d4e39c9b10767cc77c7d0091f2eae06a6ccfc33e Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Sat, 25 Dec 2021 07:34:29 -0800 Subject: [PATCH 051/122] v19.0.4 --- packages/eslint-config-airbnb-base/package.json | 4 ++-- packages/eslint-config-airbnb/CHANGELOG.md | 4 ++++ packages/eslint-config-airbnb/package.json | 2 +- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/packages/eslint-config-airbnb-base/package.json b/packages/eslint-config-airbnb-base/package.json index 2534488c92..13c3f13c6c 100644 --- a/packages/eslint-config-airbnb-base/package.json +++ b/packages/eslint-config-airbnb-base/package.json @@ -72,7 +72,7 @@ "babel-preset-airbnb": "^4.5.0", "babel-tape-runner": "^3.0.0", "eclint": "^2.8.1", - "eslint": "^7.32.0 || ^8.2.0", + "eslint": "file:../eslint-config-airbnb/node_modules/eslint", "eslint-find-rules": "^4.0.0", "eslint-plugin-import": "^2.25.3", "in-publish": "^2.0.1", @@ -80,7 +80,7 @@ "tape": "^5.3.2" }, "peerDependencies": { - "eslint": "^7.32.0 || ^8.2.0", + "eslint": "file:../eslint-config-airbnb/node_modules/eslint", "eslint-plugin-import": "^2.25.3" }, "engines": { diff --git a/packages/eslint-config-airbnb/CHANGELOG.md b/packages/eslint-config-airbnb/CHANGELOG.md index e2adecc9dd..c66e534407 100644 --- a/packages/eslint-config-airbnb/CHANGELOG.md +++ b/packages/eslint-config-airbnb/CHANGELOG.md @@ -1,3 +1,7 @@ +19.0.4 / 2021-12-25 +================== + - republish to fix #2529 + 19.0.3 / 2021-12-24 ================== - [patch] set `namedComponents` option to match style guide diff --git a/packages/eslint-config-airbnb/package.json b/packages/eslint-config-airbnb/package.json index 095c9fc03f..6cc5faa228 100644 --- a/packages/eslint-config-airbnb/package.json +++ b/packages/eslint-config-airbnb/package.json @@ -1,6 +1,6 @@ { "name": "eslint-config-airbnb", - "version": "19.0.3", + "version": "19.0.4", "description": "Airbnb's ESLint config, following our styleguide", "main": "index.js", "exports": { From 34b5bc39f1a7b8b999e041db5c3b84c0ebe0f850 Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Sat, 25 Dec 2021 12:34:37 -0800 Subject: [PATCH 052/122] [meta] revert changes from d4e39c9b10767cc77c7d0091f2eae06a6ccfc33e Caused by https://github.com/npm/cli/issues/3619 --- 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 13c3f13c6c..2534488c92 100644 --- a/packages/eslint-config-airbnb-base/package.json +++ b/packages/eslint-config-airbnb-base/package.json @@ -72,7 +72,7 @@ "babel-preset-airbnb": "^4.5.0", "babel-tape-runner": "^3.0.0", "eclint": "^2.8.1", - "eslint": "file:../eslint-config-airbnb/node_modules/eslint", + "eslint": "^7.32.0 || ^8.2.0", "eslint-find-rules": "^4.0.0", "eslint-plugin-import": "^2.25.3", "in-publish": "^2.0.1", @@ -80,7 +80,7 @@ "tape": "^5.3.2" }, "peerDependencies": { - "eslint": "file:../eslint-config-airbnb/node_modules/eslint", + "eslint": "^7.32.0 || ^8.2.0", "eslint-plugin-import": "^2.25.3" }, "engines": { From b4377fb03089dd7f08955242695860d47f9caab4 Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Tue, 11 Jan 2022 12:09:40 -0800 Subject: [PATCH 053/122] [meta] better `eclint` command --- 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 2534488c92..2bf9b40d46 100644 --- a/packages/eslint-config-airbnb-base/package.json +++ b/packages/eslint-config-airbnb-base/package.json @@ -18,7 +18,7 @@ "./package.json": "./package.json" }, "scripts": { - "prelint": "eclint check * rules/* test/*", + "prelint": "eclint check $(git ls-files | xargs find 2> /dev/null | grep -vE 'node_modules|\\.git')", "lint": "eslint --report-unused-disable-directives .", "pretests-only": "node ./test/requires", "tests-only": "babel-tape-runner ./test/test-*.js", diff --git a/packages/eslint-config-airbnb/package.json b/packages/eslint-config-airbnb/package.json index 6cc5faa228..1e2a5dd708 100644 --- a/packages/eslint-config-airbnb/package.json +++ b/packages/eslint-config-airbnb/package.json @@ -15,7 +15,7 @@ "./package.json": "./package.json" }, "scripts": { - "prelint": "eclint check * rules/* test/*", + "prelint": "eclint check $(git ls-files | xargs find 2> /dev/null | grep -vE 'node_modules|\\.git')", "lint": "eslint .", "pretests-only": "node ./test/requires", "tests-only": "babel-tape-runner ./test/test-*.js", From fd2f5a1daed62e129de3fa909421568e9fa3e2e6 Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Tue, 3 May 2022 10:29:37 -0700 Subject: [PATCH 054/122] [eslint config] [base] [deps] update `@babel/runtime`, `confusing-browser-globals`, `eslint-find-rules`, `eslint-plugin-import`, `tape` --- packages/eslint-config-airbnb-base/package.json | 12 ++++++------ packages/eslint-config-airbnb-base/rules/errors.js | 5 +++++ 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/packages/eslint-config-airbnb-base/package.json b/packages/eslint-config-airbnb-base/package.json index 2bf9b40d46..cdebd865be 100644 --- a/packages/eslint-config-airbnb-base/package.json +++ b/packages/eslint-config-airbnb-base/package.json @@ -68,26 +68,26 @@ }, "homepage": "https://github.com/airbnb/javascript", "devDependencies": { - "@babel/runtime": "^7.16.3", + "@babel/runtime": "^7.17.9", "babel-preset-airbnb": "^4.5.0", "babel-tape-runner": "^3.0.0", "eclint": "^2.8.1", "eslint": "^7.32.0 || ^8.2.0", - "eslint-find-rules": "^4.0.0", - "eslint-plugin-import": "^2.25.3", + "eslint-find-rules": "^4.1.0", + "eslint-plugin-import": "^2.26.0", "in-publish": "^2.0.1", "safe-publish-latest": "^2.0.0", - "tape": "^5.3.2" + "tape": "^5.5.3" }, "peerDependencies": { "eslint": "^7.32.0 || ^8.2.0", - "eslint-plugin-import": "^2.25.3" + "eslint-plugin-import": "^2.26.0" }, "engines": { "node": "^10.12.0 || >=12.0.0" }, "dependencies": { - "confusing-browser-globals": "^1.0.10", + "confusing-browser-globals": "^1.0.11", "object.assign": "^4.1.2", "object.entries": "^1.1.5" } diff --git a/packages/eslint-config-airbnb-base/rules/errors.js b/packages/eslint-config-airbnb-base/rules/errors.js index cdc8c26eb7..7770d5cb86 100644 --- a/packages/eslint-config-airbnb-base/rules/errors.js +++ b/packages/eslint-config-airbnb-base/rules/errors.js @@ -26,6 +26,11 @@ module.exports = { // disallow use of console 'no-console': 'warn', + // Disallows expressions where the operation doesn't affect the value + // https://eslint.org/docs/rules/no-constant-binary-expression + // TODO: semver-major, enable + 'no-constant-binary-expression': 'off', + // disallow use of constant expressions in conditions 'no-constant-condition': 'warn', From 7c0f28af8b9cdece524fa224cbddc4ac16e948fd Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Tue, 3 May 2022 10:33:40 -0700 Subject: [PATCH 055/122] [eslint config] [deps] update `@babel/runtime`, `eslint-find-rules`, `eslint-plugin-import`, `eslint-plugin-react`, `eslint-plugin-react-hooks`, `tape` --- packages/eslint-config-airbnb/package.json | 18 +++++++++--------- packages/eslint-config-airbnb/rules/react.js | 10 ++++++++++ 2 files changed, 19 insertions(+), 9 deletions(-) diff --git a/packages/eslint-config-airbnb/package.json b/packages/eslint-config-airbnb/package.json index 1e2a5dd708..2988682c42 100644 --- a/packages/eslint-config-airbnb/package.json +++ b/packages/eslint-config-airbnb/package.json @@ -71,27 +71,27 @@ "object.entries": "^1.1.5" }, "devDependencies": { - "@babel/runtime": "^7.16.3", + "@babel/runtime": "^7.17.9", "babel-preset-airbnb": "^4.5.0", "babel-tape-runner": "^3.0.0", "eclint": "^2.8.1", "eslint": "^7.32.0 || ^8.2.0", - "eslint-find-rules": "^4.0.0", - "eslint-plugin-import": "^2.25.3", + "eslint-find-rules": "^4.1.0", + "eslint-plugin-import": "^2.26.0", "eslint-plugin-jsx-a11y": "^6.5.1", - "eslint-plugin-react": "^7.28.0", - "eslint-plugin-react-hooks": "^4.3.0", + "eslint-plugin-react": "^7.29.4", + "eslint-plugin-react-hooks": "^4.5.0", "in-publish": "^2.0.1", "react": ">= 0.13.0", "safe-publish-latest": "^2.0.0", - "tape": "^5.3.2" + "tape": "^5.5.3" }, "peerDependencies": { "eslint": "^7.32.0 || ^8.2.0", - "eslint-plugin-import": "^2.25.3", + "eslint-plugin-import": "^2.26.0", "eslint-plugin-jsx-a11y": "^6.5.1", - "eslint-plugin-react": "^7.28.0", - "eslint-plugin-react-hooks": "^4.3.0" + "eslint-plugin-react": "^7.29.4", + "eslint-plugin-react-hooks": "^4.5.0" }, "engines": { "node": "^10.12.0 || ^12.22.0 || ^14.17.0 || >=16.0.0" diff --git a/packages/eslint-config-airbnb/rules/react.js b/packages/eslint-config-airbnb/rules/react.js index 4ece5a342c..2a21021de3 100644 --- a/packages/eslint-config-airbnb/rules/react.js +++ b/packages/eslint-config-airbnb/rules/react.js @@ -560,6 +560,16 @@ module.exports = { // Prevent declaring unused methods of component class // https://github.com/yannickcr/eslint-plugin-react/blob/21e01b61af7a38fc86d94f27eb66cda8054582ed/docs/rules/no-unused-class-component-methods.md 'react/no-unused-class-component-methods': 'error', + + // Ensure destructuring and symmetric naming of useState hook value and setter variables + // https://github.com/jsx-eslint/eslint-plugin-react/blob/c8833f301314dab3e79ef7ac4cf863e4d5fa0019/docs/rules/hook-use-state.md + // TODO: semver-major, enable + 'react/hook-use-state': 'off', + + // Enforce sandbox attribute on iframe elements + // https://github.com/jsx-eslint/eslint-plugin-react/blob/c8833f301314dab3e79ef7ac4cf863e4d5fa0019/docs/rules/iframe-missing-sandbox.md + // TODO: semver-major, enable + 'react/iframe-missing-sandbox': 'off', }, settings: { From 1677ba6c6a285366e38998e292d42a7eab64d18e Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Tue, 3 May 2022 10:41:03 -0700 Subject: [PATCH 056/122] [eslint config] [meta] update eslint-plugin-react repo URLs --- packages/eslint-config-airbnb/CHANGELOG.md | 16 +- packages/eslint-config-airbnb/rules/react.js | 190 +++++++++---------- 2 files changed, 103 insertions(+), 103 deletions(-) diff --git a/packages/eslint-config-airbnb/CHANGELOG.md b/packages/eslint-config-airbnb/CHANGELOG.md index c66e534407..68ba86b925 100644 --- a/packages/eslint-config-airbnb/CHANGELOG.md +++ b/packages/eslint-config-airbnb/CHANGELOG.md @@ -467,11 +467,11 @@ [space-in-parens]: https://eslint.org/docs/rules/space-in-parens [template-curly-spacing]: https://eslint.org/docs/rules/template-curly-spacing -[react/jsx-space-before-closing]: https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-space-before-closing.md -[react/sort-comp]: https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/sort-comp.md -[react/display-name]: https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/display-name.md -[react/jsx-no-bind]: https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-no-bind.md -[react/no-is-mounted]: https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/no-is-mounted.md -[react/prefer-es6-class]: https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/prefer-es6-class.md -[react/jsx-quotes]: https://github.com/yannickcr/eslint-plugin-react/blob/f817e37beddddc84b4788969f07c524fa7f0823b/docs/rules/jsx-quotes.md -[react/prefer-stateless-function]: https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/prefer-stateless-function.md +[react/jsx-space-before-closing]: https://github.com/jsx-eslint/eslint-plugin-react/blob/HEAD/docs/rules/jsx-space-before-closing.md +[react/sort-comp]: https://github.com/jsx-eslint/eslint-plugin-react/blob/HEAD/docs/rules/sort-comp.md +[react/display-name]: https://github.com/jsx-eslint/eslint-plugin-react/blob/HEAD/docs/rules/display-name.md +[react/jsx-no-bind]: https://github.com/jsx-eslint/eslint-plugin-react/blob/HEAD/docs/rules/jsx-no-bind.md +[react/no-is-mounted]: https://github.com/jsx-eslint/eslint-plugin-react/blob/HEAD/docs/rules/no-is-mounted.md +[react/prefer-es6-class]: https://github.com/jsx-eslint/eslint-plugin-react/blob/HEAD/docs/rules/prefer-es6-class.md +[react/jsx-quotes]: https://github.com/jsx-eslint/eslint-plugin-react/blob/f817e37beddddc84b4788969f07c524fa7f0823b/docs/rules/jsx-quotes.md +[react/prefer-stateless-function]: https://github.com/jsx-eslint/eslint-plugin-react/blob/HEAD/docs/rules/prefer-stateless-function.md diff --git a/packages/eslint-config-airbnb/rules/react.js b/packages/eslint-config-airbnb/rules/react.js index 2a21021de3..d957fcbe7d 100644 --- a/packages/eslint-config-airbnb/rules/react.js +++ b/packages/eslint-config-airbnb/rules/react.js @@ -15,7 +15,7 @@ module.exports = { }, // View link below for react rules documentation - // https://github.com/yannickcr/eslint-plugin-react#list-of-supported-rules + // https://github.com/jsx-eslint/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__']), @@ -47,11 +47,11 @@ module.exports = { }], // Prevent missing displayName in a React component definition - // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/display-name.md + // https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/display-name.md 'react/display-name': ['off', { ignoreTranspilerName: false }], // Forbid certain propTypes (any, array, object) - // https://github.com/yannickcr/eslint-plugin-react/blob/843d71a432baf0f01f598d7cf1eea75ad6896e4b/docs/rules/forbid-prop-types.md + // https://github.com/jsx-eslint/eslint-plugin-react/blob/843d71a432baf0f01f598d7cf1eea75ad6896e4b/docs/rules/forbid-prop-types.md 'react/forbid-prop-types': ['error', { forbid: ['any', 'array', 'object'], checkContextTypes: true, @@ -59,47 +59,47 @@ module.exports = { }], // Forbid certain props on DOM Nodes - // https://github.com/yannickcr/eslint-plugin-react/blob/843d71a432baf0f01f598d7cf1eea75ad6896e4b/docs/rules/forbid-dom-props.md + // https://github.com/jsx-eslint/eslint-plugin-react/blob/843d71a432baf0f01f598d7cf1eea75ad6896e4b/docs/rules/forbid-dom-props.md 'react/forbid-dom-props': ['off', { forbid: [] }], // Enforce boolean attributes notation in JSX - // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-boolean-value.md + // https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/jsx-boolean-value.md '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 + // https://github.com/jsx-eslint/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/master/docs/rules/jsx-closing-tag-location.md + // https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/jsx-closing-tag-location.md 'react/jsx-closing-tag-location': 'error', // 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 + // https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/jsx-curly-spacing.md '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 + // https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/jsx-handler-names.md '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 + // https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/jsx-indent-props.md '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 + // https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/jsx-key.md // Turned off because it has too many false positives '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 + // https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/jsx-max-props-per-line.md '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 + // https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/jsx-no-bind.md 'react/jsx-no-bind': ['error', { ignoreRefs: true, allowArrowFunctions: true, @@ -109,26 +109,26 @@ module.exports = { }], // Prevent duplicate props in JSX - // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-no-duplicate-props.md + // https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/jsx-no-duplicate-props.md '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 + // https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/jsx-no-literals.md '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 + // https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/jsx-no-undef.md '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 + // https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/jsx-pascal-case.md '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 + // https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/sort-prop-types.md 'react/sort-prop-types': ['off', { ignoreCase: true, callbacksLast: false, @@ -140,7 +140,7 @@ module.exports = { '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 + // https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/jsx-sort-props.md 'react/jsx-sort-props': ['off', { ignoreCase: true, callbacksLast: false, @@ -151,74 +151,74 @@ module.exports = { }], // Enforce defaultProps declarations alphabetical sorting - // https://github.com/yannickcr/eslint-plugin-react/blob/843d71a432baf0f01f598d7cf1eea75ad6896e4b/docs/rules/jsx-sort-default-props.md + // https://github.com/jsx-eslint/eslint-plugin-react/blob/843d71a432baf0f01f598d7cf1eea75ad6896e4b/docs/rules/jsx-sort-default-props.md 'react/jsx-sort-default-props': ['off', { ignoreCase: true, }], // Prevent React to be incorrectly marked as unused - // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-uses-react.md + // https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/jsx-uses-react.md '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 + // https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/jsx-uses-vars.md '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 + // https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/no-danger.md 'react/no-danger': 'warn', // Prevent usage of deprecated methods - // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/no-deprecated.md + // https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/no-deprecated.md '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 + // https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/no-did-mount-set-state.md // this is necessary for server-rendering 'react/no-did-mount-set-state': 'off', // Prevent usage of setState in componentDidUpdate - // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/no-did-update-set-state.md + // https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/no-did-update-set-state.md '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 + // https://github.com/jsx-eslint/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 + // https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/no-direct-mutation-state.md '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 + // https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/no-is-mounted.md '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 + // https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/no-multi-comp.md 'react/no-multi-comp': 'off', // Prevent usage of setState - // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/no-set-state.md + // https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/no-set-state.md 'react/no-set-state': 'off', // Prevent using string references - // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/no-string-refs.md + // https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/no-string-refs.md '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 + // https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/no-unknown-property.md '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 + // https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/prefer-es6-class.md '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 + // https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/prefer-stateless-function.md '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 + // https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/prop-types.md 'react/prop-types': ['error', { ignore: [], customValidators: [], @@ -226,19 +226,19 @@ module.exports = { }], // Prevent missing React when using JSX - // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/react-in-jsx-scope.md + // https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/react-in-jsx-scope.md 'react/react-in-jsx-scope': 'error', // Require render() methods to return something - // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/require-render-return.md + // https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/require-render-return.md '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 + // https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/self-closing-comp.md 'react/self-closing-comp': 'error', // Enforce component methods order - // https://github.com/yannickcr/eslint-plugin-react/blob/843d71a432baf0f01f598d7cf1eea75ad6896e4b/docs/rules/sort-comp.md + // https://github.com/jsx-eslint/eslint-plugin-react/blob/843d71a432baf0f01f598d7cf1eea75ad6896e4b/docs/rules/sort-comp.md 'react/sort-comp': ['error', { order: [ 'static-variables', @@ -290,7 +290,7 @@ module.exports = { }], // Prevent missing parentheses around multilines JSX - // https://github.com/yannickcr/eslint-plugin-react/blob/843d71a432baf0f01f598d7cf1eea75ad6896e4b/docs/rules/jsx-wrap-multilines.md + // https://github.com/jsx-eslint/eslint-plugin-react/blob/843d71a432baf0f01f598d7cf1eea75ad6896e4b/docs/rules/jsx-wrap-multilines.md 'react/jsx-wrap-multilines': ['error', { declaration: 'parens-new-line', assignment: 'parens-new-line', @@ -302,55 +302,55 @@ module.exports = { }], // 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 + // https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/jsx-first-prop-new-line.md '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 + // https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/jsx-equals-spacing.md 'react/jsx-equals-spacing': ['error', 'never'], // Enforce JSX indentation - // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-indent.md + // https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/jsx-indent.md 'react/jsx-indent': ['error', 2], // Disallow target="_blank" on links - // https://github.com/yannickcr/eslint-plugin-react/blob/ac102885765be5ff37847a871f239c6703e1c7cc/docs/rules/jsx-no-target-blank.md + // https://github.com/jsx-eslint/eslint-plugin-react/blob/ac102885765be5ff37847a871f239c6703e1c7cc/docs/rules/jsx-no-target-blank.md 'react/jsx-no-target-blank': ['error', { enforceDynamicLinks: 'always' }], // only .jsx files may have JSX - // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-filename-extension.md + // https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/jsx-filename-extension.md '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 + // https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/jsx-no-comment-textnodes.md 'react/jsx-no-comment-textnodes': 'error', // 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 + // https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/no-render-return-value.md '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 + // https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/require-optimization.md '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 + // https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/no-find-dom-node.md '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 + // https://github.com/jsx-eslint/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 + // https://github.com/jsx-eslint/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 + // https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/no-danger-with-children.md '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 + // https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/no-unused-prop-types.md 'react/no-unused-prop-types': ['error', { customValidators: [ ], @@ -358,19 +358,19 @@ 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 + // https://github.com/jsx-eslint/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 + // https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/no-unescaped-entities.md '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 + // https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/no-children-prop.md 'react/no-children-prop': 'error', // Validate whitespace in and around the JSX opening and closing brackets - // https://github.com/yannickcr/eslint-plugin-react/blob/843d71a432baf0f01f598d7cf1eea75ad6896e4b/docs/rules/jsx-tag-spacing.md + // https://github.com/jsx-eslint/eslint-plugin-react/blob/843d71a432baf0f01f598d7cf1eea75ad6896e4b/docs/rules/jsx-tag-spacing.md 'react/jsx-tag-spacing': ['error', { closingSlash: 'never', beforeSelfClosing: 'always', @@ -379,44 +379,44 @@ module.exports = { }], // 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 + // https://github.com/jsx-eslint/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 + // https://github.com/jsx-eslint/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/843d71a432baf0f01f598d7cf1eea75ad6896e4b/docs/rules/require-default-props.md + // https://github.com/jsx-eslint/eslint-plugin-react/blob/843d71a432baf0f01f598d7cf1eea75ad6896e4b/docs/rules/require-default-props.md 'react/require-default-props': ['error', { forbidDefaultForRequired: true, }], // Forbids using non-exported propTypes - // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/forbid-foreign-prop-types.md + // https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/forbid-foreign-prop-types.md // this is intentionally set to "warn". it would be "error", // but it's only critical if you're stripping propTypes in production. 'react/forbid-foreign-prop-types': ['warn', { allowInPropTypes: true }], // Prevent void DOM elements from receiving children - // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/void-dom-elements-no-children.md + // https://github.com/jsx-eslint/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 + // https://github.com/jsx-eslint/eslint-plugin-react/blob/9e13ae2c51e44872b45cc15bf1ac3a72105bdd0e/docs/rules/default-props-match-prop-types.md 'react/default-props-match-prop-types': ['error', { allowRequiredDefaults: false }], // Prevent usage of shouldComponentUpdate when extending React.PureComponent - // https://github.com/yannickcr/eslint-plugin-react/blob/9e13ae2c51e44872b45cc15bf1ac3a72105bdd0e/docs/rules/no-redundant-should-component-update.md + // https://github.com/jsx-eslint/eslint-plugin-react/blob/9e13ae2c51e44872b45cc15bf1ac3a72105bdd0e/docs/rules/no-redundant-should-component-update.md 'react/no-redundant-should-component-update': 'error', // Prevent unused state values - // https://github.com/yannickcr/eslint-plugin-react/pull/1103/ + // https://github.com/jsx-eslint/eslint-plugin-react/pull/1103/ 'react/no-unused-state': 'error', // Enforces consistent naming for boolean props - // https://github.com/yannickcr/eslint-plugin-react/blob/843d71a432baf0f01f598d7cf1eea75ad6896e4b/docs/rules/boolean-prop-naming.md + // https://github.com/jsx-eslint/eslint-plugin-react/blob/843d71a432baf0f01f598d7cf1eea75ad6896e4b/docs/rules/boolean-prop-naming.md 'react/boolean-prop-naming': ['off', { propTypeNames: ['bool', 'mutuallyExclusiveTrueProps'], rule: '^(is|has)[A-Z]([A-Za-z0-9]?)+', @@ -424,27 +424,27 @@ module.exports = { }], // Prevents common casing typos - // https://github.com/yannickcr/eslint-plugin-react/blob/73abadb697034b5ccb514d79fb4689836fe61f91/docs/rules/no-typos.md + // https://github.com/jsx-eslint/eslint-plugin-react/blob/73abadb697034b5ccb514d79fb4689836fe61f91/docs/rules/no-typos.md 'react/no-typos': 'error', // Enforce curly braces or disallow unnecessary curly braces in JSX props and/or children - // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-curly-brace-presence.md + // https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/jsx-curly-brace-presence.md 'react/jsx-curly-brace-presence': ['error', { props: 'never', children: 'never' }], // One JSX Element Per Line - // https://github.com/yannickcr/eslint-plugin-react/blob/843d71a432baf0f01f598d7cf1eea75ad6896e4b/docs/rules/jsx-one-expression-per-line.md + // https://github.com/jsx-eslint/eslint-plugin-react/blob/843d71a432baf0f01f598d7cf1eea75ad6896e4b/docs/rules/jsx-one-expression-per-line.md 'react/jsx-one-expression-per-line': ['error', { allow: 'single-child' }], // Enforce consistent usage of destructuring assignment of props, state, and context - // https://github.com/yannickcr/eslint-plugin-react/blob/843d71a432baf0f01f598d7cf1eea75ad6896e4b/docs/rules/destructuring-assignment.md + // https://github.com/jsx-eslint/eslint-plugin-react/blob/843d71a432baf0f01f598d7cf1eea75ad6896e4b/docs/rules/destructuring-assignment.md 'react/destructuring-assignment': ['error', 'always'], // Prevent using this.state within a this.setState - // https://github.com/yannickcr/eslint-plugin-react/blob/843d71a432baf0f01f598d7cf1eea75ad6896e4b/docs/rules/no-access-state-in-setstate.md + // https://github.com/jsx-eslint/eslint-plugin-react/blob/843d71a432baf0f01f598d7cf1eea75ad6896e4b/docs/rules/no-access-state-in-setstate.md 'react/no-access-state-in-setstate': 'error', // Prevent usage of button elements without an explicit type attribute - // https://github.com/yannickcr/eslint-plugin-react/blob/843d71a432baf0f01f598d7cf1eea75ad6896e4b/docs/rules/button-has-type.md + // https://github.com/jsx-eslint/eslint-plugin-react/blob/843d71a432baf0f01f598d7cf1eea75ad6896e4b/docs/rules/button-has-type.md 'react/button-has-type': ['error', { button: true, submit: true, @@ -455,44 +455,44 @@ module.exports = { 'react/jsx-child-element-spacing': 'off', // Prevent this from being used in stateless functional components - // https://github.com/yannickcr/eslint-plugin-react/blob/843d71a432baf0f01f598d7cf1eea75ad6896e4b/docs/rules/no-this-in-sfc.md + // https://github.com/jsx-eslint/eslint-plugin-react/blob/843d71a432baf0f01f598d7cf1eea75ad6896e4b/docs/rules/no-this-in-sfc.md 'react/no-this-in-sfc': 'error', // Validate JSX maximum depth - // https://github.com/yannickcr/eslint-plugin-react/blob/abe8381c0d6748047224c430ce47f02e40160ed0/docs/rules/jsx-max-depth.md + // https://github.com/jsx-eslint/eslint-plugin-react/blob/abe8381c0d6748047224c430ce47f02e40160ed0/docs/rules/jsx-max-depth.md 'react/jsx-max-depth': 'off', // Disallow multiple spaces between inline JSX props - // https://github.com/yannickcr/eslint-plugin-react/blob/ac102885765be5ff37847a871f239c6703e1c7cc/docs/rules/jsx-props-no-multi-spaces.md + // https://github.com/jsx-eslint/eslint-plugin-react/blob/ac102885765be5ff37847a871f239c6703e1c7cc/docs/rules/jsx-props-no-multi-spaces.md 'react/jsx-props-no-multi-spaces': 'error', // Prevent usage of UNSAFE_ methods - // https://github.com/yannickcr/eslint-plugin-react/blob/157cc932be2cfaa56b3f5b45df6f6d4322a2f660/docs/rules/no-unsafe.md + // https://github.com/jsx-eslint/eslint-plugin-react/blob/157cc932be2cfaa56b3f5b45df6f6d4322a2f660/docs/rules/no-unsafe.md 'react/no-unsafe': 'off', // Enforce shorthand or standard form for React fragments - // https://github.com/yannickcr/eslint-plugin-react/blob/bc976b837abeab1dffd90ac6168b746a83fc83cc/docs/rules/jsx-fragments.md + // https://github.com/jsx-eslint/eslint-plugin-react/blob/bc976b837abeab1dffd90ac6168b746a83fc83cc/docs/rules/jsx-fragments.md 'react/jsx-fragments': ['error', 'syntax'], // Enforce linebreaks in curly braces in JSX attributes and expressions. - // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-curly-newline.md + // https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/jsx-curly-newline.md 'react/jsx-curly-newline': ['error', { multiline: 'consistent', singleline: 'consistent', }], // Enforce state initialization style - // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/state-in-constructor.md + // https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/state-in-constructor.md // TODO: set to "never" once babel-preset-airbnb supports public class fields 'react/state-in-constructor': ['error', 'always'], // Enforces where React component static properties should be positioned - // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/static-property-placement.md + // https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/static-property-placement.md // TODO: set to "static public field" once babel-preset-airbnb supports public class fields 'react/static-property-placement': ['error', 'property assignment'], // Disallow JSX props spreading - // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-props-no-spreading.md + // https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/jsx-props-no-spreading.md 'react/jsx-props-no-spreading': ['error', { html: 'enforce', custom: 'enforce', @@ -501,11 +501,11 @@ module.exports = { }], // Enforce that props are read-only - // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/prefer-read-only-props.md + // https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/prefer-read-only-props.md 'react/prefer-read-only-props': 'off', // Prevent usage of `javascript:` URLs - // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-no-script-url.md + // https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/jsx-no-script-url.md 'react/jsx-no-script-url': ['error', [ { name: 'Link', @@ -514,51 +514,51 @@ module.exports = { ]], // Disallow unnecessary fragments - // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-no-useless-fragment.md + // https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/jsx-no-useless-fragment.md 'react/jsx-no-useless-fragment': 'error', // Prevent adjacent inline elements not separated by whitespace - // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/no-adjacent-inline-elements.md + // https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/no-adjacent-inline-elements.md // TODO: enable? semver-major 'react/no-adjacent-inline-elements': 'off', // Enforce a specific function type for function components - // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/function-component-definition.md + // https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/function-component-definition.md 'react/function-component-definition': ['error', { namedComponents: ['function-declaration', 'function-expression'], unnamedComponents: 'function-expression', }], // Enforce a new line after jsx elements and expressions - // https://github.com/yannickcr/eslint-plugin-react/blob/e2eaadae316f9506d163812a09424eb42698470a/docs/rules/jsx-newline.md + // https://github.com/jsx-eslint/eslint-plugin-react/blob/e2eaadae316f9506d163812a09424eb42698470a/docs/rules/jsx-newline.md 'react/jsx-newline': 'off', // Prevent react contexts from taking non-stable values - // https://github.com/yannickcr/eslint-plugin-react/blob/e2eaadae316f9506d163812a09424eb42698470a/docs/rules/jsx-no-constructed-context-values.md + // https://github.com/jsx-eslint/eslint-plugin-react/blob/e2eaadae316f9506d163812a09424eb42698470a/docs/rules/jsx-no-constructed-context-values.md 'react/jsx-no-constructed-context-values': 'error', // Prevent creating unstable components inside components - // https://github.com/yannickcr/eslint-plugin-react/blob/c2a790a3472eea0f6de984bdc3ee2a62197417fb/docs/rules/no-unstable-nested-components.md + // https://github.com/jsx-eslint/eslint-plugin-react/blob/c2a790a3472eea0f6de984bdc3ee2a62197417fb/docs/rules/no-unstable-nested-components.md 'react/no-unstable-nested-components': 'error', // Enforce that namespaces are not used in React elements - // https://github.com/yannickcr/eslint-plugin-react/blob/8785c169c25b09b33c95655bf508cf46263bc53f/docs/rules/no-namespace.md + // https://github.com/jsx-eslint/eslint-plugin-react/blob/8785c169c25b09b33c95655bf508cf46263bc53f/docs/rules/no-namespace.md 'react/no-namespace': 'error', // Prefer exact proptype definitions - // https://github.com/yannickcr/eslint-plugin-react/blob/8785c169c25b09b33c95655bf508cf46263bc53f/docs/rules/prefer-exact-props.md + // https://github.com/jsx-eslint/eslint-plugin-react/blob/8785c169c25b09b33c95655bf508cf46263bc53f/docs/rules/prefer-exact-props.md 'react/prefer-exact-props': 'error', // Lifecycle methods should be methods on the prototype, not class fields - // https://github.com/yannickcr/eslint-plugin-react/blob/21e01b61af7a38fc86d94f27eb66cda8054582ed/docs/rules/no-arrow-function-lifecycle.md + // https://github.com/jsx-eslint/eslint-plugin-react/blob/21e01b61af7a38fc86d94f27eb66cda8054582ed/docs/rules/no-arrow-function-lifecycle.md 'react/no-arrow-function-lifecycle': 'error', // Prevent usage of invalid attributes - // https://github.com/yannickcr/eslint-plugin-react/blob/21e01b61af7a38fc86d94f27eb66cda8054582ed/docs/rules/no-invalid-html-attribute.md + // https://github.com/jsx-eslint/eslint-plugin-react/blob/21e01b61af7a38fc86d94f27eb66cda8054582ed/docs/rules/no-invalid-html-attribute.md 'react/no-invalid-html-attribute': 'error', // Prevent declaring unused methods of component class - // https://github.com/yannickcr/eslint-plugin-react/blob/21e01b61af7a38fc86d94f27eb66cda8054582ed/docs/rules/no-unused-class-component-methods.md + // https://github.com/jsx-eslint/eslint-plugin-react/blob/21e01b61af7a38fc86d94f27eb66cda8054582ed/docs/rules/no-unused-class-component-methods.md 'react/no-unused-class-component-methods': 'error', // Ensure destructuring and symmetric naming of useState hook value and setter variables From 7fdc87a8be565fa1f1779dc1d6b6461b953f7d85 Mon Sep 17 00:00:00 2001 From: terrablue <102580937+terrablue@users.noreply.github.com> Date: Tue, 3 May 2022 19:06:48 +0200 Subject: [PATCH 057/122] [guide] fix eslint core rule URLs - fix broken eslint eol-last link - remove .html ending in eslint urls --- README.md | 84 +++++++++++++++++++++++++++---------------------------- 1 file changed, 42 insertions(+), 42 deletions(-) diff --git a/README.md b/README.md index b97db7cc7e..49eebff107 100644 --- a/README.md +++ b/README.md @@ -105,7 +105,7 @@ Other Style Guides ## References - - [2.1](#references--prefer-const) Use `const` for all of your references; avoid using `var`. eslint: [`prefer-const`](https://eslint.org/docs/rules/prefer-const.html), [`no-const-assign`](https://eslint.org/docs/rules/no-const-assign.html) + - [2.1](#references--prefer-const) Use `const` for all of your references; avoid using `var`. eslint: [`prefer-const`](https://eslint.org/docs/rules/prefer-const), [`no-const-assign`](https://eslint.org/docs/rules/no-const-assign) > Why? This ensures that you can’t reassign your references, which can lead to bugs and difficult to comprehend code. @@ -120,7 +120,7 @@ Other Style Guides ``` - - [2.2](#references--disallow-var) If you must reassign references, use `let` instead of `var`. eslint: [`no-var`](https://eslint.org/docs/rules/no-var.html) + - [2.2](#references--disallow-var) If you must reassign references, use `let` instead of `var`. eslint: [`no-var`](https://eslint.org/docs/rules/no-var) > Why? `let` is block-scoped rather than function-scoped like `var`. @@ -160,7 +160,7 @@ Other Style Guides ## Objects - - [3.1](#objects--no-new) Use the literal syntax for object creation. eslint: [`no-new-object`](https://eslint.org/docs/rules/no-new-object.html) + - [3.1](#objects--no-new) Use the literal syntax for object creation. eslint: [`no-new-object`](https://eslint.org/docs/rules/no-new-object) ```javascript // bad @@ -197,7 +197,7 @@ Other Style Guides ``` - - [3.3](#es6-object-shorthand) Use object method shorthand. eslint: [`object-shorthand`](https://eslint.org/docs/rules/object-shorthand.html) + - [3.3](#es6-object-shorthand) Use object method shorthand. eslint: [`object-shorthand`](https://eslint.org/docs/rules/object-shorthand) ```javascript // bad @@ -220,7 +220,7 @@ Other Style Guides ``` - - [3.4](#es6-object-concise) Use property value shorthand. eslint: [`object-shorthand`](https://eslint.org/docs/rules/object-shorthand.html) + - [3.4](#es6-object-concise) Use property value shorthand. eslint: [`object-shorthand`](https://eslint.org/docs/rules/object-shorthand) > Why? It is shorter and descriptive. @@ -269,7 +269,7 @@ Other Style Guides ``` - - [3.6](#objects--quoted-props) Only quote properties that are invalid identifiers. eslint: [`quote-props`](https://eslint.org/docs/rules/quote-props.html) + - [3.6](#objects--quoted-props) Only quote properties that are invalid identifiers. eslint: [`quote-props`](https://eslint.org/docs/rules/quote-props) > Why? In general we consider it subjectively easier to read. It improves syntax highlighting, and is also more easily optimized by many JS engines. @@ -334,7 +334,7 @@ Other Style Guides ## Arrays - - [4.1](#arrays--literals) Use the literal syntax for array creation. eslint: [`no-array-constructor`](https://eslint.org/docs/rules/no-array-constructor.html) + - [4.1](#arrays--literals) Use the literal syntax for array creation. eslint: [`no-array-constructor`](https://eslint.org/docs/rules/no-array-constructor) ```javascript // bad @@ -568,7 +568,7 @@ Other Style Guides ## Strings - - [6.1](#strings--quotes) Use single quotes `''` for strings. eslint: [`quotes`](https://eslint.org/docs/rules/quotes.html) + - [6.1](#strings--quotes) Use single quotes `''` for strings. eslint: [`quotes`](https://eslint.org/docs/rules/quotes) ```javascript // bad @@ -603,7 +603,7 @@ Other Style Guides ``` - - [6.3](#es6-template-literals) When programmatically building up strings, use template strings instead of concatenation. eslint: [`prefer-template`](https://eslint.org/docs/rules/prefer-template.html) [`template-curly-spacing`](https://eslint.org/docs/rules/template-curly-spacing) + - [6.3](#es6-template-literals) When programmatically building up strings, use template strings instead of concatenation. eslint: [`prefer-template`](https://eslint.org/docs/rules/prefer-template) [`template-curly-spacing`](https://eslint.org/docs/rules/template-curly-spacing) > Why? Template strings give you a readable, concise syntax with proper newlines and string interpolation features. @@ -674,7 +674,7 @@ Other Style Guides ``` - - [7.2](#functions--iife) Wrap immediately invoked function expressions in parentheses. eslint: [`wrap-iife`](https://eslint.org/docs/rules/wrap-iife.html) + - [7.2](#functions--iife) Wrap immediately invoked function expressions in parentheses. eslint: [`wrap-iife`](https://eslint.org/docs/rules/wrap-iife) > Why? An immediately invoked function expression is a single unit - wrapping both it, and its invocation parens, in parens, cleanly expresses this. Note that in a world with modules everywhere, you almost never need an IIFE. @@ -686,7 +686,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`](https://eslint.org/docs/rules/no-loop-func.html) + - [7.3](#functions--in-blocks) Never declare a function in a non-function block (`if`, `while`, etc). Assign the function to a variable instead. Browsers will allow you to do it, but they all interpret it differently, which is bad news bears. eslint: [`no-loop-func`](https://eslint.org/docs/rules/no-loop-func) - [7.4](#functions--note-on-blocks) **Note:** ECMA-262 defines a `block` as a list of statements. A function declaration is not a statement. @@ -830,7 +830,7 @@ Other Style Guides ``` - - [7.12](#functions--mutate-params) Never mutate parameters. eslint: [`no-param-reassign`](https://eslint.org/docs/rules/no-param-reassign.html) + - [7.12](#functions--mutate-params) Never mutate parameters. eslint: [`no-param-reassign`](https://eslint.org/docs/rules/no-param-reassign) > Why? Manipulating objects passed in as parameters can cause unwanted variable side effects in the original caller. @@ -847,7 +847,7 @@ Other Style Guides ``` - - [7.13](#functions--reassign-params) Never reassign parameters. eslint: [`no-param-reassign`](https://eslint.org/docs/rules/no-param-reassign.html) + - [7.13](#functions--reassign-params) Never reassign parameters. eslint: [`no-param-reassign`](https://eslint.org/docs/rules/no-param-reassign) > Why? Reassigning parameters can lead to unexpected behavior, especially when accessing the `arguments` object. It can also cause optimization issues, especially in V8. @@ -933,7 +933,7 @@ Other Style Guides ## Arrow Functions - - [8.1](#arrows--use-them) When you must use an anonymous function (as when passing an inline callback), use arrow function notation. eslint: [`prefer-arrow-callback`](https://eslint.org/docs/rules/prefer-arrow-callback.html), [`arrow-spacing`](https://eslint.org/docs/rules/arrow-spacing.html) + - [8.1](#arrows--use-them) When you must use an anonymous function (as when passing an inline callback), use arrow function notation. eslint: [`prefer-arrow-callback`](https://eslint.org/docs/rules/prefer-arrow-callback), [`arrow-spacing`](https://eslint.org/docs/rules/arrow-spacing) > Why? It creates a version of the function that executes in the context of `this`, which is usually what you want, and is a more concise syntax. @@ -954,7 +954,7 @@ Other Style Guides ``` - - [8.2](#arrows--implicit-return) If the function body consists of a single statement returning an [expression](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Expressions_and_Operators#Expressions) without side effects, omit the braces and use the implicit return. Otherwise, keep the braces and use a `return` statement. eslint: [`arrow-parens`](https://eslint.org/docs/rules/arrow-parens.html), [`arrow-body-style`](https://eslint.org/docs/rules/arrow-body-style.html) + - [8.2](#arrows--implicit-return) If the function body consists of a single statement returning an [expression](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Expressions_and_Operators#Expressions) without side effects, omit the braces and use the implicit return. Otherwise, keep the braces and use a `return` statement. eslint: [`arrow-parens`](https://eslint.org/docs/rules/arrow-parens), [`arrow-body-style`](https://eslint.org/docs/rules/arrow-body-style) > Why? Syntactic sugar. It reads well when multiple functions are chained together. @@ -1021,7 +1021,7 @@ Other Style Guides ``` - - [8.4](#arrows--one-arg-parens) Always include parentheses around arguments for clarity and consistency. eslint: [`arrow-parens`](https://eslint.org/docs/rules/arrow-parens.html) + - [8.4](#arrows--one-arg-parens) Always include parentheses around arguments for clarity and consistency. eslint: [`arrow-parens`](https://eslint.org/docs/rules/arrow-parens) > Why? Minimizes diff churn when adding or removing arguments. @@ -1469,7 +1469,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`](https://eslint.org/docs/rules/no-iterator.html) [`no-restricted-syntax`](https://eslint.org/docs/rules/no-restricted-syntax) + - [11.1](#iterators--nope) Don’t use iterators. Prefer JavaScript’s higher-order functions instead of loops like `for-in` or `for-of`. eslint: [`no-iterator`](https://eslint.org/docs/rules/no-iterator) [`no-restricted-syntax`](https://eslint.org/docs/rules/no-restricted-syntax) > Why? This enforces our immutable rule. Dealing with pure functions that return values is easier to reason about than side effects. @@ -1583,7 +1583,7 @@ Other Style Guides ## Properties - - [12.1](#properties--dot) Use dot notation when accessing properties. eslint: [`dot-notation`](https://eslint.org/docs/rules/dot-notation.html) + - [12.1](#properties--dot) Use dot notation when accessing properties. eslint: [`dot-notation`](https://eslint.org/docs/rules/dot-notation) ```javascript const luke = { @@ -1641,7 +1641,7 @@ Other Style Guides ``` - - [13.2](#variables--one-const) Use one `const` or `let` declaration per variable or assignment. eslint: [`one-var`](https://eslint.org/docs/rules/one-var.html) + - [13.2](#variables--one-const) Use one `const` or `let` declaration per variable or assignment. eslint: [`one-var`](https://eslint.org/docs/rules/one-var) > 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. @@ -1796,7 +1796,7 @@ Other Style Guides ``` - - [13.7](#variables--linebreak) Avoid linebreaks before or after `=` in an assignment. If your assignment violates [`max-len`](https://eslint.org/docs/rules/max-len.html), surround the value in parens. eslint [`operator-linebreak`](https://eslint.org/docs/rules/operator-linebreak.html). + - [13.7](#variables--linebreak) Avoid linebreaks before or after `=` in an assignment. If your assignment violates [`max-len`](https://eslint.org/docs/rules/max-len), surround the value in parens. eslint [`operator-linebreak`](https://eslint.org/docs/rules/operator-linebreak). > Why? Linebreaks surrounding `=` can obfuscate the value of an assignment. @@ -1962,7 +1962,7 @@ Other Style Guides ## Comparison Operators & Equality - - [15.1](#comparison--eqeqeq) Use `===` and `!==` over `==` and `!=`. eslint: [`eqeqeq`](https://eslint.org/docs/rules/eqeqeq.html) + - [15.1](#comparison--eqeqeq) Use `===` and `!==` over `==` and `!=`. eslint: [`eqeqeq`](https://eslint.org/docs/rules/eqeqeq) - [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: @@ -2020,7 +2020,7 @@ Other Style Guides - [15.4](#comparison--moreinfo) For more information see [Truth Equality and JavaScript](https://javascriptweblog.wordpress.com/2011/02/07/truth-equality-and-javascript/#more-2108) by Angus Croll. - - [15.5](#comparison--switch-blocks) Use braces to create blocks in `case` and `default` clauses that contain lexical declarations (e.g. `let`, `const`, `function`, and `class`). eslint: [`no-case-declarations`](https://eslint.org/docs/rules/no-case-declarations.html) + - [15.5](#comparison--switch-blocks) Use braces to create blocks in `case` and `default` clauses that contain lexical declarations (e.g. `let`, `const`, `function`, and `class`). eslint: [`no-case-declarations`](https://eslint.org/docs/rules/no-case-declarations) > 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. @@ -2068,7 +2068,7 @@ Other Style Guides ``` - - [15.6](#comparison--nested-ternaries) Ternaries should not be nested and generally be single line expressions. eslint: [`no-nested-ternary`](https://eslint.org/docs/rules/no-nested-ternary.html) + - [15.6](#comparison--nested-ternaries) Ternaries should not be nested and generally be single line expressions. eslint: [`no-nested-ternary`](https://eslint.org/docs/rules/no-nested-ternary) ```javascript // bad @@ -2089,7 +2089,7 @@ Other Style Guides ``` - - [15.7](#comparison--unneeded-ternary) Avoid unneeded ternary statements. eslint: [`no-unneeded-ternary`](https://eslint.org/docs/rules/no-unneeded-ternary.html) + - [15.7](#comparison--unneeded-ternary) Avoid unneeded ternary statements. eslint: [`no-unneeded-ternary`](https://eslint.org/docs/rules/no-unneeded-ternary) ```javascript // bad @@ -2105,7 +2105,7 @@ Other Style Guides - [15.8](#comparison--no-mixed-operators) When mixing operators, enclose them in parentheses. The only exception is the standard arithmetic operators: `+`, `-`, and `**` since their precedence is broadly understood. We recommend enclosing `/` and `*` in parentheses because their precedence can be ambiguous when they are mixed. - eslint: [`no-mixed-operators`](https://eslint.org/docs/rules/no-mixed-operators.html) + eslint: [`no-mixed-operators`](https://eslint.org/docs/rules/no-mixed-operators) > Why? This improves readability and clarifies the developer’s intention. @@ -2170,7 +2170,7 @@ Other Style Guides ``` - - [16.2](#blocks--cuddled-elses) If you’re using multiline blocks with `if` and `else`, put `else` on the same line as your `if` block’s closing brace. eslint: [`brace-style`](https://eslint.org/docs/rules/brace-style.html) + - [16.2](#blocks--cuddled-elses) If you’re using multiline blocks with `if` and `else`, put `else` on the same line as your `if` block’s closing brace. eslint: [`brace-style`](https://eslint.org/docs/rules/brace-style) ```javascript // bad @@ -2473,7 +2473,7 @@ Other Style Guides ## Whitespace - - [19.1](#whitespace--spaces) Use soft tabs (space character) set to 2 spaces. eslint: [`indent`](https://eslint.org/docs/rules/indent.html) + - [19.1](#whitespace--spaces) Use soft tabs (space character) set to 2 spaces. eslint: [`indent`](https://eslint.org/docs/rules/indent) ```javascript // bad @@ -2493,7 +2493,7 @@ Other Style Guides ``` - - [19.2](#whitespace--before-blocks) Place 1 space before the leading brace. eslint: [`space-before-blocks`](https://eslint.org/docs/rules/space-before-blocks.html) + - [19.2](#whitespace--before-blocks) Place 1 space before the leading brace. eslint: [`space-before-blocks`](https://eslint.org/docs/rules/space-before-blocks) ```javascript // bad @@ -2520,7 +2520,7 @@ Other Style Guides ``` - - [19.3](#whitespace--around-keywords) Place 1 space before the opening parenthesis in control statements (`if`, `while` etc.). Place no space between the argument list and the function name in function calls and declarations. eslint: [`keyword-spacing`](https://eslint.org/docs/rules/keyword-spacing.html) + - [19.3](#whitespace--around-keywords) Place 1 space before the opening parenthesis in control statements (`if`, `while` etc.). Place no space between the argument list and the function name in function calls and declarations. eslint: [`keyword-spacing`](https://eslint.org/docs/rules/keyword-spacing) ```javascript // bad @@ -2545,7 +2545,7 @@ Other Style Guides ``` - - [19.4](#whitespace--infix-ops) Set off operators with spaces. eslint: [`space-infix-ops`](https://eslint.org/docs/rules/space-infix-ops.html) + - [19.4](#whitespace--infix-ops) Set off operators with spaces. eslint: [`space-infix-ops`](https://eslint.org/docs/rules/space-infix-ops) ```javascript // bad @@ -2556,7 +2556,7 @@ Other Style Guides ``` - - [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) + - [19.5](#whitespace--newline-at-end) End files with a single newline character. eslint: [`eol-last`](https://eslint.org/docs/rules/eol-last) ```javascript // bad @@ -2687,7 +2687,7 @@ Other Style Guides ``` - - [19.8](#whitespace--padded-blocks) Do not pad your blocks with blank lines. eslint: [`padded-blocks`](https://eslint.org/docs/rules/padded-blocks.html) + - [19.8](#whitespace--padded-blocks) Do not pad your blocks with blank lines. eslint: [`padded-blocks`](https://eslint.org/docs/rules/padded-blocks) ```javascript // bad @@ -2782,7 +2782,7 @@ Other Style Guides ``` - - [19.10](#whitespace--in-parens) Do not add spaces inside parentheses. eslint: [`space-in-parens`](https://eslint.org/docs/rules/space-in-parens.html) + - [19.10](#whitespace--in-parens) Do not add spaces inside parentheses. eslint: [`space-in-parens`](https://eslint.org/docs/rules/space-in-parens) ```javascript // bad @@ -2807,7 +2807,7 @@ Other Style Guides ``` - - [19.11](#whitespace--in-brackets) Do not add spaces inside brackets. eslint: [`array-bracket-spacing`](https://eslint.org/docs/rules/array-bracket-spacing.html) + - [19.11](#whitespace--in-brackets) Do not add spaces inside brackets. eslint: [`array-bracket-spacing`](https://eslint.org/docs/rules/array-bracket-spacing) ```javascript // bad @@ -2820,7 +2820,7 @@ Other Style Guides ``` - - [19.12](#whitespace--in-braces) Add spaces inside curly braces. eslint: [`object-curly-spacing`](https://eslint.org/docs/rules/object-curly-spacing.html) + - [19.12](#whitespace--in-braces) Add spaces inside curly braces. eslint: [`object-curly-spacing`](https://eslint.org/docs/rules/object-curly-spacing) ```javascript // bad @@ -2831,7 +2831,7 @@ Other Style Guides ``` - - [19.13](#whitespace--max-len) Avoid having lines of code that are longer than 100 characters (including whitespace). Note: per [above](#strings--line-length), long strings are exempt from this rule, and should not be broken up. eslint: [`max-len`](https://eslint.org/docs/rules/max-len.html) + - [19.13](#whitespace--max-len) Avoid having lines of code that are longer than 100 characters (including whitespace). Note: per [above](#strings--line-length), long strings are exempt from this rule, and should not be broken up. eslint: [`max-len`](https://eslint.org/docs/rules/max-len) > Why? This ensures readability and maintainability. @@ -2965,7 +2965,7 @@ Other Style Guides ## Commas - - [20.1](#commas--leading-trailing) Leading commas: **Nope.** eslint: [`comma-style`](https://eslint.org/docs/rules/comma-style.html) + - [20.1](#commas--leading-trailing) Leading commas: **Nope.** eslint: [`comma-style`](https://eslint.org/docs/rules/comma-style) ```javascript // bad @@ -3000,7 +3000,7 @@ Other Style Guides ``` - - [20.2](#commas--dangling) Additional trailing comma: **Yup.** eslint: [`comma-dangle`](https://eslint.org/docs/rules/comma-dangle.html) + - [20.2](#commas--dangling) Additional trailing comma: **Yup.** eslint: [`comma-dangle`](https://eslint.org/docs/rules/comma-dangle) > 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. @@ -3100,7 +3100,7 @@ Other Style Guides ## Semicolons - - [21.1](#semicolons--required) **Yup.** eslint: [`semi`](https://eslint.org/docs/rules/semi.html) + - [21.1](#semicolons--required) **Yup.** eslint: [`semi`](https://eslint.org/docs/rules/semi) > Why? When JavaScript encounters a line break without a semicolon, it uses a set of rules called [Automatic Semicolon Insertion](https://tc39.github.io/ecma262/#sec-automatic-semicolon-insertion) to determine whether it should regard that line break as the end of a statement, and (as the name implies) place a semicolon into your code before the line break if it thinks so. ASI contains a few eccentric behaviors, though, and your code will break if JavaScript misinterprets your line break. These rules will become more complicated as new features become a part of JavaScript. Explicitly terminating your statements and configuring your linter to catch missing semicolons will help prevent you from encountering issues. @@ -3256,7 +3256,7 @@ Other Style Guides ``` - - [23.2](#naming--camelCase) Use camelCase when naming objects, functions, and instances. eslint: [`camelcase`](https://eslint.org/docs/rules/camelcase.html) + - [23.2](#naming--camelCase) Use camelCase when naming objects, functions, and instances. eslint: [`camelcase`](https://eslint.org/docs/rules/camelcase) ```javascript // bad @@ -3270,7 +3270,7 @@ Other Style Guides ``` - - [23.3](#naming--PascalCase) Use PascalCase only when naming constructors or classes. eslint: [`new-cap`](https://eslint.org/docs/rules/new-cap.html) + - [23.3](#naming--PascalCase) Use PascalCase only when naming constructors or classes. eslint: [`new-cap`](https://eslint.org/docs/rules/new-cap) ```javascript // bad @@ -3295,7 +3295,7 @@ Other Style Guides ``` - - [23.4](#naming--leading-underscore) Do not use trailing or leading underscores. eslint: [`no-underscore-dangle`](https://eslint.org/docs/rules/no-underscore-dangle.html) + - [23.4](#naming--leading-underscore) Do not use trailing or leading underscores. eslint: [`no-underscore-dangle`](https://eslint.org/docs/rules/no-underscore-dangle) > 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. From 42c0e2ea13e30ae47a6ebad1e1b5d95a44ac7665 Mon Sep 17 00:00:00 2001 From: Joe Lencioni Date: Tue, 24 May 2022 09:52:05 -0500 Subject: [PATCH 058/122] Fix typo in eslint-config-airbnb-base changelog --- packages/eslint-config-airbnb-base/CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/eslint-config-airbnb-base/CHANGELOG.md b/packages/eslint-config-airbnb-base/CHANGELOG.md index dcc6551f4f..51522a3f4e 100644 --- a/packages/eslint-config-airbnb-base/CHANGELOG.md +++ b/packages/eslint-config-airbnb-base/CHANGELOG.md @@ -15,7 +15,7 @@ - [readme] some updates - [meta] use `prepublishOnly` script for npm 7+ - [deps] update `eslint-plugin-import`, `eslint-plugin-react`, `object.entries` - - [dev deps] update `@babel/runtime`, ``tape` + - [dev deps] update `@babel/runtime`, `tape` 14.2.1 / 2020-11-06 ================== From a0e94052d542796bd756d3e2e0d563e5b392b804 Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Tue, 24 May 2022 08:49:47 -0700 Subject: [PATCH 059/122] [eslint config] [*] [dev deps] update `@babel/runtime` --- 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 cdebd865be..8dc7924fa5 100644 --- a/packages/eslint-config-airbnb-base/package.json +++ b/packages/eslint-config-airbnb-base/package.json @@ -68,7 +68,7 @@ }, "homepage": "https://github.com/airbnb/javascript", "devDependencies": { - "@babel/runtime": "^7.17.9", + "@babel/runtime": "^7.18.0", "babel-preset-airbnb": "^4.5.0", "babel-tape-runner": "^3.0.0", "eclint": "^2.8.1", diff --git a/packages/eslint-config-airbnb/package.json b/packages/eslint-config-airbnb/package.json index 2988682c42..257359378e 100644 --- a/packages/eslint-config-airbnb/package.json +++ b/packages/eslint-config-airbnb/package.json @@ -71,7 +71,7 @@ "object.entries": "^1.1.5" }, "devDependencies": { - "@babel/runtime": "^7.17.9", + "@babel/runtime": "^7.18.0", "babel-preset-airbnb": "^4.5.0", "babel-tape-runner": "^3.0.0", "eclint": "^2.8.1", From 206d25b55a9c6171499465cb38c8f09ea737d31f Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Tue, 24 May 2022 08:52:07 -0700 Subject: [PATCH 060/122] [eslint config] [deps] update `eslint-plugin-react` --- packages/eslint-config-airbnb/package.json | 4 ++-- packages/eslint-config-airbnb/rules/react.js | 5 +++++ 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/packages/eslint-config-airbnb/package.json b/packages/eslint-config-airbnb/package.json index 257359378e..fdb9073ad5 100644 --- a/packages/eslint-config-airbnb/package.json +++ b/packages/eslint-config-airbnb/package.json @@ -79,7 +79,7 @@ "eslint-find-rules": "^4.1.0", "eslint-plugin-import": "^2.26.0", "eslint-plugin-jsx-a11y": "^6.5.1", - "eslint-plugin-react": "^7.29.4", + "eslint-plugin-react": "^7.30.0", "eslint-plugin-react-hooks": "^4.5.0", "in-publish": "^2.0.1", "react": ">= 0.13.0", @@ -90,7 +90,7 @@ "eslint": "^7.32.0 || ^8.2.0", "eslint-plugin-import": "^2.26.0", "eslint-plugin-jsx-a11y": "^6.5.1", - "eslint-plugin-react": "^7.29.4", + "eslint-plugin-react": "^7.30.0", "eslint-plugin-react-hooks": "^4.5.0" }, "engines": { diff --git a/packages/eslint-config-airbnb/rules/react.js b/packages/eslint-config-airbnb/rules/react.js index d957fcbe7d..f1dfd20788 100644 --- a/packages/eslint-config-airbnb/rules/react.js +++ b/packages/eslint-config-airbnb/rules/react.js @@ -570,6 +570,11 @@ module.exports = { // https://github.com/jsx-eslint/eslint-plugin-react/blob/c8833f301314dab3e79ef7ac4cf863e4d5fa0019/docs/rules/iframe-missing-sandbox.md // TODO: semver-major, enable 'react/iframe-missing-sandbox': 'off', + + // Prevent problematic leaked values from being rendered + // https://github.com/jsx-eslint/eslint-plugin-react/blob/c42b624d0fb9ad647583a775ab9751091eec066f/docs/rules/jsx-no-leaked-render.md + // TODO: semver-major, enable + 'react/jsx-no-leaked-render': 'off', }, settings: { From cbf9ade10a2f6f06c9da6dbfa25b344bee4bbef6 Mon Sep 17 00:00:00 2001 From: Michael Orzel <56739010+michael-orzel@users.noreply.github.com> Date: Fri, 2 Jul 2021 09:40:46 -0400 Subject: [PATCH 061/122] [guide] Added period to 4.4 for formatting consistency. --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 49eebff107..3b1af22597 100644 --- a/README.md +++ b/README.md @@ -376,7 +376,7 @@ Other Style Guides - - [4.4](#arrays--from-iterable) To convert an iterable object to an array, use spreads `...` instead of [`Array.from`](https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/Array/from). + - [4.4](#arrays--from-iterable) To convert an iterable object to an array, use spreads `...` instead of [`Array.from`](https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/Array/from) ```javascript const foo = document.querySelectorAll('.foo'); From 5155aa5fc1ea9bb2c6493a06ddbd5c7a05414c86 Mon Sep 17 00:00:00 2001 From: Haoqun Jiang Date: Mon, 8 Aug 2022 21:56:10 +0800 Subject: [PATCH 062/122] [eslint config] [base] disable the deprecated `no-spaced-func` rule This rule was deprecated since ESLint v3.3.0 and replaced by the `func-call-spacing` rule. https://eslint.org/docs/latest/rules/no-spaced-func `func-call-spacing` was enabled in this package long ago: https://github.com/airbnb/javascript/commit/27dcb99c6d80718946d10017144b2aa68bed8b9e So there's no need for it to stay in the ruleset. Besides, it is causing some tricky issues when overriding the rules for TypeScript support (https://github.com/iamturns/eslint-config-airbnb-typescript/issues/246) --- packages/eslint-config-airbnb-base/rules/style.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/eslint-config-airbnb-base/rules/style.js b/packages/eslint-config-airbnb-base/rules/style.js index 4fad26be00..bc83e858e1 100644 --- a/packages/eslint-config-airbnb-base/rules/style.js +++ b/packages/eslint-config-airbnb-base/rules/style.js @@ -351,7 +351,8 @@ module.exports = { ], // disallow space between function identifier and application - 'no-spaced-func': 'error', + // deprecated in favor of func-call-spacing + 'no-spaced-func': 'off', // disallow tab characters entirely 'no-tabs': 'error', From 3cbf96de7cde974aab99f4ca85bd23ea0556c34a Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Sun, 18 Sep 2022 22:08:04 -0700 Subject: [PATCH 063/122] [eslint config] [base] `no-alert`: add TODO comment --- packages/eslint-config-airbnb-base/rules/best-practices.js | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/eslint-config-airbnb-base/rules/best-practices.js b/packages/eslint-config-airbnb-base/rules/best-practices.js index 31f74b51c0..90c34ccfa1 100644 --- a/packages/eslint-config-airbnb-base/rules/best-practices.js +++ b/packages/eslint-config-airbnb-base/rules/best-practices.js @@ -67,6 +67,7 @@ module.exports = { // disallow the use of alert, confirm, and prompt // https://eslint.org/docs/rules/no-alert + // TODO: enable, semver-major 'no-alert': 'warn', // disallow use of arguments.caller or arguments.callee From 5143a7a97a6969dd690fb905acee54d9f753667c Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Sun, 18 Sep 2022 22:16:08 -0700 Subject: [PATCH 064/122] [Dev Deps] update `markdownlint`, `markdownlint-cli` --- README.md | 2 +- package.json | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 3b1af22597..b2fc7d9d2c 100644 --- a/README.md +++ b/README.md @@ -3739,7 +3739,7 @@ Other Style Guides - Be cautious about stubs and mocks - they can make your tests more brittle. - We primarily use [`mocha`](https://www.npmjs.com/package/mocha) and [`jest`](https://www.npmjs.com/package/jest) at Airbnb. [`tape`](https://www.npmjs.com/package/tape) is also used occasionally for small, separate modules. - 100% test coverage is a good goal to strive for, even if it’s not always practical to reach it. - - Whenever you fix a bug, _write a regression test_. A bug fixed without a regression test is almost certainly going to break again in the future. + - 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)** diff --git a/package.json b/package.json index 77adc2e32d..04e7d56121 100644 --- a/package.json +++ b/package.json @@ -40,7 +40,7 @@ }, "homepage": "https://github.com/airbnb/javascript", "devDependencies": { - "markdownlint": "^0.20.4", - "markdownlint-cli": "^0.23.2" + "markdownlint": "^0.26.2", + "markdownlint-cli": "^0.32.2" } } From 866f441d05ae07fccdd7e6c3946125875594d6f3 Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Sun, 18 Sep 2022 22:18:17 -0700 Subject: [PATCH 065/122] [eslint config] [*] update `@babel/runtime`, `tape` --- packages/eslint-config-airbnb-base/package.json | 4 ++-- packages/eslint-config-airbnb/package.json | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/eslint-config-airbnb-base/package.json b/packages/eslint-config-airbnb-base/package.json index 8dc7924fa5..91d032ed76 100644 --- a/packages/eslint-config-airbnb-base/package.json +++ b/packages/eslint-config-airbnb-base/package.json @@ -68,7 +68,7 @@ }, "homepage": "https://github.com/airbnb/javascript", "devDependencies": { - "@babel/runtime": "^7.18.0", + "@babel/runtime": "^7.19.0", "babel-preset-airbnb": "^4.5.0", "babel-tape-runner": "^3.0.0", "eclint": "^2.8.1", @@ -77,7 +77,7 @@ "eslint-plugin-import": "^2.26.0", "in-publish": "^2.0.1", "safe-publish-latest": "^2.0.0", - "tape": "^5.5.3" + "tape": "^5.6.0" }, "peerDependencies": { "eslint": "^7.32.0 || ^8.2.0", diff --git a/packages/eslint-config-airbnb/package.json b/packages/eslint-config-airbnb/package.json index fdb9073ad5..8fc0f7dcf8 100644 --- a/packages/eslint-config-airbnb/package.json +++ b/packages/eslint-config-airbnb/package.json @@ -71,7 +71,7 @@ "object.entries": "^1.1.5" }, "devDependencies": { - "@babel/runtime": "^7.18.0", + "@babel/runtime": "^7.19.0", "babel-preset-airbnb": "^4.5.0", "babel-tape-runner": "^3.0.0", "eclint": "^2.8.1", @@ -84,7 +84,7 @@ "in-publish": "^2.0.1", "react": ">= 0.13.0", "safe-publish-latest": "^2.0.0", - "tape": "^5.5.3" + "tape": "^5.6.0" }, "peerDependencies": { "eslint": "^7.32.0 || ^8.2.0", From f6f63b89f602006278eff0ba4ad3cae617705cc3 Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Sun, 18 Sep 2022 22:18:57 -0700 Subject: [PATCH 066/122] [eslint config] [*] [deps] update `object.assign` --- 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 91d032ed76..f758c7eebb 100644 --- a/packages/eslint-config-airbnb-base/package.json +++ b/packages/eslint-config-airbnb-base/package.json @@ -88,7 +88,7 @@ }, "dependencies": { "confusing-browser-globals": "^1.0.11", - "object.assign": "^4.1.2", + "object.assign": "^4.1.4", "object.entries": "^1.1.5" } } diff --git a/packages/eslint-config-airbnb/package.json b/packages/eslint-config-airbnb/package.json index 8fc0f7dcf8..8b99aa420a 100644 --- a/packages/eslint-config-airbnb/package.json +++ b/packages/eslint-config-airbnb/package.json @@ -67,7 +67,7 @@ "homepage": "https://github.com/airbnb/javascript", "dependencies": { "eslint-config-airbnb-base": "^15.0.0", - "object.assign": "^4.1.2", + "object.assign": "^4.1.4", "object.entries": "^1.1.5" }, "devDependencies": { From 75a908aacfe9ad86a18f3930cfff9c4636ffd644 Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Sun, 18 Sep 2022 22:21:48 -0700 Subject: [PATCH 067/122] [eslint config] [deps] update `eslint-plugin-jsx-a11y`, `eslint-plugin-react`, `eslint-plugin-react-hooks` --- 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 8b99aa420a..ef4cd9632b 100644 --- a/packages/eslint-config-airbnb/package.json +++ b/packages/eslint-config-airbnb/package.json @@ -78,9 +78,9 @@ "eslint": "^7.32.0 || ^8.2.0", "eslint-find-rules": "^4.1.0", "eslint-plugin-import": "^2.26.0", - "eslint-plugin-jsx-a11y": "^6.5.1", - "eslint-plugin-react": "^7.30.0", - "eslint-plugin-react-hooks": "^4.5.0", + "eslint-plugin-jsx-a11y": "^6.6.1", + "eslint-plugin-react": "^7.31.8", + "eslint-plugin-react-hooks": "^4.6.0", "in-publish": "^2.0.1", "react": ">= 0.13.0", "safe-publish-latest": "^2.0.0", @@ -89,9 +89,9 @@ "peerDependencies": { "eslint": "^7.32.0 || ^8.2.0", "eslint-plugin-import": "^2.26.0", - "eslint-plugin-jsx-a11y": "^6.5.1", - "eslint-plugin-react": "^7.30.0", - "eslint-plugin-react-hooks": "^4.5.0" + "eslint-plugin-jsx-a11y": "^6.6.1", + "eslint-plugin-react": "^7.31.8", + "eslint-plugin-react-hooks": "^4.6.0" }, "engines": { "node": "^10.12.0 || ^12.22.0 || ^14.17.0 || >=16.0.0" From 7dbb7b154ffe38297f451440e7f59e3876a18ef7 Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Tue, 25 Oct 2022 09:42:25 -0700 Subject: [PATCH 068/122] [eslint config] [base] add disabled `logical-assignment-operators` rule --- packages/eslint-config-airbnb-base/rules/style.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/packages/eslint-config-airbnb-base/rules/style.js b/packages/eslint-config-airbnb-base/rules/style.js index bc83e858e1..2e7f6fed44 100644 --- a/packages/eslint-config-airbnb-base/rules/style.js +++ b/packages/eslint-config-airbnb-base/rules/style.js @@ -191,6 +191,13 @@ module.exports = { after: 'always', }], + // Require or disallow logical assignment logical operator shorthand + // https://eslint.org/docs/latest/rules/logical-assignment-operators + // TODO, semver-major: enable + 'logical-assignment-operators': ['off', 'always', { + enforceForIfStatements: true, + }], + // specify the maximum depth that blocks can be nested 'max-depth': ['off', 4], From 0b1f62372ee0ce9e228a1a9a98d948d323d1737f Mon Sep 17 00:00:00 2001 From: Mustafa UZUN Date: Tue, 25 Oct 2022 16:03:37 +0300 Subject: [PATCH 069/122] [editorial] convert example to use single instead of double quotes --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index b2fc7d9d2c..b351fda1c6 100644 --- a/README.md +++ b/README.md @@ -3131,7 +3131,7 @@ Other Style Guides }); // good - const reaction = "No! That’s impossible!"; + const reaction = 'No! That’s impossible!'; (async function meanwhileOnTheFalcon() { // handle `leia`, `lando`, `chewie`, `r2`, `c3p0` // ... From ca0ff97f17f355d10afc7ccd4f5ae11815d62637 Mon Sep 17 00:00:00 2001 From: Mustafa UZUN Date: Tue, 25 Oct 2022 23:26:56 +0300 Subject: [PATCH 070/122] [guide] add Nullish Coalescing operator --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index b351fda1c6..422d6ad79c 100644 --- a/README.md +++ b/README.md @@ -2096,11 +2096,13 @@ Other Style Guides const foo = a ? a : b; const bar = c ? true : false; const baz = c ? false : true; + const quux = a != null ? a : b; // good const foo = a || b; const bar = !!c; const baz = !c; + const quux = a ?? b; ``` From 6fb4f8e878264f7b913dc29bc6919520eb6be6c8 Mon Sep 17 00:00:00 2001 From: Mustafa UZUN Date: Wed, 26 Oct 2022 00:06:26 +0300 Subject: [PATCH 071/122] [guide] add Optional Chaining --- README.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/README.md b/README.md index 422d6ad79c..f3daaa8860 100644 --- a/README.md +++ b/README.md @@ -2852,6 +2852,14 @@ Other Style Guides && jsonData.foo.bar.baz.quux && jsonData.foo.bar.baz.quux.xyzzy; + // better + const foo = jsonData + ?.foo + ?.bar + ?.baz + ?.quux + ?.xyzzy; + // good $.ajax({ method: 'POST', From 6947138ee34319133da0e28a0e59abad987f1586 Mon Sep 17 00:00:00 2001 From: Mustafa UZUN Date: Wed, 26 Oct 2022 16:17:38 +0300 Subject: [PATCH 072/122] [guide] add comma to the end of the property --- README.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index f3daaa8860..a37f14536e 100644 --- a/README.md +++ b/README.md @@ -2509,7 +2509,7 @@ Other Style Guides } // bad - dog.set('attr',{ + dog.set('attr', { age: '1 year', breed: 'Bernese Mountain Dog', }); @@ -2609,7 +2609,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 @@ -2619,7 +2619,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 @@ -2627,7 +2627,7 @@ Other Style Guides const svg = leds.enter().append('svg:svg'); svg.classed('led', true).attr('width', (radius + margin) * 2); const g = svg.append('svg:g'); - g.attr('transform', `translate(${radius + margin},${radius + margin})`).call(tron.led); + g.attr('transform', `translate(${radius + margin}, ${radius + margin})`).call(tron.led); ``` @@ -3481,7 +3481,7 @@ Other Style Guides // good export const MAPPING = { - key: 'value' + key: 'value', }; ``` From c6b1a43c489d2c242f9c6c6d12966c95d27d9dfa Mon Sep 17 00:00:00 2001 From: Mustafa UZUN Date: Wed, 26 Oct 2022 13:44:17 +0300 Subject: [PATCH 073/122] [guide] rename `qux` to `quux` Fixes #2661 --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index a37f14536e..5dd908f954 100644 --- a/README.md +++ b/README.md @@ -2702,7 +2702,7 @@ Other Style Guides // bad if (baz) { - console.log(qux); + console.log(quux); } else { console.log(foo); @@ -2723,7 +2723,7 @@ Other Style Guides // good if (baz) { - console.log(qux); + console.log(quux); } else { console.log(foo); } From 38f1488918ef19f56191e855f624fa5da988d547 Mon Sep 17 00:00:00 2001 From: Maksim Ploski <50287455+plplmax@users.noreply.github.com> Date: Mon, 31 Oct 2022 21:57:59 +0300 Subject: [PATCH 074/122] [guide] fix typo in `space-before-blocks` --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 5dd908f954..94da6593ab 100644 --- a/README.md +++ b/README.md @@ -2509,7 +2509,7 @@ Other Style Guides } // bad - dog.set('attr', { + dog.set('attr',{ age: '1 year', breed: 'Bernese Mountain Dog', }); From 1fb7d76adde6f0822471c924bfda4ccd49879bc0 Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Thu, 17 Nov 2022 13:56:33 -0800 Subject: [PATCH 075/122] [eslint config] [patch] add new disabled core rules --- packages/eslint-config-airbnb-base/rules/best-practices.js | 5 +++++ packages/eslint-config-airbnb-base/rules/errors.js | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/packages/eslint-config-airbnb-base/rules/best-practices.js b/packages/eslint-config-airbnb-base/rules/best-practices.js index 90c34ccfa1..944fe71a05 100644 --- a/packages/eslint-config-airbnb-base/rules/best-practices.js +++ b/packages/eslint-config-airbnb-base/rules/best-practices.js @@ -104,6 +104,11 @@ module.exports = { // https://eslint.org/docs/rules/no-empty-pattern 'no-empty-pattern': 'error', + // Disallow empty static blocks + // https://eslint.org/docs/latest/rules/no-empty-static-block + // TODO: semver-major, enable + 'no-empty-static-block': 'off', + // disallow comparisons to null without a type-checking operator // https://eslint.org/docs/rules/no-eq-null 'no-eq-null': 'off', diff --git a/packages/eslint-config-airbnb-base/rules/errors.js b/packages/eslint-config-airbnb-base/rules/errors.js index 7770d5cb86..a3dda4e510 100644 --- a/packages/eslint-config-airbnb-base/rules/errors.js +++ b/packages/eslint-config-airbnb-base/rules/errors.js @@ -105,6 +105,11 @@ module.exports = { // disallow the use of object properties of the global object (Math and JSON) as functions 'no-obj-calls': 'error', + // Disallow new operators with global non-constructor functions + // https://eslint.org/docs/latest/rules/no-new-native-nonconstructor + // TODO: semver-major, enable + 'no-new-native-nonconstructor': 'off', + // Disallow returning values from Promise executor functions // https://eslint.org/docs/rules/no-promise-executor-return 'no-promise-executor-return': 'error', From 0d747c6d96f94e54d24d8c005da0c87105bf0fd5 Mon Sep 17 00:00:00 2001 From: Pushpendra Pal <94526347+Pushpendra100@users.noreply.github.com> Date: Mon, 14 Nov 2022 04:54:20 +0530 Subject: [PATCH 076/122] [readme] add space before code blocks --- README.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/README.md b/README.md index 94da6593ab..1bc228da5d 100644 --- a/README.md +++ b/README.md @@ -73,6 +73,8 @@ Other Style Guides - `symbol` - `bigint` +
+ ```javascript const foo = 1; let bar = foo; @@ -91,6 +93,8 @@ Other Style Guides - `array` - `function` +
+ ```javascript const foo = [1, 2]; const bar = foo; From 49d08a2f134f4d6524e99aacce57914b8957994e Mon Sep 17 00:00:00 2001 From: Mustafa UZUN Date: Sat, 29 Oct 2022 23:49:43 +0300 Subject: [PATCH 077/122] [readme] prefer `const`/`let` over `var` in examples 2.1 Use const for all of your references; avoid using var. eslint: prefer-const, no-const-assign --- README.md | 52 ++++++++++++++++++++++++++-------------------------- 1 file changed, 26 insertions(+), 26 deletions(-) diff --git a/README.md b/README.md index 1bc228da5d..59c1aaf3e9 100644 --- a/README.md +++ b/README.md @@ -778,7 +778,7 @@ Other Style Guides > Why? They are confusing to reason about. ```javascript - var b = 1; + let b = 1; // bad function count(a = b++) { console.log(a); @@ -811,10 +811,10 @@ Other Style Guides ```javascript // bad - var add = new Function('a', 'b', 'return a + b'); + const add = new Function('a', 'b', 'return a + b'); // still bad - var subtract = Function('a', 'b', 'return a - b'); + const subtract = Function('a', 'b', 'return a - b'); ``` @@ -1830,14 +1830,14 @@ Other Style Guides ```javascript // bad - var some_unused_var = 42; + const some_unused_var = 42; // Write-only variables are not considered as used. - var y = 10; + let y = 10; y = 5; // A read for a modification of itself is not considered as used. - var z = 0; + let z = 0; z = z + 1; // Unused function arguments. @@ -1851,14 +1851,14 @@ Other Style Guides return x + y; } - var x = 1; - var y = a + 2; + const x = 1; + const y = a + 2; alert(getXPlusY(x, y)); // 'type' is ignored even if unused because it has a rest property sibling. // This is a form of extracting an object that omits the specified keys. - var { type, ...coords } = data; + const { type, ...coords } = data; // 'coords' is now the 'data' object without its 'type' property. ``` @@ -2892,12 +2892,12 @@ Other Style Guides ```javascript // bad - var foo = 1,bar = 2; - var arr = [1 , 2]; + const foo = 1,bar = 2; + const arr = [1 , 2]; // good - var foo = 1, bar = 2; - var arr = [1, 2]; + const foo = 1, bar = 2; + const arr = [1, 2]; ``` @@ -2907,13 +2907,13 @@ Other Style Guides // bad obj[foo ] obj[ 'foo'] - var x = {[ b ]: a} + const x = {[ b ]: a} obj[foo[ bar ]] // good obj[foo] obj['foo'] - var x = { [b]: a } + const x = { [b]: a } obj[foo[bar]] ``` @@ -2936,11 +2936,11 @@ Other Style Guides ```javascript // bad - var obj = { foo : 42 }; - var obj2 = { foo:42 }; + const obj = { foo : 42 }; + const obj2 = { foo:42 }; // good - var obj = { foo: 42 }; + const obj = { foo: 42 }; ``` @@ -2952,24 +2952,24 @@ Other Style Guides ```javascript // bad - multiple empty lines - var x = 1; + const x = 1; - var y = 2; + const y = 2; // bad - 2+ newlines at end of file - var x = 1; - var y = 2; + const x = 1; + const y = 2; // bad - 1+ newline(s) at beginning of file - var x = 1; - var y = 2; + const x = 1; + const y = 2; // good - var x = 1; - var y = 2; + const x = 1; + const y = 2; ``` From d60170173096486bde4eff320a22148e79acff48 Mon Sep 17 00:00:00 2001 From: Mustafa UZUN Date: Sun, 30 Oct 2022 02:00:29 +0300 Subject: [PATCH 078/122] [readme] wayback machine, or remove, broken links --- README.md | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index 59c1aaf3e9..273cb92542 100644 --- a/README.md +++ b/README.md @@ -3213,7 +3213,7 @@ Other Style Guides ``` - - [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. + - [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://web.archive.org/web/20200414205431/https://jsperf.com/coercion-vs-casting/3), leave a comment explaining why and what you’re doing. ```javascript // good @@ -3636,7 +3636,7 @@ Other Style Guides ``` - - [26.3](#jquery--queries) For DOM queries use Cascading `$('.sidebar ul')` or parent > child `$('.sidebar > ul')`. [jsPerf](https://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](https://web.archive.org/web/20200414183810/https://jsperf.com/jquery-find-vs-context-sel/16) - [26.4](#jquery--find) Use `find` with scoped jQuery object queries. @@ -3760,12 +3760,12 @@ Other Style Guides ## Performance - [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/12) - - [Bang Function](https://jsperf.com/bang-function) - - [jQuery Find vs Context, Selector](https://jsperf.com/jquery-find-vs-context-sel/164) - - [innerHTML vs textContent for script text](https://jsperf.com/innerhtml-vs-textcontent-for-script-text) - - [Long String Concatenation](https://jsperf.com/ya-string-concat/38) + - [String vs Array Concat](https://web.archive.org/web/20200414200857/https://jsperf.com/string-vs-array-concat/2) + - [Try/Catch Cost In a Loop](https://web.archive.org/web/20200414190827/https://jsperf.com/try-catch-in-loop-cost/12) + - [Bang Function](https://web.archive.org/web/20200414205426/https://jsperf.com/bang-function) + - [jQuery Find vs Context, Selector](https://web.archive.org/web/20200414200850/https://jsperf.com/jquery-find-vs-context-sel/164) + - [innerHTML vs textContent for script text](https://web.archive.org/web/20200414205428/https://jsperf.com/innerhtml-vs-textcontent-for-script-text) + - [Long String Concatenation](https://web.archive.org/web/20200414203914/https://jsperf.com/ya-string-concat/38) - [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... @@ -3829,7 +3829,7 @@ Other Style Guides - [Superhero.js](http://superherojs.com/) - Kim Joar Bekkelund, Mads Mobæk, & Olav Bjorkoy - [JSBooks](https://jsbooks.revolunet.com/) - Julien Bouquillon - [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](https://amzn.com/0321812182) - David Herman + - [Effective JavaScript: 68 Specific Ways to Harness the Power of JavaScript](https://amzn.com/dp/0321812182) - David Herman - [Eloquent JavaScript](https://eloquentjavascript.net/) - Marijn Haverbeke - [You Don’t Know JS: ES6 & Beyond](https://shop.oreilly.com/product/0636920033769.do) - Kyle Simpson @@ -3911,16 +3911,15 @@ Other Style Guides - **MinnPost**: [MinnPost/javascript](https://github.com/MinnPost/javascript) - **MitocGroup**: [MitocGroup/javascript](https://github.com/MitocGroup/javascript) - **Muber**: [muber](https://github.com/muber/) - - **National Geographic**: [natgeo](https://github.com/natgeo/) + - **National Geographic Society**: [natgeosociety](https://github.com/natgeosociety/) - **NullDev**: [NullDevCo/JavaScript-Styleguide](https://github.com/NullDevCo/JavaScript-Styleguide) - **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) - **Pier 1**: [Pier1/javascript](https://github.com/pier1/javascript) - **Qotto**: [Qotto/javascript-style-guide](https://github.com/Qotto/javascript-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) + - **React**: [reactjs.org/docs/how-to-contribute.html#style-guide](https://reactjs.org/docs/how-to-contribute.html#style-guide) - **REI**: [reidev/js-style-guide](https://github.com/rei/code-style-guides/) - **Ripple**: [ripple/javascript-style-guide](https://github.com/ripple/javascript-style-guide) - **Sainsbury’s Supermarkets**: [jsainsburyplc](https://github.com/jsainsburyplc) From 4ef69edc633972a559cb7418e8aee8172cc9fbad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mert=20Can=20Alt=C4=B1n?= Date: Sun, 4 Dec 2022 00:32:01 +0300 Subject: [PATCH 079/122] [Tests] refactor test paths --- packages/eslint-config-airbnb-base/test/test-base.js | 5 +++-- packages/eslint-config-airbnb/test/test-base.js | 5 +++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/packages/eslint-config-airbnb-base/test/test-base.js b/packages/eslint-config-airbnb-base/test/test-base.js index 181e04f453..4380bf5567 100644 --- a/packages/eslint-config-airbnb-base/test/test-base.js +++ b/packages/eslint-config-airbnb-base/test/test-base.js @@ -6,9 +6,10 @@ import index from '..'; const files = { ...{ index } }; // object spread is to test parsing -fs.readdirSync(path.join(__dirname, '../rules')).forEach((name) => { +const rulesDir = path.join(__dirname, '../rules'); +fs.readdirSync(rulesDir).forEach((name) => { // eslint-disable-next-line import/no-dynamic-require - files[name] = require(`../rules/${name}`); // eslint-disable-line global-require + files[name] = require(path.join(rulesDir, name)); // eslint-disable-line global-require }); Object.keys(files).forEach(( diff --git a/packages/eslint-config-airbnb/test/test-base.js b/packages/eslint-config-airbnb/test/test-base.js index c283c3410c..8f3f054d29 100644 --- a/packages/eslint-config-airbnb/test/test-base.js +++ b/packages/eslint-config-airbnb/test/test-base.js @@ -6,13 +6,14 @@ const base = require('../base'); const files = { base }; -fs.readdirSync(path.join(__dirname, '../rules')).forEach((name) => { +const rulesDir = path.join(__dirname, '../rules'); +fs.readdirSync(rulesDir).forEach((name) => { if (name === 'react.js' || name === 'react-a11y.js') { return; } // eslint-disable-next-line import/no-dynamic-require - files[name] = require(`../rules/${name}`); // eslint-disable-line global-require + files[name] = require(path.join(rulesDir, name)); // eslint-disable-line global-require }); Object.keys(files).forEach((name) => { From 81157eec2309449b31f36bf8940493623f2530c6 Mon Sep 17 00:00:00 2001 From: Mustafa UZUN Date: Thu, 17 Nov 2022 20:15:09 +0300 Subject: [PATCH 080/122] [guide] add `Object.hasOwn` --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 273cb92542..db3bc6f31d 100644 --- a/README.md +++ b/README.md @@ -311,6 +311,8 @@ Other Style Guides /* or */ import has from 'has'; // https://www.npmjs.com/package/has console.log(has(object, key)); + /* or */ + console.log(Object.hasOwn(object, key)); // https://www.npmjs.com/package/object.hasown ``` From fd96a4fd57be26d4d9d2f2d24b373a2df7c23548 Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Fri, 30 Dec 2022 14:48:36 -0800 Subject: [PATCH 081/122] [eslint config] [*] [refactor] use object spread instead of `Object.assign` --- packages/eslint-config-airbnb-base/package.json | 1 - packages/eslint-config-airbnb-base/whitespace-async.js | 3 +-- packages/eslint-config-airbnb-base/whitespace.js | 3 +-- packages/eslint-config-airbnb/package.json | 1 - packages/eslint-config-airbnb/rules/react.js | 6 +++--- packages/eslint-config-airbnb/whitespace-async.js | 3 +-- packages/eslint-config-airbnb/whitespace.js | 3 +-- 7 files changed, 7 insertions(+), 13 deletions(-) diff --git a/packages/eslint-config-airbnb-base/package.json b/packages/eslint-config-airbnb-base/package.json index f758c7eebb..25bcb9cfd3 100644 --- a/packages/eslint-config-airbnb-base/package.json +++ b/packages/eslint-config-airbnb-base/package.json @@ -88,7 +88,6 @@ }, "dependencies": { "confusing-browser-globals": "^1.0.11", - "object.assign": "^4.1.4", "object.entries": "^1.1.5" } } diff --git a/packages/eslint-config-airbnb-base/whitespace-async.js b/packages/eslint-config-airbnb-base/whitespace-async.js index 55c5161235..d6742fb7c4 100755 --- a/packages/eslint-config-airbnb-base/whitespace-async.js +++ b/packages/eslint-config-airbnb-base/whitespace-async.js @@ -1,6 +1,5 @@ #!/usr/bin/env node -const assign = require('object.assign'); const entries = require('object.entries'); const { ESLint } = require('eslint'); @@ -20,7 +19,7 @@ function getSeverity(ruleConfig) { } async function onlyErrorOnRules(rulesToError, config) { - const errorsOnly = assign({}, config); + const errorsOnly = { ...config }; const cli = new ESLint({ useEslintrc: false, baseConfig: config diff --git a/packages/eslint-config-airbnb-base/whitespace.js b/packages/eslint-config-airbnb-base/whitespace.js index dfdf95a18e..f4b93bb492 100644 --- a/packages/eslint-config-airbnb-base/whitespace.js +++ b/packages/eslint-config-airbnb-base/whitespace.js @@ -4,7 +4,6 @@ const { CLIEngine } = require('eslint'); if (CLIEngine) { /* eslint no-inner-declarations: 0 */ - const assign = require('object.assign'); const entries = require('object.entries'); const whitespaceRules = require('./whitespaceRules'); @@ -23,7 +22,7 @@ if (CLIEngine) { } function onlyErrorOnRules(rulesToError, config) { - const errorsOnly = assign({}, config); + const errorsOnly = { ...config }; const cli = new CLIEngine({ baseConfig: config, useEslintrc: false }); const baseRules = cli.getConfigForFile(require.resolve('./')).rules; diff --git a/packages/eslint-config-airbnb/package.json b/packages/eslint-config-airbnb/package.json index ef4cd9632b..0ad2313195 100644 --- a/packages/eslint-config-airbnb/package.json +++ b/packages/eslint-config-airbnb/package.json @@ -67,7 +67,6 @@ "homepage": "https://github.com/airbnb/javascript", "dependencies": { "eslint-config-airbnb-base": "^15.0.0", - "object.assign": "^4.1.4", "object.entries": "^1.1.5" }, "devDependencies": { diff --git a/packages/eslint-config-airbnb/rules/react.js b/packages/eslint-config-airbnb/rules/react.js index f1dfd20788..447576d18a 100644 --- a/packages/eslint-config-airbnb/rules/react.js +++ b/packages/eslint-config-airbnb/rules/react.js @@ -1,4 +1,3 @@ -const assign = require('object.assign'); const baseStyleRules = require('eslint-config-airbnb-base/rules/style').rules; const dangleRules = baseStyleRules['no-underscore-dangle']; @@ -17,9 +16,10 @@ module.exports = { // View link below for react rules documentation // https://github.com/jsx-eslint/eslint-plugin-react#list-of-supported-rules rules: { - 'no-underscore-dangle': [dangleRules[0], assign({}, dangleRules[1], { + 'no-underscore-dangle': [dangleRules[0], { + ...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 diff --git a/packages/eslint-config-airbnb/whitespace-async.js b/packages/eslint-config-airbnb/whitespace-async.js index 55c5161235..d6742fb7c4 100755 --- a/packages/eslint-config-airbnb/whitespace-async.js +++ b/packages/eslint-config-airbnb/whitespace-async.js @@ -1,6 +1,5 @@ #!/usr/bin/env node -const assign = require('object.assign'); const entries = require('object.entries'); const { ESLint } = require('eslint'); @@ -20,7 +19,7 @@ function getSeverity(ruleConfig) { } async function onlyErrorOnRules(rulesToError, config) { - const errorsOnly = assign({}, config); + const errorsOnly = { ...config }; const cli = new ESLint({ useEslintrc: false, baseConfig: config diff --git a/packages/eslint-config-airbnb/whitespace.js b/packages/eslint-config-airbnb/whitespace.js index dfdf95a18e..f4b93bb492 100644 --- a/packages/eslint-config-airbnb/whitespace.js +++ b/packages/eslint-config-airbnb/whitespace.js @@ -4,7 +4,6 @@ const { CLIEngine } = require('eslint'); if (CLIEngine) { /* eslint no-inner-declarations: 0 */ - const assign = require('object.assign'); const entries = require('object.entries'); const whitespaceRules = require('./whitespaceRules'); @@ -23,7 +22,7 @@ if (CLIEngine) { } function onlyErrorOnRules(rulesToError, config) { - const errorsOnly = assign({}, config); + const errorsOnly = { ...config }; const cli = new CLIEngine({ baseConfig: config, useEslintrc: false }); const baseRules = cli.getConfigForFile(require.resolve('./')).rules; From 8091e39343b86ccc8524ed068cd218a3fd928105 Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Wed, 8 Feb 2023 22:11:42 -0800 Subject: [PATCH 082/122] [*] [dev deps] update `@babel/runtime`, `tape` --- packages/eslint-config-airbnb-base/package.json | 4 ++-- packages/eslint-config-airbnb/package.json | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/eslint-config-airbnb-base/package.json b/packages/eslint-config-airbnb-base/package.json index 25bcb9cfd3..9b71edda09 100644 --- a/packages/eslint-config-airbnb-base/package.json +++ b/packages/eslint-config-airbnb-base/package.json @@ -68,7 +68,7 @@ }, "homepage": "https://github.com/airbnb/javascript", "devDependencies": { - "@babel/runtime": "^7.19.0", + "@babel/runtime": "^7.20.13", "babel-preset-airbnb": "^4.5.0", "babel-tape-runner": "^3.0.0", "eclint": "^2.8.1", @@ -77,7 +77,7 @@ "eslint-plugin-import": "^2.26.0", "in-publish": "^2.0.1", "safe-publish-latest": "^2.0.0", - "tape": "^5.6.0" + "tape": "^5.6.3" }, "peerDependencies": { "eslint": "^7.32.0 || ^8.2.0", diff --git a/packages/eslint-config-airbnb/package.json b/packages/eslint-config-airbnb/package.json index 0ad2313195..31af4bae6d 100644 --- a/packages/eslint-config-airbnb/package.json +++ b/packages/eslint-config-airbnb/package.json @@ -70,7 +70,7 @@ "object.entries": "^1.1.5" }, "devDependencies": { - "@babel/runtime": "^7.19.0", + "@babel/runtime": "^7.20.13", "babel-preset-airbnb": "^4.5.0", "babel-tape-runner": "^3.0.0", "eclint": "^2.8.1", @@ -83,7 +83,7 @@ "in-publish": "^2.0.1", "react": ">= 0.13.0", "safe-publish-latest": "^2.0.0", - "tape": "^5.6.0" + "tape": "^5.6.3" }, "peerDependencies": { "eslint": "^7.32.0 || ^8.2.0", From 917c8d92a30db5bc35ddef85ec417f1aad0dc2c1 Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Wed, 8 Feb 2023 22:19:53 -0800 Subject: [PATCH 083/122] [*] [deps] update `eslint-plugin-import` --- packages/eslint-config-airbnb-base/package.json | 4 ++-- packages/eslint-config-airbnb-base/rules/imports.js | 10 ++++++++++ packages/eslint-config-airbnb/package.json | 4 ++-- 3 files changed, 14 insertions(+), 4 deletions(-) diff --git a/packages/eslint-config-airbnb-base/package.json b/packages/eslint-config-airbnb-base/package.json index 9b71edda09..95e6dec90a 100644 --- a/packages/eslint-config-airbnb-base/package.json +++ b/packages/eslint-config-airbnb-base/package.json @@ -74,14 +74,14 @@ "eclint": "^2.8.1", "eslint": "^7.32.0 || ^8.2.0", "eslint-find-rules": "^4.1.0", - "eslint-plugin-import": "^2.26.0", + "eslint-plugin-import": "^2.27.5", "in-publish": "^2.0.1", "safe-publish-latest": "^2.0.0", "tape": "^5.6.3" }, "peerDependencies": { "eslint": "^7.32.0 || ^8.2.0", - "eslint-plugin-import": "^2.26.0" + "eslint-plugin-import": "^2.27.5" }, "engines": { "node": "^10.12.0 || >=12.0.0" diff --git a/packages/eslint-config-airbnb-base/rules/imports.js b/packages/eslint-config-airbnb-base/rules/imports.js index 5f7f1bd470..70bc95a838 100644 --- a/packages/eslint-config-airbnb-base/rules/imports.js +++ b/packages/eslint-config-airbnb-base/rules/imports.js @@ -269,5 +269,15 @@ module.exports = { // Use this rule to prevent importing packages through relative paths. // https://github.com/benmosher/eslint-plugin-import/blob/1012eb951767279ce3b540a4ec4f29236104bb5b/docs/rules/no-relative-packages.md 'import/no-relative-packages': 'error', + + // enforce a consistent style for type specifiers (inline or top-level) + // https://github.com/import-js/eslint-plugin-import/blob/d5fc8b670dc8e6903dbb7b0894452f60c03089f5/docs/rules/consistent-type-specifier-style.md + // TODO, semver-major: enable (just in case) + 'import/consistent-type-specifier-style': ['off', 'prefer-inline'], + + // Reports the use of empty named import blocks. + // https://github.com/import-js/eslint-plugin-import/blob/d5fc8b670dc8e6903dbb7b0894452f60c03089f5/docs/rules/no-empty-named-blocks.md + // TODO, semver-minor: enable + 'import/no-empty-named-blocks': 'off', }, }; diff --git a/packages/eslint-config-airbnb/package.json b/packages/eslint-config-airbnb/package.json index 31af4bae6d..7985899643 100644 --- a/packages/eslint-config-airbnb/package.json +++ b/packages/eslint-config-airbnb/package.json @@ -76,7 +76,7 @@ "eclint": "^2.8.1", "eslint": "^7.32.0 || ^8.2.0", "eslint-find-rules": "^4.1.0", - "eslint-plugin-import": "^2.26.0", + "eslint-plugin-import": "^2.27.5", "eslint-plugin-jsx-a11y": "^6.6.1", "eslint-plugin-react": "^7.31.8", "eslint-plugin-react-hooks": "^4.6.0", @@ -87,7 +87,7 @@ }, "peerDependencies": { "eslint": "^7.32.0 || ^8.2.0", - "eslint-plugin-import": "^2.26.0", + "eslint-plugin-import": "^2.27.5", "eslint-plugin-jsx-a11y": "^6.6.1", "eslint-plugin-react": "^7.31.8", "eslint-plugin-react-hooks": "^4.6.0" From bf536566cee0b7f239e00f105ca422bb95be2d62 Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Wed, 8 Feb 2023 22:59:18 -0800 Subject: [PATCH 084/122] [eslint config] [deps] update `eslint-plugin-react`, `eslint-plugin-jsx-a11y` --- packages/eslint-config-airbnb/package.json | 8 ++++---- packages/eslint-config-airbnb/rules/react-a11y.js | 15 +++++++++++++++ packages/eslint-config-airbnb/rules/react.js | 12 ++++++++++++ 3 files changed, 31 insertions(+), 4 deletions(-) diff --git a/packages/eslint-config-airbnb/package.json b/packages/eslint-config-airbnb/package.json index 7985899643..c1d11d44e9 100644 --- a/packages/eslint-config-airbnb/package.json +++ b/packages/eslint-config-airbnb/package.json @@ -77,8 +77,8 @@ "eslint": "^7.32.0 || ^8.2.0", "eslint-find-rules": "^4.1.0", "eslint-plugin-import": "^2.27.5", - "eslint-plugin-jsx-a11y": "^6.6.1", - "eslint-plugin-react": "^7.31.8", + "eslint-plugin-jsx-a11y": "^6.7.1", + "eslint-plugin-react": "^7.32.2", "eslint-plugin-react-hooks": "^4.6.0", "in-publish": "^2.0.1", "react": ">= 0.13.0", @@ -88,8 +88,8 @@ "peerDependencies": { "eslint": "^7.32.0 || ^8.2.0", "eslint-plugin-import": "^2.27.5", - "eslint-plugin-jsx-a11y": "^6.6.1", - "eslint-plugin-react": "^7.31.8", + "eslint-plugin-jsx-a11y": "^6.7.1", + "eslint-plugin-react": "^7.32.2", "eslint-plugin-react-hooks": "^4.6.0" }, "engines": { diff --git a/packages/eslint-config-airbnb/rules/react-a11y.js b/packages/eslint-config-airbnb/rules/react-a11y.js index f7bf7c79e6..713a997b28 100644 --- a/packages/eslint-config-airbnb/rules/react-a11y.js +++ b/packages/eslint-config-airbnb/rules/react-a11y.js @@ -247,5 +247,20 @@ module.exports = { }, allowChildren: false, }], + + // Ensures anchor text is not ambiguous + // https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/blob/93f78856655696a55309440593e0948c6fb96134/docs/rules/anchor-ambiguous-text.md + // TODO: semver-major, enable + 'jsx-a11y/anchor-ambiguous-text': 'off', + + // Enforce that aria-hidden="true" is not set on focusable elements. + // https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/blob/93f78856655696a55309440593e0948c6fb96134/docs/rules/no-aria-hidden-on-focusable.md + // TODO: semver-major, enable + 'jsx-a11y/no-aria-hidden-on-focusable': 'off', + + // Enforces using semantic DOM elements over the ARIA role property. + // https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/blob/93f78856655696a55309440593e0948c6fb96134/docs/rules/prefer-tag-over-role.md + // TODO: semver-major, enable + 'jsx-a11y/prefer-tag-over-role': 'off', }, }; diff --git a/packages/eslint-config-airbnb/rules/react.js b/packages/eslint-config-airbnb/rules/react.js index 447576d18a..ac4e4e29d3 100644 --- a/packages/eslint-config-airbnb/rules/react.js +++ b/packages/eslint-config-airbnb/rules/react.js @@ -575,6 +575,18 @@ module.exports = { // https://github.com/jsx-eslint/eslint-plugin-react/blob/c42b624d0fb9ad647583a775ab9751091eec066f/docs/rules/jsx-no-leaked-render.md // TODO: semver-major, enable 'react/jsx-no-leaked-render': 'off', + + // https://github.com/jsx-eslint/eslint-plugin-react/blob/66b58dd4864678eb869a7bf434c72ff7ac530eb1/docs/rules/no-object-type-as-default-prop.md + // https://github.com/jsx-eslint/eslint-plugin-react/blob/66b58dd4864678eb869a7bf434c72ff7ac530eb1/docs/rules/no-object-type-as-default-prop.md + // TODO: semver-major, enable + 'react/no-object-type-as-default-prop': 'off', + + // https://github.com/jsx-eslint/eslint-plugin-react/blob/66b58dd4864678eb869a7bf434c72ff7ac530eb1/docs/rules/sort-default-props.md + // https://github.com/jsx-eslint/eslint-plugin-react/blob/66b58dd4864678eb869a7bf434c72ff7ac530eb1/docs/rules/sort-default-props.md + // TODO: semver-major, enable? + 'react/sort-default-props': ['off', { + ignoreCase: false + }], }, settings: { From 5c01a1094986c4dd50a6ee4d9f7617abdfabb58a Mon Sep 17 00:00:00 2001 From: syedmouaazfarrukh <97732099+syedmouaazfarrukh@users.noreply.github.com> Date: Tue, 7 Feb 2023 11:17:51 -0800 Subject: [PATCH 085/122] [readme] added JavaScript Roadmap link --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index db3bc6f31d..a9964bcac6 100644 --- a/README.md +++ b/README.md @@ -3781,6 +3781,7 @@ Other Style Guides - [ExploringJS](https://exploringjs.com/) - [ES6 Compatibility Table](https://kangax.github.io/compat-table/es6/) - [Comprehensive Overview of ES6 Features](http://es6-features.org/) + - [JavaScript Roadmap](https://roadmap.sh/javascript) **Read This** From 69fc1bf1953a9113f30f07ef93b69caaf498c689 Mon Sep 17 00:00:00 2001 From: Felipe Garcia Diaz <41710468+felipeGarciaDiaz@users.noreply.github.com> Date: Fri, 28 Apr 2023 03:33:28 -0400 Subject: [PATCH 086/122] spell checking, fixed grammar error. --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index a9964bcac6..fbed6641ba 100644 --- a/README.md +++ b/README.md @@ -464,7 +464,7 @@ Other Style Guides ``` - - [4.8](#arrays--bracket-newline) Use line breaks after open and before close array brackets if an array has multiple lines + - [4.8](#arrays--bracket-newline) Use line breaks after opening array brackets and before closing array brackets, if an array has multiple lines ```javascript // bad From 7982931ba745c0f57ba6934fc7e6cc43901dac76 Mon Sep 17 00:00:00 2001 From: Christian Koop Date: Tue, 2 May 2023 19:45:36 +0200 Subject: [PATCH 087/122] [readme] Updates ESLint rule in section 12.3 (exponentiation-operator) The change itself has already been made in f3d3a075cda2acc02011e71991c10bb5b4a15278 (tracked in/acording to https://github.com/airbnb/javascript/issues/2421#issuecomment-1371305010). #2421 Remove Math.pow from `no-restricted-properties` and use `prefer-exponentiation-operator` instead. --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index fbed6641ba..916a6c875d 100644 --- a/README.md +++ b/README.md @@ -1621,7 +1621,7 @@ Other Style Guides ``` - - [12.3](#es2016-properties--exponentiation-operator) Use exponentiation operator `**` when calculating exponentiations. eslint: [`no-restricted-properties`](https://eslint.org/docs/rules/no-restricted-properties). + - [12.3](#es2016-properties--exponentiation-operator) Use exponentiation operator `**` when calculating exponentiations. eslint: [`prefer-exponentiation-operator`](https://eslint.org/docs/rules/prefer-exponentiation-operator). ```javascript // bad From 0e627e2fa32e16296e309af314eb3cdaae00de66 Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Mon, 15 May 2023 10:15:59 -0700 Subject: [PATCH 088/122] [readme] update eslint plugin repo URLs --- README.md | 10 +-- .../eslint-config-airbnb-base/rules/es6.js | 2 +- .../rules/imports.js | 86 +++++++++---------- .../eslint-config-airbnb/rules/react-a11y.js | 70 +++++++-------- react/README.md | 44 +++++----- 5 files changed, 106 insertions(+), 106 deletions(-) diff --git a/README.md b/README.md index 916a6c875d..660909e9a5 100644 --- a/README.md +++ b/README.md @@ -1373,7 +1373,7 @@ Other Style Guides - [10.5](#modules--no-mutable-exports) Do not export mutable bindings. - eslint: [`import/no-mutable-exports`](https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/no-mutable-exports.md) + eslint: [`import/no-mutable-exports`](https://github.com/import-js/eslint-plugin-import/blob/master/docs/rules/no-mutable-exports.md) > Why? Mutation should be avoided in general, but in particular when exporting mutable bindings. While this technique may be needed for some special cases, in general, only constant references should be exported. ```javascript @@ -1388,7 +1388,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) + eslint: [`import/prefer-default-export`](https://github.com/import-js/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 @@ -1401,7 +1401,7 @@ Other Style Guides - [10.7](#modules--imports-first) Put all `import`s above non-import statements. - eslint: [`import/first`](https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/first.md) + eslint: [`import/first`](https://github.com/import-js/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 @@ -1440,7 +1440,7 @@ Other Style Guides - [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) + eslint: [`import/no-webpack-loader-syntax`](https://github.com/import-js/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 @@ -1455,7 +1455,7 @@ Other Style Guides - [10.10](#modules--import-extensions) Do not include JavaScript filename extensions - eslint: [`import/extensions`](https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/extensions.md) + eslint: [`import/extensions`](https://github.com/import-js/eslint-plugin-import/blob/master/docs/rules/extensions.md) > Why? Including extensions inhibits refactoring, and inappropriately hardcodes implementation details of the module you're importing in every consumer. ```javascript diff --git a/packages/eslint-config-airbnb-base/rules/es6.js b/packages/eslint-config-airbnb-base/rules/es6.js index 79a4cdcc25..5e59cbebf4 100644 --- a/packages/eslint-config-airbnb-base/rules/es6.js +++ b/packages/eslint-config-airbnb-base/rules/es6.js @@ -53,7 +53,7 @@ module.exports = { // disallow importing from the same path more than once // https://eslint.org/docs/rules/no-duplicate-imports - // replaced by https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/no-duplicates.md + // replaced by https://github.com/import-js/eslint-plugin-import/blob/master/docs/rules/no-duplicates.md 'no-duplicate-imports': 'off', // disallow symbol constructor diff --git a/packages/eslint-config-airbnb-base/rules/imports.js b/packages/eslint-config-airbnb-base/rules/imports.js index 70bc95a838..d36e4908fa 100644 --- a/packages/eslint-config-airbnb-base/rules/imports.js +++ b/packages/eslint-config-airbnb-base/rules/imports.js @@ -33,40 +33,40 @@ module.exports = { // Static analysis: // ensure imports point to files/modules that can be resolved - // https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/no-unresolved.md + // https://github.com/import-js/eslint-plugin-import/blob/master/docs/rules/no-unresolved.md '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 + // https://github.com/import-js/eslint-plugin-import/blob/master/docs/rules/named.md#when-not-to-use-it 'import/named': 'error', // ensure default import coupled with default export - // https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/default.md#when-not-to-use-it + // https://github.com/import-js/eslint-plugin-import/blob/master/docs/rules/default.md#when-not-to-use-it 'import/default': 'off', - // https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/namespace.md + // https://github.com/import-js/eslint-plugin-import/blob/master/docs/rules/namespace.md '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 + // https://github.com/import-js/eslint-plugin-import/blob/master/docs/rules/export.md '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 + // https://github.com/import-js/eslint-plugin-import/blob/master/docs/rules/no-named-as-default.md '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 + // https://github.com/import-js/eslint-plugin-import/blob/master/docs/rules/no-named-as-default-member.md '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 + // https://github.com/import-js/eslint-plugin-import/blob/master/docs/rules/no-deprecated.md '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 + // https://github.com/import-js/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: [ @@ -97,46 +97,46 @@ module.exports = { }], // Forbid mutable exports - // https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/no-mutable-exports.md + // https://github.com/import-js/eslint-plugin-import/blob/master/docs/rules/no-mutable-exports.md 'import/no-mutable-exports': 'error', // Module systems: // disallow require() - // https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/no-commonjs.md + // https://github.com/import-js/eslint-plugin-import/blob/master/docs/rules/no-commonjs.md 'import/no-commonjs': 'off', // disallow AMD require/define - // https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/no-amd.md + // https://github.com/import-js/eslint-plugin-import/blob/master/docs/rules/no-amd.md 'import/no-amd': 'error', // No Node.js builtin modules - // https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/no-nodejs-modules.md + // https://github.com/import-js/eslint-plugin-import/blob/master/docs/rules/no-nodejs-modules.md // TODO: enable? '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/first.md + // https://github.com/import-js/eslint-plugin-import/blob/master/docs/rules/first.md 'import/first': 'error', // disallow non-import statements appearing before import statements - // https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/imports-first.md + // https://github.com/import-js/eslint-plugin-import/blob/master/docs/rules/imports-first.md // 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 + // https://github.com/import-js/eslint-plugin-import/blob/master/docs/rules/no-duplicates.md 'import/no-duplicates': 'error', // disallow namespace imports // TODO: enable? - // https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/no-namespace.md + // https://github.com/import-js/eslint-plugin-import/blob/master/docs/rules/no-namespace.md '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 + // https://github.com/import-js/eslint-plugin-import/blob/master/docs/rules/extensions.md 'import/extensions': ['error', 'ignorePackages', { js: 'never', mjs: 'never', @@ -144,62 +144,62 @@ module.exports = { }], // ensure absolute imports are above relative imports and that unassigned imports are ignored - // https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/order.md + // https://github.com/import-js/eslint-plugin-import/blob/master/docs/rules/order.md // TODO: enforce a stricter convention in module import order? 'import/order': ['error', { groups: [['builtin', 'external', 'internal']] }], // Require a newline after the last import/require in a group - // https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/newline-after-import.md + // https://github.com/import-js/eslint-plugin-import/blob/master/docs/rules/newline-after-import.md '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 + // https://github.com/import-js/eslint-plugin-import/blob/master/docs/rules/prefer-default-export.md '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 + // https://github.com/import-js/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 + // https://github.com/import-js/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 + // https://github.com/import-js/eslint-plugin-import/blob/master/docs/rules/no-absolute-path.md '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 + // https://github.com/import-js/eslint-plugin-import/blob/master/docs/rules/no-dynamic-require.md '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 + // https://github.com/import-js/eslint-plugin-import/blob/master/docs/rules/no-internal-modules.md '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 + // https://github.com/import-js/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 - // https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/no-webpack-loader-syntax.md + // https://github.com/import-js/eslint-plugin-import/blob/master/docs/rules/no-webpack-loader-syntax.md 'import/no-webpack-loader-syntax': 'error', // Prevent unassigned imports - // https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/no-unassigned-import.md + // https://github.com/import-js/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 + // https://github.com/import-js/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 + // https://github.com/import-js/eslint-plugin-import/blob/d9b712ac7fd1fddc391f7b234827925c160d956f/docs/rules/no-anonymous-default-export.md 'import/no-anonymous-default-export': ['off', { allowArray: false, allowArrowFunction: false, @@ -210,49 +210,49 @@ module.exports = { }], // This rule enforces that all exports are declared at the bottom of the file. - // https://github.com/benmosher/eslint-plugin-import/blob/98acd6afd04dcb6920b81330114e146dc8532ea4/docs/rules/exports-last.md + // https://github.com/import-js/eslint-plugin-import/blob/98acd6afd04dcb6920b81330114e146dc8532ea4/docs/rules/exports-last.md // TODO: enable? 'import/exports-last': 'off', // Reports when named exports are not grouped together in a single export declaration // or when multiple assignments to CommonJS module.exports or exports object are present // in a single file. - // https://github.com/benmosher/eslint-plugin-import/blob/44a038c06487964394b1e15b64f3bd34e5d40cde/docs/rules/group-exports.md + // https://github.com/import-js/eslint-plugin-import/blob/44a038c06487964394b1e15b64f3bd34e5d40cde/docs/rules/group-exports.md 'import/group-exports': 'off', // forbid default exports. this is a terrible rule, do not use it. - // https://github.com/benmosher/eslint-plugin-import/blob/44a038c06487964394b1e15b64f3bd34e5d40cde/docs/rules/no-default-export.md + // https://github.com/import-js/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 + // https://github.com/import-js/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 + // https://github.com/import-js/eslint-plugin-import/blob/44a038c06487964394b1e15b64f3bd34e5d40cde/docs/rules/no-self-import.md 'import/no-self-import': 'error', // Forbid cyclical dependencies between modules - // https://github.com/benmosher/eslint-plugin-import/blob/d81f48a2506182738409805f5272eff4d77c9348/docs/rules/no-cycle.md + // https://github.com/import-js/eslint-plugin-import/blob/d81f48a2506182738409805f5272eff4d77c9348/docs/rules/no-cycle.md 'import/no-cycle': ['error', { maxDepth: '∞' }], // Ensures that there are no useless path segments - // https://github.com/benmosher/eslint-plugin-import/blob/ebafcbf59ec9f653b2ac2a0156ca3bcba0a7cf57/docs/rules/no-useless-path-segments.md + // https://github.com/import-js/eslint-plugin-import/blob/ebafcbf59ec9f653b2ac2a0156ca3bcba0a7cf57/docs/rules/no-useless-path-segments.md 'import/no-useless-path-segments': ['error', { commonjs: true }], // dynamic imports require a leading comment with a webpackChunkName - // https://github.com/benmosher/eslint-plugin-import/blob/ebafcbf59ec9f653b2ac2a0156ca3bcba0a7cf57/docs/rules/dynamic-import-chunkname.md + // https://github.com/import-js/eslint-plugin-import/blob/ebafcbf59ec9f653b2ac2a0156ca3bcba0a7cf57/docs/rules/dynamic-import-chunkname.md 'import/dynamic-import-chunkname': ['off', { importFunctions: [], webpackChunknameFormat: '[0-9a-zA-Z-_/.]+', }], // Use this rule to prevent imports to folders in relative parent paths. - // https://github.com/benmosher/eslint-plugin-import/blob/c34f14f67f077acd5a61b3da9c0b0de298d20059/docs/rules/no-relative-parent-imports.md + // https://github.com/import-js/eslint-plugin-import/blob/c34f14f67f077acd5a61b3da9c0b0de298d20059/docs/rules/no-relative-parent-imports.md 'import/no-relative-parent-imports': 'off', // Reports modules without any exports, or with unused exports - // https://github.com/benmosher/eslint-plugin-import/blob/f63dd261809de6883b13b6b5b960e6d7f42a7813/docs/rules/no-unused-modules.md + // https://github.com/import-js/eslint-plugin-import/blob/f63dd261809de6883b13b6b5b960e6d7f42a7813/docs/rules/no-unused-modules.md // TODO: enable once it supports CJS 'import/no-unused-modules': ['off', { ignoreExports: [], @@ -261,13 +261,13 @@ module.exports = { }], // Reports the use of import declarations with CommonJS exports in any module except for the main module. - // https://github.com/benmosher/eslint-plugin-import/blob/1012eb951767279ce3b540a4ec4f29236104bb5b/docs/rules/no-import-module-exports.md + // https://github.com/import-js/eslint-plugin-import/blob/1012eb951767279ce3b540a4ec4f29236104bb5b/docs/rules/no-import-module-exports.md 'import/no-import-module-exports': ['error', { exceptions: [], }], // Use this rule to prevent importing packages through relative paths. - // https://github.com/benmosher/eslint-plugin-import/blob/1012eb951767279ce3b540a4ec4f29236104bb5b/docs/rules/no-relative-packages.md + // https://github.com/import-js/eslint-plugin-import/blob/1012eb951767279ce3b540a4ec4f29236104bb5b/docs/rules/no-relative-packages.md 'import/no-relative-packages': 'error', // enforce a consistent style for type specifiers (inline or top-level) diff --git a/packages/eslint-config-airbnb/rules/react-a11y.js b/packages/eslint-config-airbnb/rules/react-a11y.js index 713a997b28..643cf64407 100644 --- a/packages/eslint-config-airbnb/rules/react-a11y.js +++ b/packages/eslint-config-airbnb/rules/react-a11y.js @@ -12,12 +12,12 @@ module.exports = { rules: { // ensure emoji are accessible - // https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/accessible-emoji.md + // https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/blob/master/docs/rules/accessible-emoji.md // disabled; rule is deprecated 'jsx-a11y/accessible-emoji': 'off', // 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 + // https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/blob/master/docs/rules/alt-text.md 'jsx-a11y/alt-text': ['error', { elements: ['img', 'object', 'area', 'input[type="image"]'], img: [], @@ -27,11 +27,11 @@ module.exports = { }], // Enforce that anchors have content - // https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/anchor-has-content.md + // https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/blob/master/docs/rules/anchor-has-content.md 'jsx-a11y/anchor-has-content': ['error', { components: [] }], // ensure tags are valid - // https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/0745af376cdc8686d85a361ce36952b1fb1ccf6e/docs/rules/anchor-is-valid.md + // https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/blob/0745af376cdc8686d85a361ce36952b1fb1ccf6e/docs/rules/anchor-is-valid.md 'jsx-a11y/anchor-is-valid': ['error', { components: ['Link'], specialLink: ['to'], @@ -39,24 +39,24 @@ module.exports = { }], // elements with aria-activedescendant must be tabbable - // https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/aria-activedescendant-has-tabindex.md + // https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/blob/master/docs/rules/aria-activedescendant-has-tabindex.md 'jsx-a11y/aria-activedescendant-has-tabindex': 'error', // Enforce all aria-* props are valid. - // https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/aria-props.md + // https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/blob/master/docs/rules/aria-props.md '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 + // https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/blob/master/docs/rules/aria-proptypes.md 'jsx-a11y/aria-proptypes': '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 + // https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/blob/master/docs/rules/aria-role.md 'jsx-a11y/aria-role': ['error', { ignoreNonDOM: false }], // 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 + // https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/blob/master/docs/rules/aria-unsupported-elements.md 'jsx-a11y/aria-unsupported-elements': 'error', // Ensure the autocomplete attribute is correct and suitable for the form field it is used with @@ -66,11 +66,11 @@ 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 + // https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/blob/master/docs/rules/click-events-have-key-events.md 'jsx-a11y/click-events-have-key-events': 'error', // Enforce that a control (an interactive element) has a text label. - // https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/control-has-associated-label.md + // https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/blob/master/docs/rules/control-has-associated-label.md 'jsx-a11y/control-has-associated-label': ['error', { labelAttributes: ['label'], controlComponents: [], @@ -99,27 +99,27 @@ 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 + // https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/blob/master/docs/rules/heading-has-content.md '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 + // https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/blob/master/docs/rules/html-has-lang.md 'jsx-a11y/html-has-lang': 'error', // ensure iframe elements have a unique title - // https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/iframe-has-title.md + // https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/blob/master/docs/rules/iframe-has-title.md 'jsx-a11y/iframe-has-title': '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 + // https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/blob/master/docs/rules/img-redundant-alt.md 'jsx-a11y/img-redundant-alt': 'error', // 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 + // https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/blob/master/docs/rules/interactive-supports-focus.md 'jsx-a11y/interactive-supports-focus': 'error', // Enforce that a label tag has a text label and an associated control. - // https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/b800f40a2a69ad48015ae9226fbe879f946757ed/docs/rules/label-has-associated-control.md + // https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/blob/b800f40a2a69ad48015ae9226fbe879f946757ed/docs/rules/label-has-associated-control.md 'jsx-a11y/label-has-associated-control': ['error', { labelComponents: [], labelAttributes: [], @@ -129,11 +129,11 @@ module.exports = { }], // require HTML element's lang prop to be valid - // https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/lang.md + // https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/blob/master/docs/rules/lang.md 'jsx-a11y/lang': 'error', // media elements must have captions - // https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/media-has-caption.md + // https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/blob/master/docs/rules/media-has-caption.md 'jsx-a11y/media-has-caption': ['error', { audio: [], video: [], @@ -141,31 +141,31 @@ module.exports = { }], // require that mouseover/out come with focus/blur, for keyboard-only users - // https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/mouse-events-have-key-events.md + // https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/blob/master/docs/rules/mouse-events-have-key-events.md '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 + // https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/blob/master/docs/rules/no-access-key.md 'jsx-a11y/no-access-key': 'error', // prohibit autoFocus prop - // https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/no-autofocus.md + // https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/blob/master/docs/rules/no-autofocus.md 'jsx-a11y/no-autofocus': ['error', { ignoreNonDOM: true }], // prevent distracting elements, like and - // https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/no-distracting-elements.md + // https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/blob/master/docs/rules/no-distracting-elements.md 'jsx-a11y/no-distracting-elements': ['error', { elements: ['marquee', 'blink'], }], // 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 + // https://github.com/jsx-eslint/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'], }], // 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 + // https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/blob/master/docs/rules/no-noninteractive-element-interactions.md 'jsx-a11y/no-noninteractive-element-interactions': ['error', { handlers: [ 'onClick', @@ -178,7 +178,7 @@ module.exports = { }], // 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 + // https://github.com/jsx-eslint/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'], @@ -188,22 +188,22 @@ module.exports = { }], // 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 + // https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/blob/master/docs/rules/no-noninteractive-tabindex.md 'jsx-a11y/no-noninteractive-tabindex': ['error', { tags: [], roles: ['tabpanel'], }], // require onBlur instead of onChange - // https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/no-onchange.md + // https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/blob/master/docs/rules/no-onchange.md 'jsx-a11y/no-onchange': 'off', // 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 + // https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/blob/master/docs/rules/no-redundant-roles.md 'jsx-a11y/no-redundant-roles': '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 + // https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/blob/master/docs/rules/no-static-element-interactions.md 'jsx-a11y/no-static-element-interactions': ['error', { handlers: [ 'onClick', @@ -217,20 +217,20 @@ module.exports = { // 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 + // https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/blob/master/docs/rules/role-has-required-aria-props.md '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 + // https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/blob/master/docs/rules/role-supports-aria-props.md 'jsx-a11y/role-supports-aria-props': 'error', // only allow to have the "scope" attr - // https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/scope.md + // https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/blob/master/docs/rules/scope.md 'jsx-a11y/scope': 'error', // Enforce tabIndex value is not greater than zero. - // https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/tabindex-no-positive.md + // https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/blob/master/docs/rules/tabindex-no-positive.md 'jsx-a11y/tabindex-no-positive': 'error', // ---------------------------------------------------- @@ -238,7 +238,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 + // https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/blob/master/docs/rules/label-has-for.md // deprecated: replaced by `label-has-associated-control` rule 'jsx-a11y/label-has-for': ['off', { components: [], diff --git a/react/README.md b/react/README.md index e7679d26da..a590a19672 100644 --- a/react/README.md +++ b/react/README.md @@ -25,14 +25,14 @@ This style guide is mostly based on the standards that are currently prevalent i ## Basic Rules - Only include one React component per file. - - 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). + - 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/jsx-eslint/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-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`. + - [`react/forbid-prop-types`](https://github.com/jsx-eslint/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 - - 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) + - If you have internal state and/or refs, prefer `class extends React.Component` over `React.createClass`. eslint: [`react/prefer-es6-class`](https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/prefer-es6-class.md) [`react/prefer-stateless-function`](https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/prefer-stateless-function.md) ```jsx // bad @@ -81,9 +81,9 @@ This style guide is mostly based on the standards that are currently prevalent i ## Naming - - **Extensions**: Use `.jsx` extension for React components. eslint: [`react/jsx-filename-extension`](https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-filename-extension.md) + - **Extensions**: Use `.jsx` extension for React components. eslint: [`react/jsx-filename-extension`](https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/jsx-filename-extension.md) - **Filename**: Use PascalCase for filenames. E.g., `ReservationCard.jsx`. - - **Reference Naming**: Use PascalCase for React components and camelCase for their instances. eslint: [`react/jsx-pascal-case`](https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-pascal-case.md) + - **Reference Naming**: Use PascalCase for React components and camelCase for their instances. eslint: [`react/jsx-pascal-case`](https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/jsx-pascal-case.md) ```jsx // bad @@ -172,7 +172,7 @@ This style guide is mostly based on the standards that are currently prevalent i ## Alignment - - Follow these alignment styles for JSX syntax. eslint: [`react/jsx-closing-bracket-location`](https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-closing-bracket-location.md) [`react/jsx-closing-tag-location`](https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-closing-tag-location.md) + - Follow these alignment styles for JSX syntax. eslint: [`react/jsx-closing-bracket-location`](https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/jsx-closing-bracket-location.md) [`react/jsx-closing-tag-location`](https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/jsx-closing-tag-location.md) ```jsx // bad @@ -259,7 +259,7 @@ This style guide is mostly based on the standards that are currently prevalent i ## Spacing - - Always include a single space in your self-closing tag. eslint: [`no-multi-spaces`](https://eslint.org/docs/rules/no-multi-spaces), [`react/jsx-tag-spacing`](https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-tag-spacing.md) + - Always include a single space in your self-closing tag. eslint: [`no-multi-spaces`](https://eslint.org/docs/rules/no-multi-spaces), [`react/jsx-tag-spacing`](https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/jsx-tag-spacing.md) ```jsx // bad @@ -276,7 +276,7 @@ This style guide is mostly based on the standards that are currently prevalent i ``` - - Do not pad JSX curly braces with spaces. eslint: [`react/jsx-curly-spacing`](https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-curly-spacing.md) + - Do not pad JSX curly braces with spaces. eslint: [`react/jsx-curly-spacing`](https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/jsx-curly-spacing.md) ```jsx // bad @@ -305,7 +305,7 @@ This style guide is mostly based on the standards that are currently prevalent i /> ``` - - Omit the value of the prop when it is explicitly `true`. eslint: [`react/jsx-boolean-value`](https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-boolean-value.md) + - Omit the value of the prop when it is explicitly `true`. eslint: [`react/jsx-boolean-value`](https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/jsx-boolean-value.md) ```jsx // bad @@ -322,7 +322,7 @@ This style guide is mostly based on the standards that are currently prevalent i