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

💅 noUndeclaredDependencies special case #4711

Open
1 task done
mrazauskas opened this issue Dec 9, 2024 · 2 comments
Open
1 task done

💅 noUndeclaredDependencies special case #4711

mrazauskas opened this issue Dec 9, 2024 · 2 comments
Labels
S-Needs discussion Status: needs a discussion to understand criteria S-Needs triage Status: this issue needs to be triaged

Comments

@mrazauskas
Copy link
Contributor

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:           "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:                 true

Linter:
  JavaScript enabled:           true
  JSON enabled:                 true
  CSS enabled:                  true
  GraphQL enabled:              false
  Recommended:                  true
  All:                          false
  Enabled rules:
  performance/noDelete
  suspicious/noCatchAssign
  suspicious/noUnsafeNegation
  complexity/noForEach
  correctness/noUnusedImports
  complexity/noUselessStringConcat
  complexity/noMultipleSpacesInRegularExpressionLiterals
  a11y/useValidLang
  complexity/noUselessEmptyExport
  suspicious/useNamespaceKeyword
  suspicious/useValidTypeof
  style/useExplicitLengthCheck
  correctness/noConstantCondition
  a11y/useAriaActivedescendantWithTabindex
  a11y/useValidAriaRole
  style/useDefaultParameterLast
  complexity/noEmptyTypeParameters
  correctness/noConstructorReturn
  style/useSelfClosingElements
  suspicious/noAssignInExpressions
  suspicious/noDuplicateParameters
  suspicious/noDuplicateSelectorsKeyframeBlock
  correctness/noUnknownProperty
  style/useTemplate
  correctness/noUnusedLabels
  complexity/noUselessTernary
  suspicious/noExplicitAny
  correctness/noUnreachableSuper
  suspicious/noCompareNegZero
  correctness/noSwitchDeclarations
  a11y/noAutofocus
  correctness/noUnsafeOptionalChaining
  correctness/noConstAssign
  suspicious/noMisplacedAssertion
  suspicious/noControlCharactersInRegex
  complexity/noUselessTypeConstraint
  style/noVar
  suspicious/noDoubleEquals
  suspicious/noRedundantUseStrict
  style/useLiteralEnumMembers
  suspicious/noGlobalIsNan
  suspicious/noEmptyInterface
  suspicious/noSkippedTests
  style/useImportType
  suspicious/noMisleadingCharacterClass
  correctness/noPrecisionLoss
  a11y/noLabelWithoutControl
  suspicious/noRedeclare
  correctness/noStringCaseMismatch
  correctness/noSetterReturn
  correctness/noInvalidConstructorSuper
  suspicious/noImplicitAnyLet
  a11y/useKeyWithClickEvents
  suspicious/noDuplicateObjectKeys
  complexity/noUselessThisAlias
  correctness/noUnreachable
  suspicious/noFallthroughSwitchClause
  suspicious/noUnsafeDeclarationMerging
  complexity/noThisInStatic
  complexity/useOptionalChain
  correctness/noInnerDeclarations
  suspicious/noDuplicateCase
  a11y/useValidAnchor
  complexity/useRegexLiterals
  correctness/noSelfAssign
  correctness/noInvalidBuiltinInstantiation
  style/noUselessElse
  style/useShorthandFunctionType
  suspicious/noShadowRestrictedNames
  correctness/noInvalidDirectionInLinearGradient
  style/useThrowNewError
  suspicious/noImportantInKeyframe
  a11y/useMediaCaption
  complexity/noUselessLabel
  complexity/noUselessCatch
  correctness/noUnsafeFinally
  a11y/useAriaPropsForRole
  style/useCollapsedElseIf
  correctness/noNonoctalDecimalEscape
  style/useEnumInitializers
  a11y/useHtmlLang
  suspicious/noDuplicateTestHooks
  correctness/noUndeclaredDependencies
  suspicious/noEvolvingTypes
  style/useWhile
  complexity/noUselessUndefinedInitialization
  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/noUnknownUnit
  correctness/useImportExtensions
  a11y/useAltText
  correctness/noEmptyCharacterClassInRegex
  a11y/useIframeTitle
  suspicious/noPrototypeBuiltins
  a11y/noSvgWithoutTitle
  correctness/noVoidElementsWithChildren
  style/useAsConstAssertion
  suspicious/noDebugger
  style/useExportType
  complexity/noUselessLoneBlockStatements
  style/noArguments
  a11y/useValidAriaValues
  suspicious/noGlobalAssign
  suspicious/noCommentText
  a11y/useFocusableInteractive
  correctness/noUnmatchableAnbSelector
  suspicious/noMisleadingInstantiator
  suspicious/noDuplicateJsxProps
  suspicious/noThenProperty
  a11y/noPositiveTabindex
  correctness/noEmptyPattern
  complexity/noExcessiveNestedTestSuites
  security/noDangerouslySetInnerHtmlWithChildren
  a11y/useKeyWithMouseEvents
  style/useNamingConvention
  suspicious/noExtraNonNullAssertion
  correctness/noRenderReturnValue
  correctness/useExhaustiveDependencies
  security/noGlobalEval
  style/noNonNullAssertion
  a11y/noRedundantRoles
  complexity/useFlatMap
  correctness/useIsNan
  correctness/noUnusedVariables
  style/useConst
  style/noYodaExpression
  suspicious/noGlobalIsFinite
  style/useConsistentBuiltinInstantiation
  suspicious/noAsyncPromiseExecutor
  suspicious/noDuplicateFontNames
  suspicious/noSelfCompare
  security/noDangerouslySetInnerHtml
  style/useNodejsImportProtocol
  a11y/noDistractingElements
  style/useConsistentArrayType
  complexity/noWith
  suspicious/noArrayIndexKey
  style/useForOf
  suspicious/noDuplicateClassMembers
  complexity/noExtraBooleanCast
  performance/noAccumulatingSpread
  a11y/useValidAriaProps
  a11y/noRedundantAlt
  complexity/useDateNow
  correctness/noChildrenProp
  correctness/noInvalidPositionAtImportRule
  correctness/noUnknownFunction
  suspicious/noConfusingLabels
  suspicious/useGetterReturn
  suspicious/noConsole
  suspicious/noConfusingVoidType
  suspicious/noFocusedTests
  a11y/useButtonType
  a11y/useSemanticElements
  suspicious/noShorthandPropertyOverrides
  a11y/noAriaUnsupportedElements
  correctness/noInvalidGridAreas
  correctness/noFlatMapIdentity
  style/useShorthandAssign
  suspicious/useErrorMessage
  suspicious/noSuspiciousSemicolonInJsx
  a11y/noBlankTarget
  a11y/useHeadingContent
  suspicious/noSparseArray
  correctness/useValidForDirection
  correctness/noUnusedPrivateClassMembers
  correctness/noVoidTypeReturn
  correctness/noInvalidUseBeforeDeclaration
  a11y/noAriaHiddenOnFocusable
  a11y/useGenericFontNames
  correctness/noUnknownMediaFeatureName
  a11y/useAnchorContent
  complexity/noUselessRename
  style/useBlockStatements
  style/useNumberNamespace
  complexity/noUselessConstructor
  a11y/noAccessKey
  correctness/noUnusedFunctionParameters
  style/noUnusedTemplateLiteral
  complexity/noUselessSwitchCase
  style/useExponentiationOperator
  correctness/noUndeclaredVariables
  style/noNegationElse
  suspicious/useAwait
  style/useSingleVarDeclarator
  suspicious/noExportsInTest
  suspicious/useNumberToFixedDigitsArgument
  a11y/noNoninteractiveElementToInteractiveRole
  style/noCommaOperator
  suspicious/noDuplicateAtImportRules
  suspicious/useIsArray
  a11y/noHeaderScope
  complexity/noUselessFragments
  suspicious/noMisrefactoredShorthandAssign
  suspicious/noEmptyBlock
  suspicious/noClassAssign
  style/noImplicitBoolean
  suspicious/noFunctionAssign

Workspace:
  Open Documents:               0

Rule name

noUndeclaredDependencies

Playground link

https://biomejs.dev/playground/?lineWidth=120&indentStyle=space&lintRules=all&code=aQBtAHAAbwByAHQAIAB2AHMAYwBvAGQAZQAgAD0AIAByAGUAcQB1AGkAcgBlACgAIgB2AHMAYwBvAGQAZQAiACkAOwAKAAoAZQB4AHAAbwByAHQAIABmAHUAbgBjAHQAaQBvAG4AIABhAGMAdABpAHYAYQB0AGUAKABjAG8AbgB0AGUAeAB0ADoAIAB2AHMAYwBvAGQAZQAuAEUAeAB0AGUAbgBzAGkAbwBuAEMAbwBuAHQAZQB4AHQAKQA6ACAAdgBvAGkAZAAgAHsACgAgACAAYwBvAG4AcwB0ACAAZABpAHMAcABvAHMAYQBiAGwAZQAgAD0AIAB2AHMAYwBvAGQAZQAuAGMAbwBtAG0AYQBuAGQAcwAuAHIAZQBnAGkAcwB0AGUAcgBDAG8AbQBtAGEAbgBkACgAIgBoAGUAbABsAG8AdwBvAHIAbABkAC4AaABlAGwAbABvAFcAbwByAGwAZAAiACwAIAAoACkAIAA9AD4AIAB7AAoAIAAgACAAIAB2AHMAYwBvAGQAZQAuAHcAaQBuAGQAbwB3AC4AcwBoAG8AdwBJAG4AZgBvAHIAbQBhAHQAaQBvAG4ATQBlAHMAcwBhAGcAZQAoACIASABlAGwAbABvACAAVwBvAHIAbABkACEAIgApADsACgAgACAAfQApADsACgAKACAAIABjAG8AbgB0AGUAeAB0AC4AcwB1AGIAcwBjAHIAaQBwAHQAaQBvAG4AcwAuAHAAdQBzAGgAKABkAGkAcwBwAG8AcwBhAGIAbABlACkAOwAKAH0ACgA%3D

Expected result

VS Code extensions must import APIs from "vscode" package. This is just a place holder, such package is not even published to npm registry.

Might be worth to treat "vscode" as a special case. I think it should not be treated as missing dependency.


By the way, it would nice to support the following syntax:

import vscode = require("vscode");

This way tsc emits cleaner code:

const vscode = require("vscode");

Code of Conduct

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

We rarely add "special cases" in our rules, and we usually tend to add options instead.

@ematipico ematipico added the S-Needs discussion Status: needs a discussion to understand criteria label Dec 9, 2024
@mrazauskas
Copy link
Contributor Author

mrazauskas commented Dec 9, 2024

Got it. I agree with this policy.

My thinking was that in this context vscode is the host, not a library. Hence it might be worth treating the imports from vscode similarly how imports of node:* APIs are treated. In a way it sounds more like a pattern, than an exception.

Just wanted to leave few more thoughts. These are your internal decisions, of course. Definitely worth a discussion.


Option sounds good. Perhaps it could look like this:

{
  "options": {
    "environment": "vscode", // or "node" (default), "deno", "bun"
  }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-Needs discussion Status: needs a discussion to understand criteria S-Needs triage Status: this issue needs to be triaged
Projects
None yet
Development

No branches or pull requests

2 participants