diff --git a/CODE_OF_CONDUCT.md b/CODE_OF_CONDUCT.md new file mode 100644 index 0000000000..f405009e86 --- /dev/null +++ b/CODE_OF_CONDUCT.md @@ -0,0 +1,3 @@ +Airbnb has adopted a Code of Conduct that we expect project participants to adhere to. Please [read the full Code of Conduct text](https://airbnb.tech/open-source/code-of-conduct/) so that you can understand what actions will and will not be tolerated. Report violations to the maintainers of this project or to [opensource-conduct@airbnb.com](mailto:opensource-conduct@airbnb.com). + +Reports sent to [opensource-conduct@airbnb.com](mailto:opensource-conduct@airbnb.com) are received by Airbnb's open source code of conduct moderation team, which is composed of Airbnb employees. All communications are private and confidential. diff --git a/README.md b/README.md index 9681aa4b51..9a325a355b 100644 --- a/README.md +++ b/README.md @@ -3406,7 +3406,7 @@ Other Style Guides this.firstName = 'Panda'; // good, in environments where WeakMaps are available - // see https://kangax.github.io/compat-table/es6/#test-WeakMap + // see https://compat-table.github.io/compat-table/es6/#test-WeakMap const firstNames = new WeakMap(); firstNames.set(this, 'Panda'); ``` @@ -3746,7 +3746,7 @@ Other Style Guides ## ECMAScript 5 Compatibility - - [27.1](#es5-compat--kangax) Refer to [Kangax](https://twitter.com/kangax/)’s ES5 [compatibility table](https://kangax.github.io/es5-compat-table/). + - [27.1](#es5-compat--kangax) Refer to [Kangax](https://twitter.com/kangax/)’s ES5 [compatibility table](https://compat-table.github.io/compat-table/es5/). **[⬆ back to top](#table-of-contents)** @@ -3860,8 +3860,8 @@ Other Style Guides - [Latest ECMA spec](https://tc39.github.io/ecma262/) - [ExploringJS](https://exploringjs.com/) - - [ES6 Compatibility Table](https://kangax.github.io/compat-table/es6/) - - [Comprehensive Overview of ES6 Features](http://es6-features.org/) + - [ES6 Compatibility Table](https://compat-table.github.io/compat-table/es6/) + - [Comprehensive Overview of ES6 Features](https://web.archive.org/web/20240404212626/http://es6-features.org/) - [JavaScript Roadmap](https://roadmap.sh/javascript) **Read This** @@ -3952,7 +3952,6 @@ Other Style Guides - **Axept**: [axept/javascript](https://github.com/axept/javascript) - **Billabong**: [billabong/javascript](https://github.com/billabong/javascript) - **Bisk**: [bisk](https://github.com/Bisk/) - - **Bonhomme**: [bonhommeparis/javascript](https://github.com/bonhommeparis/javascript) - **Brainshark**: [brainshark/javascript](https://github.com/brainshark/javascript) - **CaseNine**: [CaseNine/javascript](https://github.com/CaseNine/javascript) - **Cerner**: [Cerner](https://github.com/cerner/) @@ -3965,7 +3964,6 @@ Other Style Guides - **Digitpaint** [digitpaint/javascript](https://github.com/digitpaint/javascript) - **Drupal**: [www.drupal.org](https://git.drupalcode.org/project/drupal/blob/8.6.x/core/.eslintrc.json) - **Ecosia**: [ecosia/javascript](https://github.com/ecosia/javascript) - - **Evernote**: [evernote/javascript-style-guide](https://github.com/evernote/javascript-style-guide) - **Evolution Gaming**: [evolution-gaming/javascript](https://github.com/evolution-gaming/javascript) - **EvozonJs**: [evozonjs/javascript](https://github.com/evozonjs/javascript) - **ExactTarget**: [ExactTarget/javascript](https://github.com/ExactTarget/javascript) @@ -3978,10 +3976,10 @@ Other Style Guides - **Grooveshark**: [grooveshark/javascript](https://github.com/grooveshark/javascript) - **Grupo-Abraxas**: [Grupo-Abraxas/javascript](https://github.com/Grupo-Abraxas/javascript) - **Happeo**: [happeo/javascript](https://github.com/happeo/javascript) - - **Honey**: [honeyscience/javascript](https://github.com/honeyscience/javascript) - **How About We**: [howaboutwe/javascript](https://github.com/howaboutwe/javascript-style-guide) - **HubSpot**: [HubSpot/javascript](https://github.com/HubSpot/javascript) - **Hyper**: [hyperoslo/javascript-playbook](https://github.com/hyperoslo/javascript-playbook/blob/master/style.md) + - **ILIAS**: [ILIAS](https://github.com/ILIAS-eLearning/ILIAS) - **InterCity Group**: [intercitygroup/javascript-style-guide](https://github.com/intercitygroup/javascript-style-guide) - **Jam3**: [Jam3/Javascript-Code-Conventions](https://github.com/Jam3/Javascript-Code-Conventions) - **JSSolutions**: [JSSolutions/javascript](https://github.com/JSSolutions/javascript) @@ -4004,7 +4002,6 @@ Other Style Guides - **Pier 1**: [Pier1/javascript](https://github.com/pier1/javascript) - **Qotto**: [Qotto/javascript-style-guide](https://github.com/Qotto/javascript-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) - **Shutterfly**: [shutterfly/javascript](https://github.com/shutterfly/javascript) @@ -4028,6 +4025,7 @@ Other Style Guides - **WeBox Studio**: [weboxstudio/javascript](https://github.com/weboxstudio/javascript) - **Weggo**: [Weggo/javascript](https://github.com/Weggo/javascript) - **Zillow**: [zillow/javascript](https://github.com/zillow/javascript) + - **Zit Software**: [zit-software/javascript](https://github.com/zit-software/javascript) - **ZocDoc**: [ZocDoc/javascript](https://github.com/ZocDoc/javascript) **[⬆ back to top](#table-of-contents)** diff --git a/css-in-javascript/README.md b/css-in-javascript/README.md index d6162df55d..2e6ab68a1b 100644 --- a/css-in-javascript/README.md +++ b/css-in-javascript/README.md @@ -34,7 +34,7 @@ - Use an underscore for modifiers to other styles. - > Why? Similar to BEM, this naming convention makes it clear that the styles are intended to modify the element preceded by the underscore. Underscores do not need to be quoted, so they are preferred over other characters, such as dashes. + > Why? Similar to [BEM](https://getbem.com/introduction/), this naming convention makes it clear that the styles are intended to modify the element preceded by the underscore. Underscores do not need to be quoted, so they are preferred over other characters, such as dashes. ```js // bad diff --git a/packages/eslint-config-airbnb-base/package.json b/packages/eslint-config-airbnb-base/package.json index 39c0fdf944..8f039d4d7c 100644 --- a/packages/eslint-config-airbnb-base/package.json +++ b/packages/eslint-config-airbnb-base/package.json @@ -68,26 +68,25 @@ }, "homepage": "https://github.com/airbnb/javascript", "devDependencies": { - "@babel/runtime": "^7.22.6", + "@babel/runtime": "^7.25.6", "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.1.0", - "eslint-plugin-import": "^2.28.0", + "eslint-plugin-import": "^2.30.0", "in-publish": "^2.0.1", "safe-publish-latest": "^2.0.0", - "tape": "^5.6.6" + "tape": "^5.9.0" }, "peerDependencies": { "eslint": "^7.32.0 || ^8.2.0", - "eslint-plugin-import": "^2.28.0" + "eslint-plugin-import": "^2.30.0" }, "engines": { "node": "^10.12.0 || >=12.0.0" }, "dependencies": { - "confusing-browser-globals": "^1.0.11", - "object.entries": "^1.1.6" + "confusing-browser-globals": "^1.0.11" } } diff --git a/packages/eslint-config-airbnb-base/rules/best-practices.js b/packages/eslint-config-airbnb-base/rules/best-practices.js index 944fe71a05..09c247451a 100644 --- a/packages/eslint-config-airbnb-base/rules/best-practices.js +++ b/packages/eslint-config-airbnb-base/rules/best-practices.js @@ -217,6 +217,11 @@ module.exports = { // https://eslint.org/docs/rules/no-nonoctal-decimal-escape 'no-nonoctal-decimal-escape': 'error', + // Disallow calls to the Object constructor without an argument + // https://eslint.org/docs/latest/rules/no-object-constructor + // TODO: enable, semver-major + 'no-object-constructor': 'off', + // disallow use of (old style) octal literals // https://eslint.org/docs/rules/no-octal 'no-octal': 'error', diff --git a/packages/eslint-config-airbnb-base/whitespace-async.js b/packages/eslint-config-airbnb-base/whitespace-async.js index d6742fb7c4..06f4f89075 100755 --- a/packages/eslint-config-airbnb-base/whitespace-async.js +++ b/packages/eslint-config-airbnb-base/whitespace-async.js @@ -1,6 +1,7 @@ #!/usr/bin/env node -const entries = require('object.entries'); +const { isArray } = Array; +const { entries } = Object; const { ESLint } = require('eslint'); const baseConfig = require('.'); @@ -9,7 +10,7 @@ const whitespaceRules = require('./whitespaceRules'); const severities = ['off', 'warn', 'error']; function getSeverity(ruleConfig) { - if (Array.isArray(ruleConfig)) { + if (isArray(ruleConfig)) { return getSeverity(ruleConfig[0]); } if (typeof ruleConfig === 'number') { @@ -32,7 +33,7 @@ async function onlyErrorOnRules(rulesToError, config) { const severity = getSeverity(ruleConfig); if (rulesToError.indexOf(ruleName) === -1 && severity === 'error') { - if (Array.isArray(ruleConfig)) { + if (isArray(ruleConfig)) { errorsOnly.rules[ruleName] = ['warn'].concat(ruleConfig.slice(1)); } else if (typeof ruleConfig === 'number') { errorsOnly.rules[ruleName] = 1; diff --git a/packages/eslint-config-airbnb-base/whitespace.js b/packages/eslint-config-airbnb-base/whitespace.js index f4b93bb492..01e5198671 100644 --- a/packages/eslint-config-airbnb-base/whitespace.js +++ b/packages/eslint-config-airbnb-base/whitespace.js @@ -1,10 +1,11 @@ /* eslint global-require: 0 */ +const { isArray } = Array; +const { entries } = Object; const { CLIEngine } = require('eslint'); if (CLIEngine) { /* eslint no-inner-declarations: 0 */ - const entries = require('object.entries'); const whitespaceRules = require('./whitespaceRules'); const baseConfig = require('.'); @@ -12,7 +13,7 @@ if (CLIEngine) { const severities = ['off', 'warn', 'error']; function getSeverity(ruleConfig) { - if (Array.isArray(ruleConfig)) { + if (isArray(ruleConfig)) { return getSeverity(ruleConfig[0]); } if (typeof ruleConfig === 'number') { @@ -32,7 +33,7 @@ if (CLIEngine) { const severity = getSeverity(ruleConfig); if (rulesToError.indexOf(ruleName) === -1 && severity === 'error') { - if (Array.isArray(ruleConfig)) { + if (isArray(ruleConfig)) { errorsOnly.rules[ruleName] = ['warn'].concat(ruleConfig.slice(1)); } else if (typeof ruleConfig === 'number') { errorsOnly.rules[ruleName] = 1; @@ -50,5 +51,11 @@ if (CLIEngine) { const path = require('path'); const { execSync } = require('child_process'); - module.exports = JSON.parse(String(execSync(path.join(__dirname, 'whitespace-async.js')))); + // NOTE: ESLint adds runtime statistics to the output (so it's no longer JSON) if TIMING is set + module.exports = JSON.parse(String(execSync(path.join(__dirname, 'whitespace-async.js'), { + env: { + ...process.env, + TIMING: undefined, + } + }))); } diff --git a/packages/eslint-config-airbnb/package.json b/packages/eslint-config-airbnb/package.json index 1ac7a902a2..c36359ea7c 100644 --- a/packages/eslint-config-airbnb/package.json +++ b/packages/eslint-config-airbnb/package.json @@ -66,31 +66,30 @@ }, "homepage": "https://github.com/airbnb/javascript", "dependencies": { - "eslint-config-airbnb-base": "^15.0.0", - "object.entries": "^1.1.6" + "eslint-config-airbnb-base": "^15.0.0" }, "devDependencies": { - "@babel/runtime": "^7.22.6", + "@babel/runtime": "^7.25.6", "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.1.0", - "eslint-plugin-import": "^2.28.0", - "eslint-plugin-jsx-a11y": "^6.7.1", - "eslint-plugin-react": "^7.33.1", - "eslint-plugin-react-hooks": "^4.6.0", + "eslint-plugin-import": "^2.30.0", + "eslint-plugin-jsx-a11y": "^6.10.0", + "eslint-plugin-react": "^7.36.1", + "eslint-plugin-react-hooks": "^5.1.0", "in-publish": "^2.0.1", "react": ">= 0.13.0", "safe-publish-latest": "^2.0.0", - "tape": "^5.6.6" + "tape": "^5.9.0" }, "peerDependencies": { "eslint": "^7.32.0 || ^8.2.0", - "eslint-plugin-import": "^2.28.0", - "eslint-plugin-jsx-a11y": "^6.7.1", - "eslint-plugin-react": "^7.33.1", - "eslint-plugin-react-hooks": "^4.6.0" + "eslint-plugin-import": "^2.30.0", + "eslint-plugin-jsx-a11y": "^6.10.0", + "eslint-plugin-react": "^7.36.1", + "eslint-plugin-react-hooks": "^5.1.0" }, "engines": { "node": "^10.12.0 || ^12.22.0 || ^14.17.0 || >=16.0.0" diff --git a/packages/eslint-config-airbnb/rules/react-a11y.js b/packages/eslint-config-airbnb/rules/react-a11y.js index 643cf64407..58065120a4 100644 --- a/packages/eslint-config-airbnb/rules/react-a11y.js +++ b/packages/eslint-config-airbnb/rules/react-a11y.js @@ -192,6 +192,7 @@ module.exports = { 'jsx-a11y/no-noninteractive-tabindex': ['error', { tags: [], roles: ['tabpanel'], + allowExpressionValues: true, }], // require onBlur instead of onChange @@ -200,7 +201,9 @@ module.exports = { // ensure HTML elements do not specify redundant ARIA roles // https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/blob/master/docs/rules/no-redundant-roles.md - 'jsx-a11y/no-redundant-roles': 'error', + 'jsx-a11y/no-redundant-roles': ['error', { + nav: ['navigation'], + }], // Enforce that DOM elements without semantic behavior not have interaction handlers // https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/blob/master/docs/rules/no-static-element-interactions.md diff --git a/packages/eslint-config-airbnb/rules/react.js b/packages/eslint-config-airbnb/rules/react.js index ac4e4e29d3..c4d29e0b39 100644 --- a/packages/eslint-config-airbnb/rules/react.js +++ b/packages/eslint-config-airbnb/rules/react.js @@ -46,6 +46,13 @@ module.exports = { ], }], + // This rule enforces onChange or readonly attribute for checked property of input elements. + // https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/checked-requires-onchange-or-readonly.md + 'react/checked-requires-onchange-or-readonly': ['off', { + ignoreMissingProperties: false, + ignoreExclusiveCheckedAttribute: false + }], + // Prevent missing displayName in a React component definition // https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/display-name.md 'react/display-name': ['off', { ignoreTranspilerName: false }], @@ -576,17 +583,23 @@ module.exports = { // 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 }], + + // https://github.com/jsx-eslint/eslint-plugin-react/blob/9668ee0762acd5c23f53cd3a372e2d8d9563944d/docs/rules/forward-ref-uses-ref.md + // TODO: semver-major, enable + 'react/forward-ref-uses-ref': 'off', + + // https://github.com/jsx-eslint/eslint-plugin-react/blob/9668ee0762acd5c23f53cd3a372e2d8d9563944d/docs/rules/jsx-props-no-spread-multi.md + // TODO: semver-major, enable + 'react/jsx-props-no-spread-multi': 'off', }, settings: { diff --git a/packages/eslint-config-airbnb/whitespace-async.js b/packages/eslint-config-airbnb/whitespace-async.js index d6742fb7c4..06f4f89075 100755 --- a/packages/eslint-config-airbnb/whitespace-async.js +++ b/packages/eslint-config-airbnb/whitespace-async.js @@ -1,6 +1,7 @@ #!/usr/bin/env node -const entries = require('object.entries'); +const { isArray } = Array; +const { entries } = Object; const { ESLint } = require('eslint'); const baseConfig = require('.'); @@ -9,7 +10,7 @@ const whitespaceRules = require('./whitespaceRules'); const severities = ['off', 'warn', 'error']; function getSeverity(ruleConfig) { - if (Array.isArray(ruleConfig)) { + if (isArray(ruleConfig)) { return getSeverity(ruleConfig[0]); } if (typeof ruleConfig === 'number') { @@ -32,7 +33,7 @@ async function onlyErrorOnRules(rulesToError, config) { const severity = getSeverity(ruleConfig); if (rulesToError.indexOf(ruleName) === -1 && severity === 'error') { - if (Array.isArray(ruleConfig)) { + if (isArray(ruleConfig)) { errorsOnly.rules[ruleName] = ['warn'].concat(ruleConfig.slice(1)); } else if (typeof ruleConfig === 'number') { errorsOnly.rules[ruleName] = 1; diff --git a/packages/eslint-config-airbnb/whitespace.js b/packages/eslint-config-airbnb/whitespace.js index f4b93bb492..01e5198671 100644 --- a/packages/eslint-config-airbnb/whitespace.js +++ b/packages/eslint-config-airbnb/whitespace.js @@ -1,10 +1,11 @@ /* eslint global-require: 0 */ +const { isArray } = Array; +const { entries } = Object; const { CLIEngine } = require('eslint'); if (CLIEngine) { /* eslint no-inner-declarations: 0 */ - const entries = require('object.entries'); const whitespaceRules = require('./whitespaceRules'); const baseConfig = require('.'); @@ -12,7 +13,7 @@ if (CLIEngine) { const severities = ['off', 'warn', 'error']; function getSeverity(ruleConfig) { - if (Array.isArray(ruleConfig)) { + if (isArray(ruleConfig)) { return getSeverity(ruleConfig[0]); } if (typeof ruleConfig === 'number') { @@ -32,7 +33,7 @@ if (CLIEngine) { const severity = getSeverity(ruleConfig); if (rulesToError.indexOf(ruleName) === -1 && severity === 'error') { - if (Array.isArray(ruleConfig)) { + if (isArray(ruleConfig)) { errorsOnly.rules[ruleName] = ['warn'].concat(ruleConfig.slice(1)); } else if (typeof ruleConfig === 'number') { errorsOnly.rules[ruleName] = 1; @@ -50,5 +51,11 @@ if (CLIEngine) { const path = require('path'); const { execSync } = require('child_process'); - module.exports = JSON.parse(String(execSync(path.join(__dirname, 'whitespace-async.js')))); + // NOTE: ESLint adds runtime statistics to the output (so it's no longer JSON) if TIMING is set + module.exports = JSON.parse(String(execSync(path.join(__dirname, 'whitespace-async.js'), { + env: { + ...process.env, + TIMING: undefined, + } + }))); }