mirror of
https://github.com/denoland/deno.git
synced 2025-03-04 09:57:11 -05:00
fix(lint): don't mark plugin diagnostic as fixable, if it's not (#28147)
A vector with fixes was always created, even if there were no applicable fixes.
This commit is contained in:
parent
70d775c57d
commit
1f169f4b09
6 changed files with 48 additions and 4 deletions
|
@ -146,10 +146,14 @@ impl LintPluginContainer {
|
||||||
})
|
})
|
||||||
.collect::<Result<Vec<LintFixChange>, LintReportError>>()?;
|
.collect::<Result<Vec<LintFixChange>, LintReportError>>()?;
|
||||||
|
|
||||||
let fixes = vec![LintFix {
|
let mut fixes = vec![];
|
||||||
changes,
|
|
||||||
description: format!("Fix this {} problem", id).into(),
|
if !changes.is_empty() {
|
||||||
}];
|
fixes.push(LintFix {
|
||||||
|
changes,
|
||||||
|
description: format!("Fix this {} problem", id).into(),
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
let lint_diagnostic = LintDiagnostic {
|
let lint_diagnostic = LintDiagnostic {
|
||||||
specifier,
|
specifier,
|
||||||
|
|
6
tests/specs/lint/lint_plugin_no_fixer/__test__.jsonc
Normal file
6
tests/specs/lint/lint_plugin_no_fixer/__test__.jsonc
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
{
|
||||||
|
"tempDir": true,
|
||||||
|
"args": "lint a.ts",
|
||||||
|
"output": "lint.out",
|
||||||
|
"exitCode": 1
|
||||||
|
}
|
1
tests/specs/lint/lint_plugin_no_fixer/a.ts
Normal file
1
tests/specs/lint/lint_plugin_no_fixer/a.ts
Normal file
|
@ -0,0 +1 @@
|
||||||
|
const _a = "foo";
|
5
tests/specs/lint/lint_plugin_no_fixer/deno.json
Normal file
5
tests/specs/lint/lint_plugin_no_fixer/deno.json
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
{
|
||||||
|
"lint": {
|
||||||
|
"plugins": ["./plugin.ts"]
|
||||||
|
}
|
||||||
|
}
|
9
tests/specs/lint/lint_plugin_no_fixer/lint.out
Normal file
9
tests/specs/lint/lint_plugin_no_fixer/lint.out
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
error[test-plugin/my-rule]: should be _b
|
||||||
|
--> [WILDCARD]a.ts:1:7
|
||||||
|
|
|
||||||
|
1 | const _a = "foo";
|
||||||
|
| ^^
|
||||||
|
|
||||||
|
|
||||||
|
Found 1 problem
|
||||||
|
Checked 1 file
|
19
tests/specs/lint/lint_plugin_no_fixer/plugin.ts
Normal file
19
tests/specs/lint/lint_plugin_no_fixer/plugin.ts
Normal file
|
@ -0,0 +1,19 @@
|
||||||
|
export default {
|
||||||
|
name: "test-plugin",
|
||||||
|
rules: {
|
||||||
|
"my-rule": {
|
||||||
|
create(context) {
|
||||||
|
return {
|
||||||
|
Identifier(node) {
|
||||||
|
if (node.name === "_a") {
|
||||||
|
context.report({
|
||||||
|
node,
|
||||||
|
message: "should be _b",
|
||||||
|
});
|
||||||
|
}
|
||||||
|
},
|
||||||
|
};
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
};
|
Loading…
Add table
Reference in a new issue