If I follow your recommendations on SonarJS/packages/jsts/src/rules/README.md at master · SonarSource/SonarJS · GitHub, then I get ConfigError: Config (unnamed): Key "plugins": Cannot redefine plugin "sonarjs". error. If I remove the plugin from the list, then I get TypeError: originalContext.getScope is not a function. Rule: "sonarjs/rules-of-hooks" error.
eslint 9.14.0, eslint-plugin-sonarjs 2.0.4
Let me know if you need a reproducible example, but it seems to me that you haven’t tested the plugin with flat config.
Could you please check rule "sonarjs/rules-of-hooks" with flat config? If you can’t reproduce the issue, then of course I will make the reproducible example.
Thus, eslint complains that you are redeclaring the sonarjs plugin because the recommended configuration already declares the sonarjs plugin. If you remove the declaration of the plugin, it should work as expected:
import sonarjs from 'eslint-plugin-sonarjs';
export default [
sonarjs.configs.recommended,
];
We need to fix our documentation, I created a ticket to make sure that it is handled.
Thanks a lot for noticing and reporting the issue to us.