From c26022a41fd654e5cf68a7138f1b78124eaab281 Mon Sep 17 00:00:00 2001 From: Sysix Date: Thu, 24 Oct 2024 20:52:49 +0200 Subject: [PATCH] feat: add buildFromOxlintConfig --- .../oxlint-simple-plugin-default.json | 1 + src/__mocks__/oxlint-simple-plugin.json | 3 + .../build-from-oxlint-config.spec.ts.snap | 392 ++++++++++++++++++ src/build-from-oxlint-config.spec.ts | 34 +- src/build-from-oxlint-config.ts | 23 + 5 files changed, 451 insertions(+), 2 deletions(-) create mode 100644 src/__mocks__/oxlint-simple-plugin-default.json create mode 100644 src/__mocks__/oxlint-simple-plugin.json diff --git a/src/__mocks__/oxlint-simple-plugin-default.json b/src/__mocks__/oxlint-simple-plugin-default.json new file mode 100644 index 0000000..0967ef4 --- /dev/null +++ b/src/__mocks__/oxlint-simple-plugin-default.json @@ -0,0 +1 @@ +{} diff --git a/src/__mocks__/oxlint-simple-plugin.json b/src/__mocks__/oxlint-simple-plugin.json new file mode 100644 index 0000000..9a7f8b6 --- /dev/null +++ b/src/__mocks__/oxlint-simple-plugin.json @@ -0,0 +1,3 @@ +{ + "plugins": ["unicorn"] +} diff --git a/src/__snapshots__/build-from-oxlint-config.spec.ts.snap b/src/__snapshots__/build-from-oxlint-config.spec.ts.snap index f7e232a..9d2ee5c 100644 --- a/src/__snapshots__/build-from-oxlint-config.spec.ts.snap +++ b/src/__snapshots__/build-from-oxlint-config.spec.ts.snap @@ -2,14 +2,51 @@ exports[`detects active categories and append its rules > simpleCategoryActive 1`] = ` { + "@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-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", "import/default": "off", "import/named": "off", @@ -107,24 +144,379 @@ exports[`detects active categories and append its rules > simpleCategoryActive 1 "no-with": "off", "promise/no-callback-in-promise": "off", "promise/valid-params": "off", + "react/button-has-type": "off", + "react/checked-requires-onchange-or-readonly": "off", + "react/iframe-missing-sandbox": "off", + "react/jsx-boolean-value": "off", + "react/jsx-curly-brace-presence": "off", "react/jsx-key": "off", + "react/jsx-no-comment-textnodes": "off", "react/jsx-no-duplicate-props": "off", "react/jsx-no-target-blank": "off", "react/jsx-no-undef": "off", + "react/jsx-no-useless-fragment": "off", + "react/jsx-props-no-spread-multi": "off", "react/no-children-prop": "off", + "react/no-danger": "off", "react/no-danger-with-children": "off", "react/no-direct-mutation-state": "off", "react/no-find-dom-node": "off", "react/no-is-mounted": "off", "react/no-render-return-value": "off", + "react/no-set-state": "off", "react/no-string-refs": "off", + "react/no-unescaped-entities": "off", + "react/no-unknown-property": "off", + "react/prefer-es6-class": "off", + "react/react-in-jsx-scope": "off", + "react/require-render-return": "off", + "react/rules-of-hooks": "off", + "react/self-closing-comp": "off", "react/void-dom-elements-no-children": "off", "require-yield": "off", + "unicorn/catch-error-name": "off", + "unicorn/consistent-function-scoping": "off", + "unicorn/empty-brace-spaces": "off", + "unicorn/error-message": "off", + "unicorn/escape-case": "off", + "unicorn/explicit-length-check": "off", + "unicorn/filename-case": "off", + "unicorn/new-for-builtins": "off", + "unicorn/no-abusive-eslint-disable": "off", + "unicorn/no-anonymous-default-export": "off", + "unicorn/no-array-for-each": "off", + "unicorn/no-array-reduce": "off", + "unicorn/no-await-expression-member": "off", "unicorn/no-await-in-promise-methods": "off", + "unicorn/no-console-spaces": "off", "unicorn/no-document-cookie": "off", "unicorn/no-empty-file": "off", + "unicorn/no-hex-escape": "off", + "unicorn/no-instanceof-array": "off", "unicorn/no-invalid-remove-event-listener": "off", + "unicorn/no-length-as-slice-end": "off", + "unicorn/no-lonely-if": "off", + "unicorn/no-magic-array-flat-depth": "off", + "unicorn/no-negated-condition": "off", + "unicorn/no-negation-in-equality-check": "off", + "unicorn/no-nested-ternary": "off", + "unicorn/no-new-array": "off", + "unicorn/no-new-buffer": "off", + "unicorn/no-null": "off", + "unicorn/no-object-as-default-parameter": "off", + "unicorn/no-process-exit": "off", + "unicorn/no-single-promise-in-promise-methods": "off", + "unicorn/no-static-only-class": "off", "unicorn/no-thenable": "off", + "unicorn/no-this-assignment": "off", + "unicorn/no-typeof-undefined": "off", + "unicorn/no-unnecessary-await": "off", + "unicorn/no-unreadable-array-destructuring": "off", + "unicorn/no-unreadable-iife": "off", + "unicorn/no-useless-fallback-in-spread": "off", + "unicorn/no-useless-length-check": "off", + "unicorn/no-useless-promise-resolve-reject": "off", + "unicorn/no-useless-spread": "off", + "unicorn/no-useless-switch-case": "off", + "unicorn/no-useless-undefined": "off", + "unicorn/no-zero-fractions": "off", + "unicorn/number-literal-case": "off", + "unicorn/numeric-separators-style": "off", + "unicorn/prefer-add-event-listener": "off", + "unicorn/prefer-array-flat": "off", + "unicorn/prefer-array-flat-map": "off", + "unicorn/prefer-array-some": "off", + "unicorn/prefer-blob-reading-methods": "off", + "unicorn/prefer-code-point": "off", + "unicorn/prefer-date-now": "off", + "unicorn/prefer-dom-node-append": "off", + "unicorn/prefer-dom-node-dataset": "off", + "unicorn/prefer-dom-node-remove": "off", + "unicorn/prefer-dom-node-text-content": "off", + "unicorn/prefer-event-target": "off", + "unicorn/prefer-includes": "off", + "unicorn/prefer-logical-operator-over-ternary": "off", + "unicorn/prefer-math-trunc": "off", + "unicorn/prefer-modern-dom-apis": "off", + "unicorn/prefer-modern-math-apis": "off", + "unicorn/prefer-native-coercion-functions": "off", + "unicorn/prefer-node-protocol": "off", + "unicorn/prefer-number-properties": "off", + "unicorn/prefer-optional-catch-binding": "off", + "unicorn/prefer-prototype-methods": "off", + "unicorn/prefer-query-selector": "off", + "unicorn/prefer-reflect-apply": "off", + "unicorn/prefer-regexp-test": "off", + "unicorn/prefer-set-size": "off", + "unicorn/prefer-spread": "off", + "unicorn/prefer-string-replace-all": "off", + "unicorn/prefer-string-slice": "off", + "unicorn/prefer-string-starts-ends-with": "off", + "unicorn/prefer-string-trim-start-end": "off", + "unicorn/prefer-structured-clone": "off", + "unicorn/prefer-type-error": "off", + "unicorn/require-array-join-separator": "off", + "unicorn/require-number-to-fixed-digits-argument": "off", + "unicorn/switch-case-braces": "off", + "unicorn/text-encoding-identifier-case": "off", + "unicorn/throw-new-error": "off", "vitest/no-conditional-tests": "off", } `; + +exports[`detects plugin and append its rules > detectPluginRules 1`] = ` +{ + "unicorn/catch-error-name": "off", + "unicorn/consistent-function-scoping": "off", + "unicorn/empty-brace-spaces": "off", + "unicorn/error-message": "off", + "unicorn/escape-case": "off", + "unicorn/explicit-length-check": "off", + "unicorn/filename-case": "off", + "unicorn/new-for-builtins": "off", + "unicorn/no-abusive-eslint-disable": "off", + "unicorn/no-anonymous-default-export": "off", + "unicorn/no-array-for-each": "off", + "unicorn/no-array-reduce": "off", + "unicorn/no-await-expression-member": "off", + "unicorn/no-await-in-promise-methods": "off", + "unicorn/no-console-spaces": "off", + "unicorn/no-document-cookie": "off", + "unicorn/no-empty-file": "off", + "unicorn/no-hex-escape": "off", + "unicorn/no-instanceof-array": "off", + "unicorn/no-invalid-remove-event-listener": "off", + "unicorn/no-length-as-slice-end": "off", + "unicorn/no-lonely-if": "off", + "unicorn/no-magic-array-flat-depth": "off", + "unicorn/no-negated-condition": "off", + "unicorn/no-negation-in-equality-check": "off", + "unicorn/no-nested-ternary": "off", + "unicorn/no-new-array": "off", + "unicorn/no-new-buffer": "off", + "unicorn/no-null": "off", + "unicorn/no-object-as-default-parameter": "off", + "unicorn/no-process-exit": "off", + "unicorn/no-single-promise-in-promise-methods": "off", + "unicorn/no-static-only-class": "off", + "unicorn/no-thenable": "off", + "unicorn/no-this-assignment": "off", + "unicorn/no-typeof-undefined": "off", + "unicorn/no-unnecessary-await": "off", + "unicorn/no-unreadable-array-destructuring": "off", + "unicorn/no-unreadable-iife": "off", + "unicorn/no-useless-fallback-in-spread": "off", + "unicorn/no-useless-length-check": "off", + "unicorn/no-useless-promise-resolve-reject": "off", + "unicorn/no-useless-spread": "off", + "unicorn/no-useless-switch-case": "off", + "unicorn/no-useless-undefined": "off", + "unicorn/no-zero-fractions": "off", + "unicorn/number-literal-case": "off", + "unicorn/numeric-separators-style": "off", + "unicorn/prefer-add-event-listener": "off", + "unicorn/prefer-array-flat": "off", + "unicorn/prefer-array-flat-map": "off", + "unicorn/prefer-array-some": "off", + "unicorn/prefer-blob-reading-methods": "off", + "unicorn/prefer-code-point": "off", + "unicorn/prefer-date-now": "off", + "unicorn/prefer-dom-node-append": "off", + "unicorn/prefer-dom-node-dataset": "off", + "unicorn/prefer-dom-node-remove": "off", + "unicorn/prefer-dom-node-text-content": "off", + "unicorn/prefer-event-target": "off", + "unicorn/prefer-includes": "off", + "unicorn/prefer-logical-operator-over-ternary": "off", + "unicorn/prefer-math-trunc": "off", + "unicorn/prefer-modern-dom-apis": "off", + "unicorn/prefer-modern-math-apis": "off", + "unicorn/prefer-native-coercion-functions": "off", + "unicorn/prefer-node-protocol": "off", + "unicorn/prefer-number-properties": "off", + "unicorn/prefer-optional-catch-binding": "off", + "unicorn/prefer-prototype-methods": "off", + "unicorn/prefer-query-selector": "off", + "unicorn/prefer-reflect-apply": "off", + "unicorn/prefer-regexp-test": "off", + "unicorn/prefer-set-size": "off", + "unicorn/prefer-spread": "off", + "unicorn/prefer-string-replace-all": "off", + "unicorn/prefer-string-slice": "off", + "unicorn/prefer-string-starts-ends-with": "off", + "unicorn/prefer-string-trim-start-end": "off", + "unicorn/prefer-structured-clone": "off", + "unicorn/prefer-type-error": "off", + "unicorn/require-array-join-separator": "off", + "unicorn/require-number-to-fixed-digits-argument": "off", + "unicorn/switch-case-braces": "off", + "unicorn/text-encoding-identifier-case": "off", + "unicorn/throw-new-error": "off", +} +`; + +exports[`enables default plugin rules (react, unicorn, typescript) > defaultPluginRules 1`] = ` +{ + "@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-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", + "react/button-has-type": "off", + "react/checked-requires-onchange-or-readonly": "off", + "react/iframe-missing-sandbox": "off", + "react/jsx-boolean-value": "off", + "react/jsx-curly-brace-presence": "off", + "react/jsx-key": "off", + "react/jsx-no-comment-textnodes": "off", + "react/jsx-no-duplicate-props": "off", + "react/jsx-no-target-blank": "off", + "react/jsx-no-undef": "off", + "react/jsx-no-useless-fragment": "off", + "react/jsx-props-no-spread-multi": "off", + "react/no-children-prop": "off", + "react/no-danger": "off", + "react/no-danger-with-children": "off", + "react/no-direct-mutation-state": "off", + "react/no-find-dom-node": "off", + "react/no-is-mounted": "off", + "react/no-render-return-value": "off", + "react/no-set-state": "off", + "react/no-string-refs": "off", + "react/no-unescaped-entities": "off", + "react/no-unknown-property": "off", + "react/prefer-es6-class": "off", + "react/react-in-jsx-scope": "off", + "react/require-render-return": "off", + "react/rules-of-hooks": "off", + "react/self-closing-comp": "off", + "react/void-dom-elements-no-children": "off", + "unicorn/catch-error-name": "off", + "unicorn/consistent-function-scoping": "off", + "unicorn/empty-brace-spaces": "off", + "unicorn/error-message": "off", + "unicorn/escape-case": "off", + "unicorn/explicit-length-check": "off", + "unicorn/filename-case": "off", + "unicorn/new-for-builtins": "off", + "unicorn/no-abusive-eslint-disable": "off", + "unicorn/no-anonymous-default-export": "off", + "unicorn/no-array-for-each": "off", + "unicorn/no-array-reduce": "off", + "unicorn/no-await-expression-member": "off", + "unicorn/no-await-in-promise-methods": "off", + "unicorn/no-console-spaces": "off", + "unicorn/no-document-cookie": "off", + "unicorn/no-empty-file": "off", + "unicorn/no-hex-escape": "off", + "unicorn/no-instanceof-array": "off", + "unicorn/no-invalid-remove-event-listener": "off", + "unicorn/no-length-as-slice-end": "off", + "unicorn/no-lonely-if": "off", + "unicorn/no-magic-array-flat-depth": "off", + "unicorn/no-negated-condition": "off", + "unicorn/no-negation-in-equality-check": "off", + "unicorn/no-nested-ternary": "off", + "unicorn/no-new-array": "off", + "unicorn/no-new-buffer": "off", + "unicorn/no-null": "off", + "unicorn/no-object-as-default-parameter": "off", + "unicorn/no-process-exit": "off", + "unicorn/no-single-promise-in-promise-methods": "off", + "unicorn/no-static-only-class": "off", + "unicorn/no-thenable": "off", + "unicorn/no-this-assignment": "off", + "unicorn/no-typeof-undefined": "off", + "unicorn/no-unnecessary-await": "off", + "unicorn/no-unreadable-array-destructuring": "off", + "unicorn/no-unreadable-iife": "off", + "unicorn/no-useless-fallback-in-spread": "off", + "unicorn/no-useless-length-check": "off", + "unicorn/no-useless-promise-resolve-reject": "off", + "unicorn/no-useless-spread": "off", + "unicorn/no-useless-switch-case": "off", + "unicorn/no-useless-undefined": "off", + "unicorn/no-zero-fractions": "off", + "unicorn/number-literal-case": "off", + "unicorn/numeric-separators-style": "off", + "unicorn/prefer-add-event-listener": "off", + "unicorn/prefer-array-flat": "off", + "unicorn/prefer-array-flat-map": "off", + "unicorn/prefer-array-some": "off", + "unicorn/prefer-blob-reading-methods": "off", + "unicorn/prefer-code-point": "off", + "unicorn/prefer-date-now": "off", + "unicorn/prefer-dom-node-append": "off", + "unicorn/prefer-dom-node-dataset": "off", + "unicorn/prefer-dom-node-remove": "off", + "unicorn/prefer-dom-node-text-content": "off", + "unicorn/prefer-event-target": "off", + "unicorn/prefer-includes": "off", + "unicorn/prefer-logical-operator-over-ternary": "off", + "unicorn/prefer-math-trunc": "off", + "unicorn/prefer-modern-dom-apis": "off", + "unicorn/prefer-modern-math-apis": "off", + "unicorn/prefer-native-coercion-functions": "off", + "unicorn/prefer-node-protocol": "off", + "unicorn/prefer-number-properties": "off", + "unicorn/prefer-optional-catch-binding": "off", + "unicorn/prefer-prototype-methods": "off", + "unicorn/prefer-query-selector": "off", + "unicorn/prefer-reflect-apply": "off", + "unicorn/prefer-regexp-test": "off", + "unicorn/prefer-set-size": "off", + "unicorn/prefer-spread": "off", + "unicorn/prefer-string-replace-all": "off", + "unicorn/prefer-string-slice": "off", + "unicorn/prefer-string-starts-ends-with": "off", + "unicorn/prefer-string-trim-start-end": "off", + "unicorn/prefer-structured-clone": "off", + "unicorn/prefer-type-error": "off", + "unicorn/require-array-join-separator": "off", + "unicorn/require-number-to-fixed-digits-argument": "off", + "unicorn/switch-case-braces": "off", + "unicorn/text-encoding-identifier-case": "off", + "unicorn/throw-new-error": "off", +} +`; diff --git a/src/build-from-oxlint-config.spec.ts b/src/build-from-oxlint-config.spec.ts index 34cad4a..1c7e3cb 100644 --- a/src/build-from-oxlint-config.spec.ts +++ b/src/build-from-oxlint-config.spec.ts @@ -1,7 +1,14 @@ import { expect, it } from 'vitest'; import buildFromOxlintConfig from './build-from-oxlint-config.js'; +import configByScope from './configs-by-scope.js'; import path from 'node:path'; +const defaultPluginRules = { + ...configByScope['flat/react'].rules, + ...configByScope['flat/unicorn'].rules, + ...configByScope['flat/typescript'].rules, +}; + it('detect active rules inside "rules" scope', () => { const rules = buildFromOxlintConfig( path.resolve( @@ -12,6 +19,7 @@ it('detect active rules inside "rules" scope', () => { ); expect(rules).toStrictEqual({ + ...defaultPluginRules, eqeqeq: 'off', }); }); @@ -25,7 +33,7 @@ it('skip deactive rules inside "rules" scope', () => { ) ); - expect(rules).toStrictEqual({}); + expect(rules).toStrictEqual(defaultPluginRules); }); it('detects active categories and append its rules', () => { @@ -50,5 +58,27 @@ it('skip deactive categories ', () => { ) ); - expect(rules).toStrictEqual({}); + expect(rules).toStrictEqual(defaultPluginRules); +}); + +it('enables default plugin rules (react, unicorn, typescript)', () => { + const rules = buildFromOxlintConfig( + path.resolve( + import.meta.dirname, + '__mocks__', + 'oxlint-simple-plugin-default.json' + ) + ); + + // snapshot because it can change with the next release + expect(rules).toMatchSnapshot('defaultPluginRules'); +}); + +it('detects plugin and append its rules', () => { + const rules = buildFromOxlintConfig( + path.resolve(import.meta.dirname, '__mocks__', 'oxlint-simple-plugin.json') + ); + + // snapshot because it can change with the next release + expect(rules).toMatchSnapshot('detectPluginRules'); }); diff --git a/src/build-from-oxlint-config.ts b/src/build-from-oxlint-config.ts index f6ba463..1091477 100644 --- a/src/build-from-oxlint-config.ts +++ b/src/build-from-oxlint-config.ts @@ -1,5 +1,6 @@ import fs from 'node:fs'; import configByCategory from './configs-by-category.js'; +import configByScope from './configs-by-scope.js'; const getConfigContent = ( oxlintConfigFile: string @@ -39,6 +40,20 @@ const appendCategoriesScope = ( } }; +const appendPluginsScope = ( + plugins: string[], + rules: Record +): void => { + for (const plugin of plugins) { + const configName = `flat/${plugin}`; + + if (configName in configByScope) { + // @ts-ignore -- come on TS, we are checking if the configName exists in the configByCategory + Object.assign(rules, configByScope[configName].rules); + } + } +}; + const appendRulesScope = ( oxlintRules: Record, rules: Record @@ -65,6 +80,14 @@ export default function buildFromOxlintConfig( appendCategoriesScope(config.categories as Record, rules); } + if ('plugins' in config && Array.isArray(config.plugins)) { + appendPluginsScope(config.plugins as string[], rules); + } else { + // default values, see + // oxc is in ignoreScope + appendPluginsScope(['react', 'unicorn', 'typescript'], rules); + } + // is there a rules objects in the json file if ( 'rules' in config &&