You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 4-6.RSVP
Socket
Book a DemoInstallSign in
Socket

eslint-plugin-sonarjs

Package Overview
Dependencies
Maintainers
5
Versions
56
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

eslint-plugin-sonarjs

SonarJS rules for ESLint

3.0.4
latest
Source
npmnpm
Version published
Weekly downloads
1.4M
4.15%
Maintainers
5
Weekly downloads
 
Created

What is eslint-plugin-sonarjs?

eslint-plugin-sonarjs is an ESLint plugin that provides a set of rules inspired by SonarQube to detect bugs and suspicious patterns in JavaScript code. It aims to improve code quality by identifying potential issues early in the development process.

What are eslint-plugin-sonarjs's main functionalities?

Detecting Cognitive Complexity

This rule helps to keep functions simple and maintainable by enforcing a limit on their cognitive complexity. The code sample configures ESLint to throw an error if a function's cognitive complexity exceeds 15.

module.exports = {
  rules: {
    'sonarjs/cognitive-complexity': ['error', 15]
  }
};

Detecting Duplicated Code

This rule detects duplicated string literals in the code. The code sample configures ESLint to throw an error if a string literal is duplicated more than 3 times.

module.exports = {
  rules: {
    'sonarjs/no-duplicate-string': ['error', 3]
  }
};

Detecting Unused Function Parameters

This rule identifies function parameters that are declared but not used within the function body. The code sample configures ESLint to throw an error for any unused function parameters.

module.exports = {
  rules: {
    'sonarjs/no-unused-collection': 'error'
  }
};

Detecting Collapsible If Statements

This rule detects if statements that can be collapsed into a single statement. The code sample configures ESLint to throw an error for any collapsible if statements.

module.exports = {
  rules: {
    'sonarjs/no-collapsible-if': 'error'
  }
};

Other packages similar to eslint-plugin-sonarjs

Keywords

sonarjs

FAQs

Package last updated on 26 Jun 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts