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

feat: update to @typescript-eslint v6 #1222

Closed
wants to merge 1 commit into from
Closed

feat: update to @typescript-eslint v6 #1222

wants to merge 1 commit into from

Conversation

retrixe
Copy link

@retrixe retrixe commented Aug 17, 2023

What is the purpose of this pull request? (put an "X" next to item)

[ ] Documentation update
[ ] Bug fix
[X] New feature
[ ] Other, please explain:

What changes did you make? (Give an overview)

Which issue (if any) does this pull request address?

Fixes #1188

Is there anything you'd like reviewers to focus on?

- Update to TypeScript ESLint v6.4.0
- Handle breaking change in @typescript-eslint/restrict-plus-operands
  See: https://typescript-eslint.io/blog/announcing-typescript-eslint-v6
- Enable skipLibCheck in tsconfig.json to fix harmless compile error
  TypeScript's documentation recommends enabling skipLibCheck too:
  https://www.typescriptlang.org/tsconfig#skipLibCheck
@welcome
Copy link

welcome bot commented Aug 17, 2023

🙌 Thanks for opening this pull request! You're awesome.

@socket-security
Copy link

@@ -53,11 +53,11 @@
"TypeScript"
],
"dependencies": {
"@typescript-eslint/parser": "^5.52.0",
"@typescript-eslint/parser": "^6.4.0",
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
"@typescript-eslint/parser": "^6.4.0",
"@typescript-eslint/parser": "^6.0.0",

It's the minimal version compatible with the plugin announced to the package manager

Copy link
Contributor

Choose a reason for hiding this comment

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

The downgrade to the 6.0.0 minimum make the tests fail because of a bug in @typescript-eslint ...

I think it's safe to require 6.4.0 as a minimum version bug free with that module.

Copy link
Owner

Choose a reason for hiding this comment

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

Which bug, please?

Copy link
Contributor

Choose a reason for hiding this comment

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

With the rules handling comma, StandardJS style was not properly followed.

"eslint-config-standard": "17.1.0"
},
"peerDependencies": {
"@typescript-eslint/eslint-plugin": "^5.52.0",
"@typescript-eslint/eslint-plugin": "^6.4.0",
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
"@typescript-eslint/eslint-plugin": "^6.4.0",
"@typescript-eslint/eslint-plugin": "^6.0.0",

"@typescript-eslint_bottom/eslint-plugin": "npm:@typescript-eslint/eslint-plugin@5.52.0",
"@typescript-eslint_bottom/parser": "npm:@typescript-eslint/parser@5.52.0",
"@typescript-eslint/eslint-plugin": "5.62.0",
"@typescript-eslint_bottom/eslint-plugin": "npm:@typescript-eslint/eslint-plugin@6.4.0",
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
"@typescript-eslint_bottom/eslint-plugin": "npm:@typescript-eslint/eslint-plugin@6.4.0",
"@typescript-eslint_bottom/eslint-plugin": "npm:@typescript-eslint/eslint-plugin@6.0.0",

"@typescript-eslint_bottom/parser": "npm:@typescript-eslint/parser@5.52.0",
"@typescript-eslint/eslint-plugin": "5.62.0",
"@typescript-eslint_bottom/eslint-plugin": "npm:@typescript-eslint/eslint-plugin@6.4.0",
"@typescript-eslint_bottom/parser": "npm:@typescript-eslint/parser@6.4.0",
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
"@typescript-eslint_bottom/parser": "npm:@typescript-eslint/parser@6.4.0",
"@typescript-eslint_bottom/parser": "npm:@typescript-eslint/parser@6.0.0",

'@typescript-eslint/restrict-plus-operands': ['error', { checkCompoundAssignments: true }],
'@typescript-eslint/restrict-plus-operands': 'error',
Copy link
Owner

Choose a reason for hiding this comment

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

@@ -1,7 +1,8 @@
{
"extends": "tsconfigs/nodejs-module",
"compilerOptions": {
"outDir": "lib"
"outDir": "lib",
"skipLibCheck": true
Copy link
Owner

Choose a reason for hiding this comment

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

This may have been the reason I wasn't able to upgrade.

I wouldn't like to accept this. Can you find a different way to solve or work around the issue?

Copy link
Contributor

@jerome-benoit jerome-benoit Aug 18, 2023

Choose a reason for hiding this comment

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

The alternatives are:

  • switch the project to ESM, which is a lot of work:
{
"module": "ES2022",
"moduleResolution": "Node16",
}  

And "type": "module" in package.json

  • overload locally the culprit library type (@typescript-eslint/eslint-plugin)

See typescript-eslint/typescript-eslint#7284

Copy link
Owner

Choose a reason for hiding this comment

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

Tell me more about this wrapping, please.

Copy link
Contributor

Choose a reason for hiding this comment

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

  • overload locally the culprit library type (@typescript-eslint/eslint-plugin)

See typescript-eslint/typescript-eslint#7284

I do not see how to make it works in a very hackish way, the original culprit types are already an ugly hack:

  • @typescript-eslint/eslint-plugin/index.d.ts:1:31
  • @typescript-eslint/eslint-plugin/rules.d.ts::38:33

Maybe by redefining the imported types locally or with patch-package to fix the types declaration for the TS configuration: self-contained without import. It's still an ugly hack requiring quite of work.

Code defining custom rules with @typescript-eslint/eslint-plugin needs to switch to "Bundler" module resolution. And the amount of work to do it properly is less than trying to find a working workaround not requiring "skipLibCheck" given the repo TS code surface.

So, maybe accepts temporary the current solution to support v6 and prepares a PR for the proper v6 support by switching to ESM and module resolution to "Bundler". It's easier because there's already ESM wrapper to deal with dependencies using CommonJS.

Copy link
Owner

Choose a reason for hiding this comment

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

The patch-package approach sounds reasonable. Also, progress is being made upstream eslint-config-standard. If that turns into an ESM, then we would be able to turn this package ESM, as well..

eslint-config-love-release-bot bot pushed a commit that referenced this pull request Aug 20, 2023
## [38.0.0](v37.0.0...v38.0.0) (2023-08-20)

### ⚠ BREAKING CHANGES

* minimum @typescript-eslint packages bumped to v6.1.0
* there will be some

### Build system / dependencies

* bump package-lock.json on release ([d42bf5b](d42bf5b))
* moduleResolution: nodenext ([1f31e2b](1f31e2b))
* package-lock.json ([b3a6535](b3a6535)), closes [#1193](#1193)
* shared commitlint config ([bdd6e2d](bdd6e2d))
* use extracted releaserc ([877b004](877b004))

### Features

* [@typescript-eslint](https://github.com/typescript-eslint) 6 ([166e189](166e189))
* bump minimum [@typescript-eslint](https://github.com/typescript-eslint) to v6.1.0 ([77202d1](77202d1)), closes [#1222](#1222) [#1188](#1188)
@eslint-config-love-release-bot

🎉 This issue has been resolved in version 38.0.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

@mightyiam
Copy link
Owner

Thank you for your efforts and participation. Sorry it wasn't your PR that got merged. We just had a great session, @rostislav-simonik and I in the mob and figured it out in a couple of PRs. You're welcome to apply to join us in the mob and help drive this project forward..

@retrixe retrixe deleted the feat/typescript-eslint-6 branch August 23, 2023 10:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add support for @typescript-eslint version 6.x.x
3 participants