Skip to content

Commit

Permalink
feat(builtins): refactor @eslint rule loading
Browse files Browse the repository at this point in the history
  • Loading branch information
chiefmikey committed May 21, 2024
1 parent 93f567b commit d8a2896
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,16 @@ const convertPluginId = (pluginId: string) => {
pluginId.replace(/^eslint-plugin-/u, '');
};

// disable builtin rules
const builtinRules = linter.getRules();
for (const [ruleId, rule] of builtinRules) {
disabledRules[ruleId] = disableFix(_.cloneDeep(rule));
// read eslint rules
const eslintRules = fs
.readdirSync(path.join(dirname, nodeModules, '@eslint'))
.filter((rule) => rule.startsWith('eslint-rule'));

// import eslint rules
for (const rule of eslintRules) {
const rulePath = path.posix.join('@eslint', rule);
const importedRule = require(rulePath) as Rule.RuleModule;
disabledRules[rule] = disableFix(_.cloneDeep(importedRule));
}

// read eslint plugins
Expand Down

0 comments on commit d8a2896

Please sign in to comment.