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
12.51k stars 393 forks source link

💅 useAltText reports missing alt despite alt being provided, if followed by props spread #3081

Open wojtekmaj opened 1 month ago

wojtekmaj commented 1 month ago

Environment information

CLI:
  Version:                      1.8.0
  Color support:                true

Platform:
  CPU Architecture:             aarch64
  OS:                           macos

Environment:
  BIOME_LOG_DIR:                unset
  NO_COLOR:                     unset
  TERM:                         "xterm-256color"
  JS_RUNTIME_VERSION:           "v22.0.0"
  JS_RUNTIME_NAME:              "node"
  NODE_PACKAGE_MANAGER:         "yarn/4.1.1"

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
  Recommended:                  false
  All:                          false
  Enabled rules:
  performance/noDelete
  suspicious/noCatchAssign
  suspicious/noUnsafeNegation
  complexity/useLiteralKeys
  style/useImportType
  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
  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
  suspicious/noMisleadingCharacterClass
  correctness/noPrecisionLoss
  suspicious/noRedeclare
  correctness/noStringCaseMismatch
  correctness/noSetterReturn
  correctness/noInvalidConstructorSuper
  suspicious/noImplicitAnyLet
  suspicious/noFallthroughSwitchClause
  suspicious/noUnsafeDeclarationMerging
  correctness/noUnreachable
  a11y/useKeyWithClickEvents
  suspicious/noDuplicateObjectKeys
  complexity/noUselessThisAlias
  complexity/noThisInStatic
  complexity/useOptionalChain
  correctness/noInnerDeclarations
  style/noParameterAssign
  suspicious/noDuplicateCase
  a11y/useValidAnchor
  complexity/useRegexLiterals
  correctness/noSelfAssign
  style/noUselessElse
  style/useShorthandFunctionType
  suspicious/noShadowRestrictedNames
  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
  a11y/useAltText
  correctness/noEmptyCharacterClassInRegex
  suspicious/noSuspiciousSemicolonInJsx
  suspicious/noSparseArray
  a11y/useIframeTitle
  complexity/noBannedTypes
  a11y/noSvgWithoutTitle
  correctness/noVoidElementsWithChildren
  style/useAsConstAssertion
  correctness/useJsxKeyInIterable
  style/useExportType
  complexity/noUselessLoneBlockStatements
  style/noArguments
  a11y/useValidAriaValues
  suspicious/noDebugger
  suspicious/noMisleadingInstantiator
  suspicious/noPrototypeBuiltins
  suspicious/noGlobalAssign
  suspicious/noCommentText
  suspicious/noDuplicateJsxProps
  suspicious/noThenProperty
  a11y/noPositiveTabindex
  correctness/noEmptyPattern
  complexity/noExcessiveNestedTestSuites
  security/noDangerouslySetInnerHtmlWithChildren
  a11y/useKeyWithMouseEvents
  suspicious/noExtraNonNullAssertion
  suspicious/useGetterReturn
  correctness/noRenderReturnValue
  correctness/useExhaustiveDependencies
  security/noGlobalEval
  style/noNonNullAssertion
  a11y/noRedundantRoles
  complexity/useFlatMap
  correctness/useIsNan
  style/useConst
  suspicious/noGlobalIsFinite
  suspicious/noSelfCompare
  suspicious/noAsyncPromiseExecutor
  security/noDangerouslySetInnerHtml
  style/useNodejsImportProtocol
  a11y/noDistractingElements
  suspicious/noArrayIndexKey
  complexity/noWith
  suspicious/noDuplicateClassMembers
  complexity/noExtraBooleanCast
  performance/noAccumulatingSpread
  a11y/useValidAriaProps
  a11y/noRedundantAlt
  correctness/noChildrenProp
  suspicious/noConfusingLabels
  suspicious/noConfusingVoidType
  suspicious/noFocusedTests
  a11y/useButtonType
  a11y/noAriaUnsupportedElements
  correctness/noFlatMapIdentity
  a11y/noBlankTarget
  a11y/useHeadingContent
  correctness/useValidForDirection
  correctness/noVoidTypeReturn
  correctness/noInvalidUseBeforeDeclaration
  a11y/noAriaHiddenOnFocusable
  a11y/useAnchorContent
  complexity/noUselessRename
  correctness/noInvalidNewBuiltin
  style/useNumberNamespace
  complexity/noUselessConstructor
  a11y/noAccessKey
  style/useExponentiationOperator
  style/noUnusedTemplateLiteral
  style/useSingleVarDeclarator
  suspicious/noExportsInTest
  a11y/noNoninteractiveElementToInteractiveRole
  style/noCommaOperator
  suspicious/noConsoleLog
  suspicious/useIsArray
  a11y/noHeaderScope
  complexity/noUselessFragments
  suspicious/noMisrefactoredShorthandAssign
  complexity/noForEach
  suspicious/noClassAssign
  suspicious/noFunctionAssign

Workspace:
  Open Documents:               0

Rule name

lint/a11y/useAltText

Playground link

https://biomejs.dev/playground/?code=ZgB1AG4AYwB0AGkAbwBuACAATQB5AEkAbQBnAFcAaQB0AGgARQByAHIAbwByACgAewAKACAAIABhAGwAdAAsAAoAIAAgAHMAcgBjACwACgAgACAALgAuAC4AbwB0AGgAZQByAFAAcgBvAHAAcwAKAH0AOgAgAHsAIABhAGwAdAA6ACAAcwB0AHIAaQBuAGcAOwAgAHMAcgBjADoAIABzAHQAcgBpAG4AZwA7ACAAdwBpAGQAdABoADoAIABuAHUAbQBiAGUAcgA7ACAAaABlAGkAZwBoAHQAOgAgAG4AdQBtAGIAZQByACAAfQApACAAewAKACAAIAByAGUAdAB1AHIAbgAgADwAaQBtAGcAIABhAGwAdAA9AHsAYQBsAHQAfQAgAHMAcgBjAD0AewBzAHIAYwB9ACAAewAuAC4ALgBvAHQAaABlAHIAUAByAG8AcABzAH0AIAAvAD4AOwAKAH0ACgAKAGYAdQBuAGMAdABpAG8AbgAgAE0AeQBJAG0AZwBXAGkAdABoAG8AdQB0AEUAcgByAG8AcgAoAHsACgAgACAAYQBsAHQALAAKACAAIABzAHIAYwAsAAoAIAAgAC4ALgAuAG8AdABoAGUAcgBQAHIAbwBwAHMACgB9ADoAIAB7ACAAYQBsAHQAOgAgAHMAdAByAGkAbgBnADsAIABzAHIAYwA6ACAAcwB0AHIAaQBuAGcAOwAgAHcAaQBkAHQAaAA6ACAAbgB1AG0AYgBlAHIAOwAgAGgAZQBpAGcAaAB0ADoAIABuAHUAbQBiAGUAcgAgAH0AKQAgAHsACgAgACAAcgBlAHQAdQByAG4AIAA8AGkAbQBnACAAewAuAC4ALgBvAHQAaABlAHIAUAByAG8AcABzAH0AIABhAGwAdAA9AHsAYQBsAHQAfQAgAHMAcgBjAD0AewBzAHIAYwB9ACAALwA%2BADsACgB9AAoA

Expected result

If props spread does not overwrite alt in any way, missing alt should not be reported.

Code of Conduct

ematipico commented 1 month ago

I believe that's intentional, because the spread prop could contain an erroneous value of the alt prop. Unfortunately we don't have types available, we are a bit conservative with the approach. Should we let it slide?

wojtekmaj commented 1 month ago

Hmmm, eslint-plugin-jsx-a11y does not trigger an error if alt was provided regardless of props spread presence, but I guess from those two behaviors, Biome is preferable by playing it safe. After all that's what linters are for.

community-ken-jeong