Skip to content

💅 correctness/noUnusedVariables shows class as unused, when namespace with the same name is present #4928

Description

@f3oall

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:               0

Rule name

correctness/noUnusedVariables

Playground link

https://biomejs.dev/playground/?lintRules=all&code=YQBiAHMAdAByAGEAYwB0ACAAYwBsAGEAcwBzACAAQgBhAHMAZQAgAHsAIAAvAC8AIAB0AGgAaQBzACAAcwBoAG8AdQBsAGQAbgAnAHQAIABiAGUAIAB1AG4AdQBzAGUAZAAKACAAIAAKAH0ACgAKAG4AYQBtAGUAcwBwAGEAYwBlACAAQgBhAHMAZQAgAHsACgAgACAACgB9AAoACgBlAHgAcABvAHIAdAAgAGMAbABhAHMAcwAgAEEAIABlAHgAdABlAG4AZABzACAAQgBhAHMAZQAgAHsACgAgACAACgB9AA%3D%3D

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

Activity

  1. added
    S-Help-wantedStatus: you're familiar with the code base and want to help the project
    L-JavaScriptLanguage: JavaScript and super languages
    S-Bug-confirmedStatus: report has been confirmed as a valid bug
    and removed
    S-Needs triageStatus: this issue needs to be triaged
    on Jan 21, 2025
  2. Conaclos commented on May 29, 2025

    @Conaclos
    Member

    The issue is coming from our semantic model. The Base reference in extends Based is 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).

  3. arendjr commented on May 30, 2025

    @arendjr
    Contributor

    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.

  4. self-assigned this
    on Sep 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

A-AnalyzerArea: analyzerA-LinterArea: linterL-JavaScriptLanguage: JavaScript and super languagesS-Bug-confirmedStatus: report has been confirmed as a valid bugS-Help-wantedStatus: you're familiar with the code base and want to help the project

Type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions