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

💅 useJsxKeyInIterable: Key prop in React TSX / JSX is not checked in switch statements #4715

Open
1 task done
mio-moto opened this issue Dec 9, 2024 · 0 comments
Open
1 task done
Labels
A-Linter Area: linter L-JavaScript Language: JavaScript and super languages S-Bug-confirmed Status: report has been confirmed as a valid bug

Comments

@mio-moto
Copy link

mio-moto commented Dec 9, 2024

Environment information

CLI:
  Version:                      1.9.4
  Color support:                true

Platform:
  CPU Architecture:             x86_64
  OS:                           windows

Environment:
  BIOME_LOG_PATH:               unset
  BIOME_LOG_PREFIX_NAME:        unset
  BIOME_CONFIG_PATH:            unset
  NO_COLOR:                     unset
  TERM:                         unset
  JS_RUNTIME_VERSION:           "v20.13.1"
  JS_RUNTIME_NAME:              "node"
  NODE_PACKAGE_MANAGER:         "bun/1.1.36"

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

Linter:
  JavaScript enabled:           true
  JSON enabled:                 true
  CSS enabled:                  true
  GraphQL enabled:              false
  Recommended:                  true
  All:                          false
  Enabled rules:
  performance/noDelete
  suspicious/noCatchAssign
  suspicious/noUnsafeNegation
  complexity/useLiteralKeys
  style/useImportType
  suspicious/useNamespaceKeyword
  complexity/noMultipleSpacesInRegularExpressionLiterals
  complexity/noUselessEmptyExport
  suspicious/useValidTypeof
  suspicious/noAssignInExpressions
  correctness/noConstantCondition
  suspicious/noDuplicateParameters
  suspicious/noDuplicateSelectorsKeyframeBlock
  style/useDefaultParameterLast
  complexity/noEmptyTypeParameters
  correctness/noConstructorReturn
  style/useSelfClosingElements
  correctness/noUnknownProperty
  style/useTemplate
  correctness/noUnusedLabels
  complexity/noUselessTernary
  correctness/noUnreachableSuper
  suspicious/noCompareNegZero
  suspicious/noExplicitAny
  correctness/noSwitchDeclarations
  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/noDuplicateObjectKeys
  suspicious/noUnsafeDeclarationMerging
  complexity/noUselessThisAlias
  suspicious/noFallthroughSwitchClause
  correctness/noUnreachable
  complexity/noThisInStatic
  complexity/useOptionalChain
  correctness/noInnerDeclarations
  style/noParameterAssign
  suspicious/noDuplicateCase
  complexity/useRegexLiterals
  correctness/noSelfAssign
  correctness/noInvalidBuiltinInstantiation
  style/noUselessElse
  style/useShorthandFunctionType
  suspicious/noShadowRestrictedNames
  correctness/noInvalidDirectionInLinearGradient
  suspicious/noImportantInKeyframe
  complexity/noUselessLabel
  complexity/noUselessCatch
  correctness/noUnsafeFinally
  correctness/noNonoctalDecimalEscape
  style/useEnumInitializers
  suspicious/noDuplicateTestHooks
  complexity/noStaticOnlyClass
  style/useWhile
  complexity/useArrowFunction
  style/noInferrableTypes
  complexity/useSimpleNumberKeys
  correctness/useYield
  style/useNumericLiterals
  suspicious/noImportAssign
  suspicious/noLabelVar
  correctness/noUnnecessaryContinue
  suspicious/noApproximativeNumericConstant
  suspicious/useDefaultSwitchClauseLast
  correctness/noGlobalObjectCalls
  correctness/noUnknownUnit
  correctness/noEmptyCharacterClassInRegex
  suspicious/noSuspiciousSemicolonInJsx
  suspicious/noSparseArray
  complexity/noBannedTypes
  suspicious/noPrototypeBuiltins
  correctness/noVoidElementsWithChildren
  style/useAsConstAssertion
  correctness/useJsxKeyInIterable
  style/useExportType
  complexity/noUselessLoneBlockStatements
  style/noArguments
  suspicious/noDebugger
  suspicious/noGlobalAssign
  suspicious/noMisleadingInstantiator
  correctness/noUnmatchableAnbSelector
  suspicious/noThenProperty
  suspicious/noCommentText
  suspicious/noDuplicateJsxProps
  suspicious/useGetterReturn
  correctness/noEmptyPattern
  complexity/noExcessiveNestedTestSuites
  security/noDangerouslySetInnerHtmlWithChildren
  suspicious/noExtraNonNullAssertion
  suspicious/noShorthandPropertyOverrides
  correctness/noRenderReturnValue
  correctness/useExhaustiveDependencies
  security/noGlobalEval
  style/noNonNullAssertion
  complexity/useFlatMap
  style/useConst
  correctness/useIsNan
  suspicious/noGlobalIsFinite
  suspicious/noSelfCompare
  suspicious/noAsyncPromiseExecutor
  suspicious/noDuplicateFontNames
  security/noDangerouslySetInnerHtml
  style/useNodejsImportProtocol
  suspicious/noArrayIndexKey
  complexity/noWith
  suspicious/noDuplicateClassMembers
  complexity/noExtraBooleanCast
  performance/noAccumulatingSpread
  suspicious/noConfusingLabels
  correctness/noChildrenProp
  correctness/noUnknownFunction
  correctness/noInvalidPositionAtImportRule
  suspicious/noConfusingVoidType
  suspicious/noFocusedTests
  correctness/noInvalidGridAreas
  correctness/noFlatMapIdentity
  correctness/useValidForDirection
  correctness/noVoidTypeReturn
  correctness/noInvalidUseBeforeDeclaration
  correctness/noUnknownMediaFeatureName
  complexity/noUselessRename
  style/useNumberNamespace
  complexity/noUselessConstructor
  style/useExponentiationOperator
  style/noUnusedTemplateLiteral
  complexity/noUselessSwitchCase
  style/noDefaultExport
  style/useSingleVarDeclarator
  suspicious/noExportsInTest
  style/noCommaOperator
  suspicious/noDuplicateAtImportRules
  suspicious/useIsArray
  complexity/noUselessFragments
  suspicious/noMisrefactoredShorthandAssign
  complexity/noForEach
  suspicious/noClassAssign
  suspicious/noEmptyBlock
  suspicious/noFunctionAssign

Workspace:
  Open Documents:               0

Rule name

lint/correctness/useJsxKeyInIterable

Playground link

https://biomejs.dev/playground/?code=CgBjAG8AbgBzAHQAIABNAHkAQ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cwB0AHIAaQBuAGcAJwApACAAewAKACAAIAAgACAAIAAgACAAIAAgACAAcgBlAHQAdQByAG4AIAA8AGQAaQB2AD4AewB4AC4AdgBhAGwAdQBlAH0APAAvAGQAaQB2AD4ACgAgACAAIAAgACAAIAAgACAAfQAKACAAIAAgACAAIAAgACAAIAByAGUAdAB1AHIAbgAgADwAZABpAHYAPgB7AHgALgB2AGEAbAB1AGUAfQA8AC8AZABpAHYAPgAKACAAIAAgACAAIAAgAH0AKQB9AAoAIAAgACAAIAAgACAAewAvACoAIABMJyAAZQBtAGkAdABzACAAbgBvACAAZQByAHIAbwByACAAKgAvAH0ACgAgACAAIAAgACAAIAB7AGUAbgB0AHIAaQBlAHMALgBtAGEAcAAoACgAeAApACAAPQA%2BACAAewAKACAAIAAgACAAIAAgACAAIABzAHcAaQB0AGMAaAAgACgAeAAuAHQAeQBwAGUAKQAgAHsACgAgACAAIAAgACAAIAAgACAAIAAgAGMAYQBzAGUAIAAnAHMAdAByAGkAbgBnACcAOgAKACAAIAAgACAAIAAgACAAIAAgACAAIAAgAHIAZQB0AHUAcgBuACAAPABkAGkAdgA%2BAHsAeAAuAHYAYQBsAHUAZQB9ADwALwBkAGkAdgA%2BAAoAIAAgACAAIAAgACAAIAAgACAAIABjAGEAcwBlACAAJwBuAHUAbQBiAGUAcgAnADoACgAgACAAIAAgACAAIAAgACAAIAAgACAAIAByAGUAdAB1AHIAbgAgADwAZABpAHYAPgB7AHgALgB2AGEAbAB1AGUAfQA8AC8AZABpAHYAPgAKACAAIAAgACAAIAAgACAAIAB9AAoAIAAgACAAIAAgACAAfQApAH0ACgAgACAAIAAgADwALwA%2BAAoAIAAgACkACgB9AAoA

Expected result

The last .map of entries should emit an error about a missing key prop inside the switch statement. This is isolated by switch statements.

Additionally, map lambdas with branching return do not emit the error on early return branches.

Code of Conduct

  • I agree to follow Biome's Code of Conduct
@mio-moto mio-moto added the S-Needs triage Status: this issue needs to be triaged label Dec 9, 2024
@dyc3 dyc3 added A-Linter Area: linter L-JavaScript Language: JavaScript and super languages S-Bug-confirmed Status: report has been confirmed as a valid bug labels Dec 9, 2024
@github-actions github-actions bot removed the S-Needs triage Status: this issue needs to be triaged label Dec 9, 2024
@dyc3 dyc3 changed the title 💅 Key prop in React TSX / JSX is not checked in switch statements 💅 useJsxKeyInIterable: Key prop in React TSX / JSX is not checked in switch statements Dec 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-Linter Area: linter L-JavaScript Language: JavaScript and super languages S-Bug-confirmed Status: report has been confirmed as a valid bug
Projects
None yet
Development

No branches or pull requests

2 participants