Skip to content

🐛 svelte attribute shorthand isn't recognized #10671

Description

@machadinhos

Environment information

Details
CLI:
  Version:                      2.5.0
  Color support:                true

Platform:
  CPU Architecture:             x86_64
  OS:                           windows

Environment:
  BIOME_DISTRIBUTION:                npm
  BIOME_LOG_PATH:                    unset
  BIOME_LOG_PREFIX_NAME:             unset
  BIOME_LOG_LEVEL:                   unset
  BIOME_LOG_KIND:                    unset
  BIOME_CONFIG_PATH:                 unset
  BIOME_THREADS:                     unset
  BIOME_WATCHER_KIND:                unset
  BIOME_WATCHER_POLLING_INTERVAL:    unset
  NO_COLOR:                     unset
  TERM:                         xterm-256color
  JS_RUNTIME_VERSION:           v26.3.0
  JS_RUNTIME_NAME:              node
  NODE_PACKAGE_MANAGER:         pnpm/11.5.3

Biome Configuration:
  Status:                       Loaded successfully.
  Path:                         biome.json
  Formatter enabled:            true
  Linter enabled:               true
  Assist enabled:               true
  VCS enabled:                  true
  HTML full support enabled:    true

Workspace:
  Open Documents:               0

What happened?

Hi!

Here are the steps to reproduce:

  1. enable this in biome.json:
{
 "html": {
  "experimentalFullSupportEnabled": true,
  "formatter": {
    "enabled": true,
    "indentScriptAndStyle": true
  }
},
  1. create a .svelte file with these contents:
<script lang="ts">
  const href = "example.com";
</script>

<a {href}>test</a>

Because the href variable has the same name as the href attribute, we can use the shorthand attribute syntax to avoid writing href={href} instead we just write {href}.
This is a core svelte feature and in fact if you run the biome format command this<a href={href}>test</a> is turned into <a {href}>test</a>.

The following rule is triggered:
Provide a href attribute for the a element. (biome lint/a11y/useValidAnchor)

Thank you!

Expected result

lint/a11y/useValidAnchor rule should not be triggered.

Code of Conduct

  • I agree to follow Biome's Code of Conduct

Metadata

Metadata

Assignees

Labels

A-LinterArea: linterL-HTMLLanguage: HTML and super languagesS-Bug-confirmedStatus: report has been confirmed as a valid bug

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions