Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 44 additions & 0 deletions scripts/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,50 @@ export const scopeMaps = {
typescript: '@typescript-eslint',
};

// Some typescript-eslint rules are re-implemented version of eslint rules.
// e.g. no-array-constructor, max-params, etc...
// Since oxlint supports these rules under eslint/* and it also supports TS,
// we should override these to make implementation status up-to-date.
export const typescriptRulesExtendEslintRules = [
'block-spacing',
'brace-style',
'class-methods-use-this',
'comma-dangle',
'comma-spacing',
'default-param-last',
'func-call-spacing',
'indent',
'init-declarations',
'key-spacing',
'keyword-spacing',
'lines-around-comment',
'lines-between-class-members',
'max-params',
'no-array-constructor',
'no-dupe-class-members',
'no-empty-function',
'no-extra-parens',
'no-extra-semi',
'no-invalid-this',
'no-loop-func',
'no-loss-of-precision',
'no-magic-numbers',
'no-redeclare',
'no-restricted-imports',
'no-shadow',
'no-unused-expressions',
'no-unused-vars',
'no-use-before-define',
'no-useless-constructor',
'object-curly-spacing',
'padding-line-between-statements',
'quotes',
'semi',
'space-before-blocks',
'space-before-function-paren',
'space-infix-ops',
];

export function convertScope(scope: string) {
return Reflect.has(scopeMaps, scope)
? scopeMaps[scope as 'eslint']
Expand Down
13 changes: 13 additions & 0 deletions scripts/traverse-rules.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {
prefixScope,
SPARSE_CLONE_DIRECTORY,
TARGET_DIRECTORY,
typescriptRulesExtendEslintRules,
} from './constants.js';

// Recursive function to read files in a directory, this currently assumes that the directory
Expand Down Expand Up @@ -114,6 +115,18 @@ async function processFile(
scope: scope,
category: keywordMatch[1],
});

if (scope === 'eslint') {
let ruleName = effectiveRuleName.replace(/^.*\//, '');

if (typescriptRulesExtendEslintRules.includes(ruleName)) {
successResultArray.push({
value: `@typescript-eslint/${ruleName}`,
scope: 'typescript',
category: keywordMatch[1],
});
}
}
} else {
failureResultArray.push({
value: effectiveRuleName,
Expand Down
12 changes: 12 additions & 0 deletions src/rules-by-category.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ const pedanticRules = {
'no-inner-declarations': 'off',
'no-prototype-builtins': 'off',
'no-redeclare': 'off',
'@typescript-eslint/no-redeclare': 'off',
'no-self-compare': 'off',
radix: 'off',
'require-await': 'off',
Expand Down Expand Up @@ -54,6 +55,7 @@ const restrictionRules = {
'no-bitwise': 'off',
'no-console': 'off',
'no-empty-function': 'off',
'@typescript-eslint/no-empty-function': 'off',
'no-eval': 'off',
'no-restricted-globals': 'off',
'no-undefined': 'off',
Expand Down Expand Up @@ -85,8 +87,10 @@ const restrictionRules = {
const styleRules = {
'default-case-last': 'off',
'default-param-last': 'off',
'@typescript-eslint/default-param-last': 'off',
'guard-for-in': 'off',
'max-params': 'off',
'@typescript-eslint/max-params': 'off',
'no-continue': 'off',
'no-label-var': 'off',
'no-multi-str': 'off',
Expand Down Expand Up @@ -116,6 +120,7 @@ const styleRules = {
'jest/require-top-level-describe': 'off',
'promise/avoid-new': 'off',
'promise/param-names': 'off',
'promise/prefer-await-to-callbacks': 'off',
'promise/prefer-await-to-then': 'off',
'react/jsx-curly-brace-presence': 'off',
'react/no-set-state': 'off',
Expand Down Expand Up @@ -170,16 +175,19 @@ const conditionalFixSuggestionRules = {

const pendingRules = {
'no-array-constructor': 'off',
'@typescript-eslint/no-array-constructor': 'off',
'no-empty-static-block': 'off',
'no-extra-boolean-cast': 'off',
'no-fallthrough': 'off',
'no-iterator': 'off',
'no-magic-numbers': 'off',
'@typescript-eslint/no-magic-numbers': 'off',
'no-new-wrappers': 'off',
'no-nonoctal-decimal-escape': 'off',
'no-plusplus': 'off',
'no-proto': 'off',
'no-regex-spaces': 'off',
'no-return-assign': 'off',
'no-template-curly-in-string': 'off',
'no-void': 'off',
'sort-keys': 'off',
Expand Down Expand Up @@ -230,6 +238,7 @@ const correctnessRules = {
'no-control-regex': 'off',
'no-delete-var': 'off',
'no-dupe-class-members': 'off',
'@typescript-eslint/no-dupe-class-members': 'off',
'no-dupe-else-if': 'off',
'no-dupe-keys': 'off',
'no-duplicate-case': 'off',
Expand All @@ -242,6 +251,7 @@ const correctnessRules = {
'no-invalid-regexp': 'off',
'no-irregular-whitespace': 'off',
'no-loss-of-precision': 'off',
'@typescript-eslint/no-loss-of-precision': 'off',
'no-new-native-nonconstructor': 'off',
'no-obj-calls': 'off',
'no-self-assign': 'off',
Expand Down Expand Up @@ -361,6 +371,7 @@ const fixRules = {
'no-unsafe-negation': 'off',
'no-unused-labels': 'off',
'no-useless-constructor': 'off',
'@typescript-eslint/no-useless-constructor': 'off',
'no-useless-escape': 'off',
'no-var': 'off',
'unicode-bom': 'off',
Expand Down Expand Up @@ -456,6 +467,7 @@ const suspiciousRules = {

const dangerousSuggestionRules = {
'no-unused-vars': 'off',
'@typescript-eslint/no-unused-vars': 'off',
};

const conditionalSuggestionRules = {
Expand Down
92 changes: 52 additions & 40 deletions src/rules-by-scope.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ const eslintRules = {
'no-redeclare': 'off',
'no-regex-spaces': 'off',
'no-restricted-globals': 'off',
'no-return-assign': 'off',
'no-script-url': 'off',
'no-self-assign': 'off',
'no-self-compare': 'off',
Expand Down Expand Up @@ -113,6 +114,55 @@ const eslintRules = {
'valid-typeof': 'off',
};

const typescriptRules = {
'@typescript-eslint/default-param-last': 'off',
'@typescript-eslint/max-params': 'off',
'@typescript-eslint/no-array-constructor': 'off',
'@typescript-eslint/no-dupe-class-members': 'off',
'@typescript-eslint/no-empty-function': 'off',
'@typescript-eslint/no-loss-of-precision': 'off',
'@typescript-eslint/no-magic-numbers': 'off',
'@typescript-eslint/no-redeclare': 'off',
'@typescript-eslint/no-unused-vars': 'off',
'@typescript-eslint/no-useless-constructor': 'off',
'@typescript-eslint/adjacent-overload-signatures': 'off',
'@typescript-eslint/array-type': 'off',
'@typescript-eslint/ban-ts-comment': 'off',
'@typescript-eslint/ban-tslint-comment': 'off',
'@typescript-eslint/ban-types': 'off',
'@typescript-eslint/consistent-indexed-object-style': 'off',
'@typescript-eslint/consistent-type-definitions': 'off',
'@typescript-eslint/consistent-type-imports': 'off',
'@typescript-eslint/explicit-function-return-type': 'off',
'@typescript-eslint/no-confusing-non-null-assertion': 'off',
'@typescript-eslint/no-duplicate-enum-values': 'off',
'@typescript-eslint/no-dynamic-delete': 'off',
'@typescript-eslint/no-empty-interface': 'off',
'@typescript-eslint/no-explicit-any': 'off',
'@typescript-eslint/no-extra-non-null-assertion': 'off',
'@typescript-eslint/no-extraneous-class': 'off',
'@typescript-eslint/no-import-type-side-effects': 'off',
'@typescript-eslint/no-misused-new': 'off',
'@typescript-eslint/no-namespace': 'off',
'@typescript-eslint/no-non-null-asserted-nullish-coalescing': 'off',
'@typescript-eslint/no-non-null-asserted-optional-chain': 'off',
'@typescript-eslint/no-non-null-assertion': 'off',
'@typescript-eslint/no-this-alias': 'off',
'@typescript-eslint/no-unnecessary-type-constraint': 'off',
'@typescript-eslint/no-unsafe-declaration-merging': 'off',
'@typescript-eslint/no-useless-empty-export': 'off',
'@typescript-eslint/no-var-requires': 'off',
'@typescript-eslint/no-wrapper-object-types': 'off',
'@typescript-eslint/prefer-as-const': 'off',
'@typescript-eslint/prefer-enum-initializers': 'off',
'@typescript-eslint/prefer-for-of': 'off',
'@typescript-eslint/prefer-function-type': 'off',
'@typescript-eslint/prefer-literal-enum-member': 'off',
'@typescript-eslint/prefer-namespace-keyword': 'off',
'@typescript-eslint/prefer-ts-expect-error': 'off',
'@typescript-eslint/triple-slash-reference': 'off',
};

const importRules = {
'import/default': 'off',
'import/export': 'off',
Expand Down Expand Up @@ -267,6 +317,7 @@ const promiseRules = {
'promise/no-new-statics': 'off',
'promise/no-return-in-finally': 'off',
'promise/param-names': 'off',
'promise/prefer-await-to-callbacks': 'off',
'promise/prefer-await-to-then': 'off',
'promise/spec-only': 'off',
'promise/valid-params': 'off',
Expand Down Expand Up @@ -318,45 +369,6 @@ const treeShakingRules = {
'tree-shaking/no-side-effects-in-initialization': 'off',
};

const typescriptRules = {
'@typescript-eslint/adjacent-overload-signatures': 'off',
'@typescript-eslint/array-type': 'off',
'@typescript-eslint/ban-ts-comment': 'off',
'@typescript-eslint/ban-tslint-comment': 'off',
'@typescript-eslint/ban-types': 'off',
'@typescript-eslint/consistent-indexed-object-style': 'off',
'@typescript-eslint/consistent-type-definitions': 'off',
'@typescript-eslint/consistent-type-imports': 'off',
'@typescript-eslint/explicit-function-return-type': 'off',
'@typescript-eslint/no-confusing-non-null-assertion': 'off',
'@typescript-eslint/no-duplicate-enum-values': 'off',
'@typescript-eslint/no-dynamic-delete': 'off',
'@typescript-eslint/no-empty-interface': 'off',
'@typescript-eslint/no-explicit-any': 'off',
'@typescript-eslint/no-extra-non-null-assertion': 'off',
'@typescript-eslint/no-extraneous-class': 'off',
'@typescript-eslint/no-import-type-side-effects': 'off',
'@typescript-eslint/no-misused-new': 'off',
'@typescript-eslint/no-namespace': 'off',
'@typescript-eslint/no-non-null-asserted-nullish-coalescing': 'off',
'@typescript-eslint/no-non-null-asserted-optional-chain': 'off',
'@typescript-eslint/no-non-null-assertion': 'off',
'@typescript-eslint/no-this-alias': 'off',
'@typescript-eslint/no-unnecessary-type-constraint': 'off',
'@typescript-eslint/no-unsafe-declaration-merging': 'off',
'@typescript-eslint/no-useless-empty-export': 'off',
'@typescript-eslint/no-var-requires': 'off',
'@typescript-eslint/no-wrapper-object-types': 'off',
'@typescript-eslint/prefer-as-const': 'off',
'@typescript-eslint/prefer-enum-initializers': 'off',
'@typescript-eslint/prefer-for-of': 'off',
'@typescript-eslint/prefer-function-type': 'off',
'@typescript-eslint/prefer-literal-enum-member': 'off',
'@typescript-eslint/prefer-namespace-keyword': 'off',
'@typescript-eslint/prefer-ts-expect-error': 'off',
'@typescript-eslint/triple-slash-reference': 'off',
};

const unicornRules = {
'unicorn/catch-error-name': 'off',
'unicorn/consistent-function-scoping': 'off',
Expand Down Expand Up @@ -458,6 +470,7 @@ const vitestRules = {

export {
eslintRules,
typescriptRules,
importRules,
jestRules,
jsdocRules,
Expand All @@ -469,7 +482,6 @@ export {
reactPerfRules,
securityRules,
treeShakingRules,
typescriptRules,
unicornRules,
vitestRules,
};