Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork2.8k
Description
- I have tried restarting my IDE and the issue persists.
- I have updated to the latest version of the packages.
- I haveread the FAQ and my problem is not listed.
Repro
.eslintrc.yml
root:trueparser:'@typescript-eslint/parser'parserOptions:project:tsconfig.jsonallowAutomaticSingleRunInference:true
tsconfig.json
{"files": ["index.ts"]}
index.ts
// nothing
pnpm installDEBUG=typescript-eslint:* pnpm eslint index.ts# orDEBUG=typescript-eslint:* ./node_modules/.bin/eslint index.ts
https://github.com/cherryblossom000/typescript-eslint-single-run-pnpm
Expected Result
typescript-estree should detect that this is a single run of ESLint.
$ TSESTREE_SINGLE_RUN=true DEBUG=typescript-eslint:* pnpm eslint index.ts typescript-eslint:typescript-estree:parser parserOptions.project (excluding ignored) matched projects: Set(1) {'/path/to/typescript-eslint-single-run-pnpm/tsconfig.json'} +0ms typescript-eslint:typescript-estree:useProvidedProgram Retrieving astfor /path/to/typescript-eslint-single-run-pnpm/index.ts from provided program instance(s) +0ms typescript-eslint:typescript-estree:parser Detected single-run/CLI usage, creating Program once ahead oftimefor project: /path/to/typescript-eslint-single-run-pnpm/tsconfig.json +2ms typescript-eslint:parser:parser Resolved libs from program: ['lib' ] +0ms
Actual Result
typescript-estree did not detect that this was a single run.
$ DEBUG=typescript-eslint:* pnpm eslint index.ts typescript-eslint:typescript-estree:parser parserOptions.project (excluding ignored) matched projects: Set(1) {'/path/to/typescript-eslint-single-run-pnpm/tsconfig.json'} +0ms typescript-eslint:typescript-estree:createProjectProgram Creating project program for: /path/to/typescript-eslint-single-run-pnpm/index.ts +0ms typescript-eslint:typescript-estree:createWatchProgram File did not belong to any existing programs, moving to create/update. /path/to/typescript-eslint-single-run-pnpm/index.ts +0ms typescript-eslint:typescript-estree:createWatchProgram Creating watch programfor /path/to/typescript-eslint-single-run-pnpm/tsconfig.json. +0ms typescript-eslint:typescript-estree:createWatchProgram Found programfor file. /path/to/typescript-eslint-single-run-pnpm/index.ts +573ms typescript-eslint:parser:parser Resolved libs from program: ['lib' ] +0ms
Additional Info
Instead of copying the Node.js CLI script,pnpm creates a shell script that invokes the direct path to the script (e.g.node node_modules/eslint/bin/eslint.js
) innode_modules/.bin/eslint
:
#!/bin/shbasedir=$(dirname"$(echo"$0"| sed -e's,\\,/,g')")case`uname`in*CYGWIN*) basedir=`cygpath -w"$basedir"`;;esacif [-z"$NODE_PATH" ];thenexport NODE_PATH="/path/to/typescript-eslint-single-run-pnpm/node_modules/.pnpm/eslint@7.32.0/node_modules/eslint/bin/node_modules:/path/to/typescript-eslint-single-run-pnpm/node_modules/.pnpm/eslint@7.32.0/node_modules/eslint/node_modules:/path/to/typescript-eslint-single-run-pnpm/node_modules/.pnpm/eslint@7.32.0/node_modules:/path/to/typescript-eslint-single-run-pnpm/node_modules/.pnpm/node_modules:/path/to/typescript-eslint-single-run-pnpm/node_modules:/path/to/node_modules:/path/node_modules:/node_modules:/path/to/typescript-eslint-single-run-pnpm/node_modules/eslint/bin/node_modules:/path/to/typescript-eslint-single-run-pnpm/node_modules/eslint/node_modules"elseexport NODE_PATH="$NODE_PATH:/path/to/typescript-eslint-single-run-pnpm/node_modules/.pnpm/eslint@7.32.0/node_modules/eslint/bin/node_modules:/path/to/typescript-eslint-single-run-pnpm/node_modules/.pnpm/eslint@7.32.0/node_modules/eslint/node_modules:/path/to/typescript-eslint-single-run-pnpm/node_modules/.pnpm/eslint@7.32.0/node_modules:/path/to/typescript-eslint-single-run-pnpm/node_modules/.pnpm/node_modules:/path/to/typescript-eslint-single-run-pnpm/node_modules:/path/to/node_modules:/path/node_modules:/node_modules:/path/to/typescript-eslint-single-run-pnpm/node_modules/eslint/bin/node_modules:/path/to/typescript-eslint-single-run-pnpm/node_modules/eslint/node_modules"fiif [-x"$basedir/node" ];thenexec"$basedir/node""$basedir/../eslint/bin/eslint.js""$@"elseexec node"$basedir/../eslint/bin/eslint.js""$@"fi
This means thatprocess.argv[1]
ends withnode_modules/eslint/bin/eslint.js
instead ofnode_modules/.bin/eslint
.
I know that I can just useTSESTREE_SINGLE_RUN=true
, that ESLint could change the path to the bin file at any time, and that pnpm isn't as popular as npm and yarn, so I understand if this isn't actionable.
Versions
package | version |
---|---|
@typescript-eslint/typescript-estree | 4.29.3 |
TypeScript | 4.3.5 |
node | 16.8.0 |