eslint-plugin-etc
eslint-plugin-etc copied to clipboard
Library is broken with Typescript v5.2
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.
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
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.
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.
You may have missed my edit above, I have since added my config :)
You may have missed my edit above, I have since added my config :)
I mean the whole file.
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 🤔
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 :)
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",
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.
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.
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.
Any news on this? 😉