Skip to content

Commit

Permalink
feat: all rule configs are arrays
Browse files Browse the repository at this point in the history
BREAKING CHANGE: all rule configs are arrays.
This is a breaking change only if you are importing and processing the
exported value yourself. Otherwise, this shouldn't affect you. Sorry for
the major bump. Just being careful.
  • Loading branch information
mightyiam committed Apr 7, 2024
1 parent 2263204 commit 9738761
Show file tree
Hide file tree
Showing 3 changed files with 132 additions and 125 deletions.
248 changes: 124 additions & 124 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
import { Linter } from 'eslint'

const rules = {
'@typescript-eslint/adjacent-overload-signatures': 'error',
'@typescript-eslint/adjacent-overload-signatures': ['error'],
'@typescript-eslint/array-type': ['error', { default: 'array-simple' }],
'@typescript-eslint/await-thenable': 'error',
'@typescript-eslint/await-thenable': ['error'],
'@typescript-eslint/ban-ts-comment': ['error', {
'ts-expect-error': 'allow-with-description',
'ts-ignore': true,
'ts-nocheck': true,
'ts-check': false,
minimumDescriptionLength: 3
}],
'@typescript-eslint/ban-tslint-comment': 'error',
'@typescript-eslint/ban-tslint-comment': ['error'],
'@typescript-eslint/ban-types': ['error', {
extendDefaults: false,
types: {
Expand Down Expand Up @@ -144,39 +144,39 @@ const rules = {
singleline: { delimiter: 'comma', requireLast: false }
}
],
'@typescript-eslint/method-signature-style': 'error',
'@typescript-eslint/method-signature-style': ['error'],
'@typescript-eslint/naming-convention': ['error', {
selector: 'variableLike',
leadingUnderscore: 'allow',
trailingUnderscore: 'allow',
format: ['camelCase', 'PascalCase', 'UPPER_CASE']
}],
'@typescript-eslint/no-array-constructor': 'error',
'@typescript-eslint/no-base-to-string': 'error',
'@typescript-eslint/no-array-constructor': ['error'],
'@typescript-eslint/no-base-to-string': ['error'],
'@typescript-eslint/no-confusing-void-expression': ['error', { ignoreArrowShorthand: false, ignoreVoidOperator: false }],
'@typescript-eslint/no-dupe-class-members': 'error',
'@typescript-eslint/no-dynamic-delete': 'error',
'@typescript-eslint/no-dupe-class-members': ['error'],
'@typescript-eslint/no-dynamic-delete': ['error'],
'@typescript-eslint/no-empty-interface': ['error', { allowSingleExtends: true }],
'@typescript-eslint/no-extra-non-null-assertion': 'error',
'@typescript-eslint/no-extra-non-null-assertion': ['error'],
'@typescript-eslint/no-extra-parens': ['error', 'functions'],
'@typescript-eslint/no-extraneous-class': ['error', { allowWithDecorator: true }],
'@typescript-eslint/no-floating-promises': 'error',
'@typescript-eslint/no-for-in-array': 'error',
'@typescript-eslint/no-implied-eval': 'error',
'@typescript-eslint/no-invalid-void-type': 'error',
'@typescript-eslint/no-loss-of-precision': 'error',
'@typescript-eslint/no-misused-new': 'error',
'@typescript-eslint/no-misused-promises': 'error',
'@typescript-eslint/no-namespace': 'error',
'@typescript-eslint/no-non-null-asserted-optional-chain': 'error',
'@typescript-eslint/no-non-null-assertion': 'error',
'@typescript-eslint/no-floating-promises': ['error'],
'@typescript-eslint/no-for-in-array': ['error'],
'@typescript-eslint/no-implied-eval': ['error'],
'@typescript-eslint/no-invalid-void-type': ['error'],
'@typescript-eslint/no-loss-of-precision': ['error'],
'@typescript-eslint/no-misused-new': ['error'],
'@typescript-eslint/no-misused-promises': ['error'],
'@typescript-eslint/no-namespace': ['error'],
'@typescript-eslint/no-non-null-asserted-optional-chain': ['error'],
'@typescript-eslint/no-non-null-assertion': ['error'],
'@typescript-eslint/no-redeclare': ['error', { builtinGlobals: false }],
'@typescript-eslint/no-this-alias': ['error', { allowDestructuring: true }],
'@typescript-eslint/no-throw-literal': 'error',
'@typescript-eslint/no-unnecessary-boolean-literal-compare': 'error',
'@typescript-eslint/no-unnecessary-type-assertion': 'error',
'@typescript-eslint/no-unnecessary-type-constraint': 'error',
'@typescript-eslint/no-unsafe-argument': 'error',
'@typescript-eslint/no-throw-literal': ['error'],
'@typescript-eslint/no-unnecessary-boolean-literal-compare': ['error'],
'@typescript-eslint/no-unnecessary-type-assertion': ['error'],
'@typescript-eslint/no-unnecessary-type-constraint': ['error'],
'@typescript-eslint/no-unsafe-argument': ['error'],
'@typescript-eslint/no-unused-expressions': ['error', {
allowShortCircuit: true,
allowTernary: true,
Expand All @@ -196,19 +196,19 @@ const rules = {
typedefs: false
}],
'@typescript-eslint/no-useless-constructor': ['error'],
'@typescript-eslint/no-var-requires': 'error',
'@typescript-eslint/non-nullable-type-assertion-style': 'error',
'@typescript-eslint/no-var-requires': ['error'],
'@typescript-eslint/non-nullable-type-assertion-style': ['error'],
'@typescript-eslint/object-curly-spacing': ['error', 'always'],
'@typescript-eslint/prefer-function-type': 'error',
'@typescript-eslint/prefer-includes': 'error',
'@typescript-eslint/prefer-function-type': ['error'],
'@typescript-eslint/prefer-includes': ['error'],
'@typescript-eslint/prefer-nullish-coalescing': ['error', { ignoreConditionalTests: false, ignoreMixedLogicalExpressions: false }],
'@typescript-eslint/prefer-optional-chain': 'error',
'@typescript-eslint/prefer-promise-reject-errors': 'error',
'@typescript-eslint/prefer-readonly': 'error',
'@typescript-eslint/prefer-reduce-type-parameter': 'error',
'@typescript-eslint/prefer-return-this-type': 'error',
'@typescript-eslint/prefer-ts-expect-error': 'error',
'@typescript-eslint/promise-function-async': 'error',
'@typescript-eslint/prefer-optional-chain': ['error'],
'@typescript-eslint/prefer-promise-reject-errors': ['error'],
'@typescript-eslint/prefer-readonly': ['error'],
'@typescript-eslint/prefer-reduce-type-parameter': ['error'],
'@typescript-eslint/prefer-return-this-type': ['error'],
'@typescript-eslint/prefer-ts-expect-error': ['error'],
'@typescript-eslint/promise-function-async': ['error'],
'@typescript-eslint/quotes': ['error', 'single', { avoidEscape: true, allowTemplateLiterals: false }],
'@typescript-eslint/require-array-sort-compare': ['error', { ignoreStringArrays: true }],
'@typescript-eslint/restrict-plus-operands': ['error', { skipCompoundAssignments: false }],
Expand All @@ -217,7 +217,7 @@ const rules = {
'@typescript-eslint/semi': ['error', 'never'],
'@typescript-eslint/space-before-blocks': ['error', 'always'],
'@typescript-eslint/space-before-function-paren': ['error', 'always'],
'@typescript-eslint/space-infix-ops': 'error',
'@typescript-eslint/space-infix-ops': ['error'],
'@typescript-eslint/strict-boolean-expressions': ['error', {
allowString: false,
allowNumber: false,
Expand All @@ -228,7 +228,7 @@ const rules = {
allowAny: false
}],
'@typescript-eslint/triple-slash-reference': ['error', { lib: 'never', path: 'never', types: 'never' }],
'@typescript-eslint/type-annotation-spacing': 'error',
'@typescript-eslint/type-annotation-spacing': ['error'],
'@typescript-eslint/unbound-method': ['error', { ignoreStatic: false }],

'accessor-pairs': ['error', { setWithoutGet: true, enforceForClassMembers: true }],
Expand All @@ -240,52 +240,52 @@ const rules = {
'arrow-spacing': ['error', { before: true, after: true }],
'comma-style': ['error', 'last'],
'computed-property-spacing': ['error', 'never', { enforceForClassMembers: true }],
'constructor-super': 'error',
'constructor-super': ['error'],
curly: ['error', 'multi-line'],
'default-case-last': 'error',
'default-case-last': ['error'],
'dot-location': ['error', 'property'],
'eol-last': 'error',
'eol-last': ['error'],
eqeqeq: ['error', 'always', { null: 'ignore' }],
'generator-star-spacing': ['error', { before: true, after: true }],
'multiline-ternary': ['error', 'always-multiline'],
'new-cap': ['error', { newIsCap: true, capIsNew: false, properties: true }],
'new-parens': 'error',
'no-async-promise-executor': 'error',
'no-caller': 'error',
'no-case-declarations': 'error',
'no-class-assign': 'error',
'no-compare-neg-zero': 'error',
'no-cond-assign': 'error',
'no-const-assign': 'error',
'new-parens': ['error'],
'no-async-promise-executor': ['error'],
'no-caller': ['error'],
'no-case-declarations': ['error'],
'no-class-assign': ['error'],
'no-compare-neg-zero': ['error'],
'no-cond-assign': ['error'],
'no-const-assign': ['error'],
'no-constant-condition': ['error', { checkLoops: false }],
'no-control-regex': 'error',
'no-debugger': 'error',
'no-delete-var': 'error',
'no-dupe-args': 'error',
'no-dupe-keys': 'error',
'no-duplicate-case': 'error',
'no-useless-backreference': 'error',
'no-control-regex': ['error'],
'no-debugger': ['error'],
'no-delete-var': ['error'],
'no-dupe-args': ['error'],
'no-dupe-keys': ['error'],
'no-duplicate-case': ['error'],
'no-useless-backreference': ['error'],
'no-empty': ['error', { allowEmptyCatch: true }],
'no-empty-character-class': 'error',
'no-empty-pattern': 'error',
'no-eval': 'error',
'no-ex-assign': 'error',
'no-extend-native': 'error',
'no-extra-bind': 'error',
'no-extra-boolean-cast': 'error',
'no-fallthrough': 'error',
'no-floating-decimal': 'error',
'no-func-assign': 'error',
'no-global-assign': 'error',
'no-import-assign': 'error',
'no-invalid-regexp': 'error',
'no-irregular-whitespace': 'error',
'no-iterator': 'error',
'no-empty-character-class': ['error'],
'no-empty-pattern': ['error'],
'no-eval': ['error'],
'no-ex-assign': ['error'],
'no-extend-native': ['error'],
'no-extra-bind': ['error'],
'no-extra-boolean-cast': ['error'],
'no-fallthrough': ['error'],
'no-floating-decimal': ['error'],
'no-func-assign': ['error'],
'no-global-assign': ['error'],
'no-import-assign': ['error'],
'no-invalid-regexp': ['error'],
'no-irregular-whitespace': ['error'],
'no-iterator': ['error'],
'no-labels': ['error', { allowLoop: false, allowSwitch: false }],
'no-lone-blocks': 'error',
'no-misleading-character-class': 'error',
'no-prototype-builtins': 'error',
'no-useless-catch': 'error',
'no-lone-blocks': ['error'],
'no-misleading-character-class': ['error'],
'no-prototype-builtins': ['error'],
'no-useless-catch': ['error'],
'no-mixed-operators': ['error', {
groups: [
['==', '!=', '===', '!==', '>', '>=', '<', '<='],
Expand All @@ -294,47 +294,47 @@ const rules = {
],
allowSamePrecedence: true
}],
'no-mixed-spaces-and-tabs': 'error',
'no-multi-spaces': 'error',
'no-multi-str': 'error',
'no-mixed-spaces-and-tabs': ['error'],
'no-multi-spaces': ['error'],
'no-multi-str': ['error'],
'no-multiple-empty-lines': ['error', { max: 1, maxBOF: 0, maxEOF: 0 }],
'no-new': 'error',
'no-new-func': 'error',
'no-new-object': 'error',
'no-new-symbol': 'error',
'no-new-wrappers': 'error',
'no-obj-calls': 'error',
'no-octal': 'error',
'no-octal-escape': 'error',
'no-proto': 'error',
'no-regex-spaces': 'error',
'no-new': ['error'],
'no-new-func': ['error'],
'no-new-object': ['error'],
'no-new-symbol': ['error'],
'no-new-wrappers': ['error'],
'no-obj-calls': ['error'],
'no-octal': ['error'],
'no-octal-escape': ['error'],
'no-proto': ['error'],
'no-regex-spaces': ['error'],
'no-return-assign': ['error', 'except-parens'],
'no-self-assign': ['error', { props: true }],
'no-self-compare': 'error',
'no-sequences': 'error',
'no-shadow-restricted-names': 'error',
'no-sparse-arrays': 'error',
'no-tabs': 'error',
'no-template-curly-in-string': 'error',
'no-this-before-super': 'error',
'no-trailing-spaces': 'error',
'no-undef-init': 'error',
'no-unexpected-multiline': 'error',
'no-unmodified-loop-condition': 'error',
'no-self-compare': ['error'],
'no-sequences': ['error'],
'no-shadow-restricted-names': ['error'],
'no-sparse-arrays': ['error'],
'no-tabs': ['error'],
'no-template-curly-in-string': ['error'],
'no-this-before-super': ['error'],
'no-trailing-spaces': ['error'],
'no-undef-init': ['error'],
'no-unexpected-multiline': ['error'],
'no-unmodified-loop-condition': ['error'],
'no-unneeded-ternary': ['error', { defaultAssignment: false }],
'no-unreachable': 'error',
'no-unreachable-loop': 'error',
'no-unsafe-finally': 'error',
'no-unsafe-negation': 'error',
'no-useless-call': 'error',
'no-useless-computed-key': 'error',
'no-useless-escape': 'error',
'no-useless-rename': 'error',
'no-useless-return': 'error',
'no-var': 'warn',
'no-unreachable': ['error'],
'no-unreachable-loop': ['error'],
'no-unsafe-finally': ['error'],
'no-unsafe-negation': ['error'],
'no-useless-call': ['error'],
'no-useless-computed-key': ['error'],
'no-useless-escape': ['error'],
'no-useless-rename': ['error'],
'no-useless-return': ['error'],
'no-var': ['warn'],
'no-void': ['error', { allowAsStatement: true }],
'no-whitespace-before-property': 'error',
'no-with': 'error',
'no-whitespace-before-property': ['error'],
'no-with': ['error'],
'object-curly-newline': ['error', { multiline: true, consistent: true }],
'object-property-newline': ['error', { allowMultiplePropertiesPerLine: true }],
'object-shorthand': ['warn', 'properties'],
Expand All @@ -352,7 +352,7 @@ const rules = {
line: { markers: ['*package', '!', '/', ',', '='] },
block: { balanced: true, markers: ['*package', '!', ',', ':', '::', 'flow-include'], exceptions: ['*'] }
}],
'symbol-description': 'error',
'symbol-description': ['error'],
'template-curly-spacing': ['error', 'never'],
'template-tag-spacing': ['error', 'never'],
'unicode-bom': ['error', 'never'],
Expand All @@ -365,22 +365,22 @@ const rules = {
'yield-star-spacing': ['error', 'both'],
yoda: ['error', 'never'],

'import/export': 'error',
'import/first': 'error',
'import/export': ['error'],
'import/first': ['error'],
'import/no-absolute-path': ['error', { esmodule: true, commonjs: true, amd: false }],
'import/no-duplicates': 'error',
'import/no-named-default': 'error',
'import/no-webpack-loader-syntax': 'error',
'import/no-duplicates': ['error'],
'import/no-named-default': ['error'],
'import/no-webpack-loader-syntax': ['error'],

'n/handle-callback-err': ['error', '^(err|error)$'],
'n/no-callback-literal': 'error',
'n/no-deprecated-api': 'error',
'n/no-exports-assign': 'error',
'n/no-new-require': 'error',
'n/no-path-concat': 'error',
'n/process-exit-as-throw': 'error',
'n/no-callback-literal': ['error'],
'n/no-deprecated-api': ['error'],
'n/no-exports-assign': ['error'],
'n/no-new-require': ['error'],
'n/no-path-concat': ['error'],
'n/process-exit-as-throw': ['error'],

'promise/param-names': 'error'
'promise/param-names': ['error']
} satisfies Linter.RulesRecord

const eslintRuleNames = [...(new Linter()).getRules().keys()]
Expand Down Expand Up @@ -408,7 +408,7 @@ const config = {
project: true
},
rules: {
...Object.fromEntries(namesOfEslintRulesForWhichWeAreUsingTsEquivalents.map(name => [name, 'off'])),
...Object.fromEntries(namesOfEslintRulesForWhichWeAreUsingTsEquivalents.map(name => [name, ['off']])),
...rules
}

Expand Down
2 changes: 1 addition & 1 deletion src/test/equivalents.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@ test('JS equivalent rules are off', async (t) => {
if (!Object.prototype.hasOwnProperty.call(typescriptEslintRules, bareName)) return
if (!equivalents.includes(bareName)) return
const config = ourRules[bareName]
t.is(config, 'off', bareName)
t.deepEqual(config, ['off'], bareName)
})
})
7 changes: 7 additions & 0 deletions src/test/misc.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import test from 'ava'
import exported from '..'

test('rule configs are arrays', (t) => {
const nonArrayConfigs = Object.entries(exported.rules).filter(([_rule, config]) => !Array.isArray(config))
t.deepEqual(nonArrayConfigs, [])
})

0 comments on commit 9738761

Please sign in to comment.