-
Notifications
You must be signed in to change notification settings - Fork 70
Working with ESLint 9 #438
Comments
Hello @brettz9, Thank you for highlighting this concern. The migration of our ESLint plugin to ESLint's new flat config is indeed a recognized issue (#403, SonarSource/SonarJS#3968), and we fully acknowledge its significance. Unfortunately, providing a specific timeframe for addressing this issue is challenging at the moment. However, I will take this matter to the team for discussion, and we will consider when we can prioritize and work on it. I appreciate your patience, and I will keep you informed of any updates. |
Thank you. Just a heads up though that the API change mentioned in the original post is the most critical issue, as one can still use the package |
ESLint 9.0.0 has been released. This plugin still does not work with it. |
just hit this when upgrading to eslint 9 |
Same. This is really unfortunate. I tried using the FlatCompat API and it still doesn't work. |
For information, we are working on it. There is no ETA yet, but as soon as we have one, we'll update this issue, so stay tuned. |
This issue has been migrated to Jira. ESLINTJS-30 |
is there not support for eslint 9 yet? |
any update? |
v1.0.0 breaks with eslint v8.57.0, I think it's not backwards compatible. Versions: "@typescript-eslint/parser": "7.8.0",
"eslint": "8.57.0",
"eslint-plugin-sonarjs": "1.0.0", I'm on node v20.12.2 Error:
The whole error:
|
@snigdha920 , thanks for the report. I assume you are extending This is documented there. |
It works!! thanks !!🎉 |
Sorry I missed that 😅 Thank you, that works! |
Actually, the documentation was partially wrong, which may explain why you missed it. We are fixing it right now. |
but how can I use it in eslint with flat config? this is my "eslint.config.mjs" file:
|
Hi @ocsoares, You can use the SonarJS plugin exactly like you would any other plugin, following the instructions in the ESLint plugin documentation. For example, if you want to use the recommended configuration of the plugin, you can use it this way: import sonarJSPlugin from "eslint-plugin-sonars";
export default tseslint.config(
sonarJSPlugin.configs.recommended,
// ...
); Note that you do not need to reference it in the import sonarJSPlugin from "eslint-plugin-sonars";
export default tseslint.config(
{
plugins: {
sonarjs: sonarJSPlugin
},
rules: {
'sonarjs/no-empty-collection': "warn"
}
},
// ...
); You can mix both approaches; for example, import all the recommended rules but change only the severity level of some. Note that in this case, you don't need to reference the plugin in the import sonarJSPlugin from "eslint-plugin-sonars";
export default tseslint.config(
sonarJSPlugin.configs.recommended,
{
rules: {
'sonarjs/no-empty-collection': "warn"
}
},
// ...
); |
@ericmorand-sonarsource thanks, it works ! |
It doesn't work: "plugins": [
"unused-imports",
"sonarjs"
],
"extends": [
"plugin:@angular-eslint/recommended",
"plugin:@angular-eslint/template/process-inline-templates",
"plugin:sonarjs/recommended-legacy"
],
|
FWIW, while I'd love to help out debugging and fixing the alpha, the "Issue" setup on this project puts so many barriers in my way that I won't:
|
Hi @bmulholland, Thanks for the feedback. Please share as much as possible; these alpha versions are a big change from the current stable version, including all SonarJS rules instead of the small list that was available in this repo (this repo will be archived, by the way). I'll try to reproduce those 2 errors you point out. As for issue reporting, please go through the community forum and just explain that this is about the Thanks again! |
Sure, I'm out of time today but I can help out here if that works for you :) FYI, these errors are in a vue project. Let me know if you can't easily repro and I'll see what I can do to get you more info. |
yes, we can keep the conversation here as well as you are already some users reporting issues with alpha. Thanks for the vue hint. |
Hi, I'd like to second @bmulholland's sentiment about issue reporting. I can relate to wanting to centralize things, but it takes more time to go through a forum sign up process (+ adjusting notification settings) than to report 90% of bugs. Some days ago I noticed that alpha versions are being marked as latest on npm, which is a mistake, tried Jira, realized that it's read-only for outsiders, and stopped, as it was starting to eat into my workday. Why not sync Jira with GitHub issues? |
Hi @bmulholland, sorry, I was not able to reproduce any of the issues (both I was able to raise issues from both rules on my code snippets. What ESLint version are you using? I've tested with ESLint 8 and 9 and did not get any errors. If you can share some code that makes eslint fail would be very helpful. Cheers! |
Hi @alecmev, I understand that for many developers who are used to Github issues, this is not ideal. But this has been a Sonar-wide move to centralize everything in Jira + Sonar Community forum. |
@alecmev It's fixed now. I'm using the tag |
Hi SonarLint team, the alpha version is pulling in 300+ dependencies compared to 0.25.x. Is this expected? |
Hi @slowtick, yes, it's expected. We import rules from other eslint plugins and modify their behaviour (by removing what we consider false positives or by adding new cases). Also, one rule ( One question, what version are you referring to with 0.25.x? Stable version is 1.0.x |
Thanks for the clarification @vdiez Sorry about version I mentioned, I'm currently at 1.0.3 Will switch to alpha and report any other issues. |
This error is still happening on the "eslint-plugin-sonarjs": "^2.0.1", Argument of type 'Config' is not assignable to parameter of type 'ConfigWithExtends'. import sonarjs from 'eslint-plugin-sonarjs'; tseslint.config( |
I can confirm this. |
I am facing the same issue? Anyone got this working? |
They don't monitor github, check here |
Thanks @Sparticuz for the heads-up to all reporters. We still keep an eye on here, though indeed github is not the official channel any more. Just to mention that we are aware of the issues reported here and 2.0.2 should fix type error. There are some others, like some rules crashing with ESLint 9, that we'll fix them in the coming weeks. We'll update the docs to mention that ESLint 9 and typescript-eslint 8 are not fully supported yet. Sorry all for the inconvenience. |
Version 2.0.2 is out, please let us know if are still facing type issues. Cheers. |
yes the type error has been fixed. However I've seen (I'm sure you have seen it too but in case I'll report it just to let you know) that there are some dependencies on your package which has incorrect peers. You have this in your package.json which actually doesn't accept eslint 9. |
Hello @Pnlvfx, can you please clarify what you mean by "incorrect peers"? We are aware of our current problem with ESLint 9 due to some rules implementation, so we have modified the README again to make it clear that we don't yet support that version. We are working on that to have it ready ASAP. Version 1 of the plugin, the version that lived in this repo, supported v9, but those were only ~30 rules. Now that v2 includes all rules from SonarJS we have to rethink many of them that SonarJS extended ESLint core or typescript-eslint rules. So we are tight to a specific version of those packages (for the implementation of their rules). We are still in the process of deciding how to solve this. |
I think you are both saying the same thing, eslint9 can't be supported yet because eslint-plugin-sonarjs still uses v7 of @typescript-eslint (which doesn't support eslint9, hence the warnings on |
I mean that you have this packages on your dependencies and they don't support eslint 9. "@babel/eslint-parser": "7.24.1", Idk about babel plugin but Sorry, I'm not English, that's why I write so bad. 🙂 |
In fact: -latest: (support eslint 9) "name": "@typescript-eslint/utils",
} -your current: (doesn't support eslint 9) "@typescript-eslint/eslint-plugin@npm:^5.4.2 || ^6.0.0 || ^7.0.0": Also they write in their docs that to use eslint 9 you had to upgrade to typescript-eslint 8: docs: The v8 versions of typescript-eslint starting with v8.0.0-alpha.10 now support ESLint v9. |
ok, all clear, thanks. As you listed those dependencies and mentioned "incorrect peers" I thought you meant incompatibilities between those specific packages. As mentioned, we are tight to specific versions of typescript-eslint due to their rules. We cannot just upgrade the version without modifying the rules implementation. So yes, ESLint v9 is not supported right now and we are working to have this fixed. As a reminder, please use https://community.sonarsource.com/ to report any more issues. Please avoid further comments here. |
Hello @mmospanenko, as already mentioned latest version is not yet compatible with ESLint 9. We are working on that. |
hi, are there any updates here or an issue / merge request to follow? thanks in advance :) |
Hi @SmootherSpike, the Epic is here Not all related to ESLint plugin, but we will focus on them next week. |
@vdiez If you haven't seen, note that ESLint has put out an official support policy and v8 goes end of life on October 5 (six months after the v9 release). |
hi @aarongoldenthal, yes we are aware. Still, thanks for the heads-up |
Unsafe argument of type error typed assigned to a parameter of type The type error is gone but now the config is returning any. |
I want to request a feature.
Projects wishing to future-proof their code are now unable to use SonarJS with the alpha versions of ESLint 9.0.0 at least in one instance because of some API changes (dropping
context.getScope
; see https://eslint.org/blog/2023/09/preparing-custom-rules-eslint-v9/#context.getscope() ). This is the more serious road-block as there are no workarounds.The text was updated successfully, but these errors were encountered: