From a5e0f2274a6697c08e2b316ded6c3fce17166845 Mon Sep 17 00:00:00 2001 From: Alexander S Date: Thu, 20 Jun 2024 08:56:31 +0200 Subject: [PATCH] fix(docs): detect typescript alias rules and mark them as supported (#3779) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Some tpyescript rules are extensions of the core eslint rules. Now we mark them as supported :) Maybe add a info for the user about this behavior? Some discord discussion: https://discord.com/channels/1079625926024900739/1080712072012238858/1226407188650659845 ## Current State Found Aliases: - default-param-last - max-params - no-array-constructor - require-await - no-dupe-class-members - no-empty-function - no-loss-of-precision - no-redeclare - no-useless-constructor Todo: why im getting following output: ``` 👀 typescript/require-await is implemented but not found in their rules 👀 tree-shaking/no-side-effects-in-initialization is implemented but not found in their rules ``` --- tasks/lint_rules/src/eslint-rules.cjs | 4 ++++ tasks/lint_rules/src/oxlint-rules.cjs | 13 +++++++++++++ 2 files changed, 17 insertions(+) diff --git a/tasks/lint_rules/src/eslint-rules.cjs b/tasks/lint_rules/src/eslint-rules.cjs index 8068285be17c9..0ee0be1c51d59 100644 --- a/tasks/lint_rules/src/eslint-rules.cjs +++ b/tasks/lint_rules/src/eslint-rules.cjs @@ -263,3 +263,7 @@ exports.loadTargetPluginRules = (linter) => { loadPluginReactPerfRules(linter); loadPluginNextRules(linter); }; + +// some typescript rules are some extension of the basic eslint rules +// we need them later to map them for both +exports.pluginTypeScriptRulesNames = Object.keys(pluginTypeScriptAllRules); \ No newline at end of file diff --git a/tasks/lint_rules/src/oxlint-rules.cjs b/tasks/lint_rules/src/oxlint-rules.cjs index 4a6b2f65f3225..03572267beaa7 100644 --- a/tasks/lint_rules/src/oxlint-rules.cjs +++ b/tasks/lint_rules/src/oxlint-rules.cjs @@ -1,5 +1,6 @@ const { resolve } = require("node:path"); const { readFile } = require("node:fs/promises"); +const { pluginTypeScriptRulesNames } = require("./eslint-rules.cjs"); const readAllImplementedRuleNames = async () => { const rulesFile = await readFile( @@ -34,6 +35,18 @@ const readAllImplementedRuleNames = async () => { // Ignore no reference rules if (prefixedName.startsWith("oxc/")) continue; + // some tyescript rules are extensions of eslint core rules + if (prefixedName.startsWith("eslint/")) { + const ruleName = prefixedName.replace('eslint/', ''); + + // there is no alias + if (!pluginTypeScriptRulesNames.includes(ruleName)) { + continue; + } + + rules.add(`typescript/${ruleName}`); + } + rules.add(prefixedName); } }