Skip to content

Commit

Permalink
fix(docs): detect typescript alias rules and mark them as supported (#…
Browse files Browse the repository at this point in the history
…3779)

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
```
  • Loading branch information
Sysix authored Jun 20, 2024
1 parent 24df880 commit a5e0f22
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
4 changes: 4 additions & 0 deletions tasks/lint_rules/src/eslint-rules.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
13 changes: 13 additions & 0 deletions tasks/lint_rules/src/oxlint-rules.cjs
Original file line number Diff line number Diff line change
@@ -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(
Expand Down Expand Up @@ -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);
}
}
Expand Down

0 comments on commit a5e0f22

Please sign in to comment.