diff --git a/core/deprecated.js b/core/deprecated.js deleted file mode 100644 index 5c6b8e2..0000000 --- a/core/deprecated.js +++ /dev/null @@ -1,25 +0,0 @@ -module.exports = { - 'callback-return': 'off', - 'global-require': 'off', - 'handle-callback-err': 'off', - 'id-blacklist': 'off', - 'indent-legacy': 'off', - 'lines-around-directive': 'off', - 'newline-after-var': 'off', - 'newline-before-return': 'off', - 'no-buffer-constructor': 'off', - 'no-catch-shadow': 'off', - 'no-mixed-requires': 'off', - 'no-native-reassign': 'off', - 'no-negated-in-lhs': 'off', - 'no-new-require': 'off', - 'no-path-concat': 'off', - 'no-process-env': 'off', - 'no-process-exit': 'off', - 'no-restricted-modules': 'off', - 'no-spaced-func': 'off', - 'no-sync': 'off', - 'prefer-reflect': 'off', - 'require-jsdoc': 'off', - 'valid-jsdoc': 'off' -} diff --git a/core/layout.js b/core/layout.js deleted file mode 100644 index 0f5ad13..0000000 --- a/core/layout.js +++ /dev/null @@ -1,88 +0,0 @@ -const prettier = require('../utils/prettier.js') - -module.exports = { - 'array-bracket-newline': 'off', - 'array-bracket-spacing': 'off', - 'array-element-newline': 'off', - 'arrow-parens': 'off', - 'arrow-spacing': 'off', - 'block-spacing': 'off', - 'brace-style': 'off', - 'comma-dangle': 'off', - 'comma-spacing': 'off', - 'comma-style': 'off', - 'computed-property-spacing': 'off', - 'dot-location': 'off', - 'eol-last': 'off', - 'func-call-spacing': 'off', - 'function-call-argument-newline': 'off', - 'function-paren-newline': 'off', - 'generator-star-spacing': 'off', - 'implicit-arrow-linebreak': 'off', - indent: 'off', - 'jsx-quotes': 'off', - 'key-spacing': 'off', - 'keyword-spacing': 'off', - 'line-comment-position': 'error', - 'linebreak-style': 'off', - 'lines-around-comment': [ - 'error', - { - allowBlockStart: true, - allowObjectStart: true, - allowArrayStart: true, - allowClassStart: true - } - ], - 'lines-between-class-members': 'error', - 'max-len': [ - 'error', - { - code: prettier.js.printWidth, - ignorePattern: /^(?!\s+(\/\/|\*))|eslint-disable/.source, - ignoreUrls: true, - ignoreRegExpLiterals: true, - ignoreStrings: true, - ignoreTemplateLiterals: true - } - ], - 'max-statements-per-line': 'off', - 'multiline-ternary': 'off', - 'new-parens': 'off', - 'newline-per-chained-call': 'off', - 'no-extra-parens': 'off', - 'no-mixed-spaces-and-tabs': 'off', - 'no-multi-spaces': 'off', - 'no-multiple-empty-lines': 'off', - 'no-tabs': ['error', { allowIndentationTabs: true }], - 'no-trailing-spaces': 'off', - 'no-whitespace-before-property': 'off', - 'nonblock-statement-body-position': 'off', - 'object-curly-newline': 'off', - 'object-curly-spacing': 'off', - 'object-property-newline': 'off', - 'operator-linebreak': 'off', - 'padded-blocks': 'off', - 'padding-line-between-statements': 'off', - quotes: [ - 'error', - prettier.js.singleQuote ? 'single' : 'double', - { avoidEscape: true, allowTemplateLiterals: false } - ], - 'rest-spread-spacing': 'off', - semi: 'off', - 'semi-spacing': 'off', - 'semi-style': 'off', - 'space-before-blocks': 'off', - 'space-before-function-paren': 'off', - 'space-in-parens': 'off', - 'space-infix-ops': 'off', - 'space-unary-ops': 'off', - 'switch-colon-spacing': 'off', - 'template-curly-spacing': 'off', - 'template-tag-spacing': 'off', - 'unicode-bom': 'off', - 'wrap-iife': 'off', - 'wrap-regex': 'off', - 'yield-star-spacing': 'off' -} diff --git a/core/problem.js b/core/problem.js deleted file mode 100644 index 27dd1b7..0000000 --- a/core/problem.js +++ /dev/null @@ -1,60 +0,0 @@ -module.exports = { - 'array-callback-return': ['error', { allowImplicit: true }], - 'constructor-super': 'error', - 'for-direction': 'error', - 'getter-return': 'error', - 'no-async-promise-executor': 'error', - 'no-await-in-loop': 'off', - 'no-class-assign': 'error', - 'no-compare-neg-zero': 'error', - 'no-cond-assign': 'error', - 'no-const-assign': 'error', - 'no-constant-binary-expression': 'error', - 'no-constant-condition': 'error', - 'no-constructor-return': 'error', - 'no-control-regex': 'error', - 'no-debugger': 'error', - 'no-dupe-args': 'error', - 'no-dupe-class-members': 'error', - 'no-dupe-else-if': 'error', - 'no-dupe-keys': 'error', - 'no-duplicate-case': 'error', - 'no-duplicate-imports': ['error', { includeExports: true }], - 'no-empty-character-class': 'error', - 'no-empty-pattern': 'error', - 'no-ex-assign': 'error', - 'no-fallthrough': 'error', - 'no-func-assign': 'error', - 'no-import-assign': 'error', - 'no-inner-declarations': 'error', - 'no-invalid-regexp': 'error', - 'no-irregular-whitespace': ['error', { skipStrings: false }], - 'no-loss-of-precision': 'error', - 'no-misleading-character-class': 'error', - 'no-new-native-nonconstructor': 'error', - 'no-new-symbol': 'error', - 'no-obj-calls': 'error', - 'no-promise-executor-return': 'error', - 'no-prototype-builtins': 'error', - 'no-self-assign': 'error', - 'no-self-compare': 'error', - 'no-setter-return': 'error', - 'no-sparse-arrays': 'off', - 'no-template-curly-in-string': 'off', - 'no-this-before-super': 'error', - 'no-undef': 'error', - 'no-unexpected-multiline': 'off', - 'no-unmodified-loop-condition': 'off', - 'no-unreachable': 'error', - 'no-unreachable-loop': 'error', - 'no-unsafe-finally': 'error', - 'no-unsafe-negation': 'error', - 'no-unsafe-optional-chaining': 'error', - 'no-unused-private-class-members': 'error', - 'no-unused-vars': ['error', { ignoreRestSiblings: true }], - 'no-use-before-define': 'error', - 'no-useless-backreference': 'error', - 'require-atomic-updates': 'off', - 'use-isnan': ['error', { enforceForIndexOf: true }], - 'valid-typeof': 'error' -} diff --git a/index.js b/index.js index 603d3ea..fe05177 100644 --- a/index.js +++ b/index.js @@ -1,3 +1,4 @@ +const rules = require('./plugins/core') const getIgnorePatterns = require('./utils/getIgnorePatterns.js') /** @@ -20,7 +21,9 @@ module.exports = { sourceType: 'module' }, plugins: [], - rules: {}, + rules: { + ...rules + }, settings: {}, overrides: [ /** @@ -139,11 +142,6 @@ module.exports = { ] } -for (const name of ['deprecated', 'layout', 'problem', 'suggestion']) { - const rules = require(`./core/${name}`) - Object.assign(module.exports.rules, rules) -} - for (const name of [ 'eslint-comments', 'import', diff --git a/core/suggestion.js b/plugins/core.js similarity index 56% rename from core/suggestion.js rename to plugins/core.js index fcda599..4db85eb 100644 --- a/core/suggestion.js +++ b/plugins/core.js @@ -1,6 +1,7 @@ const confusingBrowserGlobals = require('confusing-browser-globals') const allowedProperties = require('../utils/allowedProperties.js') +const prettier = require('../utils/prettier.js') module.exports = { 'accessor-pairs': 'error', @@ -198,5 +199,166 @@ module.exports = { strict: 'error', 'symbol-description': 'error', 'vars-on-top': 'off', - yoda: 'error' + yoda: 'error', + 'array-callback-return': ['error', { allowImplicit: true }], + 'constructor-super': 'error', + 'for-direction': 'error', + 'getter-return': 'error', + 'no-async-promise-executor': 'error', + 'no-await-in-loop': 'off', + 'no-class-assign': 'error', + 'no-compare-neg-zero': 'error', + 'no-cond-assign': 'error', + 'no-const-assign': 'error', + 'no-constant-binary-expression': 'error', + 'no-constant-condition': 'error', + 'no-constructor-return': 'error', + 'no-control-regex': 'error', + 'no-debugger': 'error', + 'no-dupe-args': 'error', + 'no-dupe-class-members': 'error', + 'no-dupe-else-if': 'error', + 'no-dupe-keys': 'error', + 'no-duplicate-case': 'error', + 'no-duplicate-imports': ['error', { includeExports: true }], + 'no-empty-character-class': 'error', + 'no-empty-pattern': 'error', + 'no-ex-assign': 'error', + 'no-fallthrough': 'error', + 'no-func-assign': 'error', + 'no-import-assign': 'error', + 'no-inner-declarations': 'error', + 'no-invalid-regexp': 'error', + 'no-irregular-whitespace': ['error', { skipStrings: false }], + 'no-loss-of-precision': 'error', + 'no-misleading-character-class': 'error', + 'no-new-native-nonconstructor': 'error', + 'no-new-symbol': 'error', + 'no-obj-calls': 'error', + 'no-promise-executor-return': 'error', + 'no-prototype-builtins': 'error', + 'no-self-assign': 'error', + 'no-self-compare': 'error', + 'no-setter-return': 'error', + 'no-sparse-arrays': 'off', + 'no-template-curly-in-string': 'off', + 'no-this-before-super': 'error', + 'no-undef': 'error', + 'no-unexpected-multiline': 'off', + 'no-unmodified-loop-condition': 'off', + 'no-unreachable': 'error', + 'no-unreachable-loop': 'error', + 'no-unsafe-finally': 'error', + 'no-unsafe-negation': 'error', + 'no-unsafe-optional-chaining': 'error', + 'no-unused-private-class-members': 'error', + 'no-unused-vars': ['error', { ignoreRestSiblings: true }], + 'no-use-before-define': 'error', + 'no-useless-backreference': 'error', + 'require-atomic-updates': 'off', + 'use-isnan': ['error', { enforceForIndexOf: true }], + 'valid-typeof': 'error', + 'callback-return': 'off', + 'global-require': 'off', + 'handle-callback-err': 'off', + 'id-blacklist': 'off', + 'indent-legacy': 'off', + 'lines-around-directive': 'off', + 'newline-after-var': 'off', + 'newline-before-return': 'off', + 'no-buffer-constructor': 'off', + 'no-catch-shadow': 'off', + 'no-mixed-requires': 'off', + 'no-native-reassign': 'off', + 'no-negated-in-lhs': 'off', + 'no-new-require': 'off', + 'no-path-concat': 'off', + 'no-process-env': 'off', + 'no-process-exit': 'off', + 'no-restricted-modules': 'off', + 'no-spaced-func': 'off', + 'no-sync': 'off', + 'prefer-reflect': 'off', + 'require-jsdoc': 'off', + 'valid-jsdoc': 'off', + 'array-bracket-newline': 'off', + 'array-bracket-spacing': 'off', + 'array-element-newline': 'off', + 'arrow-parens': 'off', + 'arrow-spacing': 'off', + 'block-spacing': 'off', + 'brace-style': 'off', + 'comma-dangle': 'off', + 'comma-spacing': 'off', + 'comma-style': 'off', + 'computed-property-spacing': 'off', + 'dot-location': 'off', + 'eol-last': 'off', + 'func-call-spacing': 'off', + 'function-call-argument-newline': 'off', + 'function-paren-newline': 'off', + 'generator-star-spacing': 'off', + 'implicit-arrow-linebreak': 'off', + indent: 'off', + 'jsx-quotes': 'off', + 'key-spacing': 'off', + 'keyword-spacing': 'off', + 'line-comment-position': 'error', + 'linebreak-style': 'off', + 'lines-around-comment': [ + 'error', + { + allowBlockStart: true, + allowObjectStart: true, + allowArrayStart: true, + allowClassStart: true + } + ], + 'lines-between-class-members': 'error', + 'max-len': [ + 'error', + { + code: prettier.js.printWidth, + ignorePattern: /^(?!\s+(\/\/|\*))|eslint-disable/.source, + ignoreUrls: true, + ignoreRegExpLiterals: true, + ignoreStrings: true, + ignoreTemplateLiterals: true + } + ], + 'max-statements-per-line': 'off', + 'multiline-ternary': 'off', + 'new-parens': 'off', + 'newline-per-chained-call': 'off', + 'no-extra-parens': 'off', + 'no-mixed-spaces-and-tabs': 'off', + 'no-multi-spaces': 'off', + 'no-multiple-empty-lines': 'off', + 'no-tabs': ['error', { allowIndentationTabs: true }], + 'no-trailing-spaces': 'off', + 'no-whitespace-before-property': 'off', + 'nonblock-statement-body-position': 'off', + 'object-curly-newline': 'off', + 'object-curly-spacing': 'off', + 'object-property-newline': 'off', + 'operator-linebreak': 'off', + 'padded-blocks': 'off', + 'padding-line-between-statements': 'off', + quotes: ['error', 'single', { avoidEscape: true, allowTemplateLiterals: false }], + 'rest-spread-spacing': 'off', + semi: 'off', + 'semi-spacing': 'off', + 'semi-style': 'off', + 'space-before-blocks': 'off', + 'space-before-function-paren': 'off', + 'space-in-parens': 'off', + 'space-infix-ops': 'off', + 'space-unary-ops': 'off', + 'switch-colon-spacing': 'off', + 'template-curly-spacing': 'off', + 'template-tag-spacing': 'off', + 'unicode-bom': 'off', + 'wrap-iife': 'off', + 'wrap-regex': 'off', + 'yield-star-spacing': 'off' } diff --git a/test/core.test.js b/test/core.test.js index 08bb726..9623457 100644 --- a/test/core.test.js +++ b/test/core.test.js @@ -3,18 +3,7 @@ const { test } = require('node:test') const { builtinRules } = require('eslint/use-at-your-own-risk') -const byCategory = new Map() -for (const [name, { meta }] of builtinRules) { - const cat = meta.deprecated ? 'deprecated' : meta.type - const categoryRules = byCategory.get(cat) || [] - byCategory.set(cat, categoryRules) - categoryRules.push(name) - categoryRules.sort() -} - -for (const [category, categoryRules] of Object.entries(byCategory)) { - test(`define all rules in the ${category} category`, () => { - const config = require(`eslint-config-remcohaszing/core/${category}`) - assert.deepEqual(Object.keys(config).sort(), categoryRules) - }) -} +test(`define all core rules`, () => { + const config = require(`eslint-config-remcohaszing/plugins/core`) + assert.deepEqual(Object.keys(config).sort(), [...builtinRules.keys()].sort()) +})