-
Notifications
You must be signed in to change notification settings - Fork 364
Detect root via lockfiles; do not treat package.json as root #2076
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
base: main
Are you sure you want to change the base?
Detect root via lockfiles; do not treat package.json as root #2076
Conversation
…Ensures auto working directory stops only when a lockfile or eslint config is present.
fab8285 to
d55c506
Compare
|
@kapral18 thanks for the PR. Should the logic not be like this:
|
yes that + logic for flat config files also signaling root, would be a better root detection probably, especially considering that there can be eslintConfig blocks inside package.json (which are no longer supported in v9+ but still) |
…ow ESLint best practices
|
@microsoft-github-policy-service agree |
…and add safety improvements - Replace multiple fs.existsSync calls with single fs.readdirSync per directory (22x performance improvement) - Add maximum iteration limit to prevent infinite loops in traversal - Fix unnecessary array copy when finding uppermost package.json - Normalize workspace folder path once for consistent path comparison
43795eb to
9fea788
Compare
|
@dbaeumer I split the indicators into semantic groups so that the priority and connection is a little clearer to read and easier to work with. Priority is handled a little more explicitly I think now, but check out and let me know what you think? I didn't add test infrastructure to avoid exploding this PR's size since there is no testing infra for server available in the first place. But I tested locally so let me know if this can work |
|
@dbaeumer actually I just realized that this very repository is breaking my assumptions about eslint.config.js usage. In my proposal I am looking at eslint.config.js as a primary boundary indicator superior to lock files, because flat config files like eslint.config.js are supposed to be used in project roots, but here you have lock roots and eslintrc.js root file in server and client respectively while putting an eslint.config.js on the .git root level. Can you kindly help me understand what is the grand design here? |
|
@kapral18 the |
|
@dbaeumer I still see them in https://github.com/microsoft/vscode-eslint/blob/main/server/src/eslint.ts#L816 or what do you mean? Do you mean VSCode extension no longer supports .eslintrc.json files specifically? |
Fixes #2077
package.jsonas a project root by itself in projectFolderIndicatorspackage-lock.json,yarn.lock,pnpm-lock.yaml,bun.lockbetc...) as rootspnpm-workspace.yaml,lerna.json,nx.json,rush.json,.yarnrc.yml) as rootseslint.config.*entriespackage.jsonwhen no lockfiles existfs.readdirSyncper directory instead of multiplefs.existsSynccallsThis ensures
autoworking directory detection stops at real project roots (lockfiles) while allowing nestedpackage.jsonwithout lockfiles to bubble up to where root configs live. The refactored logic is more modular, performant, and follows ESLint flat config best practices.A few examples of
package.json-containing packages that are not roots:https://github.com/remix-run/react-router/blob/main/packages/react-router/package.json
https://github.com/elastic/kibana/blob/main/packages/kbn-dependency-usage/package.json
https://github.com/facebook/react/blob/main/packages/react-art/package.json