Skip to content

Commit 2704ef0

Browse files
committed
refactor(linter): store ExternalRuleId in OxlintOverrides not raw names
1 parent 85a34ce commit 2704ef0

File tree

5 files changed

+51
-0
lines changed

5 files changed

+51
-0
lines changed

napi/oxlint2/test/__snapshots__/e2e.test.ts.snap

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -364,6 +364,13 @@ Found 0 warnings and 6 errors.
364364
Finished in Xms on 2 files using X threads."
365365
`;
366366

367+
exports[`oxlint2 CLI > should report an error if a a rule is not found within a custom plugin (via overrides) 1`] = `
368+
"Failed to build configuration.
369+
370+
x Rule 'missing' not found in plugin 'basic-custom-plugin'
371+
"
372+
`;
373+
367374
exports[`oxlint2 CLI > should report an error if a custom plugin cannot be loaded 1`] = `
368375
"Failed to parse configuration file.
369376

napi/oxlint2/test/e2e.test.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,15 @@ describe('oxlint2 CLI', () => {
8484
expect(normalizeOutput(stdout)).toMatchSnapshot();
8585
});
8686

87+
it('should report an error if a a rule is not found within a custom plugin (via overrides)', async () => {
88+
const { stdout, exitCode } = await runOxlint(
89+
'test/fixtures/custom_plugin_via_overrides_missing_rule',
90+
);
91+
92+
expect(exitCode).toBe(1);
93+
expect(normalizeOutput(stdout)).toMatchSnapshot();
94+
});
95+
8796
it('should report the correct severity when using a custom plugin', async () => {
8897
const { stdout, exitCode } = await runOxlint(
8998
'test/fixtures/basic_custom_plugin_warn_severity',
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{
2+
"rules": {
3+
"no-debugger": "off",
4+
},
5+
"overrides": [
6+
{
7+
"files": ["*.js"],
8+
"plugins": ["./test_plugin"],
9+
"rules": {
10+
"basic-custom-plugin/missing": "error"
11+
}
12+
}
13+
],
14+
"ignorePatterns": ["test_plugin"]
15+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
debugger;
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
export default {
2+
meta: {
3+
name: "basic-custom-plugin",
4+
},
5+
rules: {
6+
"no-debugger": {
7+
create(context) {
8+
return {
9+
DebuggerStatement(debuggerStatement) {
10+
context.report({
11+
message: "Unexpected Debugger Statement",
12+
node: debuggerStatement,
13+
});
14+
},
15+
};
16+
},
17+
},
18+
},
19+
};

0 commit comments

Comments
 (0)