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
docs: blog post on parserOptions.projectService #8031
base: main
Are you sure you want to change the base?
docs: blog post on parserOptions.projectService #8031
Conversation
Thanks for the PR, @JoshuaKGoldberg! typescript-eslint is a 100% community driven project, and we are incredibly grateful that you are contributing to that community. The core maintainers work on this in their personal time, so please understand that it may not be possible for them to review your work immediately. Thanks again! 🙏 Please, if you or your company is finding typescript-eslint valuable, help us sustain the project by sponsoring it transparently on https://opencollective.com/typescript-eslint. |
❌ Deploy Preview for typescript-eslint failed.
|
packages/website/blog/2023-09-18-parser-options-project-true.md
Outdated
Show resolved
Hide resolved
packages/website/blog/2024-03-01-parser-options-project-service.md
Outdated
Show resolved
Hide resolved
### Flat ESLint Config | ||
|
||
```diff title="eslint.config.js" | ||
export default tseslint.flatConfig({ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🤞 hopefully
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Heh if we don't support flat config by the time this rolls out I will be in a lot of emotional pain...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note: before un-drafting, I"ll want to revisit this and align it to how our flat config support ended up looking.
packages/website/blog/2024-03-01-parser-options-project-service.md
Outdated
Show resolved
Hide resolved
packages/website/blog/2024-03-01-parser-options-project-service.md
Outdated
Show resolved
Hide resolved
} | ||
``` | ||
|
||
For example, specifying `projectService.additionalFiles: ['./*']` would solve the common case of projects that have root-level files such as `eslint.config.js` and `vitest.config.ts`: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I personally don't like this advice because it's a lot wider than we might otherwise intend and will match all files in the root.
I think it's better to not suggest ./*
and instead suggest being explicit to keep things narrow and cleaner.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Blurgh, I'm torn. It's rather inconvenient having to specify files by name. It's pretty common to have >=3 files there. https://github.com/JoshuaKGoldberg/create-typescript-app has ESLint, tsup, and Vitest right now.
Having a ['./*']
be the starting recommending means users can copy+paste without having to pause to tinker with individual file names. IMO the much smoother onboarding there is a pretty big value prop.
Given that #7752 has it throw an error if a file is redundantly included, what are the practical downsides of having a permissive glob?
packages/website/blog/2024-03-01-parser-options-project-service.md
Outdated
Show resolved
Hide resolved
|
||
<!--/tabs--> | ||
|
||
See [typescript-eslint/examples](https://github.com/typescript-eslint/examples) for more references of how to configure linting in different projects. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
note for before landing - this doesn't exist yet.
packages/website/blog/2024-03-01-parser-options-project-service.md
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
babel/babel#16192 ❤️ - would be nice to have a "success stories" section...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great to see exciting features
packages/website/blog/2024-03-01-parser-options-project-service.md
Outdated
Show resolved
Hide resolved
packages/website/blog/2024-03-01-parser-options-project-service.md
Outdated
Show resolved
Hide resolved
packages/website/blog/2024-03-01-parser-options-project-service.md
Outdated
Show resolved
Hide resolved
|
||
See [typescript-eslint/examples](https://github.com/typescript-eslint/examples) for more references of how to configure linting in different projects. | ||
|
||
## Performance Comparisons |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe also good to have - #7906 ...
Co-authored-by: Joshua Chen <sidachen2003@gmail.com>
project: true, | ||
// Add this line | ||
projectService: true, | ||
tsconfigRootDir: __dirname, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
__dirname
is not available inside an NodeJS ES Module.
Use import.meta.dirname
(since v21.2.0) or join(fileURLToPath(import.meta.url), '..')
PR Checklist
Overview
Adds a blog post that describes using
parserOptions.projectService
(what we currently callparserOptions.EXPERIMENTAL_useProjectService
). It sets up a plan to call itprojectService
in v7, then replaceproject
in v8.Note that this is blocked on:
This is where my mindset is for the option.
💖