Environment information
Details
CLI:
Version: 2.4.11
Color support: true
Platform:
CPU Architecture: aarch64
OS: macos
Environment:
BIOME_LOG_PATH: unset
BIOME_LOG_PREFIX_NAME: unset
BIOME_LOG_LEVEL: unset
BIOME_LOG_KIND: unset
BIOME_CONFIG_PATH: unset
BIOME_THREADS: unset
BIOME_WATCHER_KIND: unset
BIOME_WATCHER_POLLING_INTERVAL: unset
NO_COLOR: unset
TERM: xterm-256color
JS_RUNTIME_VERSION: v24.13.0
JS_RUNTIME_NAME: node
NODE_PACKAGE_MANAGER: unset
Biome Configuration:
Status: Loaded successfully
Path: /Users/matt/src/web-zumper/biome.json
Formatter enabled: true
Linter enabled: true
Assist enabled: true
VCS enabled: false
HTML full support enabled: unset
Linter:
JavaScript enabled: unset
JSON enabled: unset
CSS enabled: true
GraphQL enabled: unset
Recommended: true
Enabled rules:
a11y/noAccessKey
a11y/noAriaHiddenOnFocusable
a11y/noAriaUnsupportedElements
a11y/noAutofocus
a11y/noDistractingElements
a11y/noHeaderScope
a11y/noInteractiveElementToNoninteractiveRole
a11y/noLabelWithoutControl
a11y/noNoninteractiveElementToInteractiveRole
a11y/noNoninteractiveTabindex
a11y/noPositiveTabindex
a11y/noRedundantAlt
a11y/noRedundantRoles
a11y/noStaticElementInteractions
a11y/noSvgWithoutTitle
a11y/useAltText
a11y/useAnchorContent
a11y/useAriaActivedescendantWithTabindex
a11y/useAriaPropsForRole
a11y/useAriaPropsSupportedByRole
a11y/useButtonType
a11y/useFocusableInteractive
a11y/useGenericFontNames
a11y/useHeadingContent
a11y/useHtmlLang
a11y/useIframeTitle
a11y/useKeyWithClickEvents
a11y/useKeyWithMouseEvents
a11y/useMediaCaption
a11y/useSemanticElements
a11y/useValidAnchor
a11y/useValidAriaProps
a11y/useValidAriaRole
a11y/useValidAriaValues
a11y/useValidAutocomplete
a11y/useValidLang
complexity/noAdjacentSpacesInRegex
complexity/noArguments
complexity/noBannedTypes
complexity/noCommaOperator
complexity/noEmptyTypeParameters
complexity/noExtraBooleanCast
complexity/noFlatMapIdentity
complexity/noForEach
complexity/noImportantStyles
complexity/noStaticOnlyClass
complexity/noThisInStatic
complexity/noUselessCatch
complexity/noUselessConstructor
complexity/noUselessContinue
complexity/noUselessEmptyExport
complexity/noUselessEscapeInRegex
complexity/noUselessFragments
complexity/noUselessLabel
complexity/noUselessLoneBlockStatements
complexity/noUselessRename
complexity/noUselessStringRaw
complexity/noUselessSwitchCase
complexity/noUselessTernary
complexity/noUselessThisAlias
complexity/noUselessTypeConstraint
complexity/noUselessUndefinedInitialization
complexity/useArrowFunction
complexity/useDateNow
complexity/useFlatMap
complexity/useIndexOf
complexity/useLiteralKeys
complexity/useNumericLiterals
complexity/useOptionalChain
complexity/useRegexLiterals
complexity/useSimpleNumberKeys
correctness/noChildrenProp
correctness/noConstAssign
correctness/noConstantCondition
correctness/noConstantMathMinMaxClamp
correctness/noConstructorReturn
correctness/noEmptyCharacterClassInRegex
correctness/noEmptyPattern
correctness/noGlobalObjectCalls
correctness/noInnerDeclarations
correctness/noInvalidBuiltinInstantiation
correctness/noInvalidConstructorSuper
correctness/noInvalidDirectionInLinearGradient
correctness/noInvalidGridAreas
correctness/noInvalidPositionAtImportRule
correctness/noInvalidUseBeforeDeclaration
correctness/noMissingVarFunction
correctness/noNonoctalDecimalEscape
correctness/noPrecisionLoss
correctness/noSelfAssign
correctness/noSetterReturn
correctness/noStringCaseMismatch
correctness/noSwitchDeclarations
correctness/noUnknownFunction
correctness/noUnknownMediaFeatureName
correctness/noUnknownProperty
correctness/noUnknownPseudoClass
correctness/noUnknownPseudoElement
correctness/noUnknownTypeSelector
correctness/noUnknownUnit
correctness/noUnmatchableAnbSelector
correctness/noUnreachable
correctness/noUnreachableSuper
correctness/noUnsafeFinally
correctness/noUnsafeOptionalChaining
correctness/noUnusedFunctionParameters
correctness/noUnusedImports
correctness/noUnusedLabels
correctness/noUnusedPrivateClassMembers
correctness/noUnusedVariables
correctness/noVoidElementsWithChildren
correctness/noVoidTypeReturn
correctness/useExhaustiveDependencies
correctness/useGraphqlNamedOperations
correctness/useHookAtTopLevel
correctness/useIsNan
correctness/useJsxKeyInIterable
correctness/useParseIntRadix
correctness/useValidForDirection
correctness/useValidTypeof
correctness/useYield
performance/noAccumulatingSpread
performance/noDelete
performance/noDynamicNamespaceImportAccess
security/noBlankTarget
security/noDangerouslySetInnerHtml
security/noGlobalEval
style/noDescendingSpecificity
style/noInferrableTypes
style/noNonNullAssertion
style/noParameterAssign
style/noRestrictedImports
style/noUnusedTemplateLiteral
style/noUselessElse
style/useArrayLiterals
style/useConst
style/useDefaultParameterLast
style/useDeprecatedReason
style/useEnumInitializers
style/useExponentiationOperator
style/useExportType
style/useImportType
style/useLiteralEnumMembers
style/useNodejsImportProtocol
style/useSelfClosingElements
style/useShorthandFunctionType
style/useSingleVarDeclarator
style/useTemplate
suspicious/noApproximativeNumericConstant
suspicious/noArrayIndexKey
suspicious/noAssignInExpressions
suspicious/noAsyncPromiseExecutor
suspicious/noBiomeFirstException
suspicious/noCatchAssign
suspicious/noClassAssign
suspicious/noCommentText
suspicious/noCompareNegZero
suspicious/noConfusingLabels
suspicious/noConfusingVoidType
suspicious/noConstEnum
suspicious/noControlCharactersInRegex
suspicious/noDebugger
suspicious/noDocumentCookie
suspicious/noDoubleEquals
suspicious/noDuplicateAtImportRules
suspicious/noDuplicateCase
suspicious/noDuplicateClassMembers
suspicious/noDuplicateCustomProperties
suspicious/noDuplicateElseIf
suspicious/noDuplicateFields
suspicious/noDuplicateFontNames
suspicious/noDuplicateJsxProps
suspicious/noDuplicateObjectKeys
suspicious/noDuplicateParameters
suspicious/noDuplicateProperties
suspicious/noDuplicateSelectorsKeyframeBlock
suspicious/noDuplicateTestHooks
suspicious/noEmptyBlock
suspicious/noExplicitAny
suspicious/noExportsInTest
suspicious/noExtraNonNullAssertion
suspicious/noFallthroughSwitchClause
suspicious/noFunctionAssign
suspicious/noGlobalAssign
suspicious/noGlobalIsFinite
suspicious/noGlobalIsNan
suspicious/noImplicitAnyLet
suspicious/noImportAssign
suspicious/noImportantInKeyframe
suspicious/noIrregularWhitespace
suspicious/noLabelVar
suspicious/noMisleadingCharacterClass
suspicious/noMisleadingInstantiator
suspicious/noMisrefactoredShorthandAssign
suspicious/noNonNullAssertedOptionalChain
suspicious/noOctalEscape
suspicious/noPrototypeBuiltins
suspicious/noQuickfixBiome
suspicious/noRedeclare
suspicious/noSelfCompare
suspicious/noShadowRestrictedNames
suspicious/noShorthandPropertyOverrides
suspicious/noSparseArray
suspicious/noSuspiciousSemicolonInJsx
suspicious/noTemplateCurlyInString
suspicious/noThenProperty
suspicious/noTsIgnore
suspicious/noUnknownAtRules
suspicious/noUnsafeDeclarationMerging
suspicious/noUnsafeNegation
suspicious/noUselessEscapeInString
suspicious/noUselessRegexBackrefs
suspicious/noVar
suspicious/noWith
suspicious/useAdjacentOverloadSignatures
suspicious/useBiomeIgnoreFolder
suspicious/useDefaultSwitchClauseLast
suspicious/useGetterReturn
suspicious/useGoogleFontDisplay
suspicious/useIsArray
suspicious/useIterableCallbackReturn
suspicious/useNamespaceKeyword
Workspace:
Open Documents: 0
The fix for noThisInStatic is not safe and can break existing code. Below is an example of it breaking.
class Base {
constructor(public name: string) {}
static create<T extends typeof Base>(this: T, name: string): InstanceType<T> {
// biome suggests replacing `this` with `Base` — compiles, but breaks at runtime
return new this(name) as InstanceType<T>;
}
}
class Sub extends Base {
greet() {
return `Hi, ${this.name}`;
}
}
const sub = Sub.create("Alice");
console.log(sub instanceof Sub); // true with `this`, false with `Base`
sub.greet(); // works with `this`, runtime error with `Base`
With new this(name): Sub.create("Alice") returns a Sub instance.
With Biome's "safe fix" new Base(name): it returns a Base instance — sub.greet() throws because Base has no greet method.
The fix is only safe when the static method is never called on a subclass.
Rule name
noThisInStatic
Playground link
https://biomejs.dev/playground/?tab=formatter&pane=Diagnostics&code=YwBsAGEAcwBzACAAQgBhAHMAZQAgAHsAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgAAoAIAAgAGMAbwBuAHMAdAByAHUAYwB0AG8AcgAoAHAAdQBiAGwAaQBjACAAbgBhAG0AZQA6ACAAcwB0AHIAaQBuAGcAKQAgAHsAfQAKACAAIABzAHQAYQB0AGkAYwAgAGMAcgBlAGEAdABlACgAbgBhAG0AZQA6ACAAcwB0AHIAaQBuAGcAKQAgAHsAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAKACAAIAAgACAAcgBlAHQAdQByAG4AIABuAGUAdwAgAHQAaABpAHMAKABuAGEAbQBlACkAOwAKACAAIAB9AAoAfQAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAACgAKAGMAbABhAHMAcwAgAFMAdQBiACAAZQB4AHQAZQBuAGQAcwAgAEIAYQBzAGUAIAB7AAoAIAAgAGcAcgBlAGUAdAAoACkAIAB7AAoAIAAgACAAIAByAGUAdAB1AHIAbgAgAGAASABpACwAIAAkAHsAdABoAGkAcwAuAG4AYQBtAGUAfQBgADsACgAgACAAfQAKAH0ACgA%3D
Expected result
The fix shouldn't be applied unless running with --unsafe.
Code of Conduct
Environment information
Details
The fix for
noThisInStaticis not safe and can break existing code. Below is an example of it breaking.With
new this(name): Sub.create("Alice")returns aSubinstance.With Biome's "safe fix"
new Base(name): it returns aBaseinstance —sub.greet()throws becauseBasehas no greet method.The fix is only safe when the static method is never called on a subclass.
Rule name
noThisInStatic
Playground link
https://biomejs.dev/playground/?tab=formatter&pane=Diagnostics&code=YwBsAGEAcwBzACAAQgBhAHMAZQAgAHsAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgAAoAIAAgAGMAbwBuAHMAdAByAHUAYwB0AG8AcgAoAHAAdQBiAGwAaQBjACAAbgBhAG0AZQA6ACAAcwB0AHIAaQBuAGcAKQAgAHsAfQAKACAAIABzAHQAYQB0AGkAYwAgAGMAcgBlAGEAdABlACgAbgBhAG0AZQA6ACAAcwB0AHIAaQBuAGcAKQAgAHsAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAKACAAIAAgACAAcgBlAHQAdQByAG4AIABuAGUAdwAgAHQAaABpAHMAKABuAGEAbQBlACkAOwAKACAAIAB9AAoAfQAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAACgAKAGMAbABhAHMAcwAgAFMAdQBiACAAZQB4AHQAZQBuAGQAcwAgAEIAYQBzAGUAIAB7AAoAIAAgAGcAcgBlAGUAdAAoACkAIAB7AAoAIAAgACAAIAByAGUAdAB1AHIAbgAgAGAASABpACwAIAAkAHsAdABoAGkAcwAuAG4AYQBtAGUAfQBgADsACgAgACAAfQAKAH0ACgA%3D
Expected result
The fix shouldn't be applied unless running with
--unsafe.Code of Conduct