From 64d816e5d52d407ccdb85c65d1a849eaacbec45b Mon Sep 17 00:00:00 2001 From: Mustafa UZUN Date: Mon, 7 Aug 2023 13:38:45 +0300 Subject: [PATCH 1/3] Add arrays bracket newline https://github.com/airbnb/javascript#arrays--bracket-newline --- packages/eslint-config-airbnb-base/legacy.js | 6 +++--- .../rules/best-practices.js | 2 +- .../eslint-config-airbnb-base/rules/es6.js | 8 ++++---- .../eslint-config-airbnb-base/rules/imports.js | 12 ++++++------ .../eslint-config-airbnb-base/rules/strict.js | 4 ++-- .../eslint-config-airbnb-base/rules/style.js | 18 +++++++++--------- .../whitespaceRules.js | 2 +- packages/eslint-config-airbnb/hooks.js | 2 +- packages/eslint-config-airbnb/index.js | 2 +- .../eslint-config-airbnb/rules/react-a11y.js | 4 ++-- packages/eslint-config-airbnb/rules/react.js | 16 ++++++++-------- 11 files changed, 38 insertions(+), 38 deletions(-) diff --git a/packages/eslint-config-airbnb-base/legacy.js b/packages/eslint-config-airbnb-base/legacy.js index e5c9089c75..63705ef33c 100644 --- a/packages/eslint-config-airbnb-base/legacy.js +++ b/packages/eslint-config-airbnb-base/legacy.js @@ -4,14 +4,14 @@ module.exports = { './rules/errors', './rules/node', './rules/style', - './rules/variables' + './rules/variables', ].map(require.resolve), env: { browser: true, node: true, amd: false, mocha: false, - jasmine: false + jasmine: false, }, rules: { 'comma-dangle': ['error', 'never'], @@ -30,5 +30,5 @@ module.exports = { 'no-var': 'off', 'prefer-object-spread': 'off', strict: ['error', 'safe'], - } + }, }; diff --git a/packages/eslint-config-airbnb-base/rules/best-practices.js b/packages/eslint-config-airbnb-base/rules/best-practices.js index 944fe71a05..933ebf79e0 100644 --- a/packages/eslint-config-airbnb-base/rules/best-practices.js +++ b/packages/eslint-config-airbnb-base/rules/best-practices.js @@ -414,6 +414,6 @@ module.exports = { // require or disallow Yoda conditions // https://eslint.org/docs/rules/yoda - yoda: 'error' + yoda: 'error', } }; diff --git a/packages/eslint-config-airbnb-base/rules/es6.js b/packages/eslint-config-airbnb-base/rules/es6.js index 5e59cbebf4..fe3ac2fc25 100644 --- a/packages/eslint-config-airbnb-base/rules/es6.js +++ b/packages/eslint-config-airbnb-base/rules/es6.js @@ -7,8 +7,8 @@ module.exports = { sourceType: 'module', ecmaFeatures: { generators: false, - objectLiteralDuplicateProperties: false - } + objectLiteralDuplicateProperties: false, + }, }, rules: { @@ -73,7 +73,7 @@ module.exports = { // https://eslint.org/docs/rules/no-restricted-imports 'no-restricted-imports': ['off', { paths: [], - patterns: [] + patterns: [], }], // disallow to use this/super before super() calling in constructors. @@ -180,6 +180,6 @@ module.exports = { // enforce spacing around the * in yield* expressions // https://eslint.org/docs/rules/yield-star-spacing - 'yield-star-spacing': ['error', 'after'] + 'yield-star-spacing': ['error', 'after'], } }; diff --git a/packages/eslint-config-airbnb-base/rules/imports.js b/packages/eslint-config-airbnb-base/rules/imports.js index d36e4908fa..72f1a87353 100644 --- a/packages/eslint-config-airbnb-base/rules/imports.js +++ b/packages/eslint-config-airbnb-base/rules/imports.js @@ -1,20 +1,20 @@ module.exports = { env: { - es6: true + es6: true, }, parserOptions: { ecmaVersion: 6, - sourceType: 'module' + sourceType: 'module', }, plugins: [ - 'import' + 'import', ], settings: { 'import/resolver': { node: { - extensions: ['.mjs', '.js', '.json'] - } + extensions: ['.mjs', '.js', '.json'], + }, }, 'import/extensions': [ '.js', @@ -91,7 +91,7 @@ module.exports = { '**/protractor.conf.js', // protractor config '**/protractor.conf.*.js', // protractor config '**/karma.conf.js', // karma config - '**/.eslintrc.js' // eslint config + '**/.eslintrc.js', // eslint config ], optionalDependencies: false, }], diff --git a/packages/eslint-config-airbnb-base/rules/strict.js b/packages/eslint-config-airbnb-base/rules/strict.js index 67cfd5e8a3..c48e5abb96 100644 --- a/packages/eslint-config-airbnb-base/rules/strict.js +++ b/packages/eslint-config-airbnb-base/rules/strict.js @@ -1,6 +1,6 @@ module.exports = { rules: { // babel inserts `'use strict';` for us - strict: ['error', 'never'] - } + strict: ['error', 'never'], + }, }; diff --git a/packages/eslint-config-airbnb-base/rules/style.js b/packages/eslint-config-airbnb-base/rules/style.js index 2e7f6fed44..e546d71ab7 100644 --- a/packages/eslint-config-airbnb-base/rules/style.js +++ b/packages/eslint-config-airbnb-base/rules/style.js @@ -128,14 +128,14 @@ module.exports = { // MemberExpression: null, FunctionDeclaration: { parameters: 1, - body: 1 + body: 1, }, FunctionExpression: { parameters: 1, - body: 1 + body: 1, }, CallExpression: { - arguments: 1 + arguments: 1, }, ArrayExpression: 1, ObjectExpression: 1, @@ -143,7 +143,7 @@ module.exports = { flatTernaryExpressions: false, // list derived from https://github.com/benjamn/ast-types/blob/HEAD/def/jsx.js ignoredNodes: ['JSXElement', 'JSXElement > *', 'JSXAttribute', 'JSXIdentifier', 'JSXNamespacedName', 'JSXMemberExpression', 'JSXSpreadAttribute', 'JSXExpressionContainer', 'JSXOpeningElement', 'JSXClosingElement', 'JSXFragment', 'JSXOpeningFragment', 'JSXClosingFragment', 'JSXText', 'JSXEmptyExpression', 'JSXSpreadChild'], - ignoreComments: false + ignoreComments: false, }], // specify whether double or single quotes should be used in JSX attributes @@ -160,7 +160,7 @@ module.exports = { overrides: { return: { after: true }, throw: { after: true }, - case: { after: true } + case: { after: true }, } }], @@ -216,7 +216,7 @@ module.exports = { 'max-lines': ['off', { max: 300, skipBlankLines: true, - skipComments: true + skipComments: true, }], // enforce a maximum function length @@ -307,7 +307,7 @@ module.exports = { ['==', '!=', '===', '!=='], ['&&', '||'], ], - allowSamePrecedence: false + allowSamePrecedence: false, }], // disallow mixed spaces and tabs for indentation @@ -484,7 +484,7 @@ module.exports = { 'space-before-function-paren': ['error', { anonymous: 'always', named: 'never', - asyncArrow: 'always' + asyncArrow: 'always', }], // require or disallow spaces inside parentheses @@ -529,6 +529,6 @@ module.exports = { 'unicode-bom': ['error', 'never'], // require regex literals to be wrapped in parentheses - 'wrap-regex': 'off' + 'wrap-regex': 'off', } }; diff --git a/packages/eslint-config-airbnb-base/whitespaceRules.js b/packages/eslint-config-airbnb-base/whitespaceRules.js index 6b0d3bfec7..aa8af3dcf1 100644 --- a/packages/eslint-config-airbnb-base/whitespaceRules.js +++ b/packages/eslint-config-airbnb-base/whitespaceRules.js @@ -45,5 +45,5 @@ module.exports = [ 'spaced-comment', 'switch-colon-spacing', 'template-tag-spacing', - 'import/newline-after-import' + 'import/newline-after-import', ]; diff --git a/packages/eslint-config-airbnb/hooks.js b/packages/eslint-config-airbnb/hooks.js index a7f70284e3..50931c1c58 100644 --- a/packages/eslint-config-airbnb/hooks.js +++ b/packages/eslint-config-airbnb/hooks.js @@ -2,5 +2,5 @@ module.exports = { extends: [ './rules/react-hooks.js', ].map(require.resolve), - rules: {} + rules: {}, }; diff --git a/packages/eslint-config-airbnb/index.js b/packages/eslint-config-airbnb/index.js index 6432e10dda..57f830820b 100644 --- a/packages/eslint-config-airbnb/index.js +++ b/packages/eslint-config-airbnb/index.js @@ -4,5 +4,5 @@ module.exports = { './rules/react', './rules/react-a11y', ].map(require.resolve), - rules: {} + rules: {}, }; diff --git a/packages/eslint-config-airbnb/rules/react-a11y.js b/packages/eslint-config-airbnb/rules/react-a11y.js index 643cf64407..e7be3dc627 100644 --- a/packages/eslint-config-airbnb/rules/react-a11y.js +++ b/packages/eslint-config-airbnb/rules/react-a11y.js @@ -1,7 +1,7 @@ module.exports = { plugins: [ 'jsx-a11y', - 'react' + 'react', ], parserOptions: { @@ -125,7 +125,7 @@ module.exports = { labelAttributes: [], controlComponents: [], assert: 'both', - depth: 25 + depth: 25, }], // require HTML element's lang prop to be valid diff --git a/packages/eslint-config-airbnb/rules/react.js b/packages/eslint-config-airbnb/rules/react.js index ac4e4e29d3..1fbea5882a 100644 --- a/packages/eslint-config-airbnb/rules/react.js +++ b/packages/eslint-config-airbnb/rules/react.js @@ -42,7 +42,7 @@ module.exports = { 'componentDidUpdate', 'componentWillUnmount', 'componentDidCatch', - 'getSnapshotBeforeUpdate' + 'getSnapshotBeforeUpdate', ], }], @@ -222,7 +222,7 @@ module.exports = { 'react/prop-types': ['error', { ignore: [], customValidators: [], - skipUndeclared: false + skipUndeclared: false, }], // Prevent missing React when using JSX @@ -280,11 +280,11 @@ module.exports = { 'getSnapshotBeforeUpdate', 'componentDidUpdate', 'componentDidCatch', - 'componentWillUnmount' + 'componentWillUnmount', ], rendering: [ '/^render.+$/', - 'render' + 'render', ], }, }], @@ -343,7 +343,7 @@ module.exports = { // Forbid certain elements // https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/forbid-elements.md - 'react/forbid-elements': ['off', { forbid: [], }], + 'react/forbid-elements': ['off', { forbid: [] }], // Prevent problem with children and props.dangerouslySetInnerHTML // https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/no-danger-with-children.md @@ -585,15 +585,15 @@ module.exports = { // 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 + ignoreCase: false, }], }, settings: { 'import/resolver': { node: { - extensions: ['.js', '.jsx', '.json'] - } + extensions: ['.js', '.jsx', '.json'], + }, }, react: { pragma: 'React', From 83fcc83d97e4368667c8332d15f12384a5f71c1a Mon Sep 17 00:00:00 2001 From: Mustafa UZUN Date: Mon, 7 Aug 2023 13:39:02 +0300 Subject: [PATCH 2/3] Add array destructuring https://github.com/airbnb/javascript#destructuring--array And severities array put inside the getSeverity function --- packages/eslint-config-airbnb-base/whitespace-async.js | 7 +++---- packages/eslint-config-airbnb-base/whitespace.js | 7 +++---- packages/eslint-config-airbnb/whitespace-async.js | 7 +++---- packages/eslint-config-airbnb/whitespace.js | 7 +++---- 4 files changed, 12 insertions(+), 16 deletions(-) diff --git a/packages/eslint-config-airbnb-base/whitespace-async.js b/packages/eslint-config-airbnb-base/whitespace-async.js index d6742fb7c4..a4a737b212 100755 --- a/packages/eslint-config-airbnb-base/whitespace-async.js +++ b/packages/eslint-config-airbnb-base/whitespace-async.js @@ -6,9 +6,9 @@ const { ESLint } = require('eslint'); const baseConfig = require('.'); const whitespaceRules = require('./whitespaceRules'); -const severities = ['off', 'warn', 'error']; - function getSeverity(ruleConfig) { + const severities = ['off', 'warn', 'error']; + if (Array.isArray(ruleConfig)) { return getSeverity(ruleConfig[0]); } @@ -27,8 +27,7 @@ async function onlyErrorOnRules(rulesToError, config) { const baseRules = (await cli.calculateConfigForFile(require.resolve('./'))).rules; entries(baseRules).forEach((rule) => { - const ruleName = rule[0]; - const ruleConfig = rule[1]; + const [ruleName, ruleConfig] = rule; const severity = getSeverity(ruleConfig); if (rulesToError.indexOf(ruleName) === -1 && severity === 'error') { diff --git a/packages/eslint-config-airbnb-base/whitespace.js b/packages/eslint-config-airbnb-base/whitespace.js index f4b93bb492..fec4bce5e4 100644 --- a/packages/eslint-config-airbnb-base/whitespace.js +++ b/packages/eslint-config-airbnb-base/whitespace.js @@ -9,9 +9,9 @@ if (CLIEngine) { const baseConfig = require('.'); - const severities = ['off', 'warn', 'error']; - function getSeverity(ruleConfig) { + const severities = ['off', 'warn', 'error']; + if (Array.isArray(ruleConfig)) { return getSeverity(ruleConfig[0]); } @@ -27,8 +27,7 @@ if (CLIEngine) { const baseRules = cli.getConfigForFile(require.resolve('./')).rules; entries(baseRules).forEach((rule) => { - const ruleName = rule[0]; - const ruleConfig = rule[1]; + const [ruleName, ruleConfig] = rule; const severity = getSeverity(ruleConfig); if (rulesToError.indexOf(ruleName) === -1 && severity === 'error') { diff --git a/packages/eslint-config-airbnb/whitespace-async.js b/packages/eslint-config-airbnb/whitespace-async.js index d6742fb7c4..a4a737b212 100755 --- a/packages/eslint-config-airbnb/whitespace-async.js +++ b/packages/eslint-config-airbnb/whitespace-async.js @@ -6,9 +6,9 @@ const { ESLint } = require('eslint'); const baseConfig = require('.'); const whitespaceRules = require('./whitespaceRules'); -const severities = ['off', 'warn', 'error']; - function getSeverity(ruleConfig) { + const severities = ['off', 'warn', 'error']; + if (Array.isArray(ruleConfig)) { return getSeverity(ruleConfig[0]); } @@ -27,8 +27,7 @@ async function onlyErrorOnRules(rulesToError, config) { const baseRules = (await cli.calculateConfigForFile(require.resolve('./'))).rules; entries(baseRules).forEach((rule) => { - const ruleName = rule[0]; - const ruleConfig = rule[1]; + const [ruleName, ruleConfig] = rule; const severity = getSeverity(ruleConfig); if (rulesToError.indexOf(ruleName) === -1 && severity === 'error') { diff --git a/packages/eslint-config-airbnb/whitespace.js b/packages/eslint-config-airbnb/whitespace.js index f4b93bb492..fec4bce5e4 100644 --- a/packages/eslint-config-airbnb/whitespace.js +++ b/packages/eslint-config-airbnb/whitespace.js @@ -9,9 +9,9 @@ if (CLIEngine) { const baseConfig = require('.'); - const severities = ['off', 'warn', 'error']; - function getSeverity(ruleConfig) { + const severities = ['off', 'warn', 'error']; + if (Array.isArray(ruleConfig)) { return getSeverity(ruleConfig[0]); } @@ -27,8 +27,7 @@ if (CLIEngine) { const baseRules = cli.getConfigForFile(require.resolve('./')).rules; entries(baseRules).forEach((rule) => { - const ruleName = rule[0]; - const ruleConfig = rule[1]; + const [ruleName, ruleConfig] = rule; const severity = getSeverity(ruleConfig); if (rulesToError.indexOf(ruleName) === -1 && severity === 'error') { From 81e36bb64e3ea8d2e906f74c03cb4d9fa0c37ee6 Mon Sep 17 00:00:00 2001 From: Mustafa UZUN Date: Mon, 7 Aug 2023 14:21:20 +0300 Subject: [PATCH 3/3] Change severities array location --- packages/eslint-config-airbnb-base/whitespace-async.js | 4 ++-- packages/eslint-config-airbnb-base/whitespace.js | 4 ++-- packages/eslint-config-airbnb/whitespace-async.js | 4 ++-- packages/eslint-config-airbnb/whitespace.js | 4 ++-- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/packages/eslint-config-airbnb-base/whitespace-async.js b/packages/eslint-config-airbnb-base/whitespace-async.js index a4a737b212..0720d593c4 100755 --- a/packages/eslint-config-airbnb-base/whitespace-async.js +++ b/packages/eslint-config-airbnb-base/whitespace-async.js @@ -6,9 +6,9 @@ const { ESLint } = require('eslint'); const baseConfig = require('.'); const whitespaceRules = require('./whitespaceRules'); -function getSeverity(ruleConfig) { - const severities = ['off', 'warn', 'error']; +const severities = ['off', 'warn', 'error']; +function getSeverity(ruleConfig) { if (Array.isArray(ruleConfig)) { return getSeverity(ruleConfig[0]); } diff --git a/packages/eslint-config-airbnb-base/whitespace.js b/packages/eslint-config-airbnb-base/whitespace.js index fec4bce5e4..336d66b2b4 100644 --- a/packages/eslint-config-airbnb-base/whitespace.js +++ b/packages/eslint-config-airbnb-base/whitespace.js @@ -9,9 +9,9 @@ if (CLIEngine) { const baseConfig = require('.'); - function getSeverity(ruleConfig) { - const severities = ['off', 'warn', 'error']; + const severities = ['off', 'warn', 'error']; + function getSeverity(ruleConfig) { if (Array.isArray(ruleConfig)) { return getSeverity(ruleConfig[0]); } diff --git a/packages/eslint-config-airbnb/whitespace-async.js b/packages/eslint-config-airbnb/whitespace-async.js index a4a737b212..0720d593c4 100755 --- a/packages/eslint-config-airbnb/whitespace-async.js +++ b/packages/eslint-config-airbnb/whitespace-async.js @@ -6,9 +6,9 @@ const { ESLint } = require('eslint'); const baseConfig = require('.'); const whitespaceRules = require('./whitespaceRules'); -function getSeverity(ruleConfig) { - const severities = ['off', 'warn', 'error']; +const severities = ['off', 'warn', 'error']; +function getSeverity(ruleConfig) { if (Array.isArray(ruleConfig)) { return getSeverity(ruleConfig[0]); } diff --git a/packages/eslint-config-airbnb/whitespace.js b/packages/eslint-config-airbnb/whitespace.js index fec4bce5e4..336d66b2b4 100644 --- a/packages/eslint-config-airbnb/whitespace.js +++ b/packages/eslint-config-airbnb/whitespace.js @@ -9,9 +9,9 @@ if (CLIEngine) { const baseConfig = require('.'); - function getSeverity(ruleConfig) { - const severities = ['off', 'warn', 'error']; + const severities = ['off', 'warn', 'error']; + function getSeverity(ruleConfig) { if (Array.isArray(ruleConfig)) { return getSeverity(ruleConfig[0]); }