Skip to content

Commit

Permalink
fix(plugin-eslint): parse rule names containing slashes correctly
Browse files Browse the repository at this point in the history
  • Loading branch information
matejchalk committed Dec 17, 2024
1 parent 9d6eacf commit f1163d0
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
4 changes: 3 additions & 1 deletion packages/plugin-eslint/src/lib/meta/parse.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@ export type RuleData = {
};

export function parseRuleId(ruleId: string): { plugin?: string; name: string } {
const i = ruleId.lastIndexOf('/');
const i = ruleId.startsWith('@')
? ruleId.lastIndexOf('/')
: ruleId.indexOf('/');
if (i === -1) {
return { name: ruleId };
}
Expand Down
5 changes: 5 additions & 0 deletions packages/plugin-eslint/src/lib/meta/parse.unit.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,11 @@ describe('parseRuleId', () => {
plugin: '@angular-eslint/template',
name: 'no-negated-async',
},
{
ruleId: 'n/prefer-promises/fs',
plugin: 'n',
name: 'prefer-promises/fs',
},
])('$ruleId => name: $name, plugin: $plugin', ({ ruleId, name, plugin }) => {
expect(parseRuleId(ruleId)).toEqual({ name, plugin });
});
Expand Down

0 comments on commit f1163d0

Please sign in to comment.