Skip to content

Commit

Permalink
feat: add config name for better debug (#140)
Browse files Browse the repository at this point in the history
we can have a rule set name while inspect eslint config by `npx eslint
--inspect-config`

![CleanShot 2024-08-16 at 10 46
44@2x](https://github.com/user-attachments/assets/1506274b-1103-4104-add0-612ab1598d01)
  • Loading branch information
BBboy01 authored Aug 16, 2024
1 parent 2939d63 commit 2170d8a
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
4 changes: 4 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,21 @@ const allRules: Record<string, string> = Object.assign(
export default {
configs: {
recommended: {
name: 'oxlint ignore rules recommended',
plugins: ['oxlint'],
rules: ruleMapsByCategory.correctnessRules,
},
all: {
name: 'oxlint ignore rules all',
plugins: ['oxlint'],
rules: allRules,
},
'flat/all': {
name: 'oxlint ignore rules all',
rules: allRules,
},
'flat/recommended': {
name: 'oxlint ignore rules recommended',
rules: ruleMapsByCategory.correctnessRules,
},
...createFlatRulesConfig(ruleMapsByScope),
Expand Down
8 changes: 6 additions & 2 deletions src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,12 @@ export function createFlatRulesConfig(rulesModule: { [key: string]: unknown }) {
for (const key of Object.keys(rulesModule)) {
if (key.endsWith('Rules')) {
// Ensure the property is a rules set
const flatKey = `flat/${kebabCase(key.replace('Rules', ''))}`; // Create the new key
flatRulesConfig[flatKey] = { rules: rulesModule[key] }; // Assign the rules to the new key
const ruleName = kebabCase(key.replace('Rules', ''));
const flatKey = `flat/${ruleName}`; // Create the new key
flatRulesConfig[flatKey] = {
name: `oxlint/${ruleName}`,
rules: rulesModule[key],
}; // Assign the rules to the new key
}
}

Expand Down

0 comments on commit 2170d8a

Please sign in to comment.