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

chore: Enable useProjectService #16192

Merged
merged 2 commits into from
Dec 26, 2023

Conversation

liuxingbaoyu
Copy link
Member

Q                       A
Fixed Issues? Fixes #1, Fixes #2
Patch: Bug Fix?
Major: Breaking Change?
Minor: New Feature?
Tests Added + Pass? Yes
Documentation PR Link
Any Dependency Changes?
License MIT

typescript-eslint/typescript-eslint#8031
The overall lint time is reduced from 38 seconds to 36 seconds.

@babel-bot
Copy link
Collaborator

babel-bot commented Dec 23, 2023

Build successful! You can test your changes in the REPL here: https://babeljs.io/repl/build/56061/

@nicolo-ribaudo
Copy link
Member

(fyi @JoshuaKGoldberg :) )

Copy link
Member

@nicolo-ribaudo nicolo-ribaudo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CI failure is unrelated

@JoshuaKGoldberg
Copy link
Contributor

Ah thanks for tagging me, really lovely to see this! A 5% reduction in lint times and one less JSON file to manage is nice to see. 🙂

eslint.config.js Outdated Show resolved Hide resolved
Co-authored-by: Josh Goldberg ✨ <git@joshuakgoldberg.com>
@liuxingbaoyu liuxingbaoyu merged commit 365aa94 into babel:main Dec 26, 2023
47 of 48 checks passed
@liuxingbaoyu liuxingbaoyu deleted the lint-useProjectService branch December 26, 2023 05:05
@liuxingbaoyu
Copy link
Member Author

@JoshuaKGoldberg
There seems to be an issue here with eslint-vscode , if I undo the modifications of this PR it will work fine, do you have any suggestions?

[Error - 15:59:10] An unexpected error occurred:
[Error - 15:59:10] Error: Error while loading rule '@typescript-eslint/await-thenable': You have used a rule which requires parserServices to be generated. You must therefore provide a value for the "parserOptions.project" property for @typescript-eslint/parser.
Occurred while linting F:\babel\packages\babel-helpers\src\helpers\get.ts
    at getParserServices (F:\babel\node_modules\@typescript-eslint\utils\dist\eslint-utils\getParserServices.js:29:15)
    at create (F:\babel\node_modules\@typescript-eslint\eslint-plugin\dist\rules\await-thenable.js:47:55)
    at Object.create (F:\babel\node_modules\@typescript-eslint\utils\dist\eslint-utils\RuleCreator.js:38:20)
    at createRuleListeners (F:\babel\node_modules\eslint\lib\linter\linter.js:895:21)
    at F:\babel\node_modules\eslint\lib\linter\linter.js:1066:110
    at Array.forEach (<anonymous>)
    at runRules (F:\babel\node_modules\eslint\lib\linter\linter.js:1003:34)
    at Linter._verifyWithFlatConfigArrayAndWithoutProcessors (F:\babel\node_modules\eslint\lib\linter\linter.js:1730:31)
    at Linter._verifyWithFlatConfigArray (F:\babel\node_modules\eslint\lib\linter\linter.js:1861:21)
    at Linter.verify (F:\babel\node_modules\eslint\lib\linter\linter.js:1433:65)

@JoshuaKGoldberg
Copy link
Contributor

JoshuaKGoldberg commented Jan 9, 2024

🤔 I don't reproduce that locally when I open .ts files under packages/babel-helpers. Adding code like await 1234567; to packages/babel-helpers/src/index.ts does give me the expected Unexpected await of a non-Promise (non-"Thenable").

I also don't have a src/helpers/get.ts file locally, and am on Mac rather than Windows. Could you post your branch & how you're running ESLint? (i.e. I think I might need full reproduction steps)

@liuxingbaoyu
Copy link
Member Author

liuxingbaoyu commented Jan 9, 2024

Sorry I made the wrong assumption, I mistakenly thought that helpers/*.ts would trigger this error.
After my testing, this seems to only occur in the vscode extension of eslint, and only files added after initialization will report this error.

Steps to reproduce:

  1. Enable eslint-vscode
  2. Create any new .ts file anywhere
  3. View the output of eslint extension

If I restart vscode, the newly created files will work fine.

image

@nicolo-ribaudo
Copy link
Member

nicolo-ribaudo commented Jan 9, 2024

I also see this error sometimes, and yes restarting vscode seems to make it go away (for some reason restarting the TS server is not enough)

@JoshuaKGoldberg
Copy link
Contributor

Yeah, this is a long-standing issue with running ESLint with typescript-eslint in editors such as VS Code. The only way in ESLint's current API to create type info behind-the-scenes for files is in a parser. But parsers don't get notified of file system events. So @typescript-eslint/parser has no way of knowing of editor actions such as adding new files.

I've been meaning to file couple issues for a while now:

  • A docs issue on our side to add an FAQ
  • Something on vscode-eslint to re-parse on file changes

Thanks for the reminder 🙂 - I need to pull together research for those issues, but will Soon ™️.

eslint/rfcs#102 is a rejected ESLint RFC that would have helped with this issue some (or at least opened the door to better stability). eslint/eslint#16557 tracks the longer-term rewrite that's intended to solve this down the road.

@github-actions github-actions bot added the outdated A closed issue/PR that is archived due to age. Recommended to make a new issue label Apr 23, 2024
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 23, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
outdated A closed issue/PR that is archived due to age. Recommended to make a new issue
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants