-
Notifications
You must be signed in to change notification settings - Fork 212
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
Deduplicate checks between ESLint and TypeScript #3008
Deduplicate checks between ESLint and TypeScript #3008
Conversation
Size Change: -4.73 kB (-1%) Total Size: 891 kB
ℹ️ View Unchanged
|
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.
In others, we disable TypeScript checks because ESLint handles them more flexible (i.e., still allows the project to build, which is useful during development, but still shows an error on linting).
This is a really nice change, thank you!
Tested this PR locally, and it behaved just as you describe: when there's an unused import, the app builds fine but you cannot commit.
files: ["*.ts"], | ||
rules: { | ||
"tsdoc/syntax": "error", | ||
// This rule is disabled above to avoid forcing ESM syntax on regular JS files |
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.
What does "forcing ESM syntax on regular JS files" mean here? Where do we do that?
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.
The disabled rule would raise on every usage of require
in our regular JavaScript files and require them to be turned into import
statements instead. Our tooling doesn't support that across the board, but our TypeScript files can abide by that rule (because TypeScript supports that syntax out of the box). If we wanted to enable this rule everywhere we would need to change the node scripts we run directly (locales, tapes, etc) to mjs
... or run them with ts-node
.
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.
LGTM. Appreciate the in-code comments explaining where ESLint is preferable over TS and vice versa.
Co-authored-by: Olga Bulat <[email protected]>
Fixes
Fixes #3007 by @sarayourfriend
Description
Enables the import plugin's typescript config and does some additional configuration to improve the relationship between TypeScript and ESLint. In some cases, we disable ESLint rules because TypeScript already handles them. In others, we disable TypeScript checks because ESLint handles them more flexible (i.e., still allows the project to build, which is useful during development, but still shows an error on linting).
Testing Instructions
Checkout the branch and run
pnpm install && pnpm run eslint
and confirm linting is working. Try something like importing or declaring an unused variable in a frontend file and confirm that you get an ESLint error when runningpnpm run eslint
, but that you do not see a TS error about it when runningjust p frontend types
.Checklist
Update index.md
).main
) or a parent feature branch.Developer Certificate of Origin
Developer Certificate of Origin