feat(linter): disable no-unused-labels for svelte (#1919)

This commit is contained in:
Boshen 2024-01-07 00:25:52 +08:00 committed by GitHub
parent f2ed83ca3b
commit c2e8ef56a5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 21 additions and 0 deletions

View file

@ -1,5 +1,23 @@
<script>
debugger;
export let title;
export let person;
// this will update `document.title` whenever
// the `title` prop changes
$: document.title = title;
$: {
console.log(`multiple statements can be combined`);
console.log(`the current title is ${title}`);
}
// this will update `name` when 'person' changes
$: ({ name } = person);
// don't do this. it will run before the previous line
let name2 = name;
</script>
<h1>Hello {name}!</h1>

View file

@ -42,6 +42,9 @@ declare_oxc_lint!(
impl Rule for NoUnusedLabels {
fn run_once(&self, ctx: &LintContext) {
if ctx.file_path().extension().is_some_and(|ext| ext == "svelte") {
return;
}
for id in ctx.semantic().unused_labels() {
let node = ctx.semantic().nodes().get_node(*id);
if let AstKind::LabeledStatement(stmt) = node.kind() {