Repository navigation
💅 correctness/noUnusedVariables shows class as unused, when namespace with the same name is present #4928
Copy link
Copy link
Labels
A-AnalyzerArea: analyzerArea: analyzerA-LinterArea: linterArea: linterL-JavaScriptLanguage: JavaScript and super languagesLanguage: JavaScript and super languagesS-Bug-confirmedStatus: report has been confirmed as a valid bugStatus: report has been confirmed as a valid bugS-Help-wantedStatus: you're familiar with the code base and want to help the projectStatus: you're familiar with the code base and want to help the project
Description
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: "v22.11.0"
JS_RUNTIME_NAME: "node"
NODE_PACKAGE_MANAGER: "npm/10.9.0"
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:
correctness/noUnusedImports
suspicious/noCatchAssign
suspicious/noUnsafeNegation
complexity/useLiteralKeys
suspicious/noClassAssign
complexity/noMultipleSpacesInRegularExpressionLiterals
a11y/useValidLang
complexity/noUselessEmptyExport
suspicious/useNamespaceKeyword
suspicious/useValidTypeof
suspicious/noAssignInExpressions
a11y/useValidAriaRole
a11y/useAriaActivedescendantWithTabindex
correctness/noConstantCondition
style/useDefaultParameterLast
complexity/noEmptyTypeParameters
correctness/noConstructorReturn
style/useSelfClosingElements
suspicious/noDuplicateParameters
suspicious/noDuplicateSelectorsKeyframeBlock
correctness/noUnknownProperty
style/useTemplate
correctness/noUnusedLabels
complexity/noUselessTernary
correctness/noUnreachableSuper
suspicious/noCompareNegZero
correctness/noSwitchDeclarations
a11y/noAutofocus
correctness/noUnsafeOptionalChaining
correctness/noConstAssign
suspicious/noControlCharactersInRegex
complexity/noUselessTypeConstraint
style/noVar
suspicious/noDoubleEquals
suspicious/noRedundantUseStrict
suspicious/noGlobalIsNan
suspicious/noEmptyInterface
suspicious/noConstEnum
suspicious/noMisleadingCharacterClass
correctness/noPrecisionLoss
a11y/noLabelWithoutControl
suspicious/noRedeclare
correctness/noStringCaseMismatch
correctness/noSetterReturn
correctness/noInvalidConstructorSuper
suspicious/noImplicitAnyLet
suspicious/noDuplicateObjectKeys
suspicious/noFallthroughSwitchClause
complexity/noUselessThisAlias
correctness/noUnreachable
suspicious/noUnsafeDeclarationMerging
a11y/useKeyWithClickEvents
complexity/noThisInStatic
complexity/useOptionalChain
correctness/noInnerDeclarations
style/noParameterAssign
suspicious/noDuplicateCase
a11y/useValidAnchor
correctness/useArrayLiterals
complexity/useRegexLiterals
correctness/noSelfAssign
correctness/noInvalidBuiltinInstantiation
nursery/noProcessEnv
style/noUselessElse
style/useShorthandFunctionType
correctness/noInvalidDirectionInLinearGradient
suspicious/noShadowRestrictedNames
suspicious/noEmptyBlockStatements
suspicious/noImportantInKeyframe
a11y/useMediaCaption
complexity/noUselessLabel
complexity/noUselessCatch
correctness/noUnsafeFinally
a11y/useAriaPropsForRole
style/useCollapsedElseIf
correctness/noNonoctalDecimalEscape
style/useEnumInitializers
a11y/useHtmlLang
suspicious/noDuplicateTestHooks
complexity/noStaticOnlyClass
suspicious/noEvolvingTypes
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
style/noParameterProperties
suspicious/useDefaultSwitchClauseLast
correctness/noEmptyCharacterClassInRegex
correctness/noUnknownUnit
correctness/useImportExtensions
a11y/useAltText
a11y/useIframeTitle
complexity/noBannedTypes
a11y/noSvgWithoutTitle
correctness/noVoidElementsWithChildren
style/useAsConstAssertion
correctness/useJsxKeyInIterable
style/useExportType
complexity/noUselessLoneBlockStatements
complexity/noVoid
a11y/useValidAriaValues
style/noArguments
style/useThrowOnlyError
a11y/useFocusableInteractive
correctness/noUnmatchableAnbSelector
suspicious/noCommentText
suspicious/noDuplicateJsxProps
suspicious/noGlobalAssign
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/useIsNan
correctness/noUnusedVariables
style/useConst
style/noYodaExpression
suspicious/noGlobalIsFinite
suspicious/noAsyncPromiseExecutor
suspicious/noDuplicateFontNames
suspicious/noSelfCompare
suspicious/noThenProperty
security/noDangerouslySetInnerHtml
style/useNodejsImportProtocol
a11y/noDistractingElements
style/useConsistentArrayType
complexity/noWith
suspicious/noArrayIndexKey
suspicious/noDuplicateClassMembers
complexity/noExtraBooleanCast
performance/noAccumulatingSpread
a11y/useValidAriaProps
a11y/noRedundantAlt
complexity/useDateNow
correctness/noChildrenProp
correctness/noInvalidPositionAtImportRule
correctness/noUnknownFunction
suspicious/noConfusingLabels
suspicious/noMisleadingInstantiator
suspicious/noPrototypeBuiltins
suspicious/noSparseArray
suspicious/noSuspiciousSemicolonInJsx
suspicious/useGetterReturn
suspicious/noConfusingVoidType
suspicious/noFocusedTests
a11y/useButtonType
a11y/useSemanticElements
a11y/noAriaUnsupportedElements
correctness/noInvalidGridAreas
nursery/noCommonJs
correctness/noFlatMapIdentity
a11y/noBlankTarget
a11y/useHeadingContent
correctness/useValidForDirection
correctness/noVoidTypeReturn
correctness/noInvalidUseBeforeDeclaration
a11y/noAriaHiddenOnFocusable
a11y/useGenericFontNames
correctness/noUnknownMediaFeatureName
a11y/useAnchorContent
complexity/noUselessRename
style/useNumberNamespace
complexity/noUselessConstructor
a11y/noAccessKey
complexity/useSimplifiedLogicExpression
correctness/noUnusedFunctionParameters
complexity/noUselessSwitchCase
style/noUnusedTemplateLiteral
correctness/noUndeclaredVariables
style/useExponentiationOperator
style/noNegationElse
style/noDefaultExport
style/useSingleVarDeclarator
suspicious/noExportsInTest
suspicious/useAwait
a11y/noNoninteractiveElementToInteractiveRole
style/noCommaOperator
suspicious/noConsoleLog
suspicious/noDuplicateAtImportRules
suspicious/useIsArray
a11y/noHeaderScope
complexity/noUselessFragments
suspicious/noMisrefactoredShorthandAssign
suspicious/noEmptyBlock
correctness/noNewSymbol
complexity/noForEach
suspicious/noFunctionAssign
Workspace:
Open Documents: 0Rule name
correctness/noUnusedVariables
Playground link
Expected result
I expect linter to not show that class is unused, when it's actually used.
Code of Conduct
- I agree to follow Biome's Code of Conduct
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
A-AnalyzerArea: analyzerArea: analyzerA-LinterArea: linterArea: linterL-JavaScriptLanguage: JavaScript and super languagesLanguage: JavaScript and super languagesS-Bug-confirmedStatus: report has been confirmed as a valid bugStatus: report has been confirmed as a valid bugS-Help-wantedStatus: you're familiar with the code base and want to help the projectStatus: you're familiar with the code base and want to help the project
Activity
Conaclos commentedon May 29, 2025
The issue is coming from our semantic model. The
Basereference inextends Basedis bound to the namespace.This is not easy to fix because this is related to how we architectured the semantic model: we are currently not able to merge declarations or to make cohabit two bindings with the same kind (value or type).
arendjr commentedon May 30, 2025
With #6173, the module graph's semantic analysis can now track both classes and namespaces of the same name independently. It's still limited if there are multiple namespaces of the same name, but it would be enough to potentially fix this bug.
Maybe we should consider letting rules such as this make more use of the module graph so that we only need to maintain a single semantic model.
Update dependency @biomejs/biome to v2.5.12 (#21)
Update dependency @biomejs/biome to v2.5.12 (#43)