biomejs / biome

A toolchain for web projects, aimed to provide functionalities to maintain them. Biome offers formatter and linter, usable via CLI and LSP.
https://biomejs.dev
Apache License 2.0
15.1k stars 471 forks source link

🐛 `lint/a11y/noAutofocus` contradicts with MDN recommendations for <dialog> #4339

Open andy128k opened 1 week ago

andy128k commented 1 week ago

Environment information

CLI:
  Version:                      1.9.4
  Color support:                true

Platform:
  CPU Architecture:             x86_64
  OS:                           linux

Environment:
  BIOME_LOG_PATH:               unset
  BIOME_LOG_PREFIX_NAME:        unset
  BIOME_CONFIG_PATH:            unset
  NO_COLOR:                     unset
  TERM:                         "xterm-256color"
  JS_RUNTIME_VERSION:           "v20.11.1"
  JS_RUNTIME_NAME:              "node"
  NODE_PACKAGE_MANAGER:         unset

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

Workspace:
  Open Documents:               0

What happened?

A lint/a11y/noAutofocus contradicts with MDN recommendations for

:

The autofocus attribute should be added to the element the user is expected to interact with immediately upon opening a modal dialog. If no other element involves more immediate interaction, it is recommended to add autofocus to the close button inside the dialog, or the dialog itself if the user is expected to click/activate it to dismiss.

https://developer.mozilla.org/en-US/docs/Web/HTML/Element/dialog

Code example

Expected result

It should permit autoFocus when it is used inside a dialog.

Code of Conduct

  • [X] I agree to follow Biome's Code of Conduct
ematipico commented 5 days ago

autoFocus should be valid also for elements that use the attribute popover.

Once we fix the issue, we should update the rule to be inspired and provide examples.