ESLint plugin maintained by Sonar that provides original JS/TS rules from the SonarJS analyzer, including code smell, bug detection, testing, accessibility, and security rules. Version 4.0.3 supports ESLint 8/9/10 and ships TypeScript types. Release cadence is frequent with regular bug fixes and rule additions. Key differentiator: direct integration of SonarQube/SonarCloud rules into ESLint, offering a single recommended config for ESLint 9 and a legacy config for ESLint 8.
npm install eslint-plugin-sonarjsVerified import paths — ran on the pinned version, not inferred.
Shows usage with ESLint 9 flat config, importing plugin and enabling recommended config plus custom rules.
If using ESLint 8, use .eslintrc with extends: ['plugin:sonarjs/recommended-legacy'] instead of the flat config import.
Check the rule list in the plugin documentation or SonarQube documentation for differences.
Migrate to ESLint 9 flat config when possible.
Ensure your Node.js version matches the requirement for your ESLint version.
Override rule severity in your config, e.g., 'sonarjs/cognitive-complexity': 'warn'.
Run 'npm install eslint-plugin-sonarjs --save-dev' or the equivalent yarn command.
Ensure the plugin is properly declared in plugins field (ESLint 9) or in .eslintrc plugins array (ESLint 8). Check rule options are valid.