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

Upgrade @typescript-eslint/eslint-plugin @typescript-eslint/parser #150

Open
TrevorKarjanis opened this issue Jul 24, 2024 · 2 comments
Open
Assignees

Comments

@TrevorKarjanis
Copy link
Collaborator

After upgrading to Angular 17, the following warning is received when running the linter.

WARNING: You are currently running a version of TypeScript which is not officially supported by @typescript-eslint/typescript-estree.
You may find that it works just fine, or you may not.
SUPPORTED TYPESCRIPT VERSIONS: >=3.3.1 <5.2.0
YOUR TYPESCRIPT VERSION: 5.4.5
Please only submit bug reports when using the officially supported version.

This is because @typescript-eslint/eslint-plugin @typescript-eslint/parser are incompatible with [email protected]. This is not an npm dependency. It is defined at runtime in @typescript-eslint/typescript-estree.

These packages, version ^5.62.0, are peer dependencies of @ni/eslint-config-typescript, so upgrading them requires forcing the install. @typescript-eslint/[email protected] supports <5.5, so a minimal upgrade of @typescript-eslint/[email protected] @typescript-eslint/[email protected] would be required.

Have we considered upgrading them, or why have they not been upgraded?

@rajsite
Copy link
Member

rajsite commented Jul 25, 2024

Have we considered upgrading them, or why have they not been upgraded?

No specific reason I'm aware. Don't have a rennovate integration so would be manual. Looking at the getting started today they don't even pull from the scoped packages like we are which is interesting: https://typescript-eslint.io/getting-started/

Edit: Ahh we are on the "legacy" eslint configuration: https://typescript-eslint.io/getting-started/legacy-eslint-setup

@jattasNI
Copy link
Collaborator

We agreed we should fix this soon. May need to do a bit of testing to ensure the new packages don't change the behavior of any rules in unexpected ways.

@jattasNI jattasNI mentioned this issue Sep 19, 2024
1 task
@m-akinc m-akinc assigned m-akinc and unassigned TrevorKarjanis Jan 8, 2025
jattasNI pushed a commit that referenced this issue Feb 10, 2025
Addresses #157 

In addition to updating the dependency version, I'm fixing the
following:
- #150
- #153 

## Implementation
Updated dependencies:
 - `@angular/core` to `18.2.13` (latest <19)
 - `@angular-eslint` packages to `18.4.3` (latest <19)
- `@typescript-eslint/eslint-plugin` and `@typescript-eslint/parser` to
`7.18.0` (latest <8)
- After updating the version of `@typescript-eslint/parser`, I began
getting the following test failure:
     ```
Error: Error while loading rule
'@typescript-eslint/prefer-optional-chain': You have used a rule which
requires parserServices to be generated. You must therefore provide a
value for the "parserOptions.project" property for
@typescript-eslint/parser.
Parser:
C:\dev\javascript-styleguide\node_modules\@typescript-eslint\parser\dist\index.js
Occurred while linting
C:\dev\javascript-styleguide\tests\typescript\index.ts
     ```
It turns out that `@typescript-eslint/prefer-optional-chain` now [does
require type
checking](https://typescript-eslint.io/rules/prefer-optional-chain), so
I had to move it to the `requiring-type-checking.js` configuration.
- `@typescript-eslint/eslint-plugin` version 6 [introduced significant
changes](https://github.com/typescript-eslint/typescript-eslint/blob/9e8828b31fda6e0fa45e0397cd6cc4e1662ba356/packages/website/blog/2023-07-09-announcing-typescript-eslint-v6.md#user-facing-breaking-changes).
In `requiring-type-checking.js`, I changed it from extending
`@typescript-eslint/recommended-requiring-type-checking` to
`@typescript-eslint/recommended-type-checked` and
`@typescript-eslint/stylistic-type-checked`. Similarly, in
`eslint-config-typescript/index.js`, I added
`@typescript-eslint/stylistic` to the extended configs. Subsequently,
the output of `npm run print-evaluated-rules:diff` showed over a dozen
changes. I added overrides to minimize the scope of changes in this PR,
and ultimately ended up with the following diff:
- `@typescript-eslint/consistent-generic-constructors` is new ("error")
-- Despite adding an override to turn this rule off, it remains on. This
may be a bug in `@typescript-eslint`. I don't think we want to let this
block us, so clients should either fix reported violations or use
in-source suppressions.
- `@typescript-eslint/lines-between-class-members` was
`["error","always",{"exceptAfterSingleLine":true}]`, now is
`["error","always",{"exceptAfterSingleLine":true,"exceptAfterOverload":true}]`
-- This seems like a harmless difference.
- `no-new-native-nonconstructor` is new ("off") -- Explicitly turning
off this new rule that defaulted to "error".
- `@typescript-eslint/no-duplicate-enum-values` is new ("off") --
Explicitly turning off this new rule that defaulted to "error".
- `@typescript-eslint/no-unsafe-declaration-merging` is new ("off") --
Explicitly turning off this new rule that defaulted to "error".
- `@typescript-eslint/no-duplicate-type-constituents` is new ("off") --
Explicitly turning off this new rule that defaulted to "error".
- `@typescript-eslint/no-redundant-type-constituents` is new ("off") --
Explicitly turning off this new rule that defaulted to "error".
- `@typescript-eslint/no-unsafe-enum-comparison` is new ("off") --
Explicitly turning off this new rule that defaulted to "error".
- `@angular-eslint/runtime-localize` is new ("error") -- We specifically
want this enabled.

### Testing
- Ran `npm run print-evaluated-rules:diff` and handled differences as
described above.
- Ran `npm run print-available-rules` with these changes:
- `@typescript-eslint/no-duplicate-imports` - removed from TS Extensions
- `@typescript-eslint/class-methods-use-this` - added to TS Extensions
   - `@typescript-eslint/max-params` - added to TS Extensions
- `@typescript-eslint/prefer-ts-expect-error` - moved from TS
Recommended to Remaining TS Rules
- `@typescript-eslint/prefer-optional-chain` - moved from TS Recommended
to TS Recommended (Requiring Type Checks)
- `@typescript-eslint/no-implicit-any-catch` - removed from Remaining TS
Rules
- `@typescript-eslint/no-parameter-properties` - removed from Remaining
TS Rules
- `@typescript-eslint/sort-type-union-intersection-members` - removed
from Remaining TS Rules
- `@typescript-eslint/no-empty-object-type` - added to Remaining TS
Rules
- `@typescript-eslint/no-unnecessary-parameter-property-assignment` -
added to Remaining TS Rules
- `@typescript-eslint/no-unsafe-function-type` - added to Remaining TS
Rules
- `@typescript-eslint/no-wrapper-object-types` - added to Remaining TS
Rules
- `@typescript-eslint/no-empty-object-type` - added to Remaining TS
Rules
- `@typescript-eslint/no-empty-object-type` - added to Remaining TS
Rules
- `@typescript-eslint/consistent-return` - added to TS Extensions
(Requiring Type Checks)
- `@typescript-eslint/only-throw-error` - added to TS Extensions
(Requiring Type Checks)
- `@typescript-eslint/prefer-destructuring` - added to TS Extensions
(Requiring Type Checks)
- `@typescript-eslint/prefer-promise-reject-errors` - added to TS
Extensions (Requiring Type Checks)
- `@typescript-eslint/no-array-delete` - added to TS Recommended
(Requiring Type Checks)
- `@typescript-eslint/no-confusing-void-expression` - moved from
Remaining TS Rules (Requiring Type Checks) to TS Recommended (Requiring
Type Checks)
- `@typescript-eslint/no-duplicate-type-constituents` - moved from
Remaining TS Rules (Requiring Type Checks) to TS Recommended (Requiring
Type Checks)
- `@typescript-eslint/no-redundant-type-constituents` - moved from
Remaining TS Rules (Requiring Type Checks) to TS Recommended (Requiring
Type Checks)
- `@typescript-eslint/no-unnecessary-template-expression` - added to TS
Recommended Requiring Type Checks
- `@typescript-eslint/use-unknown-in-catch-callback-variable` - added to
TS Recommended Requiring Type Checks
- `@typescript-eslint/no-unnecessary-type-parameters` - added to
Remaining TS Rules (Requiring Type Checks)
- `@typescript-eslint/no-unsafe-unary-minus` - added to Remaining TS
Rules (Requiring Type Checks)
- `@typescript-eslint/no-useless-template-literals` - added to Remaining
TS Rules (Requiring Type Checks)
- `@typescript-eslint/prefer-find` - added to Remaining TS Rules
(Requiring Type Checks)
- `@angular-eslint/no-host-metadata-property` - moved from Angular
Recommended to Remaining Angular
   - `@angular-eslint/runtime-localize` - added to Remaining Angular
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

No branches or pull requests

4 participants