Giter Site home page Giter Site logo

sonarsource / sonarts Goto Github PK

View Code? Open in Web Editor NEW
763.0 39.0 53.0 7.16 MB

Static code analyzer for TypeScript

License: GNU Lesser General Public License v3.0

Shell 50.25% Java 49.75%
typescript tslint code-quality static-analysis sonarqube sonarcloud linter tslint-plugin language-team

sonarts's Introduction

Build Status Quality Gate

TypeScript analysis for SonarQube was migrated to JavaScript analyzer. This is a legacy repository which is used to produce an artifact required for backward compatibility with SonarQube.

If you are interested in the plugin for TSLint, check v1.9 which was the last release of tslint-sonarts package (deprecated now).

If you have any question or feedback please start a topic on SonarSource Community Forum.

sonarts's People

Contributors

alban-auzeill avatar andrea-guarino-sonarsource avatar andreaguarino avatar benzonico avatar christophe-zurn-sonarsource avatar dbmeneses avatar ganncamp avatar godin avatar henryju avatar hosszubalazs avatar inverno avatar kmdev1 avatar lqc avatar maximelkin avatar michalb-sonar avatar no23reason avatar pynicolas avatar quentin-jaquier-sonarsource avatar saberduck avatar stas-vilchik avatar timmikeladze avatar tomverin avatar vilchik-elena avatar viperx77 avatar wohops avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

sonarts's Issues

Release 0.1.0

  • finish README.md
  • add rule docs
  • test with different ts & tslint versions -> peer dep is added for tslint@^5.1.0 (which implicitly forces supported typescript version)
  • and .npmignore
  • add prepublish script to compile the project

Rule: Useless Cast and not null assertion

The TypeScript compiler automatically casts objects to a specific type inside conditionals with instanceof :

if(x instanceof string) {
  x = (x as string).concat("postfix"); // This cast is not required
}

but also when property values that are set at type definition are checked for :

class Wolf extends Animal {
  kind = hunting.PackHunter;
  howl() {}
}

class Cat extends Animal {
  kind = hunting.SoloHunter;
  meow() {}
}

function emitSound(animal: Animal) {
  if(animal.kind === hunting.PackHunter) {
    (animal as Wolf).howl(); // This case is not required either
  }
}

compute basic metrics

on typescript side

  • lines of code (NCLOC)
  • comment lines
  • number of functions/classes/statements
  • NOSONAR lines

on java side

  • lines of code (NCLOC)
  • comment lines
  • number of functions/classes/statements
  • NOSONAR lines

Extend S1526 : Let/Const variables should not be used before declaration

When a variable is used within an inner function the TS compiler can't say if that variable is declared before or after its use. In some specific cases (methods well known to execute their callbacks on the fly) it is detectable :

arr.forEach( e => newArray.push(e.foo()));
let newArray = [];

add syntax highlighting

On typescript part:

  • keywords
  • comments (structured or not)
  • string literals, template literals
  • numbers (as constants)

Rule type-checker independent version of no-unused-variable

There is no-unused-variable from tslint core which is base on compiler option (not part of default profile). May be for users it would be valuable to have the same rule but not using type-checker.
To validate this idea we have look through some regular projects using tslint and see if they enabled that rule.

Integrate SonarTS with SonarQube

  • embed tslint and sonarts folders in jar
  • maven plugin to download npm
  • plugin integration test
  • QA chain
  • add ability to integrate measures and highlighting
  • document some rules

Rename repository to align to SonarSource standard

This repository is called SonarTS, which seems unusual. Language plugin namings usually follow the kebab-case style:
sonar-java
sonar-css
sonar-javascript

Rename the repository to align to the common style. Suggestion:
sonar-typescript

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.