npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

eslint-plugin-sonarjs

v1.0.3

Published

SonarJS rules for ESLint

Downloads

4,372,284

Readme

eslint-plugin-sonarjs npm version Build Status Quality Gate Coverage

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.

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.

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:

import sonarjs from "eslint-plugin-sonarjs";

[
  sonarjs.configs.recommended,
  {
    "plugins": {
      sonarjs,
    }
  }
]

For ESLint 8: add plugins option to your .eslintrc and plugin:sonarjs/recommended to the extends option to enable all recommended rules:

{
  "plugins": ["sonarjs"],
  "extends": ["plugin:sonarjs/recommended-legacy"]
}
  • or enable only some rules manually:
{
  "rules": {
    "sonarjs/cognitive-complexity": "error",
    "sonarjs/no-identical-expressions": "error"
    // etc.
  }
}
  • 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!