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 reports different results if current working directory changes #2475

Closed
1 task done
ipanasenko opened this issue Apr 15, 2024 · 6 comments
Closed
1 task done
Labels
A-Analyzer Area: analyzer A-Project Area: project S-Bug-confirmed Status: report has been confirmed as a valid bug

Comments

@ipanasenko
Copy link
Contributor

Environment information

CLI:
  Version:                      1.7.0
  Color support:                true

Platform:
  CPU Architecture:             aarch64
  OS:                           macos

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

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

Linter:
  Recommended:                  true
  All:                          false
  Rules:                        a11y/noSvgWithoutTitle = "off"
                                a11y/useKeyWithClickEvents = "off"
                                a11y/useKeyWithMouseEvents = "off"
                                a11y/useValidAnchor = "off"
                                complexity/noExcessiveNestedTestSuites = "error"
                                complexity/noUselessLoneBlockStatements = "error"
                                complexity/noUselessTernary = "error"
                                correctness/noInvalidUseBeforeDeclaration = "off"
                                correctness/noNewSymbol = "error"
                                correctness/noUnusedImports = "error"
                                correctness/noUnusedPrivateClassMembers = "error"
                                correctness/noUnusedVariables = "error"
                                correctness/useExhaustiveDependencies = "off"
                                correctness/useHookAtTopLevel = "error"
                                nursery/noConstantMathMinMaxClamp = "error"
                                nursery/noEvolvingAny = "error"
                                nursery/noFlatMapIdentity = "error"
                                nursery/noMisplacedAssertion = "error"
                                nursery/noUndeclaredDependencies = "off"
                                performance/noDelete = "off"
                                style/noNegationElse = "error"
                                style/noNonNullAssertion = "off"
                                style/noRestrictedGlobals = "error"
                                style/noShoutyConstants = "error"
                                style/noUnusedTemplateLiteral = "off"
                                style/useBlockStatements = "error"
                                style/useCollapsedElseIf = "error"
                                style/useForOf = "error"
                                style/useImportType = "error"
                                style/useNodejsImportProtocol = "error"
                                style/useNumberNamespace = "error"
                                style/useShorthandAssign = "error"
                                style/useShorthandFunctionType = "error"
                                style/useSingleCaseStatement = "error"
                                suspicious/noConsoleLog = "error"
                                suspicious/noRedeclare = "off"
                                suspicious/noSkippedTests = "off"

Workspace:
  Open Documents:               0

Rule name

noUndeclaredDependencies

Playground link

not applicable

Expected result

I don't really know what additional info to provide. I will try to create a reproducible repo, but for now this all I have.

Note that this is a monorepo. Dependencies are declared NOT in root package.json file.

/package.json
/apps
    /app-1
        /package.json      <- dependencies used in `File.tsx` are declared here
            /src
                /File.tsx

When running npx biome check I see no errors. But at the same time WebStorm and VSCode highlight imports as errors, and I see the same error during precommit hook.

npx biome check:
image

git commit:
image

WebStorm:
image

Let me know if I need to provide more info, thank you!

Code of Conduct

  • I agree to follow Biome's Code of Conduct
@GabenGar
Copy link
Contributor

Within the monorepo setting include biome.json at the root of your monorepo. Third-party tools cannot into multi-root setups like monorepos and cannot read multiple biome config files.
It sucks, especially if you use different configs for different projects within the monorepo, but so far it is the least problematic setup.

@ipanasenko
Copy link
Contributor Author

I have single biome.json and it's is in the repo root. I don't have Biome configuration issue, it just reports things differently in IDE/precommit hook and from CLI

@Sec-ant
Copy link
Member

Sec-ant commented Apr 16, 2024

I think this is because the root directory detection (cwd) has different results in CLI, LSP and git hooks. I will look into this issue.

@Sec-ant
Copy link
Member

Sec-ant commented Jun 18, 2024

I did some debugging but couldn't find time to implement the fix, others are welcome to tackle it. Here is what I found:

  1. The problem is not only about LSP, it also happens in CLI commands, see 💅 noUndeclaredDependencies checks root package.json in monorepo workspaces #3202
  2. The reason is that we associate only one manifest file for each project. It will only resolve it once from the workspace root or working directory. However we can have many manifest files in a project like a monorepo in this issue. Relative code at
    fn resolve_manifest(cli_session: &CliSession) -> Result<(), WorkspaceError> {
    and
    pub(crate) async fn load_manifest(&self) {
  3. To fix it we may need to revamp the structure of the project/workspace internal structure.

@Sec-ant Sec-ant removed their assignment Jun 18, 2024
@Sec-ant Sec-ant added S-Help-wanted Status: you're familiar with the code base and want to help the project A-Project Area: project S-Bug-confirmed Status: report has been confirmed as a valid bug A-Analyzer Area: analyzer labels Jun 18, 2024
@aminya
Copy link

aminya commented Sep 25, 2024

For me, it fails to detect dependencies in a pnpm monorepo workspace even from CLI. It also errors out in VsCode.

@arendjr arendjr removed the S-Help-wanted Status: you're familiar with the code base and want to help the project label Jan 7, 2025
@arendjr arendjr changed the title 💅 noUndeclaredDependencies - works fine during check, reports false-positives in WebStorm, VSCode and during precommit hook using lefthook 💅 noUndeclaredDependencies reports different results if current working directory changes Jan 7, 2025
@arendjr
Copy link
Contributor

arendjr commented Jan 7, 2025

Will be fixed in 2.0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-Analyzer Area: analyzer A-Project Area: project S-Bug-confirmed Status: report has been confirmed as a valid bug
Projects
None yet
Development

No branches or pull requests

5 participants