Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(lint): don't mark plugin diagnostic as fixable, if it's not #28147

Merged
merged 3 commits into from
Feb 17, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions cli/ops/lint.rs
Original file line number Diff line number Diff line change
Expand Up @@ -146,10 +146,14 @@ impl LintPluginContainer {
})
.collect::<Result<Vec<LintFixChange>, LintReportError>>()?;

let fixes = vec![LintFix {
changes,
description: format!("Fix this {} problem", id).into(),
}];
let mut fixes = vec![];

if !changes.is_empty() {
fixes.push(LintFix {
changes,
description: format!("Fix this {} problem", id).into(),
});
}

let lint_diagnostic = LintDiagnostic {
specifier,
Expand Down
6 changes: 6 additions & 0 deletions tests/specs/lint/lint_plugin_no_fixer/__test__.jsonc
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"tempDir": true,
"args": "lint a.ts",
"output": "lint.out",
"exitCode": 1
}
1 change: 1 addition & 0 deletions tests/specs/lint/lint_plugin_no_fixer/a.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
const _a = "foo";
5 changes: 5 additions & 0 deletions tests/specs/lint/lint_plugin_no_fixer/deno.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"lint": {
"plugins": ["./plugin.ts"]
}
}
9 changes: 9 additions & 0 deletions tests/specs/lint/lint_plugin_no_fixer/lint.out
Original file line number Diff line number Diff line change
@@ -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 changes: 19 additions & 0 deletions tests/specs/lint/lint_plugin_no_fixer/plugin.ts
Original file line number Diff line number Diff line change
@@ -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",
});
}
},
};
},
},
},
};