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: use typescript-eslint@v8's projectService for typed linting #11315

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion eslint.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ export default [
languageOptions: {
parser: typescriptParser,
parserOptions: {
project: ['./packages/*/tsconfig.json', './tsconfig.eslint.json'],
projectService: true,
tsconfigRootDir: __dirname,
},
},
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@
"prettier-plugin-astro": "^0.14.1",
"turbo": "^1.13.4",
"typescript": "~5.5.4",
"typescript-eslint": "^7.18.0"
"typescript-eslint": "^8.0.1"
},
"pnpm": {
"packageExtensions": {
Expand Down
135 changes: 66 additions & 69 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 0 additions & 6 deletions tsconfig.eslint.json

This file was deleted.

21 changes: 18 additions & 3 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,20 @@
// Yes this file is intentionally empty!
// Yes this file is intentionally near-empty!
// ---
// Having a blank `tsconfig.json` file prevents TypeScript from crawling up your directory tree
// and possibly picking up a parent `tsconfig.json` (which, unsurprisingly, is very hard to debug)
{}
// and possibly picking up a parent `tsconfig.json` (which, unsurprisingly, is very hard to debug).
// This is also used for linting out-of-project files with type information.
{
"extends": "./tsconfig.base.json",
"compilerOptions": {
"allowJs": true,
"noEmit": true
},
"include": [
".",
"packages/upgrade/upgrade.mjs",
// ...and yet:
// /Users/josh/repos/astro/packages/upgrade/upgrade.mjs
// 0:0 error Parsing error: /Users/josh/repos/astro/packages/upgrade/upgrade.mjs was not found by the project service.
// Consider either including it in the tsconfig.json or including it in allowDefaultProject
]
}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Well, I figured it out. https://github.com/JoshuaKGoldberg/repros/tree/tseslint-project-service-non-included-nearest-tsconfig is a simplified reproduction.

Basically:

  • packages/upgrade/tsconfig.json includes ["src"]
  • packages/upgrade/upgrade.mjs is not in that includes
  • The project service therefore isn't picking up the file

This would be a good case to stick with parserOptions.project, to give more fine-grained control over what projects include each file. I filed typescript-eslint/typescript-eslint#9753 to document this better.

Loading