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

docs: blog post on parserOptions.projectService #8031

Draft
wants to merge 7 commits into
base: main
Choose a base branch
from

Conversation

JoshuaKGoldberg
Copy link
Member

@JoshuaKGoldberg JoshuaKGoldberg commented Dec 6, 2023

PR Checklist

Overview

Adds a blog post that describes using parserOptions.projectService (what we currently call parserOptions.EXPERIMENTAL_useProjectService). It sets up a plan to call it projectService in v7, then replace project in v8.

Note that this is blocked on:

This is where my mindset is for the option.

💖

@typescript-eslint
Copy link
Contributor

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.

Copy link

netlify bot commented Dec 6, 2023

Deploy Preview for typescript-eslint failed.

Name Link
🔨 Latest commit a7097ac
🔍 Latest deploy log https://app.netlify.com/sites/typescript-eslint/deploys/663f85b5c85a5900080ae4c3

### Flat ESLint Config

```diff title="eslint.config.js"
export default tseslint.flatConfig({
Copy link
Member

Choose a reason for hiding this comment

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

🤞 hopefully

Copy link
Member Author

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...

Copy link
Member Author

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.

}
```

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`:
Copy link
Member

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.

Copy link
Member Author

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?


<!--/tabs-->

See [typescript-eslint/examples](https://github.com/typescript-eslint/examples) for more references of how to configure linting in different projects.
Copy link
Member

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.

Copy link
Member Author

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...

Copy link
Member

@Josh-Cena Josh-Cena left a 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


See [typescript-eslint/examples](https://github.com/typescript-eslint/examples) for more references of how to configure linting in different projects.

## Performance Comparisons
Copy link
Member Author

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,

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), '..')

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Docs: Add blog post for EXPERIMENTAL_useProjectService
4 participants