mirror of
https://github.com/danbulant/oxc
synced 2026-05-19 12:19:15 +00:00
fix(linter): exclude svelte files from no_unused_vars rule (#8170)
This commit is contained in:
parent
cfb51f2551
commit
f3050d4f31
2 changed files with 4 additions and 4 deletions
|
|
@ -628,7 +628,7 @@ mod test {
|
|||
let args = &["fixtures/svelte/debugger.svelte"];
|
||||
let result = test(args);
|
||||
assert_eq!(result.number_of_files, 1);
|
||||
assert_eq!(result.number_of_warnings, 2);
|
||||
assert_eq!(result.number_of_warnings, 1);
|
||||
assert_eq!(result.number_of_errors, 0);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -214,12 +214,12 @@ impl Rule for NoUnusedVars {
|
|||
}
|
||||
|
||||
fn should_run(&self, ctx: &ContextHost) -> bool {
|
||||
// ignore .d.ts and vue files.
|
||||
// ignore .d.ts and vue/svelte files.
|
||||
// 1. declarations have side effects (they get merged together)
|
||||
// 2. vue scripts declare variables that get used in the template, which
|
||||
// 2. vue/svelte scripts declare variables that get used in the template, which
|
||||
// we can't detect
|
||||
!ctx.source_type().is_typescript_definition()
|
||||
&& !ctx.file_path().extension().is_some_and(|ext| ext == "vue")
|
||||
&& !ctx.file_path().extension().is_some_and(|ext| ext == "vue" || ext == "svelte")
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue