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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

馃拝 Svelte Reactive Blocks marked as Unexpected/Unused #2571

Closed
1 task done
helloimalastair opened this issue Apr 23, 2024 · 5 comments 路 Fixed by #2692
Closed
1 task done

馃拝 Svelte Reactive Blocks marked as Unexpected/Unused #2571

helloimalastair opened this issue Apr 23, 2024 · 5 comments 路 Fixed by #2692
Assignees
Labels
S-Needs discussion Status: needs a discussion to understand criteria

Comments

@helloimalastair
Copy link

helloimalastair commented Apr 23, 2024

Environment information

CLI:
  Version:                      1.7.1
  Color support:                true

Platform:
  CPU Architecture:             aarch64
  OS:                           macos

Environment:
  BIOME_LOG_DIR:                unset
  NO_COLOR:                     unset
  TERM:                         "xterm-256color"
  JS_RUNTIME_VERSION:           "v21.7.3"
  JS_RUNTIME_NAME:              "node"
  NODE_PACKAGE_MANAGER:         "pnpm/9.0.5"

Biome Configuration:
  Status:                       Loaded successfully
  Formatter disabled:           false
  Linter disabled:              false
  Organize imports disabled:    false
  VCS disabled:                 false

Linter:
  Recommended:                  true
  All:                          false
  Rules:
Workspace:
  Open Documents:               0

Rule names

lint/suspicious/noConfusingLabels, lint/correctness/noUnusedLabels

Playground link

https://biomejs.dev/playground/?code=JAA6ACAAewAKACAAIABjAG8AbgBzAG8AbABlAC4AbABvAGcAKAAiAEkAJwBtACAAaQBuACAAYQAgAHIAZQBhAGMAdABpAHYAZQAgAGIAbABvAGMAawAhACIAKQAKAH0A

Expected result

While in a Svelte Code Block, a Reactive Block

$: {
	console.log(someData);
};

can be defined, which will trigger whenever its variables change. In this case, Biome is marking the $ symbol as an Unepected/Unused label, which can cause it to be removed with --apply.

I would expect the $ symbol to be an allowed symbol in the context of Svelte Code Blocks, and thus allowed to exist.

Code of Conduct

  • I agree to follow Biome's Code of Conduct
@ematipico ematipico added the S-Needs discussion Status: needs a discussion to understand criteria label Apr 23, 2024
@ematipico
Copy link
Member

We have two options here:

  • Document the caveat on the website, and tell people to disable the rules themselves;
  • We start disabling rules based on file extension. For example, we would need to disable other rules for other files, such as noUnusedVariables for Astro files. And noUnusedImports for all vue/astro/svelte files

@Conaclos
Copy link
Member

We start disabling rules based on file extension. For example, we would need to disable other rules for other files, such as noUnusedVariables for Astro files. And noUnusedImports for all vue/astro/svelte files

One caveat of this approach is that users cannot enable a rule if they want to.

I see a third approach: providing a default config file where we have an overrides that disable some rules for a given extension.

@ematipico
Copy link
Member

One caveat of this approach is that users cannot enable a rule if they want to.

how would a user need to use a rule that triggers false positives?

@Conaclos
Copy link
Member

Conaclos commented May 3, 2024

how would a user need to use a rule that triggers false positives?

Because all labels are not labels that indicate a reactive statement?
We completely lose the interest of the rule.

I think a better strategy is just ignoring labels named $ in svelte components.
This is what I did in #2692

@ematipico
Copy link
Member

Fair point

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-Needs discussion Status: needs a discussion to understand criteria
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants