sonarsource / sonarts Goto Github PK
View Code? Open in Web Editor NEWStatic code analyzer for TypeScript
License: GNU Lesser General Public License v3.0
Static code analyzer for TypeScript
License: GNU Lesser General Public License v3.0
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.
Implements RSPEC-2681
On typescript part:
Implements RSPEC-1481
RSPEC-2123
Implements RSPEC-1764
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
RSPEC-1854
Implements RSPEC-3981
As per [RSPEC-1451]
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 = [];
Useful only for var
We should automate update of documentation:
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
}
}
on typescript side
on java side
Implements RSPEC-3801
function foo(p: number) { // Noncompliant, function can implicitly return undefined
if (p > 0) {
return 43;
}
}
include in the message only method/function name, not entire callee
Add ==, ===, !==, !=
See developer docs and MMF-739
Implements RSPEC-4043
This rule might intersect with whitespace
Implements RSPEC-128
Currently we distribute entire project, including cfg-viewer. It makes the size of the artifact significant.
RSPEC-1871
const x = 1;
switch (x) { // Noncompliant
case 2 * 4:
//...
case 1 + 5:
// ...
}
RSPEC-1854
Only non-breaking flows
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.