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
14.19k stars 439 forks source link

`lint/correctness/noUnusedVariables` errors on unused function params #3596

Open tylerlaprade opened 1 month ago

tylerlaprade commented 1 month ago

Environment information

CLI:
  Version:                      1.8.3
  Color support:                true

Platform:
  CPU Architecture:             aarch64
  OS:                           macos

Environment:
  BIOME_LOG_DIR:                unset
  NO_COLOR:                     unset
  TERM:                         "xterm-256color"
  JS_RUNTIME_VERSION:           "v18.17.1"
  JS_RUNTIME_NAME:              "node"
  NODE_PACKAGE_MANAGER:         "npm/9.6.7"

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

Linter:
  JavaScript enabled:           true
  JSON enabled:                 true
  CSS enabled:                  false
  Recommended:                  false
  All:                          false
  Enabled rules:
  performance/noDelete
  suspicious/noCatchAssign
  suspicious/noUnsafeNegation
  complexity/useLiteralKeys
  suspicious/useNamespaceKeyword
  complexity/noMultipleSpacesInRegularExpressionLiterals
  complexity/noUselessEmptyExport
  suspicious/useValidTypeof
  correctness/noConstantCondition
  suspicious/noDuplicateParameters
  style/useDefaultParameterLast
  complexity/noEmptyTypeParameters
  correctness/noConstructorReturn
  style/useSelfClosingElements
  style/useTemplate
  correctness/noUnusedLabels
  complexity/noUselessTernary
  correctness/noUnreachableSuper
  suspicious/noCompareNegZero
  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
  style/noUselessElse
  style/useShorthandFunctionType
  complexity/noUselessLabel
  complexity/noUselessCatch
  correctness/noUnsafeFinally
  correctness/noNonoctalDecimalEscape
  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/noEmptyCharacterClassInRegex
  suspicious/noSuspiciousSemicolonInJsx
  suspicious/noSparseArray
  complexity/noBannedTypes
  suspicious/noPrototypeBuiltins
  correctness/noVoidElementsWithChildren
  style/useAsConstAssertion
  correctness/useJsxKeyInIterable
  style/useExportType
  complexity/noUselessLoneBlockStatements
  suspicious/noMisleadingInstantiator
  suspicious/noGlobalAssign
  suspicious/noDebugger
  style/noArguments
  suspicious/noThenProperty
  suspicious/noCommentText
  suspicious/useGetterReturn
  suspicious/noDuplicateJsxProps
  correctness/noEmptyPattern
  complexity/noExcessiveNestedTestSuites
  security/noDangerouslySetInnerHtmlWithChildren
  suspicious/noExtraNonNullAssertion
  correctness/noRenderReturnValue
  correctness/useExhaustiveDependencies
  security/noGlobalEval
  style/noNonNullAssertion
  style/useConst
  complexity/useFlatMap
  correctness/useHookAtTopLevel
  correctness/useIsNan
  correctness/noUnusedVariables
  suspicious/noGlobalIsFinite
  suspicious/noSelfCompare
  suspicious/noAsyncPromiseExecutor
  security/noDangerouslySetInnerHtml
  style/useNodejsImportProtocol
  suspicious/noArrayIndexKey
  complexity/noWith
  suspicious/noDuplicateClassMembers
  complexity/noExtraBooleanCast
  performance/noAccumulatingSpread
  suspicious/noConfusingLabels
  correctness/noChildrenProp
  suspicious/noFocusedTests
  correctness/noFlatMapIdentity
  correctness/useValidForDirection
  correctness/noVoidTypeReturn
  correctness/noInvalidUseBeforeDeclaration
  complexity/noUselessRename
  correctness/noInvalidNewBuiltin
  style/useNumberNamespace
  complexity/noUselessConstructor
  style/useExponentiationOperator
  style/noUnusedTemplateLiteral
  complexity/noUselessSwitchCase
  style/useSingleVarDeclarator
  suspicious/noExportsInTest
  style/noCommaOperator
  suspicious/useIsArray
  complexity/noUselessFragments
  suspicious/noMisrefactoredShorthandAssign
  complexity/noForEach
  correctness/noUnusedImports
  suspicious/noClassAssign
  suspicious/noFunctionAssign

Workspace:
  Open Documents:               0


### Rule name

`noUnusedVariables`

### Playground link

https://biomejs.dev/playground/?lintRules=all&code=YwBvAG4AcwB0ACAAaABhAG4AZABsAGUAQwBoAGEAbgBnAGUAIAA9ACAAKABlAHYAZQBuAHQAOgAgAFMAeQBuAHQAaABlAHQAaQBjAEUAdgBlAG4AdAAsACAAbgBlAHcAVgBhAGwAdQBlADoAIABzAHQAcgBpAG4AZwApACAAPQA%2BACAAewAKACAAIAAgACAAcwBlAHQAVgBhAGwAdQBlACgAbgBlAHcAVgBhAGwAdQBlACkAOwAKACAAIAB9ADsA

### Expected result

![image](https://github.com/user-attachments/assets/88007b2f-08b7-4ca2-b3d4-8d5c29b11f17)
It should behave the same as these cited rules
https://biomejs.dev/linter/rules/no-unused-variables/

### Code of Conduct

- [X] I agree to follow Biome's Code of Conduct
Conaclos commented 1 month ago

Indeed, noUnusedVariables should not report unused function parameters because we have a dedicated rule for this purpose (noUnusedFunctionParameters).

Conaclos commented 1 month ago

Actually, it is not a bug. noUnusedFunctionParameters is still in the nursery rule. However, I think we can make the change, because it is fair to assume that noUnusedFunctionParameters will be stabilized in the next release.