SonarSource / sonarjs-cli

[ ⛔️DEPRECATED] CLI for SonarJS
https://github.com/SonarSource/SonarJS
GNU Lesser General Public License v3.0
8 stars 1 forks source link
analyzer code-quality javascript linter npm-package

[DEPRECATED] SonarJS Build Status NPM version

This package allows to use the SonarJS analyzer as a command line tool and as a JavaScript/TypeScript library.

SonarJS is a static code analyser for the JavaScript language. It will allow you to produce stable and easily supported code by helping you to find and to correct bugs, vulnerabilities and code smells in your code.

It provides ~80 rules (including ~40 bug detection), which represent the "Sonar Way" profile of the SonarJS analyzer.

Usage

As a Command Line Tool

SonarJS in VS Code terminal

As a JavaScript/TypeScript Library

// for JavaScript const { analyze } = require("sonarjs");

* Analyze
```typescript
async function runSonarJS() {
  const issues = await analyze("/path/to/project");
  issues.forEach(issue => {
    // ...
  });
}

function onStart() { console.log("Analysis is started"); }

function onEnd() { console.log("Analysis is finished"); }

async function runSonarJS() { const issues = await analyze("/path/to/project", { log, onStart, onEnd }); // ... }


* Provide options to exclude folders from analysis
```typescript
async function runSonarJS() {
  const issues = await analyze("/path/to/project", { exclusions: "**/tests/**" });
  // ...
}

Java Environment

Note that SonarJS requires a JRE, so if it's not available on your machine (Java 1.8 version) it will be downloaded during the first analysis.