eslint-plugin-etc icon indicating copy to clipboard operation
eslint-plugin-etc copied to clipboard

Library is broken with Typescript v5.2

Open AndreaPontrandolfo opened this issue 1 year ago • 12 comments

With Typescript v5.2 using ESlint with this plugin throws an exception:

TypeError: DeprecationError: 'originalKeywordKind' has been deprecated since v5.0.0 and can no longer be used. Use 'identifierToKeywordKind(identifier)' instead.

AndreaPontrandolfo avatar Sep 12 '23 12:09 AndreaPontrandolfo

Also got an error on

Error while loading rule 'etc/no-internal': Cannot read properties of undefined (reading 'text')

Appears to happen on TS 5.2 and 5.3

DoubleJ-G avatar Sep 20 '23 05:09 DoubleJ-G

I was doing a TS 5.2 upgrade today and saw this issue. However, I wasn't seeing any problem on TS 5.2 in my own project, which doesn't configure eslint-plugin-etc to do anything but the default.

i.e. all I do in .eslintrc.js is this:

plugins: [
  // other plugins
  'etc'
]

Curious what the repro steps are for an issue? For example, do I need code that breaks a certain rule, or a certain rule enabled, to see an issue?

I am on version 2.0.2 if that makes a difference.

ekilah avatar Sep 20 '23 20:09 ekilah

Curious what the repro steps are for an issue? For example, do I need code that breaks a certain rule, or a certain rule enabled, to see an issue?

Can you share the full configuration? Because of course, if you not enabling ANY eslint-plugin-etc rules, you are not gonna see any errors.

AndreaPontrandolfo avatar Sep 20 '23 20:09 AndreaPontrandolfo

You may have missed my edit above, I have since added my config :)

ekilah avatar Sep 20 '23 20:09 ekilah

You may have missed my edit above, I have since added my config :)

I mean the whole file.

AndreaPontrandolfo avatar Sep 20 '23 21:09 AndreaPontrandolfo

I use lots of lint configs, so I won't post the whole thing, but the only other relevant part of the file (to eslint-plugin-etc) is the config for one of the rules:

'etc/no-implicit-any-catch': ['error', {allowExplicitAny: false}],

Otherwise, the plugin bit above should mean that I'm using the recommended rule set, I believe:

https://github.com/cartant/eslint-plugin-etc/blob/e04da45c70d404177a11294ed3891cc85aaf4def/source/configs/recommended.ts

but maybe that's not how it works 🤔

ekilah avatar Sep 20 '23 21:09 ekilah

Ah, right, I forgot, that is indeed not how it works. I don't have

extends: ["plugin:etc/recommended"],

so i guess I'll amend my previous statement: It seems like this one rule etc/no-implicit-any-catch works fine on TS 5.2 from my limited tests :)

ekilah avatar Sep 20 '23 21:09 ekilah

I have the same issue of https://github.com/cartant/eslint-plugin-etc/issues/64#issue-1892415732 I specifically for:

type AnyObject = Record<string, unknown>;

// HERE IS THE LINE THAT BREAK
function pick<T extends AnyObject, K extends keyof T>(
  obj: T,
  keys: Array<K>
): Pick<T, K> {
  const picked: Partial<Pick<T, K>> = {};

  for (const key of keys) {
    if (key in obj) {
      picked[key] = obj[key];
    }
  }

  return picked as Pick<T, K>;
}

and the rule that breaks is "etc/no-misused-generics": "error",

nirtamir2 avatar Oct 02 '23 08:10 nirtamir2

I've taken a look at this. Fixing this is not straightforward, as the error is being effected from a dep that's pretty deep down:

https://github.com/ajafff/tsutils/pull/156

A lot of these lint rules rely on tsutils, so this is likely to remain a problem until it's fixed in that package and a new version is published.

cartant avatar Oct 04 '23 11:10 cartant

From the comments on your linked issue it actually seems like this eslint-plugin-etc package should be using ts-api-utils instead of the outdated tsutils package, there is not going to be a new version of tsutils published, ts-api-utils IS the new version made by the eslint team. I was planning to make a PR, but it seems like the entire stack of *etc is based on tsutils, so I'll leave you to update this, but I did want to inform you about this development in that issue.

Jelmerro avatar Nov 08 '23 13:11 Jelmerro

Thanks for reading that issue's comments more thoroughly than I did, @Jelmerro. I'll take a look at ts-api-utils to see what'll be involved in getting things upgraded.

cartant avatar Nov 08 '23 20:11 cartant

Any news on this? 😉

CHE1RON avatar Feb 29 '24 12:02 CHE1RON