SonarSource/eslint-plugin-sonarjs sits at 1.2k stars on GitHub, written primarily in TypeScript. SonarJS rules for ESLint
Snapshot summary built from the project's own GitHub metadata — there's no written TopGit review yet. The page will update automatically when a full review is published.
WHY NO REVIEW YET
TopGit writes full reviews for the most-starred, most-requested repositories. This page is a snapshot until then — see the READ ME tab for the original README in full.
This repository contains eslint-plugin-sonarjs up to version ^1.0.0. For versions >=2.0.0 please go to the repository of the SonarJS analyzer. The new versions of eslint-plugin-sonarjs makes all SonarJS rules available for ESLint users, instead of a subset as it was with ^1.0.0 living here.
No new changes are expected to land here.
eslint-plugin-sonarjs
SonarJS rules for ESLint to help developers produce Clean Code by detecting bugs and suspicious patterns.
Rules
Bug Detection :bug:
Rules in this category aim to find places in code that have a high chance of being bugs, i.e. don't work as intended.
All branches in a conditional structure should not have exactly the same implementation (no-all-duplicated-branches)
Collection elements should not be replaced unconditionally (no-element-overwrite)
Empty collections should not be accessed or iterated (no-empty-collection)
Function calls should not pass extra arguments (no-extra-arguments)
Related "if/else if" statements should not have the same condition (no-identical-conditions)
Identical expressions should not be used on both sides of a binary operator (no-identical-expressions)
Return values from functions without side effects should not be ignored (no-ignored-return) (uses-types)
Loops with at most one iteration should be refactored (no-one-iteration-loop)
The output of functions that don't return anything should not be used (no-use-of-empty-return-value)
Non-existent operators '=+', '=-' and '=!' should not be used (non-existent-operator) (:wrench: fixable)
Code Smell Detection :pig:
Code Smells, or maintainability issues, are raised for places of code which might be costly to change in the future. These rules also help to keep the high code quality and readability. And finally, some rules report issues on different suspicious code patterns.
Cognitive Complexity of functions should not be too high (cognitive-complexity)
"if ... else if" constructs should end with "else" clauses (elseif-without-else) (disabled)
"switch" statements should not have too many "case" clauses (max-switch-cases)
Collapsible "if" statements should be merged (no-collapsible-if)
Collection sizes and array length comparisons should make sense (no-collection-size-mischeck) (:wrench: fixable, uses-types)
String literals should not be duplicated (no-duplicate-string)
Two branches in a conditional structure should not have exactly the same implementation (no-duplicated-branches)
Boolean expressions should not be gratuitous (no-gratuitous-expressions)
Functions should not have identical implementations (no-identical-functions)
Boolean checks should not be inverted (no-inverted-boolean-check) (:wrench: fixable, disabled)
"switch" statements should not be nested (no-nested-switch)
Template literals should not be nested (no-nested-template-literals)
Boolean literals should not be redundant (no-redundant-boolean)
Jump statements should not be redundant (no-redundant-jump) (:wrench: fixable)
Conditionals should start on new lines (no-same-line-conditional) (:wrench: fixable)
"switch" statements should have at least 3 "case" clauses (no-small-switch)
Collection and array contents should be used (no-unused-collection)
"catch" clauses should do more than rethrow (no-useless-catch)
Local variables should not be declared and then immediately returned or thrown (prefer-immediate-return) (:wrench: fixable)
Object literal syntax should be used (prefer-object-literal)
Return of boolean expressions should not be wrapped into an "if-then-else" statement (prefer-single-boolean-return) (:wrench: fixable)
A "while" loop should be used instead of a "for" loop (prefer-while) (:wrench: fixable)
Prerequisites
Node.js (>=16.x).
ESLint 8.x or 9.x (peer dependency for the plugin).
Usage
If you don't have ESLint yet configured for your project, follow these instructions.
Install eslint-plugin-sonarjs using npm (or yarn) for your project or globally:
npm install eslint-plugin-sonarjs --save-dev # install for your project
npm install eslint-plugin-sonarjs -g # or install globally
Add eslint-plugin-sonarjs to the plugins of your ESLint config.
For ESLint 9: add plugins option to your eslint.config.js and include the recommended config to enable all rules:
To allow each of the rules to fully perform, use @typescript-eslint/parser as a parser for ESLint (like we do) and set the parserOptions.project option. Thanks to it, type information is available, which is beneficial or even essential for some rules.
Available Configurations
This plugin provides only a recommended configuration. Almost all rules are activated in this profile with a few exceptions (check the disabled tag in the rules list). The recommended configuration activates rules with error severity.
We include a recommended-legacy configuration to be backward compatible with ESLint v8, with the same rule configuration..
ESLint and Sonar
This plugin exposes to ESLint users a subset of JS/TS rules from Sonar-* products (aka SonarJS). We extracted the rules that are not available in ESLint core or other ESLint plugins to be beneficial for the ESLint community.
If you are a SonarQube or SonarCloud user, to lint your code locally, we suggest using SonarLint IDE extension (available for VSCode, JetBrains IDEs and Eclipse). You can connect SonarLint to your SonarQube/SonarCloud project to synchronize rules configuration, issue statuses, etc.
Contributing
Do you want to participate in the development of the project? Have a look at our contributing guide!
How active is development on SonarSource/eslint-plugin-sonarjs?
The most recent commit recorded on SonarSource/eslint-plugin-sonarjs was 2.1 years ago, based on the GitHub push timestamp. The repository has 65 forks — one of the better signals of community interest.
How many stars does SonarSource/eslint-plugin-sonarjs have?
SonarSource/eslint-plugin-sonarjs has 1.2k GitHub stars — refresh the page for the live number, or check github.com/SonarSource/eslint-plugin-sonarjs. TopGit mirrors GitHub's count but does not claim minute-by-minute accuracy.
Is SonarSource/eslint-plugin-sonarjs open source?
Yes — SonarSource/eslint-plugin-sonarjs ships under the LGPL-3.0 license, which makes its source code freely readable (and, depending on license terms, forkable and reusable). Source: github.com/SonarSource/eslint-plugin-sonarjs.
What else is in the Frontend space?
SonarSource/eslint-plugin-sonarjs is tracked by TopGit under the Frontend category, alongside 7 GitHub-tagged topics. Trending and Topics pages list peer repositories of comparable stars and language.
What is SonarSource/eslint-plugin-sonarjs?
SonarSource/eslint-plugin-sonarjs (SonarSource/eslint-plugin-sonarjs) is a TypeScript project on GitHub. From the project's own README: SonarJS rules for ESLint
What language is SonarSource/eslint-plugin-sonarjs written in?
SonarSource/eslint-plugin-sonarjs is written primarily in TypeScript. GitHub's language field is based on the largest share of bytes in the default branch.
What license does SonarSource/eslint-plugin-sonarjs use?
SonarSource/eslint-plugin-sonarjs is released under the LGPL-3.0 license. Always verify the LICENSE file directly on GitHub for the authoritative terms — license strings can be edited out of sync with a project's actual stance.
Where do I read more about SonarSource/eslint-plugin-sonarjs?
This TopGit page is a snapshot — the READ ME tab shows the project's own README content (links stripped, images preserved). The GitHub repository at github.com/SonarSource/eslint-plugin-sonarjs is the definitive source.
Read full README in the tab above.
Curious whether eslint-plugin-sonarjs is right for you?
Let ChatGPT, Claude, or Perplexity look into it — click below and see what AI actually says about eslint-plugin-sonarjs.