Skip to content

linter: Files in the node_modules under non-git repo will be scanned #13793

@fengmk2

Description

@fengmk2

What version of Oxlint are you using?

1.15.0

What command did you run?

npx oxlint

What does your .oxlintrc.json config file look like?

no

What happened?

I used create-vite to create a new project. When trying to run oxlint, it was found that it scanned all files under node_modules, and .gitignore ignores the node_modules directory.
Trigger condition: The current directory is not a git repo

Steps to reproduce:

npm create vite@latest my-vite-app -- --template vanilla-ts
cd my-vite-app
npm i
npx oxlint

You will see that oxlint scans the files under node_modules

  ⚠ eslint(no-unused-vars): Variable 'import_stream' is declared but never used. Unused variables should start with a '_'.
       ╭─[node_modules/vite/dist/node/chunks/dep-M_KD0XSK.js:24036:5]
 24035 │ //#region ../../node_modules/.pnpm/[email protected]/node_modules/ws/wrapper.mjs
 24036 │ var import_stream = /* @__PURE__ */ __toESM(require_stream(), 1);
       ·     ──────┬──────
       ·           ╰── 'import_stream' is declared here
 24037 │ var import_receiver = /* @__PURE__ */ __toESM(require_receiver(), 1);
       ╰────
  help: Consider removing this declaration.

...

 199119 │     })({ get exports() { return ts; }, set exports(v) { ts = v; if (typeof module !== "undefined" && module.exports) { module.exports = v; } } })
        ╰────
  help: This expression always evaluates to the constant on the left-hand side

Found 695 warnings and 0 errors.
Finished in 1.7s on 279 files with 88 rules using 16 threads.

The issue disappears once I initialize the current directory as a git repo.

git init
npx oxlint

Found 0 warnings and 0 errors.
Finished in 2ms on 3 files with 88 rules using 16 threads.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions