-
-
Notifications
You must be signed in to change notification settings - Fork 867
feat(linter/no-unused-vars): add experimental fix mode controls (off|suggestion|fix) #19774
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -899,6 +899,39 @@ fn test_imports() { | |
| .test_and_snapshot(); | ||
| } | ||
|
|
||
| #[test] | ||
| fn test_fix_options() { | ||
| let pass = vec![]; | ||
| let fail = vec![ | ||
| ("import foo from './foo';", Some(json!([{ "fix": { "imports": "off" } }]))), | ||
| ("let a = 1;", Some(json!([{ "fix": { "variables": "off" } }]))), | ||
| ]; | ||
|
|
||
| let fix = vec![ | ||
| ( | ||
| "let a = 1;", | ||
| "", | ||
| Some(json!([{ "fix": { "imports": "off" } }])), | ||
| FixKind::DangerousSuggestion, | ||
| ), | ||
| ( | ||
| "import foo from './foo';", | ||
| "", | ||
| Some(json!([{ "fix": { "variables": "off" } }])), | ||
| FixKind::DangerousSuggestion, | ||
| ), | ||
| ( | ||
| "import foo from './foo';", | ||
| "", | ||
| Some(json!([{ "fix": { "imports": "fix" } }])), | ||
| FixKind::DangerousFix, | ||
| ), | ||
| ("let a = 1;", "", Some(json!([{ "fix": { "variables": "fix" } }])), FixKind::DangerousFix), | ||
| ]; | ||
|
|
||
| Tester::new(NoUnusedVars::NAME, NoUnusedVars::PLUGIN, pass, fail).expect_fix(fix).test(); | ||
| } | ||
|
Comment on lines
+902
to
+933
|
||
|
|
||
| #[test] | ||
| fn test_used_declarations() { | ||
| let pass = vec![ | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
parse_fix_modeonly accepts string values ("off" | "suggestion" | "fix"), but the fallback error message says "Expected a boolean or string". This is misleading when users pass an invalid type (e.g. number/bool). Update the message to reflect the actual accepted types (e.g. "Expected a string") or add explicit boolean handling if booleans are intended to be supported.