diff --git a/scripts/traverse-rules.ts b/scripts/traverse-rules.ts index 9e2f633..d9ee7cb 100644 --- a/scripts/traverse-rules.ts +++ b/scripts/traverse-rules.ts @@ -27,25 +27,30 @@ export async function readFilesRecursively( (entry) => entry.isFile() && entry.name === 'mod.rs' ); - for (const entry of entries) { - const entryPath = path.join(directory, entry.name); - if (entry.isDirectory()) { - await readFilesRecursively( - entryPath, - successResultArray, - skippedResultArray, - failureResultArray - ); // Recursive call for directories - } else if (entry.isFile() && (!containsModRs || entry.name === 'mod.rs')) { - await processFile( - entryPath, - directory, - successResultArray, - skippedResultArray, - failureResultArray - ); // Process each file - } - } + await Promise.all( + entries.map(async (entry) => { + const entryPath = path.join(directory, entry.name); + if (entry.isDirectory()) { + await readFilesRecursively( + entryPath, + successResultArray, + skippedResultArray, + failureResultArray + ); // Recursive call for directories + } else if ( + entry.isFile() && + (!containsModRs || entry.name === 'mod.rs') + ) { + await processFile( + entryPath, + directory, + successResultArray, + skippedResultArray, + failureResultArray + ); // Process each file + } + }) + ); } export interface Rule { @@ -209,6 +214,16 @@ export async function traverseRules(): Promise<{ failureResultArray ); + successResultArray.sort((aRule, bRule) => { + const scopeCompare = aRule.scope.localeCompare(bRule.scope); + + if (scopeCompare !== 0) { + return scopeCompare; + } + + return aRule.value.localeCompare(bRule.value); + }); + console.log( `>> Parsed ${successResultArray.length} rules, skipped ${skippedResultArray.length} and encountered ${failureResultArray.length} failures\n` ); diff --git a/src/generated/configs-by-scope.ts b/src/generated/configs-by-scope.ts index 6d172b0..25437e0 100644 --- a/src/generated/configs-by-scope.ts +++ b/src/generated/configs-by-scope.ts @@ -7,11 +7,6 @@ const eslintConfig = { rules: rules.eslintRules, }; -const typescriptConfig = { - name: 'oxlint/typescript', - rules: rules.typescriptRules, -}; - const importConfig = { name: 'oxlint/import', rules: rules.importRules, @@ -67,6 +62,11 @@ const treeShakingConfig = { rules: rules.treeShakingRules, }; +const typescriptConfig = { + name: 'oxlint/typescript', + rules: rules.typescriptRules, +}; + const unicornConfig = { name: 'oxlint/unicorn', rules: rules.unicornRules, @@ -79,7 +79,6 @@ const vitestConfig = { const configByScope = { 'flat/eslint': eslintConfig, - 'flat/typescript': typescriptConfig, 'flat/import': importConfig, 'flat/jest': jestConfig, 'flat/jsdoc': jsdocConfig, @@ -91,6 +90,7 @@ const configByScope = { 'flat/react-hooks': reactHooksConfig, 'flat/react-perf': reactPerfConfig, 'flat/tree-shaking': treeShakingConfig, + 'flat/typescript': typescriptConfig, 'flat/unicorn': unicornConfig, 'flat/vitest': vitestConfig, }; diff --git a/src/generated/rules-by-category.ts b/src/generated/rules-by-category.ts index 4fcd29b..9397a3a 100644 --- a/src/generated/rules-by-category.ts +++ b/src/generated/rules-by-category.ts @@ -6,7 +6,6 @@ const pedanticRules = { 'max-classes-per-file': 'off', 'max-lines': 'off', 'no-array-constructor': 'off', - '@typescript-eslint/no-array-constructor': 'off', 'no-case-declarations': 'off', 'no-constructor-return': 'off', 'no-else-return': 'off', @@ -15,7 +14,6 @@ const pedanticRules = { 'no-new-wrappers': 'off', 'no-prototype-builtins': 'off', 'no-redeclare': 'off', - '@typescript-eslint/no-redeclare': 'off', 'no-self-compare': 'off', 'no-throw-literal': 'off', radix: 'off', @@ -36,6 +34,8 @@ const pedanticRules = { 'react/no-unescaped-entities': 'off', '@typescript-eslint/ban-ts-comment': 'off', '@typescript-eslint/ban-types': 'off', + '@typescript-eslint/no-array-constructor': 'off', + '@typescript-eslint/no-redeclare': 'off', '@typescript-eslint/no-unsafe-function-type': 'off', '@typescript-eslint/prefer-enum-initializers': 'off', '@typescript-eslint/prefer-ts-expect-error': 'off', @@ -101,7 +101,6 @@ const restrictionRules = { 'no-div-regex': 'off', 'no-empty': 'off', 'no-empty-function': 'off', - '@typescript-eslint/no-empty-function': 'off', 'no-eq-null': 'off', 'no-eval': 'off', 'no-iterator': 'off', @@ -130,6 +129,7 @@ const restrictionRules = { 'react/no-unknown-property': 'off', '@typescript-eslint/explicit-function-return-type': 'off', '@typescript-eslint/no-dynamic-delete': 'off', + '@typescript-eslint/no-empty-function': 'off', '@typescript-eslint/no-explicit-any': 'off', '@typescript-eslint/no-import-type-side-effects': 'off', '@typescript-eslint/no-namespace': 'off', @@ -153,15 +153,12 @@ const restrictionRules = { const styleRules = { 'default-case-last': 'off', 'default-param-last': 'off', - '@typescript-eslint/default-param-last': 'off', 'func-names': 'off', 'guard-for-in': 'off', 'max-params': 'off', - '@typescript-eslint/max-params': 'off', 'no-continue': 'off', 'no-label-var': 'off', 'no-magic-numbers': 'off', - '@typescript-eslint/no-magic-numbers': 'off', 'no-multi-str': 'off', 'no-new-func': 'off', 'no-return-assign': 'off', @@ -225,7 +222,10 @@ const styleRules = { '@typescript-eslint/ban-tslint-comment': 'off', '@typescript-eslint/consistent-indexed-object-style': 'off', '@typescript-eslint/consistent-type-definitions': 'off', + '@typescript-eslint/default-param-last': 'off', + '@typescript-eslint/max-params': 'off', '@typescript-eslint/no-empty-interface': 'off', + '@typescript-eslint/no-magic-numbers': 'off', '@typescript-eslint/prefer-for-of': 'off', '@typescript-eslint/prefer-function-type': 'off', '@typescript-eslint/prefer-namespace-keyword': 'off', @@ -275,7 +275,6 @@ const correctnessRules = { 'no-debugger': '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', @@ -290,7 +289,6 @@ 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-nonoctal-decimal-escape': 'off', 'no-obj-calls': 'off', @@ -305,7 +303,6 @@ const correctnessRules = { 'no-unused-labels': 'off', 'no-unused-private-class-members': 'off', 'no-unused-vars': 'off', - '@typescript-eslint/no-unused-vars': 'off', 'no-useless-catch': 'off', 'no-useless-escape': 'off', 'no-useless-rename': 'off', @@ -398,12 +395,15 @@ const correctnessRules = { 'react/no-render-return-value': 'off', 'react/no-string-refs': 'off', 'react/void-dom-elements-no-children': 'off', + '@typescript-eslint/no-dupe-class-members': 'off', '@typescript-eslint/no-duplicate-enum-values': 'off', '@typescript-eslint/no-extra-non-null-assertion': 'off', + '@typescript-eslint/no-loss-of-precision': 'off', '@typescript-eslint/no-misused-new': 'off', '@typescript-eslint/no-non-null-asserted-optional-chain': 'off', '@typescript-eslint/no-this-alias': 'off', '@typescript-eslint/no-unsafe-declaration-merging': 'off', + '@typescript-eslint/no-unused-vars': 'off', '@typescript-eslint/no-useless-empty-export': 'off', '@typescript-eslint/no-wrapper-object-types': 'off', '@typescript-eslint/prefer-as-const': 'off', @@ -439,7 +439,6 @@ const suspiciousRules = { 'no-unexpected-multiline': 'off', 'no-useless-concat': 'off', 'no-useless-constructor': 'off', - '@typescript-eslint/no-useless-constructor': 'off', 'import/no-duplicates': 'off', 'import/no-named-as-default': 'off', 'import/no-named-as-default-member': 'off', @@ -452,6 +451,7 @@ const suspiciousRules = { '@typescript-eslint/no-confusing-non-null-assertion': 'off', '@typescript-eslint/no-extraneous-class': 'off', '@typescript-eslint/no-unnecessary-type-constraint': 'off', + '@typescript-eslint/no-useless-constructor': 'off', 'unicorn/consistent-function-scoping': 'off', 'unicorn/prefer-add-event-listener': 'off', } as const; diff --git a/src/generated/rules-by-scope.ts b/src/generated/rules-by-scope.ts index c586325..40174fd 100644 --- a/src/generated/rules-by-scope.ts +++ b/src/generated/rules-by-scope.ts @@ -117,56 +117,6 @@ const eslintRules = { 'valid-typeof': 'off', } as const; -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-unsafe-function-type': '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', -} as const; - const importRules = { 'import/default': 'off', 'import/export': 'off', @@ -379,6 +329,56 @@ const treeShakingRules = { 'tree-shaking/no-side-effects-in-initialization': 'off', } as const; +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/default-param-last': 'off', + '@typescript-eslint/explicit-function-return-type': 'off', + '@typescript-eslint/max-params': 'off', + '@typescript-eslint/no-array-constructor': 'off', + '@typescript-eslint/no-confusing-non-null-assertion': 'off', + '@typescript-eslint/no-dupe-class-members': 'off', + '@typescript-eslint/no-duplicate-enum-values': 'off', + '@typescript-eslint/no-dynamic-delete': 'off', + '@typescript-eslint/no-empty-function': '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-loss-of-precision': 'off', + '@typescript-eslint/no-magic-numbers': '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-redeclare': 'off', + '@typescript-eslint/no-this-alias': 'off', + '@typescript-eslint/no-unnecessary-type-constraint': 'off', + '@typescript-eslint/no-unsafe-declaration-merging': 'off', + '@typescript-eslint/no-unsafe-function-type': 'off', + '@typescript-eslint/no-unused-vars': 'off', + '@typescript-eslint/no-useless-constructor': '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', +} as const; + const unicornRules = { 'unicorn/catch-error-name': 'off', 'unicorn/consistent-empty-array-spread': 'off', @@ -482,7 +482,6 @@ const vitestRules = { export { eslintRules, - typescriptRules, importRules, jestRules, jsdocRules, @@ -494,6 +493,7 @@ export { reactHooksRules, reactPerfRules, treeShakingRules, + typescriptRules, unicornRules, vitestRules, };