-
Notifications
You must be signed in to change notification settings - Fork 146
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: upgrade @typescript-eslint
#852
chore: upgrade @typescript-eslint
#852
Conversation
`eslint-config-kentcdodds` uses some outdated packages which block us from upgrading TypeScript dependencies.
Because `@typescript-eslint` uses package.json `exports`, we had to upgrade some dependencies which didn't support `exports` (see typescript-eslint/typescript-eslint#7284). Affected dependencies: - `jest`
extends: [ | ||
'kentcdodds', |
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.
eslint-config-kentcdodds
uses some outdated packages which block us from upgrading TypeScript dependencies properly. It didn't bring many rules so decided just use eslint:recommended
, plugin:import/recommended
and configure some rules manually.
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 like this change! We should apply it anyway.
@@ -53,7 +53,7 @@ jobs: | |||
fail-fast: false | |||
matrix: | |||
# The .x indicates "the most recent one" | |||
node: [19.x, 18.x, 17.x, 16.x, 14.x, 14.17.0, 12.x, 12.22.0] |
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.
Dropped support for Node.js versions lower than 16. They're not maintained for a long time and don't support package.json exports
which is used at least in @typescript-eslint
.
# Files | ||
package-lock.json | ||
|
||
# Folders | ||
node_modules/ | ||
dist/ |
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.
Add .prettierignore
to ignore dist
folder.
@@ -44,8 +55,8 @@ module.exports = { | |||
project: ['./tsconfig.eslint.json'], | |||
}, | |||
extends: [ | |||
'plugin:@typescript-eslint/recommended', | |||
'plugin:@typescript-eslint/recommended-requiring-type-checking', | |||
'plugin:@typescript-eslint/strict-type-checked', |
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.
We can also add plugin:@typescript-eslint/stylistic-type-checked
which brings some useful rules but I wasn't sure what rules should be used in the project.
@@ -54,6 +65,25 @@ module.exports = { | |||
{ argsIgnorePattern: '^_' }, | |||
], | |||
'@typescript-eslint/no-use-before-define': 'off', | |||
'@typescript-eslint/no-unnecessary-condition': 'off', |
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.
Disabled that rule because we have a lot of errors from it in the project and fixing it might cause some issues. If we want to enable this rule, we need to fix it carefully.
// @ts-expect-error -- TODO: fix me | ||
property.init.value > 0 |
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.
Previously, we had suppressImplicitAnyIndexErrors: true
in tsconfig.json
which allowed such code. But in TypeScript v5, it complains about this configuration so I removed it.
I think we should fix such places but it's better to do it in a separate PR.
"module": "Node16", | ||
"moduleResolution": "Node16", |
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.
We need this to support exports
from package.json
(typescript-eslint/typescript-eslint#7284).
"esModuleInterop": true, | ||
"resolveJsonModule": true, | ||
"forceConsistentCasingInFileNames": true, | ||
"noImplicitAny": true, | ||
"outDir": "./dist", | ||
"removeComments": true, | ||
"skipLibCheck": true, | ||
"sourceMap": false, | ||
"suppressImplicitAnyIndexErrors": true | ||
"sourceMap": false | ||
}, | ||
"include": ["./lib/**/*.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 think we should include all TS files by default so IDE can process all TS files and have a separate TS config for building the package. Decided to not do this in this PR.
Hi @lesha1201. Thanks for your contribution, but I'm afraid I have to reject this PR until ESLint v9 is released, and we bump the plugin to the next major:
|
We only dropped support for Node.js lower than v16 in this PR. And it might work fine in v12 and v14 because they also support package.json The main issue that motivated me to open this PR is that a lot of popular ESLint plugins uses ESLint v9 won't be released soon. We can create a major release now that upgrades TS related packages and then create another major release that upgrades ESLint v9 and something else. Users who rely on old Node.js versions can use the current version of Should I open separate PRs for some changes? If so can you please write a list of changes that you would like to see in separate PRs? Also do you have other tasks I can work on? For example, we can upgrade Prettier. |
That's already a breaking change, but also it's not in the same page as versions supported by ESLint v8.
We could indeed. No idea when ESLint will be released, but I want to avoid releasing a major just for the sake of upgrading typescript-eslint. I get the motivation for all the updates you did (I was planning to start working on it during Christmas break, so any help is appreciated). However, we can't perform them all at once, and some will have to wait a bit. In order to keep discussing it, I'll open a new issue. |
eslint-plugin-testing-library
has an outdateddependency
-@typescript-eslint/utils
and because of it, in modern setups, it might result in duplicate@typescript-eslint/parser
packages.This PR upgrades all
@typescript-eslint
dependencies as well as TypeScript.Because
@typescript-eslint@6
uses package.jsonexports
, we had to upgrade some dependencies which didn't supportexports
(see typescript-eslint/typescript-eslint#7284). Affected dependencies:jest
I also dropped support for Node.js versions lower than 16 because they're not maintained anymore (v16 also not maintained but decided to leave it for now).
@typescript-eslint@6
Upgrading
@typescript-eslint
brought new rules. The rules I fixed:@typescript-eslint/no-redundant-type-constituents
@typescript-eslint/no-confusing-void-expression