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

💅 Bun monorepo hoisting of node modules confuses biome's noUndeclaredDependencies rule #4414

Closed
1 task done
calvinusesyourcode opened this issue Oct 29, 2024 · 1 comment
Labels
S-Needs triage Status: this issue needs to be triaged

Comments

@calvinusesyourcode
Copy link

Environment information

CLI:
  Version:                      1.9.4
  Color support:                true

Platform:
  CPU Architecture:             aarch64
  OS:                           macos

Environment:
  BIOME_LOG_PATH:               unset
  BIOME_LOG_PREFIX_NAME:        unset
  BIOME_CONFIG_PATH:            unset
  NO_COLOR:                     unset
  TERM:                         "xterm-256color"
  JS_RUNTIME_VERSION:           unset
  JS_RUNTIME_NAME:              unset
  NODE_PACKAGE_MANAGER:         unset

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:                  false
  All:                          true
  Enabled rules:
  performance/noDelete
  suspicious/noCatchAssign
  suspicious/noUnsafeNegation
  complexity/useLiteralKeys
  a11y/noHeaderScope
  suspicious/noMisrefactoredShorthandAssign
  complexity/noMultipleSpacesInRegularExpressionLiterals
  suspicious/useNamespaceKeyword
  complexity/noUselessEmptyExport
  a11y/useValidLang
  suspicious/useValidTypeof
  suspicious/noDuplicateSelectorsKeyframeBlock
  a11y/useValidAriaRole
  suspicious/noDuplicateParameters
  a11y/useAriaActivedescendantWithTabindex
  style/useDefaultParameterLast
  correctness/noConstantCondition
  correctness/noConstructorReturn
  suspicious/noMisplacedAssertion
  style/useExplicitLengthCheck
  complexity/noEmptyTypeParameters
  complexity/noForEach
  correctness/noUnknownProperty
  suspicious/noClassAssign
  correctness/noUnusedLabels
  complexity/noUselessTernary
  correctness/noUnreachableSuper
  suspicious/noCompareNegZero
  style/useImportType
  correctness/noSwitchDeclarations
  a11y/noAutofocus
  correctness/noUnsafeOptionalChaining
  correctness/noConstAssign
  suspicious/noControlCharactersInRegex
  complexity/noUselessTypeConstraint
  style/noVar
  suspicious/noDoubleEquals
  suspicious/noRedundantUseStrict
  style/useLiteralEnumMembers
  suspicious/noGlobalIsNan
  suspicious/noEmptyInterface
  suspicious/noConstEnum
  suspicious/noSkippedTests
  suspicious/noMisleadingCharacterClass
  correctness/noPrecisionLoss
  a11y/noLabelWithoutControl
  style/useDefaultSwitchClause
  correctness/noStringCaseMismatch
  suspicious/noRedeclare
  correctness/noSetterReturn
  correctness/noInvalidConstructorSuper
  suspicious/noImplicitAnyLet
  a11y/useKeyWithClickEvents
  suspicious/noDuplicateObjectKeys
  suspicious/noUnsafeDeclarationMerging
  suspicious/noFallthroughSwitchClause
  complexity/noUselessThisAlias
  correctness/noUnreachable
  complexity/noThisInStatic
  correctness/noInnerDeclarations
  complexity/useOptionalChain
  suspicious/noDuplicateCase
  a11y/useValidAnchor
  correctness/useArrayLiterals
  complexity/useRegexLiterals
  correctness/noSelfAssign
  correctness/noInvalidBuiltinInstantiation
  style/noUselessElse
  style/useShorthandFunctionType
  suspicious/noShadowRestrictedNames
  correctness/noInvalidDirectionInLinearGradient
  style/useThrowNewError
  suspicious/noImportantInKeyframe
  complexity/noUselessLabel
  complexity/noUselessCatch
  correctness/noUnsafeFinally
  a11y/useAriaPropsForRole
  style/useCollapsedElseIf
  style/useNodeAssertStrict
  correctness/noNonoctalDecimalEscape
  style/useEnumInitializers
  suspicious/noDuplicateTestHooks
  a11y/useHtmlLang
  correctness/noUndeclaredDependencies
  style/noDoneCallback
  complexity/noStaticOnlyClass
  suspicious/noEvolvingTypes
  style/useWhile
  complexity/noUselessUndefinedInitialization
  complexity/useArrowFunction
  style/noInferrableTypes
  a11y/noNoninteractiveTabindex
  complexity/useSimpleNumberKeys
  correctness/useYield
  a11y/noInteractiveElementToNoninteractiveRole
  suspicious/noLabelVar
  correctness/noUnnecessaryContinue
  suspicious/noApproximativeNumericConstant
  style/useNumericLiterals
  suspicious/noImportAssign
  suspicious/useDefaultSwitchClauseLast
  correctness/noGlobalObjectCalls
  style/noParameterProperties
  correctness/noEmptyCharacterClassInRegex
  correctness/noUnknownUnit
  suspicious/noSuspiciousSemicolonInJsx
  suspicious/noSparseArray
  a11y/useIframeTitle
  complexity/noBannedTypes
  correctness/noVoidElementsWithChildren
  style/useThrowOnlyError
  suspicious/noPrototypeBuiltins
  style/useAsConstAssertion
  style/useExportType
  complexity/noUselessLoneBlockStatements
  style/noArguments
  a11y/useValidAriaValues
  suspicious/noGlobalAssign
  suspicious/noCommentText
  suspicious/noThenProperty
  suspicious/useGetterReturn
  suspicious/noDebugger
  suspicious/noMisleadingInstantiator
  style/useFragmentSyntax
  a11y/noPositiveTabindex
  complexity/noVoid
  a11y/useFocusableInteractive
  correctness/noUnmatchableAnbSelector
  suspicious/noDuplicateJsxProps
  correctness/noEmptyPattern
  complexity/noExcessiveNestedTestSuites
  correctness/noRenderReturnValue
  security/noGlobalEval
  style/noYodaExpression
  a11y/useKeyWithMouseEvents
  a11y/noRedundantRoles
  suspicious/noSelfCompare
  security/noDangerouslySetInnerHtmlWithChildren
  suspicious/noExtraNonNullAssertion
  suspicious/noShorthandPropertyOverrides
  style/useConst
  style/noNonNullAssertion
  suspicious/noAsyncPromiseExecutor
  complexity/useFlatMap
  correctness/useHookAtTopLevel
  correctness/useIsNan
  security/noDangerouslySetInnerHtml
  style/useNodejsImportProtocol
  suspicious/noGlobalIsFinite
  style/useConsistentBuiltinInstantiation
  complexity/noWith
  suspicious/noDuplicateFontNames
  a11y/noDistractingElements
  suspicious/noDuplicateClassMembers
  complexity/noExtraBooleanCast
  performance/noAccumulatingSpread
  suspicious/noConfusingLabels
  style/useConsistentArrayType
  correctness/noChildrenProp
  correctness/noUnknownFunction
  correctness/noInvalidPositionAtImportRule
  a11y/useValidAriaProps
  a11y/noRedundantAlt
  complexity/useDateNow
  suspicious/noConfusingVoidType
  suspicious/noFocusedTests
  a11y/useButtonType
  a11y/useSemanticElements
  style/noShoutyConstants
  a11y/noAriaUnsupportedElements
  correctness/noInvalidGridAreas
  style/useFilenamingConvention
  style/useShorthandArrayType
  correctness/noFlatMapIdentity
  style/useShorthandAssign
  suspicious/useErrorMessage
  a11y/noBlankTarget
  a11y/useHeadingContent
  correctness/useValidForDirection
  correctness/noConstantMathMinMaxClamp
  correctness/noUnusedPrivateClassMembers
  correctness/noVoidTypeReturn
  correctness/noInvalidUseBeforeDeclaration
  a11y/noAriaHiddenOnFocusable
  a11y/useGenericFontNames
  correctness/noUnknownMediaFeatureName
  correctness/noInvalidNewBuiltin
  a11y/useAnchorContent
  complexity/noUselessRename
  style/useNumberNamespace
  complexity/noUselessConstructor
  style/noRestrictedGlobals
  correctness/noUnusedFunctionParameters
  style/useExponentiationOperator
  suspicious/useAwait
  a11y/noAccessKey
  complexity/noUselessSwitchCase
  style/useSingleVarDeclarator
  suspicious/noExportsInTest
  suspicious/useNumberToFixedDigitsArgument
  a11y/noNoninteractiveElementToInteractiveRole
  style/noCommaOperator
  suspicious/noDuplicateAtImportRules
  suspicious/useIsArray
  complexity/noUselessFragments
  correctness/noNewSymbol
  performance/useTopLevelRegex
  complexity/noUselessStringConcat
  correctness/noUnusedImports
  suspicious/noEmptyBlock
  suspicious/noFunctionAssign

Workspace:
  Open Documents:               0

Rule name

noUndeclaredDependencies

Playground link

https://github.com/calvinusesyourcode/biome-reproducible-error

Expected result

Expected result

Biome should know to use the package.json closest to the file.

Error

TLDR: I am using bun and have a monorepo with a packages/ folder, and I am getting linter errors relating to the root package.json, meanwhile biome should be using the package's package.json.

Cause of error (in theory)

Because bun monorepos hoist the depedencies up into the root node_modules, instead of using a local node_modules folder in the nested package, biome gets confused when it sees the npm package installed in the root node_modules folder but no depedency mentioned in the root package.json. I bet it would have no problem if the npm package was installed in the nested package's node_modules.

To reproduce:

  1. Clone the minimalist example repo
  2. Open the app/page.tsx
  3. Look at line 3

Here's a one-liner:

git clone https://github.com/calvinusesyourcode/biome-reproducible-error && cd biome-reproducible-error && bun install && code ./packages/react/app/page.tsx

And then look at line 3 and 'react' should give a warning with the message The current dependency isn't specified in your package.json. biome(lint/correctness/noUndeclaredDependencies)

Code of Conduct

  • I agree to follow Biome's Code of Conduct
@calvinusesyourcode calvinusesyourcode added the S-Needs triage Status: this issue needs to be triaged label Oct 29, 2024
@ematipico
Copy link
Member

Monorepos aren't currently supported

#2228

@ematipico ematipico closed this as not planned Won't fix, can't repro, duplicate, stale Nov 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-Needs triage Status: this issue needs to be triaged
Projects
None yet
Development

No branches or pull requests

2 participants