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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

💅 Incorrect suggestion for <form role="search"> #4323

Open
1 task done
redbmk opened this issue Oct 17, 2024 · 0 comments
Open
1 task done

💅 Incorrect suggestion for <form role="search"> #4323

redbmk opened this issue Oct 17, 2024 · 0 comments
Labels
S-Needs triage Status: this issue needs to be triaged

Comments

@redbmk
Copy link

redbmk commented Oct 17, 2024

Environment information

CLI:
  Version:                      1.9.3
  Color support:                true

Platform:
  CPU Architecture:             aarch64
  OS:                           macos

Environment:
  BIOME_LOG_PATH:               unset
  BIOME_LOG_PREFIX_NAME:        unset
  BIOME_CONFIG_PATH:            unset
  NO_COLOR:                     unset
  TERM:                         "xterm-256color"
  JS_RUNTIME_VERSION:           "v21.5.0"
  JS_RUNTIME_NAME:              "node"
  NODE_PACKAGE_MANAGER:         "bun/1.1.30"

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

Linter:
  JavaScript enabled:           true
  JSON enabled:                 true
  CSS enabled:                  false
  GraphQL enabled:              false
  Recommended:                  true
  All:                          false
  Enabled rules:
  performance/noDelete
  suspicious/noCatchAssign
  suspicious/noUnsafeNegation
  complexity/useLiteralKeys
  correctness/noUnusedImports
  suspicious/noClassAssign
  complexity/noMultipleSpacesInRegularExpressionLiterals
  a11y/useValidLang
  complexity/noUselessEmptyExport
  suspicious/useNamespaceKeyword
  suspicious/useValidTypeof
  a11y/useValidAriaRole
  correctness/noConstantCondition
  a11y/useAriaActivedescendantWithTabindex
  suspicious/noAssignInExpressions
  style/useDefaultParameterLast
  complexity/noEmptyTypeParameters
  correctness/noConstructorReturn
  style/useSelfClosingElements
  suspicious/noDuplicateParameters
  suspicious/noDuplicateSelectorsKeyframeBlock
  correctness/noUnknownProperty
  style/useTemplate
  correctness/noUnusedLabels
  complexity/noUselessTernary
  correctness/noUnreachableSuper
  suspicious/noCompareNegZero
  suspicious/noExplicitAny
  correctness/noSwitchDeclarations
  a11y/noAutofocus
  correctness/noUnsafeOptionalChaining
  correctness/noConstAssign
  suspicious/noControlCharactersInRegex
  complexity/noUselessTypeConstraint
  style/noVar
  suspicious/noDoubleEquals
  suspicious/noRedundantUseStrict
  style/useLiteralEnumMembers
  suspicious/noGlobalIsNan
  suspicious/noEmptyInterface
  suspicious/noConstEnum
  style/useImportType
  nursery/noDuplicateElseIf
  correctness/noPrecisionLoss
  nursery/noRestrictedImports
  suspicious/noMisleadingCharacterClass
  suspicious/noRedeclare
  correctness/noStringCaseMismatch
  correctness/noSetterReturn
  correctness/noInvalidConstructorSuper
  suspicious/noImplicitAnyLet
  suspicious/noDuplicateObjectKeys
  suspicious/noFallthroughSwitchClause
  complexity/noUselessThisAlias
  correctness/noUnreachable
  a11y/useKeyWithClickEvents
  suspicious/noUnsafeDeclarationMerging
  complexity/noThisInStatic
  complexity/useOptionalChain
  correctness/noInnerDeclarations
  style/noParameterAssign
  suspicious/noDuplicateCase
  a11y/useValidAnchor
  correctness/useArrayLiterals
  complexity/useRegexLiterals
  correctness/noSelfAssign
  correctness/noInvalidBuiltinInstantiation
  style/noUselessElse
  style/useShorthandFunctionType
  suspicious/noShadowRestrictedNames
  correctness/noInvalidDirectionInLinearGradient
  suspicious/noEmptyBlockStatements
  suspicious/noImportantInKeyframe
  a11y/useMediaCaption
  complexity/noUselessLabel
  complexity/noUselessCatch
  correctness/noUnsafeFinally
  a11y/useAriaPropsForRole
  correctness/noNonoctalDecimalEscape
  style/useEnumInitializers
  a11y/useHtmlLang
  suspicious/noDuplicateTestHooks
  complexity/noStaticOnlyClass
  style/useWhile
  complexity/useArrowFunction
  style/noInferrableTypes
  a11y/noNoninteractiveTabindex
  complexity/useSimpleNumberKeys
  correctness/useYield
  a11y/noInteractiveElementToNoninteractiveRole
  style/useNumericLiterals
  correctness/noUnnecessaryContinue
  suspicious/noApproximativeNumericConstant
  suspicious/noImportAssign
  suspicious/noLabelVar
  correctness/noGlobalObjectCalls
  suspicious/useDefaultSwitchClauseLast
  correctness/noEmptyCharacterClassInRegex
  correctness/noUnknownUnit
  a11y/useAltText
  suspicious/noSuspiciousSemicolonInJsx
  a11y/useIframeTitle
  complexity/noBannedTypes
  a11y/noSvgWithoutTitle
  correctness/noVoidElementsWithChildren
  style/useAsConstAssertion
  correctness/useJsxKeyInIterable
  style/useExportType
  complexity/noUselessLoneBlockStatements
  suspicious/noDebugger
  style/noArguments
  a11y/useValidAriaValues
  suspicious/noCommentText
  a11y/useFocusableInteractive
  correctness/noUnmatchableAnbSelector
  suspicious/noGlobalAssign
  suspicious/noDuplicateJsxProps
  suspicious/noMisleadingInstantiator
  a11y/noPositiveTabindex
  correctness/noEmptyPattern
  complexity/noExcessiveNestedTestSuites
  security/noDangerouslySetInnerHtmlWithChildren
  a11y/useKeyWithMouseEvents
  suspicious/noExtraNonNullAssertion
  suspicious/noShorthandPropertyOverrides
  correctness/noRenderReturnValue
  correctness/useExhaustiveDependencies
  security/noGlobalEval
  style/noNonNullAssertion
  a11y/noRedundantRoles
  complexity/useFlatMap
  correctness/noUnusedVariables
  correctness/useHookAtTopLevel
  correctness/useIsNan
  style/useConst
  suspicious/noGlobalIsFinite
  suspicious/noAsyncPromiseExecutor
  suspicious/noDuplicateFontNames
  suspicious/noSelfCompare
  suspicious/noThenProperty
  security/noDangerouslySetInnerHtml
  style/useNodejsImportProtocol
  a11y/noDistractingElements
  suspicious/noArrayIndexKey
  complexity/noWith
  suspicious/useGetterReturn
  suspicious/noDuplicateClassMembers
  complexity/noExtraBooleanCast
  performance/noAccumulatingSpread
  a11y/useValidAriaProps
  a11y/noRedundantAlt
  correctness/noChildrenProp
  correctness/noUnknownFunction
  correctness/noInvalidPositionAtImportRule
  suspicious/noConfusingLabels
  suspicious/noPrototypeBuiltins
  suspicious/noConfusingVoidType
  suspicious/noFocusedTests
  a11y/useButtonType
  a11y/useSemanticElements
  a11y/noAriaUnsupportedElements
  correctness/noInvalidGridAreas
  correctness/noFlatMapIdentity
  a11y/noBlankTarget
  a11y/useHeadingContent
  suspicious/noSparseArray
  correctness/noConstantMathMinMaxClamp
  correctness/useValidForDirection
  correctness/noUnusedPrivateClassMembers
  correctness/noVoidTypeReturn
  correctness/noInvalidUseBeforeDeclaration
  a11y/noAriaHiddenOnFocusable
  a11y/useGenericFontNames
  correctness/noUnknownMediaFeatureName
  a11y/useAnchorContent
  complexity/noUselessRename
  correctness/noInvalidNewBuiltin
  style/useNumberNamespace
  complexity/noUselessConstructor
  a11y/noAccessKey
  correctness/noUnusedFunctionParameters
  style/noUnusedTemplateLiteral
  complexity/noUselessSwitchCase
  style/useExponentiationOperator
  correctness/noUndeclaredVariables
  style/useSingleVarDeclarator
  suspicious/noExportsInTest
  a11y/noNoninteractiveElementToInteractiveRole
  style/noCommaOperator
  suspicious/noDuplicateAtImportRules
  suspicious/useIsArray
  a11y/noHeaderScope
  complexity/noUselessFragments
  suspicious/noMisrefactoredShorthandAssign
  suspicious/noEmptyBlock
  correctness/noNewSymbol
  complexity/noForEach
  suspicious/noFunctionAssign

Workspace:
  Open Documents:               0

Rule name

lint/a11y/useSemanticElements

Playground link

https://biomejs.dev/playground/?code=PABmAG8AcgBtACAAaQBkAD0AIgBzAGUAYQByAGMAaAAiACAAcgBvAGwAZQA9ACIAcwBlAGEAcgBjAGgAIgA%2BAAoAIAAgADwAbABhAGIAZQBsACAAZgBvAHIAPQAiAHMAZQBhAHIAYwBoAC0AaQBuAHAAdQB0ACIAPgBTAGUAYQByAGMAaAAgAHQAaABpAHMAIABzAGkAdABlADwALwBsAGEAYgBlAGwAPgAKACAAIAA8AGkAbgBwAHUAdAAgAHQAeQBwAGUAPQAiAHMAZQBhAHIAYwBoACIAIABpAGQAPQAiAHMAZQBhAHIAYwBoAC0AaQBuAHAAdQB0ACIAIABuAGEAbQBlAD0AIgBzAGUAYQByAGMAaAAiACAAcwBwAGUAbABsAGMAaABlAGMAawA9ACIAZgBhAGwAcwBlACIAIAAvAD4ACgAgACAAPABpAG4AcAB1AHQAIAB2AGEAbAB1AGUAPQAiAFMAdQBiAG0AaQB0ACIAIAB0AHkAcABlAD0AIgBzAHUAYgBtAGkAdAAiACAALwA%2BAAoAPAAvAGYAbwByAG0APgA%3D

Expected result

Using <form role="search"> throws an error saying that we should instead use <input type="search">. However, according to MDN's ARIA: search role documentation:

The search role is a landmark role that can be added to the container element that encompasses all of the elements that combined to form the search feature of the document or application, including a descendant (<input type="search">). ... There is a input of type search), though this does not define a search landmark by itself. Using is an alternative way to define a search landmark.

and they provide an example recommending using the "search" role on a "form":

When a <form> is a search form, use the search role instead of form role.

<form id="search" role="search">
  <label for="search-input">Search this site</label>
  <input type="search" id="search-input" name="search" spellcheck="false">
  <input value="Submit" type="submit">
</form>

They do recommend an alternative, using <search> as the landmark instead, which might be a better error message for this case, so the way to fix the above example might be:

<search>
  <form id="search">
    <label for="search-input">Search this site</label>
    <input type="search" id="search-input" name="search" spellcheck="false">
    <input value="Submit" type="submit">
  </form>
</search>

Code of Conduct

  • I agree to follow Biome's Code of Conduct
@redbmk redbmk added the S-Needs triage Status: this issue needs to be triaged label Oct 17, 2024
@redbmk redbmk changed the title 💅 Incorrect suggestion for role="search" 💅 Incorrect suggestion for <form role="search"> Oct 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-Needs triage Status: this issue needs to be triaged
Projects
None yet
Development

No branches or pull requests

1 participant