Closed tillig closed 5 months ago
This issue relates to the blog Preparing your custom rules for ESLint v9.0.0 published on Sep 26, 2023
Good to see that there is already a merged PR for this as Eslint v9 was announced released on Apr 5, 2024.
Thanks for reporting. I will take a look into it and try to make a patch release ASAP.
I’ve cherry-picked the changes from #347 and made a patch release v10.4.2. Unfortunately I forgot to make a release after merging #347 to main
and now main
contains a few breaking changes which are planned for v11.
Please let me know if v10.4.2 fixes the issues with ESLint v9.
@lo1tuma
Please let me know if v10.4.2 fixes the issues with ESLint v9.
I tested with eslint@9.0.0
and my errors were gone. I also checked for backwards compatibility with eslint@8.57.0
and I saw no issue.
Many thanks!
@MikeMcC399 thanks for confirming... in this case I will close this issue.
Yup, also verified. Thanks!
Hello,
I believe the 10.4.2 patch broke compatibility with eslint versions prior to 8 (We get the error on 7.32.0):
TypeError: Cannot read properties of undefined (reading 'getScope')
@mcat95
I believe the 10.4.2 patch broke compatibility with eslint versions prior to 8 (We get the error on 7.32.0):
TypeError: Cannot read properties of undefined (reading 'getScope')
Ouch!
It sounds like this needs to be a new issue leading to a new fix release.
The example in https://eslint.org/blog/2023/09/preparing-custom-rules-eslint-v9/#context.getscope() shows supporting both the deprecated API and the new API. If only the new API has been implemented, then it would break compatibility with anything below ESLint v8.37.0
🤭
module.exports = {
create(context) {
const { sourceCode } = context;
return {
Program(node) {
const scope = sourceCode.getScope
? sourceCode.getScope(node)
: context.getScope();
// do something with scope
}
}
}
};
@mcat95
@mcat95
This was fixed in 10.4.3.
It appears there have been quite a few breaking changes with ESLint 9.0.0, and with that it looks like
context.getScope()
is no longer an available shortcut.It looks like a PR got merged that has the fix for this back on Feb 16, but it appears that hasn't been released yet - it's not in v10.4.1, which is the current latest.
Is there a plan to release that in the near future?