From 1a617cd8efc60fb83fc2205ec2290a1013c5a09e Mon Sep 17 00:00:00 2001 From: Robert Rossmann Date: Wed, 7 Feb 2024 15:50:41 +0100 Subject: [PATCH] =?UTF-8?q?feat:=20migrate=20deprecated=20rules=20to=20htt?= =?UTF-8?q?ps://eslint.style=20=F0=9F=9A=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .eslintrc.js | 5 - package-lock.json | 104 ++++++++++++++++ packages/eslint-config-base/index.js | 3 +- packages/eslint-config-base/package.json | 3 +- packages/eslint-config-base/style.js | 120 +++++++++---------- packages/eslint-config-react-native/index.js | 2 +- packages/eslint-config-react/index.js | 6 +- packages/eslint-config-react/style.js | 22 ++-- packages/eslint-config-typescript/index.js | 4 - packages/eslint-config-typescript/style.js | 65 +--------- 10 files changed, 185 insertions(+), 149 deletions(-) diff --git a/.eslintrc.js b/.eslintrc.js index 9b59dbe..403cc40 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -18,10 +18,5 @@ module.exports = { rules: { // If your editor cannot show these to you, occasionally turn this off and run the linter 'no-warning-comments': 0, - - // TODO: eslint-plugin-node does not correctly recognise `ecmaVersion: 2021` - 'node/no-unsupported-features/es-syntax': ['error', { - version: '>=20', - }], }, } diff --git a/package-lock.json b/package-lock.json index da8de58..3dececa 100644 --- a/package-lock.json +++ b/package-lock.json @@ -7211,6 +7211,109 @@ "resolved": "packages/textlint-rule-preset-strv", "link": true }, + "node_modules/@stylistic/eslint-plugin": { + "version": "1.6.0", + "resolved": "https://registry.npmjs.org/@stylistic/eslint-plugin/-/eslint-plugin-1.6.0.tgz", + "integrity": "sha512-Bdz9mFIvOkpM03QLoTSg7rTTYj+u3kokWIQ+nI5UFE+FkRQSVgvL41cwkdCebud/L4dMcItuBPA25h6XOuHFPA==", + "dependencies": { + "@stylistic/eslint-plugin-js": "1.6.0", + "@stylistic/eslint-plugin-jsx": "1.6.0", + "@stylistic/eslint-plugin-plus": "1.6.0", + "@stylistic/eslint-plugin-ts": "1.6.0" + }, + "engines": { + "node": "^16.0.0 || >=18.0.0" + }, + "peerDependencies": { + "eslint": ">=8.40.0" + } + }, + "node_modules/@stylistic/eslint-plugin-js": { + "version": "1.6.0", + "resolved": "https://registry.npmjs.org/@stylistic/eslint-plugin-js/-/eslint-plugin-js-1.6.0.tgz", + "integrity": "sha512-qlBAu08fy4d5BEF+c31E5y0OvEOVZo3SfOOs2Qrb4/CwAaXrAch++axBWedzgR3n0XqkuXjr6dbexqrdOm92ag==", + "dependencies": { + "acorn": "^8.11.3", + "escape-string-regexp": "^4.0.0", + "eslint-visitor-keys": "^3.4.3", + "espree": "^10.0.0" + }, + "engines": { + "node": "^16.0.0 || >=18.0.0" + }, + "peerDependencies": { + "eslint": ">=8.40.0" + } + }, + "node_modules/@stylistic/eslint-plugin-js/node_modules/espree": { + "version": "10.0.0", + "resolved": "https://registry.npmjs.org/espree/-/espree-10.0.0.tgz", + "integrity": "sha512-gdlKrfXQWv/3vubKqeQIiBUoWeknNQVEDpKD7OD3bC53g5EKISTuhcIoA1H1e+zqIuosdKrKuTDMmj8eFfhOnA==", + "dependencies": { + "acorn": "^8.11.3", + "acorn-jsx": "^5.3.2", + "eslint-visitor-keys": "^3.4.1" + }, + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + }, + "funding": { + "url": "https://opencollective.com/eslint" + } + }, + "node_modules/@stylistic/eslint-plugin-jsx": { + "version": "1.6.0", + "resolved": "https://registry.npmjs.org/@stylistic/eslint-plugin-jsx/-/eslint-plugin-jsx-1.6.0.tgz", + "integrity": "sha512-MlRpiuNpanQrszotBlar77GDf71HjemJNNQBvLnsk/MHxo6fxbIcAyLSNSVQJhP14ah6PvpPFcExRK4Hj7MGeg==", + "dependencies": { + "@stylistic/eslint-plugin-js": "^1.6.0", + "estraverse": "^5.3.0", + "picomatch": "^3.0.1" + }, + "engines": { + "node": "^16.0.0 || >=18.0.0" + }, + "peerDependencies": { + "eslint": ">=8.40.0" + } + }, + "node_modules/@stylistic/eslint-plugin-jsx/node_modules/picomatch": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-3.0.1.tgz", + "integrity": "sha512-I3EurrIQMlRc9IaAZnqRR044Phh2DXY+55o7uJ0V+hYZAcQYSuFWsc9q5PvyDHUSCe1Qxn/iBz+78s86zWnGag==", + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/jonschlinkert" + } + }, + "node_modules/@stylistic/eslint-plugin-plus": { + "version": "1.6.0", + "resolved": "https://registry.npmjs.org/@stylistic/eslint-plugin-plus/-/eslint-plugin-plus-1.6.0.tgz", + "integrity": "sha512-XfLBBkKIERzMYGEX1A5RCe/gVe9pTdGuHC2xDzlEIs2npudMHxm304K7l2CqlAWGyJ/yP6wwrsSEHozQUIo/Og==", + "dependencies": { + "@typescript-eslint/utils": "^6.20.0" + }, + "peerDependencies": { + "eslint": "*" + } + }, + "node_modules/@stylistic/eslint-plugin-ts": { + "version": "1.6.0", + "resolved": "https://registry.npmjs.org/@stylistic/eslint-plugin-ts/-/eslint-plugin-ts-1.6.0.tgz", + "integrity": "sha512-qM9Vw8TfZeGmN8oreWwUIdEdCs/py9/X88O4ksJv0V/kDmaupVKL8Uu06IlphN2crN6SPU8ljv9rcGXZoxwvmA==", + "dependencies": { + "@stylistic/eslint-plugin-js": "1.6.0", + "@typescript-eslint/utils": "^6.20.0" + }, + "engines": { + "node": "^16.0.0 || >=18.0.0" + }, + "peerDependencies": { + "eslint": ">=8.40.0" + } + }, "node_modules/@textlint/ast-node-types": { "version": "12.6.1", "resolved": "https://registry.npmjs.org/@textlint/ast-node-types/-/ast-node-types-12.6.1.tgz", @@ -28333,6 +28436,7 @@ "version": "3.5.0", "license": "BSD-3-Clause", "dependencies": { + "@stylistic/eslint-plugin": "^1.6.0", "eslint-plugin-import": "^2.27.0" }, "engines": { diff --git a/packages/eslint-config-base/index.js b/packages/eslint-config-base/index.js index 223dccb..92b9eb4 100644 --- a/packages/eslint-config-base/index.js +++ b/packages/eslint-config-base/index.js @@ -13,6 +13,7 @@ const globs = require('./globs') module.exports = { plugins: [ + '@stylistic', 'import', ], @@ -162,7 +163,7 @@ module.exports = { // JavaScript will more or less let you put semicolons after any statement without complaining. // Typos and misunderstandings about where semicolons are required can lead to extra semicolons // that are unnecessary. - 'no-extra-semi': 'error', + '@stylistic/no-extra-semi': 'error', // Disallow Function Assignment // JavaScript functions can be written as a FunctionDeclaration `function foo() { ... }` or as a diff --git a/packages/eslint-config-base/package.json b/packages/eslint-config-base/package.json index 4d28a2e..3b20f39 100644 --- a/packages/eslint-config-base/package.json +++ b/packages/eslint-config-base/package.json @@ -11,7 +11,8 @@ "Danny Kijkov " ], "dependencies": { - "eslint-plugin-import": "^2.27.0" + "eslint-plugin-import": "^2.27.0", + "@stylistic/eslint-plugin": "^1.6.0" }, "engines": { "node": ">=20" diff --git a/packages/eslint-config-base/style.js b/packages/eslint-config-base/style.js index d26dfa4..01e8912 100644 --- a/packages/eslint-config-base/style.js +++ b/packages/eslint-config-base/style.js @@ -20,16 +20,16 @@ module.exports = { // enforce line breaks after opening and before closing array brackets // Requires consistent usage of linebreaks for each pair of brackets. It reports an error if one // bracket in the pair has a linebreak inside it and the other bracket does not. - 'array-bracket-newline': ['warn', 'consistent'], + '@stylistic/array-bracket-newline': ['warn', 'consistent'], // Disallow or enforce spaces inside of brackets // Disallow - 'array-bracket-spacing': ['warn', 'never'], + '@stylistic/array-bracket-spacing': ['warn', 'never'], // enforce line breaks between array elements // A number of style guides require or disallow line breaks between array elements. This ruleset // requires consistent usage of linebreaks between array elements. - 'array-element-newline': ['warn', 'consistent'], + '@stylistic/array-element-newline': ['warn', 'consistent'], // Require braces in arrow function body // This rule can enforce the use of braces around arrow function body. @@ -39,23 +39,23 @@ module.exports = { // Arrow functions can omit parentheses when they have exactly one parameter. Since their main // strength lies in being short and concise, parens around arguments should be omitted when they // are not needed. - 'arrow-parens': ['warn', 'as-needed'], + '@stylistic/arrow-parens': ['warn', 'as-needed'], // Require space before/after arrow function's arrow - 'arrow-spacing': ['warn', { + '@stylistic/arrow-spacing': ['warn', { before: true, after: true, }], // Disallow or enforce spaces inside of single line blocks // Enforce - 'block-spacing': ['warn', 'always'], + '@stylistic/block-spacing': ['warn', 'always'], // Require Brace Style // The one true brace style is one of the most common brace styles in JavaScript, in which the // opening curly brace of a block is placed on the same line as its corresponding statement or // declaration. - 'brace-style': ['warn', '1tbs', { + '@stylistic/brace-style': ['warn', '1tbs', { allowSingleLine: true, }], @@ -68,12 +68,12 @@ module.exports = { // This rule enforces consistent use of trailing commas in object and array literals // Allow trailing commas for func parameters, array and object literals spread across // multiple lines - 'comma-dangle': ['warn', 'always-multiline'], + '@stylistic/comma-dangle': ['warn', 'always-multiline'], // Enforces spacing around commas // This rule aims to enforce spacing around a comma. // A space must be only after comma, i.e. `var a, b` - 'comma-spacing': ['warn', { + '@stylistic/comma-spacing': ['warn', { before: false, after: true, }], @@ -81,12 +81,12 @@ module.exports = { // Comma style // This rule is aimed at enforcing a particular comma style in JavaScript. // Commas should be placed at the end of line, not at the beginning - 'comma-style': ['warn', 'last'], + '@stylistic/comma-style': ['warn', 'last'], // Disallow or enforce spaces inside of computed properties // This rule aims to maintain consistency around the spacing inside of computed properties. // No spaces allowed - 'computed-property-spacing': ['warn', 'never'], + '@stylistic/computed-property-spacing': ['warn', 'never'], // Require Consistent This // This rule designates a variable as the chosen alias for `this`. @@ -109,7 +109,7 @@ module.exports = { // This rule aims to enforce newline consistency in member expressions. This rule prevents the // use of mixed newlines around the dot in a member expression. // Require the dot to be placed together with the property identifier - 'dot-location': ['warn', 'property'], + '@stylistic/dot-location': ['warn', 'property'], // Require Dot Notation // This rule is aimed at maintaining code consistency and improving code readability by @@ -119,17 +119,17 @@ module.exports = { // Require file to end with single newline // Benefits of trailing newlines include the ability to concatenate or append to files as well // as output files to the terminal without interfering with shell prompts. - 'eol-last': ['warn', 'unix'], + '@stylistic/eol-last': ['warn', 'unix'], // Enforce consistent line breaks inside function parentheses // Requires linebreaks inside function parentheses if any of the parameters/arguments have a // line break between them. Otherwise, it disallows linebreaks. - 'function-paren-newline': ['warn', 'multiline'], + '@stylistic/function-paren-newline': ['warn', 'multiline'], // Require or disallow spacing between function identifiers and their invocations // This rule disallows spaces between the function name and the opening parenthesis that calls // it. - 'func-call-spacing': 'warn', + '@stylistic/func-call-spacing': 'warn', // Enforce Function Style // Due to these different behaviors, it is common to have guidelines as to which style of @@ -149,7 +149,7 @@ module.exports = { // is that a generator function is a special type of function, therefore it should come together // with the `function` keyword. In contrast, it has nothing to do with the function's name, // which may be missing completely. - 'generator-star-spacing': ['warn', { + '@stylistic/generator-star-spacing': ['warn', { before: false, after: true, // For class/object methods, the * should come together with the name @@ -180,34 +180,34 @@ module.exports = { // Validate Indentation // This rule is aimed to enforce consistent indentation style. - indent: ['warn', 2, { + '@stylistic/indent': ['warn', 2, { SwitchCase: 1, }], // Enforce Property Spacing // This rule will warn when spacing in properties does not match the specified options. In the // case of long lines, it is acceptable to add a new line wherever whitespace is allowed. - 'key-spacing': ['warn', { + '@stylistic/key-spacing': ['warn', { beforeColon: false, afterColon: true, mode: 'strict', }], // This rule will enforce consistency of spacing around keywords and keyword-like tokens - 'keyword-spacing': ['warn', { + '@stylistic/keyword-spacing': ['warn', { before: true, after: true, }], // Disallow mixing CRLF and LF linebreaks // This rule aims to ensure having consistent line endings independent of operating system. - 'linebreak-style': ['error', 'unix'], + '@stylistic/linebreak-style': ['error', 'unix'], // Require an empty line between class members // This rule improves readability by enforcing lines between class members. It will not check // empty lines before the first member and after the last member, since that is already taken // care of by padded-blocks. - 'lines-between-class-members': ['warn', 'always', { + '@stylistic/lines-between-class-members': ['warn', 'always', { exceptAfterSingleLine: true, }], @@ -215,7 +215,7 @@ module.exports = { // Very long lines of code in any language can be difficult to read. In order to aid in // readability and maintainability many coders have developed a convention to limit lines of // code to a certain number of characters. - 'max-len': ['warn', + '@stylistic/max-len': ['warn', { code: 120, ignoreTrailingComments: true, ignoreUrls: true, ignorePattern: '^import\\W.*' }], // Limit Maximum Number of Parameters @@ -232,7 +232,7 @@ module.exports = { // A line of code containing too many statements can be difficult to read. Code is generally // read from the top down, especially when scanning, so limiting the number of statements // allowed on a single line can be very beneficial for readability and maintainability. - 'max-statements-per-line': 'warn', + '@stylistic/max-statements-per-line': 'warn', // Enforce a particular style for multiline comments // Prefer consecutive line comments for multiline comment block @@ -241,12 +241,12 @@ module.exports = { // Enforce newlines between operands of ternary expressions // Enforce either the whole ternary on a single line or each part of the ternary on its own line // if the expression contains a newline - 'multiline-ternary': ['warn', 'always-multiline'], + '@stylistic/multiline-ternary': ['warn', 'always-multiline'], // Newline Per Chained Method Call // This rule checks and reports the chained calls if there are no new lines after each call or // deep member access. - 'newline-per-chained-call': ['warn', { + '@stylistic/newline-per-chained-call': ['warn', { ignoreChainWithDepth: 3, }], @@ -263,13 +263,13 @@ module.exports = { // Require Parens for Constructors // This rule is aimed at highlighting a lack of convention and increasing code clarity by // requiring the use of parentheses when invoking a constructor via the new keyword. - 'new-parens': 'warn', + '@stylistic/new-parens': 'warn', // Enforce the location of single-line statements // When writing if, else, while, do-while, and for statements, the body can be a single // statement instead of a block. It can be useful to enforce a consistent location for these // single statements. - 'nonblock-statement-body-position': ['warn', 'below', { + '@stylistic/nonblock-statement-body-position': ['warn', 'below', { overrides: { if: 'beside', else: 'beside', @@ -289,7 +289,7 @@ module.exports = { // Disallow unnecessary parentheses // This rule restricts the use of parentheses to only where they are necessary. // developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Operator_Precedence - 'no-extra-parens': ['warn', 'all', { + '@stylistic/no-extra-parens': ['warn', 'all', { nestedBinaryExpressions: false, returnAssign: false, ignoreJSX: 'multi-line', @@ -300,7 +300,7 @@ module.exports = { // decimal point be preceded or followed by a number. Although not a syntax error, this format // for numbers can make it difficult to distinguish between true decimal numbers and the dot // operator. - 'no-floating-decimal': 'warn', + '@stylistic/no-floating-decimal': 'warn', // Disallow the type conversion with shorter notations // This rule is aimed to flag shorter notations for the type conversion, then suggest a more @@ -319,12 +319,12 @@ module.exports = { // Enclosing complex expressions by parentheses clarifies the developer’s intention, which makes // the code more readable. This rule warns when different operators are used consecutively // without parentheses in an expression. - 'no-mixed-operators': 'warn', + '@stylistic/no-mixed-operators': 'warn', // Disallow mixed spaces and tabs for indentation // The no-mixed-spaces-and-tabs rule is aimed at flagging any lines of code that are indented // with a mixture of tabs and spaces. - 'no-mixed-spaces-and-tabs': 'warn', + '@stylistic/no-mixed-spaces-and-tabs': 'warn', // Disallow Use of Chained Assignment Expressions // This rule disallows using multiple assignments within a single statement. @@ -333,7 +333,7 @@ module.exports = { // Disallows multiple blank lines // Whitespace is useful for separating logical sections of code, but excess whitespace takes up // more of the screen. - 'no-multiple-empty-lines': ['warn', { + '@stylistic/no-multiple-empty-lines': ['warn', { max: 2, maxEOF: 0, maxBOF: 0, @@ -343,13 +343,13 @@ module.exports = { // This rule aims to disallow multiple whitespace around logical expressions, conditional // expressions, declarations, array elements, object properties, sequences and function // parameters. - 'no-multi-spaces': 'warn', + '@stylistic/no-multi-spaces': 'warn', // Disallow tabs // Use of tabs is discouraged in favour of spaces because there is no "standard" width for a tab // character and many viewers/editors use their own tab width, which could cause code to be // misaligned and not formatted as intended/indented. - 'no-tabs': 'warn', + '@stylistic/no-tabs': 'warn', // Disallow Nested Ternaries // The no-nested-ternary rule aims to increase the clarity and readability of code by @@ -361,7 +361,7 @@ module.exports = { // lines. These whitespace differences can be picked up by source control systems and flagged as // diffs, causing frustration for developers. While this extra whitespace causes no functional // issues, many code conventions require that trailing spaces be removed before checkin. - 'no-trailing-spaces': 'warn', + '@stylistic/no-trailing-spaces': 'warn', // Disallow Dangling Underscores in Identifiers 'no-underscore-dangle': 'warn', @@ -388,22 +388,22 @@ module.exports = { // This rule alerts for whitespace around the dot or brackets before properties of objects if // they are on the same line. It does not alert for whitespace when the object and property are // on separate lines. - 'no-whitespace-before-property': 'warn', + '@stylistic/no-whitespace-before-property': 'warn', // Enforce consistent line breaks inside braces - 'object-curly-newline': ['warn', { + '@stylistic/object-curly-newline': ['warn', { consistent: true, }], // Enforce spaces inside of curly braces in objects // This rule aims to maintain consistency around the spacing inside of object literals. It also // applies to EcmaScript 6 destructured assignment and import/export specifiers. - 'object-curly-spacing': ['warn', 'always'], + '@stylistic/object-curly-spacing': ['warn', 'always'], // Enforce placing object properties on separate lines // This rule makes it possible to ensure, as some style guides require, that property // specifications appear on separate lines or on the same line for better readability. - 'object-property-newline': ['warn', { + '@stylistic/object-property-newline': ['warn', { allowAllPropertiesOnSameLine: true, }], @@ -425,7 +425,7 @@ module.exports = { // This rule enforces a consistent coding style where newlines are required after each var // declaration or just when there is a variable initialization. It ignores var declarations // inside for loop conditionals. - 'one-var-declaration-per-line': 'warn', + '@stylistic/one-var-declaration-per-line': 'warn', // Operator Assignment Shorthand // This rule enforces use of the shorthand assignment operators by requiring them where @@ -436,16 +436,16 @@ module.exports = { // When a statement is too long to fit on a single line, line breaks are generally inserted next // to the operators separating expressions. This rule is aimed at enforcing a particular // operator line break style. - 'operator-linebreak': ['warn', 'before'], + '@stylistic/operator-linebreak': ['warn', 'before'], // Enforce padding within blocks // This rule enforces consistent padding within blocks. - 'padded-blocks': ['warn', 'never'], + '@stylistic/padded-blocks': ['warn', 'never'], // Require or disallow padding lines between statements // This rule requires or disallows blank lines between the given 2 kinds of statements. Properly // blank lines help developers to understand the code. - 'padding-line-between-statements': [ + '@stylistic/padding-line-between-statements': [ 'warn', { blankLine: 'always', next: '*', prev: ['cjs-import', 'directive'] }, { blankLine: 'always', prev: '*', next: ['cjs-export', 'class', 'export', 'function'] }, @@ -491,19 +491,19 @@ module.exports = { // Quoting Style for Property Names // This rule aims to enforce use of quotes in property names. // Require quotes where necessary, disallow where unnecessary - 'quote-props': ['warn', 'as-needed'], + '@stylistic/quote-props': ['warn', 'as-needed'], // Enforce Quote Style // This rule is aimed at ensuring consistency of string quotes. - quotes: ['warn', 'single', 'avoid-escape'], + '@stylistic/quotes': ['warn', 'single', 'avoid-escape'], // Enforce spacing between rest and spread operators and their expressions // This rule aims to enforce consistent spacing between rest and spread operators and their // expressions. - 'rest-spread-spacing': ['warn', 'never'], + '@stylistic/rest-spread-spacing': ['warn', 'never'], // Enforce spacing before and after semicolons - 'semi-spacing': ['warn', { + '@stylistic/semi-spacing': ['warn', { before: false, after: true, }], @@ -512,18 +512,18 @@ module.exports = { // Generally, semicolons are at the end of lines. However, in semicolon-less style, semicolons // are at the beginning of lines. This rule enforces that semicolons are at the configured // location. - 'semi-style': ['warn', 'first'], + '@stylistic/semi-style': ['warn', 'first'], // Enforce or Disallow Semicolons // This rule is aimed at ensuring consistent use of semicolons. - semi: ['warn', 'never'], + '@stylistic/semi': ['warn', 'never'], // Require Or Disallow Space Before Blocks // This rule will enforce consistency of spacing before blocks. - 'space-before-blocks': ['warn', 'always'], + '@stylistic/space-before-blocks': ['warn', 'always'], // Require or disallow a space before function parenthesis - 'space-before-function-paren': ['warn', { + '@stylistic/space-before-function-paren': ['warn', { anonymous: 'never', named: 'never', asyncArrow: 'always', @@ -533,23 +533,23 @@ module.exports = { // This rule will enforce consistency of spacing directly inside of parentheses, by disallowing // or requiring one or more spaces to the right of ( and to the left of ). In either case, () // will still be allowed. - 'space-in-parens': ['warn', 'never'], + '@stylistic/space-in-parens': ['warn', 'never'], // Require Spaces Around Infix Operators // This rule is aimed at ensuring there are spaces around infix operators. - 'space-infix-ops': 'warn', + '@stylistic/space-infix-ops': 'warn', // Require or disallow spaces before/after unary operators // This rule enforces consistency regarding the spaces after words unary operators and // after/before nonwords unary operators. - 'space-unary-ops': ['warn', { + '@stylistic/space-unary-ops': ['warn', { words: true, nonwords: false, }], // Require or disallow a whitespace beginning a comment // This rule will enforce consistency of spacing after the start of a comment // or /*. - 'spaced-comment': ['warn', 'always', { + '@stylistic/spaced-comment': ['warn', 'always', { // Allow TypeScript's `/// ` stanzas markers: ['/'], }], @@ -557,22 +557,22 @@ module.exports = { // Enforce spacing around colons of switch statements // This rule controls spacing around colons of case and default clauses in switch statements. // Spacing around colons improves readability of case/default clauses. - 'switch-colon-spacing': 'warn', + '@stylistic/switch-colon-spacing': 'warn', // Enforce Usage of Spacing in Template Strings // This rule aims to maintain consistency around the spacing inside of template literals. - 'template-curly-spacing': 'warn', + '@stylistic/template-curly-spacing': 'warn', // Require or disallow spacing between template tags and their literals // This rule aims to maintain consistency around the spacing between template tag functions and // their template literals. - 'template-tag-spacing': ['warn', 'never'], + '@stylistic/template-tag-spacing': ['warn', 'never'], // Require IIFEs to be Wrapped - 'wrap-iife': ['warn', 'inside'], + '@stylistic/wrap-iife': ['warn', 'inside'], // Enforce spacing around the * in `yield*` expressions - 'yield-star-spacing': ['warn', 'after'], + '@stylistic/yield-star-spacing': ['warn', 'after'], // Require or disallow Yoda Conditions // Yoda conditions are so named because the literal value of the condition comes first while the diff --git a/packages/eslint-config-react-native/index.js b/packages/eslint-config-react-native/index.js index b4a6507..5acf6ae 100644 --- a/packages/eslint-config-react-native/index.js +++ b/packages/eslint-config-react-native/index.js @@ -22,7 +22,7 @@ module.exports = { 'react-hooks/exhaustive-deps': 'warn', // overrides the base config, creates issues with import rules setup in the Expo universe config - 'padding-line-between-statements': 'off', + '@stylistic/padding-line-between-statements': 'off', // overrides base config, adds exceptions to the id-length rule from base config // coordinates are often used in React Native and it is not a good idea to rename them diff --git a/packages/eslint-config-react/index.js b/packages/eslint-config-react/index.js index a19cc6b..60d45be 100644 --- a/packages/eslint-config-react/index.js +++ b/packages/eslint-config-react/index.js @@ -223,7 +223,7 @@ module.exports = { // Enforce or disallow spaces inside of curly braces in JSX attributes and expressions. // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-child-element-spacing.md - 'react/jsx-child-element-spacing': 'error', + '@stylistic/jsx-child-element-spacing': 'error', // Restrict file extensions that may contain JSX // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-filename-extension.md @@ -279,7 +279,7 @@ module.exports = { // This rule allows you to 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 - 'react/jsx-curly-brace-presence': ['warn', 'never'], + '@stylistic/jsx-curly-brace-presence': ['warn', 'never'], // Enforce shorthand or standard form for React fragments // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-fragments.md 'react/jsx-fragments': 'warn', @@ -292,7 +292,7 @@ module.exports = { // Enforces coding style that user-defined JSX components are defined andreferenced in // PascalCase // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-pascal-case.md - 'react/jsx-pascal-case': [ + '@stylistic/jsx-pascal-case': [ 'error', { allowAllCaps: true, diff --git a/packages/eslint-config-react/style.js b/packages/eslint-config-react/style.js index a3cf575..bf3f4c1 100644 --- a/packages/eslint-config-react/style.js +++ b/packages/eslint-config-react/style.js @@ -25,18 +25,18 @@ module.exports = { ], // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-closing-tag-location.md - 'react/jsx-closing-tag-location': 'warn', + '@stylistic/jsx-closing-tag-location': 'warn', // Validate closing bracket location in JSX // This rule checks all JSX multiline elements and verifies the location of the closing bracket. - 'react/jsx-closing-bracket-location': ['warn', 'line-aligned'], + '@stylistic/jsx-closing-bracket-location': ['warn', 'line-aligned'], // Disallow unnecessary curly braces in JSX props and/or children - 'react/jsx-curly-brace-presence': ['warn', 'never'], + '@stylistic/jsx-curly-brace-presence': ['warn', 'never'], // Disallow spaces inside of curly braces in JSX attributes - 'react/jsx-curly-spacing': [ + '@stylistic/jsx-curly-spacing': [ 'warn', { when: 'never', @@ -47,16 +47,16 @@ module.exports = { // Enforce or disallow spaces around equal signs in JSX attributes // This rule will enforce consistency of spacing around equal signs in JSX attributes, by // requiring or one or more spaces before and after =. - 'react/jsx-equals-spacing': ['warn', 'never'], + '@stylistic/jsx-equals-spacing': ['warn', 'never'], // Configure the position of the first property - 'react/jsx-first-prop-new-line': ['warn', 'multiline'], + '@stylistic/jsx-first-prop-new-line': ['warn', 'multiline'], // Validate JSX indentation - 'react/jsx-indent': ['warn', 2], + '@stylistic/jsx-indent': ['warn', 2], // Validate props indentation in JSX - 'react/jsx-indent-props': ['warn', 2], + '@stylistic/jsx-indent-props': ['warn', 2], // Validate JSX maximum depth 'react/jsx-max-depth': [ @@ -69,7 +69,7 @@ module.exports = { // Enforce PascalCase for user-defined JSX components // Enforces coding style that user-defined JSX components are defined and referenced in // PascalCase. - 'react/jsx-pascal-case': [ + '@stylistic/jsx-pascal-case': [ 'warn', { allowAllCaps: true, @@ -80,11 +80,11 @@ module.exports = { // Disallow multiple spaces between inline JSX props // Enforces that there is exactly one space between all attributes and after tag name and the // first attribute in the same line. - 'react/jsx-props-no-multi-spaces': 'warn', + '@stylistic/jsx-props-no-multi-spaces': 'warn', // Validate whitespace in and around the JSX opening and closing brackets // This rule checks the whitespace inside and surrounding the JSX syntactic elements. - 'react/jsx-tag-spacing': 'warn', + '@stylistic/jsx-tag-spacing': 'warn', // Prevent extra closing tags for components without children 'react/self-closing-comp': 'warn', diff --git a/packages/eslint-config-typescript/index.js b/packages/eslint-config-typescript/index.js index 25cdb9a..8f130ed 100644 --- a/packages/eslint-config-typescript/index.js +++ b/packages/eslint-config-typescript/index.js @@ -157,10 +157,6 @@ module.exports = { // the type can be easily inferred from its value. '@typescript-eslint/no-explicit-any': 'error', - // Disallow unnecessary semicolons - '@typescript-eslint/no-extra-semi': base.rules['no-extra-semi'], - 'no-extra-semi': 'off', - // Forbids the use of classes as namespaces // This rule warns when a class is accidentally used as a namespace. '@typescript-eslint/no-extraneous-class': ['warn', { diff --git a/packages/eslint-config-typescript/style.js b/packages/eslint-config-typescript/style.js index 1848dfa..4b92fe4 100644 --- a/packages/eslint-config-typescript/style.js +++ b/packages/eslint-config-typescript/style.js @@ -18,17 +18,6 @@ module.exports = { // Conflicts with typescript camelcase: 'off', - // Enforce consistent brace style for blocks - '@typescript-eslint/brace-style': style.rules['brace-style'], - 'brace-style': 'off', - - '@typescript-eslint/comma-dangle': style.rules['comma-dangle'], - 'comma-dangle': 'off', - - // Enforces consistent spacing before and after commas - '@typescript-eslint/comma-spacing': style.rules['comma-spacing'], - 'comma-spacing': 'off', - // Enforces consistent usage of type assertions // This rule aims to standardise the use of type assertion style across the codebase. '@typescript-eslint/consistent-type-assertions': ['warn', { @@ -49,28 +38,9 @@ module.exports = { '@typescript-eslint/dot-notation': style.rules['dot-notation'], 'dot-notation': 'off', - // Require or disallow spacing between function identifiers and their invocations - // This rule extends the base eslint/func-call-spacing rule. It supports all options and - // features of the base rule. This version adds support for generic type parameters on function - // calls. - '@typescript-eslint/func-call-spacing': style.rules['func-call-spacing'], - 'func-call-spacing': 'off', - - // Enforce consistent indentation - '@typescript-eslint/indent': style.rules.indent, - indent: 'off', - - // This rule will enforce consistency of spacing around keywords and keyword-like tokens - '@typescript-eslint/keyword-spacing': style.rules['keyword-spacing'], - 'keyword-spacing': 'off', - - // Require an empty line between class members - '@typescript-eslint/lines-between-class-members': style.rules['lines-between-class-members'], - 'lines-between-class-members': 'off', - // Require a specific member delimiter style for interfaces and type literals // This rule aims to standardise the way interface and type literal members are delimited. - '@typescript-eslint/member-delimiter-style': ['warn', { + '@stylistic/member-delimiter-style': ['warn', { multiline: { delimiter: 'none', }, @@ -100,10 +70,6 @@ module.exports = { // Reports if a resolved path is imported more than once 'import/no-duplicates': 'warn', - // disallow unnecessary parentheses - '@typescript-eslint/no-extra-parens': style.rules['no-extra-parens'], - 'no-extra-parens': 'off', - // Disallow extra non-null assertion '@typescript-eslint/no-extra-non-null-assertion': 'warn', @@ -123,10 +89,6 @@ module.exports = { // Prefers a non-null assertion over explicit type cast when possible '@typescript-eslint/non-nullable-type-assertion-style': 'warn', - // Enforce consistent spacing inside braces - '@typescript-eslint/object-curly-spacing': style.rules['object-curly-spacing'], - 'object-curly-spacing': 'off', - // Prefer usage of `as const` over literal type // This rule recommends usage of `const` assertion when type primitive value is equal to type. '@typescript-eslint/prefer-as-const': 'warn', @@ -159,33 +121,10 @@ module.exports = { '@typescript-eslint/prefer-ts-expect-error': 'warn', - // Enforce the consistent use of either backticks, double, or single quotes - // This rule extends the base eslint/quotes rule. It supports all options and features of the - // base rule. - '@typescript-eslint/quotes': style.rules.quotes, - quotes: 'off', - - // Enforce or Disallow Semicolons - // This rule is aimed at ensuring consistent use of semicolons. - '@typescript-eslint/semi': style.rules.semi, - semi: 'off', - - // Enforces consistent spacing before blocks - '@typescript-eslint/space-before-blocks': 'warn', - 'space-before-blocks': 'off', - - // Require or disallow a space before function parenthesis - '@typescript-eslint/space-before-function-paren': style.rules['space-before-function-paren'], - 'space-before-function-paren': 'off', - - // This rule is aimed at ensuring there are spaces around infix operators - '@typescript-eslint/space-infix-ops': style.rules['space-infix-ops'], - 'space-infix-ops': 'off', - // Require consistent spacing around type annotations // This rule aims to enforce specific spacing patterns around type annotations and function // types in type literals. - '@typescript-eslint/type-annotation-spacing': 'warn', + '@stylistic/type-annotation-spacing': 'warn', // Warns for any two overloads that could be unified into one // Warns for any two overloads that could be unified into one by using a union or an