Eslint-plugin-sonarjs v2 major regressions on ESLint v9

When I upgrade to eslint-plugin-sonarjs v2.0.1, so many rules crash. They’re trying to access things that aren’t available in ESLint v9, like context.getScope. I tried disabling some rules but they all seem to do it. v1.0.4 didn’t try to do this, so the major release goes significantly backward for the latest version of ESLint v9. It’s very odd. If v9 isn’t supported, then it should be explicitly flagged.

Here’s just one example from searching the code: SonarJS/packages/jsts/src/rules/helpers/decorators/interceptor.ts at b4a88d2cd3fef874de2cc6dc0e6414429cf82134 · SonarSource/SonarJS · GitHub

There seems to be no attempt to deal with ESLint v9, even though the README explicitly says v9 is supported. (Also the suggested README config for v9 is broken – throws an error “cannot redefine plugin sonarjs.”)

BTW, ESLint v8 is EOL in October: Version Support - ESLint - Pluggable JavaScript Linter

Hello @Brendan_Mulholland,

Thanks for the feedback. We are aware of those issues, and indeed, there was a regression because v1 of the ESLint plugin supported ESLint 9. However, when we included all rules from SonarJS (which still uses ESLint 8 internally), not all the rules were migrated.

We are changing the README to mention that we don’t support yet ESLint 9, and we are working to have all rules properly migrated to the new APIs. Same with typescript-eslint v8, as we’ve seen that the v8 parser changes the AST slightly.

Since version 2.0.x almost all devDependencies became regular dependencies while some not being compatible with ESLint 9. This leads to numerous npm peer dependency warnings.

You can see the differences here:

E.G. the typescript-eslint/* packages are only compatible with ESLint 9 since version 8 and they generate errors in version 2.0.2.