mirror of
https://github.com/github/codeql.git
synced 2026-04-30 11:15:13 +02:00
JS: Update OK-style comments to $-style
This commit is contained in:
@@ -1,10 +1,10 @@
|
||||
function f() {
|
||||
if (arguments[0].isArray())
|
||||
arguments = arguments[0]; // NOT OK
|
||||
arguments = arguments[0]; // $ Alert
|
||||
}
|
||||
|
||||
function g(x, y) {
|
||||
var arguments = [y, x]; // NOT OK
|
||||
var arguments = [y, x]; // $ Alert
|
||||
}
|
||||
|
||||
(function (){
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
declare function ambientArguments(arguments: string[]): string; // OK
|
||||
declare function ambientArguments(arguments: string[]): string;
|
||||
|
||||
declare function ambientArgumentsVarArgs(...arguments: string[]): string; // OK
|
||||
declare function ambientArgumentsVarArgs(...arguments: string[]): string;
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
const C = 45;
|
||||
|
||||
// NOT OK
|
||||
class C {}
|
||||
class C {} // $ Alert
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// OK: `const` is block scoped in ECMAScript 2015
|
||||
// OK - `const` is block scoped in ECMAScript 2015
|
||||
function f() {
|
||||
{
|
||||
const val = 1;
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
const C = 45;
|
||||
|
||||
// NOT OK
|
||||
function C() {}
|
||||
function C() {} // $ Alert
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
// OK
|
||||
|
||||
const s = "there";
|
||||
@@ -1,23 +1,19 @@
|
||||
const x = 23, y = 42;
|
||||
|
||||
// NOT OK
|
||||
x = 42;
|
||||
x = 42; // $ Alert
|
||||
|
||||
// NOT OK
|
||||
y = 23;
|
||||
y = 23; // $ Alert
|
||||
|
||||
// NOT OK
|
||||
var y = -1;
|
||||
var y = -1; // $ Alert
|
||||
|
||||
// NOT OK
|
||||
++x;
|
||||
++x; // $ Alert
|
||||
|
||||
var z = 56;
|
||||
|
||||
// OK
|
||||
|
||||
z = 72;
|
||||
|
||||
// OK
|
||||
|
||||
const s = "hi";
|
||||
|
||||
(function (){
|
||||
|
||||
@@ -1,12 +1,11 @@
|
||||
for (var iter in Iterator(aExtraHeaders)) {
|
||||
// NOT OK
|
||||
var key = iter[0], key = iter[1];
|
||||
var key = iter[0], key = iter[1]; // $ Alert
|
||||
xhr.setRequestHeader(key, value);
|
||||
}
|
||||
|
||||
// OK
|
||||
|
||||
var tmp = f(),
|
||||
tmp = tmp + 19;
|
||||
|
||||
// OK
|
||||
|
||||
var a, b, a = 42;
|
||||
@@ -1,31 +1,30 @@
|
||||
// NOT OK
|
||||
g = 23;
|
||||
g = 23; // $ Alert
|
||||
|
||||
|
||||
// OK
|
||||
h = 23;
|
||||
alert(h);
|
||||
|
||||
// OK
|
||||
|
||||
uid = 0;
|
||||
function incr() {
|
||||
return uid++;
|
||||
}
|
||||
|
||||
// OK
|
||||
|
||||
function foo() {
|
||||
var x;
|
||||
x = 0;
|
||||
}
|
||||
|
||||
// OK
|
||||
|
||||
onload = function() {}
|
||||
|
||||
// OK
|
||||
|
||||
global = 42;
|
||||
|
||||
// OK
|
||||
|
||||
prop = 42;
|
||||
|
||||
// OK
|
||||
|
||||
/*global otherGlobal*/
|
||||
otherGlobal = 56;
|
||||
@@ -1,11 +1,11 @@
|
||||
import dummy from 'dummy';
|
||||
|
||||
var key1 = "key1"; // OK
|
||||
var key1 = "key1";
|
||||
export class NoConstructor {
|
||||
[key1] = 4;
|
||||
}
|
||||
|
||||
var key2 = "key2"; // OK
|
||||
var key2 = "key2";
|
||||
export class WithConstructor {
|
||||
[key2] = 4;
|
||||
|
||||
|
||||
@@ -1,16 +1,16 @@
|
||||
import { Foo } from "./exportSymbol" // OK
|
||||
import { Foo } from "./exportSymbol"
|
||||
|
||||
export interface FooMap {
|
||||
[Foo]: number; // OK
|
||||
[Foo]: number;
|
||||
}
|
||||
|
||||
const Bar = "Bar"; // OK
|
||||
const Bar = "Bar";
|
||||
|
||||
export interface BarMap {
|
||||
[Bar]: number;
|
||||
}
|
||||
|
||||
const Baz = "Baz"; // OK
|
||||
const Baz = "Baz";
|
||||
|
||||
if (false) {
|
||||
Baz;
|
||||
@@ -18,7 +18,7 @@ if (false) {
|
||||
|
||||
function getBaz(): typeof Baz { return null; }
|
||||
|
||||
class C {} // OK
|
||||
class C {}
|
||||
|
||||
if (false) {
|
||||
C;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
var C1 = global.C1; // OK
|
||||
var C2 = global.C2; // OK
|
||||
var C1 = global.C1;
|
||||
var C2 = global.C2;
|
||||
|
||||
class C extends C1 {}
|
||||
export default class extends C2 {}
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
var C1 = global.C1; // OK
|
||||
var C1 = global.C1;
|
||||
|
||||
export default function(x=C1) {}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
const React = require('react'); // OK: used in `extends` clause below
|
||||
const React = require('react'); // OK - used in `extends` clause below
|
||||
|
||||
class Foo extends React.Component {
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@ function f() {
|
||||
let y = false;
|
||||
for (const x of [1, 2, 3]) {
|
||||
if (x > 0) {
|
||||
y = true; // OK
|
||||
y = true;
|
||||
continue;
|
||||
}
|
||||
return;
|
||||
|
||||
@@ -9,5 +9,5 @@ namespace a.b.q {
|
||||
|
||||
registerSomething(c);
|
||||
|
||||
function foo() {} // OK
|
||||
function foo() {}
|
||||
}
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
export function foo() {
|
||||
function bar(x: number): number; // OK
|
||||
function bar(x: string): string; // OK
|
||||
function bar(x: any) { // OK
|
||||
function bar(x: number): number;
|
||||
function bar(x: string): string;
|
||||
function bar(x: any) {
|
||||
return x;
|
||||
}
|
||||
|
||||
function baz(x: number): number; // OK
|
||||
function baz(x: string): string; // OK
|
||||
function baz(x: any) { // NOT OK, overwritten before use
|
||||
function baz(x: number): number;
|
||||
function baz(x: string): string;
|
||||
function baz(x: any) { // $ Alert - overwritten before use
|
||||
return x;
|
||||
}
|
||||
baz = (x) => x;
|
||||
|
||||
@@ -1,17 +1,15 @@
|
||||
function f() {
|
||||
// OK: initialization to default value
|
||||
// OK - initialization to default value
|
||||
var x = null, y = undefined, z;
|
||||
x = {};
|
||||
// NOT OK
|
||||
y = 23;
|
||||
y = 23; // $ Alert
|
||||
y = 42;
|
||||
for (var p in x)
|
||||
y+p;
|
||||
// OK: assignment to global
|
||||
// OK - assignment to global
|
||||
global = 42;
|
||||
// NOT OK
|
||||
var a = 23; a = 42;
|
||||
// OK: captured variable
|
||||
var a = 23; a = 42; // $ Alert
|
||||
// OK - captured variable
|
||||
var b = 42;
|
||||
return function() {
|
||||
return b%2
|
||||
@@ -20,14 +18,14 @@ function f() {
|
||||
|
||||
function g() {
|
||||
var x;
|
||||
// OK
|
||||
|
||||
x = 23, x += 19;
|
||||
// OK
|
||||
|
||||
var y = 42;
|
||||
}
|
||||
|
||||
function h() {
|
||||
// OK
|
||||
|
||||
var x = false;
|
||||
try {
|
||||
this.mayThrow();
|
||||
@@ -37,7 +35,7 @@ function h() {
|
||||
}
|
||||
|
||||
function k(data) {
|
||||
// OK
|
||||
|
||||
for(var i=0;i<data.length;i++);
|
||||
}
|
||||
|
||||
@@ -62,7 +60,7 @@ function p() {
|
||||
var i;
|
||||
for (i=0; i < 10; ++i) {
|
||||
if (Math.random() > .5)
|
||||
// OK
|
||||
|
||||
i = 23;
|
||||
}
|
||||
}
|
||||
@@ -87,11 +85,11 @@ function s() {
|
||||
var container = document.createElement("div"),
|
||||
div = document.createElement("div");
|
||||
doStuffWith(container, div);
|
||||
// OK
|
||||
|
||||
container = div = null;
|
||||
}
|
||||
|
||||
// OK: the function expression could be made anonymous, but it's not
|
||||
// OK - the function expression could be made anonymous, but it's not
|
||||
// worth flagging this as a violation
|
||||
defineGetter(req, 'subdomains', function subdomains() {
|
||||
var hostname = this.hostname;
|
||||
@@ -103,7 +101,7 @@ defineGetter(req, 'subdomains', function subdomains() {
|
||||
return subdomains.slice(offset);
|
||||
});
|
||||
|
||||
// OK: assigning default values
|
||||
// OK - assigning default values
|
||||
function t() {
|
||||
var x;
|
||||
x = false;
|
||||
@@ -112,7 +110,7 @@ function t() {
|
||||
x = 42; return x;
|
||||
}
|
||||
|
||||
// OK: unnecessary initialisation as type hint
|
||||
// OK - unnecessary initialisation as type hint
|
||||
function u() {
|
||||
var x;
|
||||
x = [];
|
||||
@@ -120,7 +118,7 @@ function u() {
|
||||
x = 42; return x;
|
||||
}
|
||||
|
||||
// OK: assigning `undefined`
|
||||
// OK - assigning `undefined`
|
||||
function v() {
|
||||
var x;
|
||||
x = void 0;
|
||||
@@ -134,7 +132,7 @@ function v() {
|
||||
return x;
|
||||
}
|
||||
|
||||
// OK: assignments in dead code not flagged
|
||||
// OK - assignments in dead code not flagged
|
||||
!function() {
|
||||
return;
|
||||
var x;
|
||||
@@ -159,7 +157,7 @@ function v() {
|
||||
});
|
||||
|
||||
(function() {
|
||||
let [x] = [0], // OK, but flagged due to destructuring limitations
|
||||
let [x] = [0], // $ SPURIOUS: Alert - flagged due to destructuring limitations
|
||||
y = 0;
|
||||
x = 42;
|
||||
y = 87;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
function outer(b) {
|
||||
// OK
|
||||
|
||||
let addSubdomain = false;
|
||||
|
||||
if (x) {
|
||||
@@ -16,14 +16,13 @@ function outer(b) {
|
||||
}
|
||||
|
||||
function f(event) {
|
||||
// OK
|
||||
|
||||
var message = event.data;
|
||||
eme.init().then(() => NativeInfo.processApp('install', message.id));
|
||||
}
|
||||
|
||||
function g() {
|
||||
// NOT OK
|
||||
let x = 23;
|
||||
let x = 23; // $ Alert
|
||||
{
|
||||
x = 42;
|
||||
}
|
||||
|
||||
@@ -1,2 +1 @@
|
||||
// NOT OK
|
||||
exports = module.exports = { a: 23 };
|
||||
exports = module.exports = { a: 23 }; // $ Alert
|
||||
|
||||
@@ -1,2 +1 @@
|
||||
// NOT OK
|
||||
module.exports = exports = { a: 23 };
|
||||
module.exports = exports = { a: 23 }; // $ Alert
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
class C {
|
||||
static get foo() {} // OK
|
||||
static set foo(v) {} // OK
|
||||
static get foo() {}
|
||||
static set foo(v) {}
|
||||
|
||||
get bar() {} // OK
|
||||
set bar(v) {} // OK
|
||||
get bar() {}
|
||||
set bar(v) {}
|
||||
}
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
var exports = module.exports;
|
||||
exports.answer = "yes"; // NOT OK
|
||||
exports.answer = "yes"; // $ Alert
|
||||
exports.answer = "no";
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
class C {
|
||||
f; // OK
|
||||
f;
|
||||
|
||||
constructor() {
|
||||
this.f = 5;
|
||||
@@ -7,7 +7,7 @@ class C {
|
||||
}
|
||||
|
||||
class D {
|
||||
f = 4; // NOT OK
|
||||
f = 4; // $ Alert
|
||||
|
||||
constructor() {
|
||||
this.f = 5;
|
||||
@@ -15,7 +15,7 @@ class D {
|
||||
}
|
||||
|
||||
class G {
|
||||
constructor(public h: string) { // NOT OK
|
||||
constructor(public h: string) { // $ Alert
|
||||
this.h = h;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
var o = f1();
|
||||
while (f2()) {
|
||||
if (f4()) {
|
||||
o.p = 42; // NOT OK
|
||||
o.p = 42; // $ Alert
|
||||
break;
|
||||
}
|
||||
f5();
|
||||
@@ -12,8 +12,8 @@
|
||||
|
||||
(function(){
|
||||
var o = f1();
|
||||
o.p1 = o.p1 += 42; // NOT OK
|
||||
o.p2 -= (o.p2 *= 42); // NOT OK
|
||||
o.p1 = o.p1 += 42; // $ Alert
|
||||
o.p2 -= (o.p2 *= 42); // $ Alert
|
||||
});
|
||||
|
||||
(function(){
|
||||
@@ -26,7 +26,7 @@
|
||||
f3();
|
||||
} catch (e) {
|
||||
f4();
|
||||
o.p = 42; // NOT OK
|
||||
o.p = 42; // $ Alert
|
||||
}
|
||||
}
|
||||
o.p = 42;
|
||||
@@ -35,5 +35,5 @@
|
||||
|
||||
(function(){
|
||||
var o = f1();
|
||||
o.p = f2() ? o.p = f3() : f4(); // NOT OK
|
||||
o.p = f2() ? o.p = f3() : f4(); // $ Alert
|
||||
});
|
||||
|
||||
@@ -1,26 +1,26 @@
|
||||
(function(){
|
||||
var o = {};
|
||||
o.pure1 = 42; // NOT OK
|
||||
o.pure1 = 42; // $ Alert
|
||||
o.pure1 = 42;
|
||||
|
||||
o.pure2 = 42; // NOT OK
|
||||
o.pure2 = 42; // $ Alert
|
||||
o.pure2 = 43;
|
||||
|
||||
o.impure3 = 42;
|
||||
f();
|
||||
o.impure3 = 42;
|
||||
|
||||
o.pure4 = 42; // NOT OK
|
||||
o.pure4 = 42; // $ Alert
|
||||
43;
|
||||
o.pure4 = 42;
|
||||
|
||||
o.impure5 = 42;
|
||||
o.impure5 = f();
|
||||
|
||||
o.pure6 = f(); // NOT OK
|
||||
o.pure6 = f(); // $ Alert
|
||||
o.pure6 = 42;
|
||||
|
||||
o.pure7 = 42; // NOT OK
|
||||
o.pure7 = 42; // $ Alert
|
||||
if(x){}
|
||||
o.pure7 = 42;
|
||||
|
||||
@@ -73,7 +73,7 @@
|
||||
o15.pure15_aliasWrite = 42;
|
||||
|
||||
var o16 = x? o: null;
|
||||
o.pure16_simpleAliasWrite = 42; // NOT OK
|
||||
o.pure16_simpleAliasWrite = 42; // $ Alert
|
||||
o16.pure16_simpleAliasWrite = 42;
|
||||
|
||||
var o17 = {
|
||||
@@ -82,31 +82,31 @@
|
||||
}
|
||||
|
||||
// DOM
|
||||
o.clientTop = 42; // OK
|
||||
o.clientTop = 42;
|
||||
o.clientTop = 42;
|
||||
|
||||
o.defaulted1 = null; // OK
|
||||
o.defaulted1 = null;
|
||||
o.defaulted1 = 42;
|
||||
|
||||
o.defaulted2 = -1; // OK
|
||||
o.defaulted2 = -1;
|
||||
o.defaulted2 = 42;
|
||||
|
||||
var o = {};
|
||||
o.pure18 = 42; // NOT OK
|
||||
o.pure18 = 42; // NOT OK
|
||||
o.pure18 = 42; // $ Alert
|
||||
o.pure18 = 42; // $ Alert
|
||||
o.pure18 = 42;
|
||||
|
||||
var o = {};
|
||||
Object.defineProperty(o, "setter", { // OK
|
||||
Object.defineProperty(o, "setter", {
|
||||
set: function (value) { }
|
||||
});
|
||||
o.setter = "";
|
||||
|
||||
var o = { set setter(value) { } }; // OK
|
||||
var o = { set setter(value) { } };
|
||||
o.setter = "";
|
||||
|
||||
var o = {
|
||||
set accessor(value) { }, // OK
|
||||
set accessor(value) { },
|
||||
get accessor() { }
|
||||
};
|
||||
|
||||
@@ -115,24 +115,24 @@
|
||||
o.setter = 87;
|
||||
|
||||
var o = {};
|
||||
Object.defineProperty(o, "prop", {writable:!0,configurable:!0,enumerable:!1, value: getInitialValue()}) // NOT OK
|
||||
Object.defineProperty(o, "prop", {writable:!0,configurable:!0,enumerable:!1, value: getInitialValue()}) // $ Alert
|
||||
o.prop = 42;
|
||||
|
||||
var o = {};
|
||||
Object.defineProperty(o, "prop", {writable:!0,configurable:!0,enumerable:!1, value: undefined}) // OK, default value
|
||||
Object.defineProperty(o, "prop", {writable:!0,configurable:!0,enumerable:!1, value: undefined}) // OK - default value
|
||||
o.prop = 42;
|
||||
|
||||
var o = {};
|
||||
Object.defineProperty(o, "prop", {writable:!0,configurable:!0,enumerable:!1}) // OK
|
||||
Object.defineProperty(o, "prop", {writable:!0,configurable:!0,enumerable:!1})
|
||||
o.prop = 42;
|
||||
|
||||
var o = {};
|
||||
o.pure19 = 42; // OK
|
||||
o.pure19 = 42;
|
||||
o.some_other_property = 42;
|
||||
o.pure19 = 42;
|
||||
|
||||
var o = {};
|
||||
o.pure20 = 42; // OK
|
||||
o.pure20 = 42;
|
||||
some_other_obj.some_other_property = 42;
|
||||
o.pure20 = 42;
|
||||
});
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
/*global w, x:true*/
|
||||
/* global y*/ // not a proper JSLint global declaration, but we (and JSHint) accept it anyway
|
||||
/*global: z*/ // also not a proper global declaration
|
||||
w; // OK
|
||||
x; // OK
|
||||
y; // not OK
|
||||
z; // not OK
|
||||
w;
|
||||
x;
|
||||
y; // $ Alert
|
||||
z; // $ Alert
|
||||
var x, y, z;
|
||||
@@ -1,11 +1,11 @@
|
||||
function f(x) {
|
||||
console.log(x); // OK
|
||||
console.log(x);
|
||||
}
|
||||
|
||||
console.log(x); // NOT OK
|
||||
console.log(x); // $ Alert
|
||||
var x = 1;
|
||||
|
||||
function g() {
|
||||
console.log(y); // OK (not in same function)
|
||||
console.log(y); // OK - not in same function
|
||||
}
|
||||
var y = 1;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
@Component(Foo) // OK
|
||||
@Component(Foo)
|
||||
class Foo {}
|
||||
|
||||
declare class Bar extends Baz {} // OK
|
||||
declare class Bar extends Baz {}
|
||||
declare class Baz {}
|
||||
|
||||
export type { I }; // OK - does not refer to the constant 'I'
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
// NOT OK
|
||||
var a, b, a = 42;
|
||||
var a, b, a = 42; // $ Alert
|
||||
|
||||
|
||||
// OK
|
||||
var x;
|
||||
var y;
|
||||
var x;
|
||||
@@ -1 +1 @@
|
||||
function getStuff(number) {} // OK: don't report anything related type annotations in .js files
|
||||
function getStuff(number) {} // OK - don't report anything related type annotations in .js files
|
||||
|
||||
@@ -1,36 +1,36 @@
|
||||
import { MyType, x } from 'somewhere';
|
||||
|
||||
function join<T>(items: T[], callback: (T) => string) { // NOT OK: (T) should be (x:T)
|
||||
function join<T>(items: T[], callback: (T) => string) { // $ Alert - (T) should be (x:T)
|
||||
return items.map(callback).join(", ")
|
||||
}
|
||||
|
||||
var box : <T>(T) => T[] = (x) => [x]; // NOT OK: (T) should be (x:T)
|
||||
var box : <T>(T) => T[] = (x) => [x]; // $ Alert - (T) should be (x:T)
|
||||
|
||||
interface EventEmitter<T> {
|
||||
addListener(listener: (T) => void): void; // NOT OK: (T) should be (x:T)
|
||||
forwardFrom<S>(other: EventEmitter<S>, converter: (S) => T); // NOT OK: (S) should be (x:S)
|
||||
addListener(listener: (T) => void): void; // $ Alert - (T) should be (x:T)
|
||||
forwardFrom<S>(other: EventEmitter<S>, converter: (S) => T); // $ Alert - (S) should be (x:S)
|
||||
}
|
||||
|
||||
interface NumberFormatter {
|
||||
format(number): string; // NOT OK: (number) should be (x:number)
|
||||
(number): string; // NOT OK: (number) should be (x:number)
|
||||
format(number): string; // $ Alert - (number) should be (x:number)
|
||||
(number): string; // $ Alert - (number) should be (x:number)
|
||||
}
|
||||
|
||||
type TextFormatter = (NumberFormatter) => string; // NOT OK: (NumberFormatter) should be (x:NumberFormatter)
|
||||
type TextFormatter = (NumberFormatter) => string; // $ Alert - (NumberFormatter) should be (x:NumberFormatter)
|
||||
|
||||
var myGlobal : MyType;
|
||||
var myCallback: (MyType) => void; // NOT OK: (MyType) should be (x:MyType)
|
||||
var myCallback: (MyType) => void; // $ Alert - (MyType) should be (x:MyType)
|
||||
|
||||
var myOtherCallback : (x) => void; // OK: nothing indicates that 'x' is a type name.
|
||||
var myOtherCallback : (x) => void; // OK - nothing indicates that 'x' is a type name.
|
||||
|
||||
interface Repeated { x: number; }
|
||||
interface Repeated { y: number; }
|
||||
interface Repeated { z: number; }
|
||||
|
||||
type Callback = (Repeated) => void; // NOT OK: but should only be reported once
|
||||
type Callback = (Repeated) => void; // $ Alert - but should only be reported once
|
||||
|
||||
class C {
|
||||
getName(string) { // OK: parameter name is not part of signature
|
||||
getName(string) { // OK - parameter name is not part of signature
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
abstract class Audio3D {
|
||||
setAudioStream() {
|
||||
setAudioProperties(); // NOT OK
|
||||
setAudioProperties(); // $ Alert
|
||||
}
|
||||
|
||||
abstract setAudioProperties();
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
class Audio3D {
|
||||
setAudioStream() {
|
||||
externs_setAudioProperties(); // OK
|
||||
externs_setAudioProperties();
|
||||
}
|
||||
|
||||
externs_setAudioProperties(){
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/*global setAudioProperties*/
|
||||
class Audio3D {
|
||||
setAudioStream() {
|
||||
setAudioProperties(); // OK
|
||||
setAudioProperties();
|
||||
}
|
||||
|
||||
setAudioProperties(){
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
class X {
|
||||
m() {
|
||||
m("default"); // OK
|
||||
m("default");
|
||||
}
|
||||
|
||||
resty(...x) {
|
||||
m("default"); // NOT OK
|
||||
m("default"); // $ Alert
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
class Audio3D {
|
||||
setAudioStream() {
|
||||
setAudioProperties(); // NOT OK
|
||||
setAudioProperties(); // $ Alert
|
||||
}
|
||||
|
||||
setAudioProperties(){
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
class Audio3D {
|
||||
static setAudioStream() {
|
||||
setAudioProperties(); // NOT OK
|
||||
setAudioProperties(); // $ Alert
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -1,39 +1,39 @@
|
||||
class GlobalClass {
|
||||
globalFunction(){
|
||||
globalFunction(); // NOT OK
|
||||
globalFunction() {
|
||||
globalFunction(); // $ Alert
|
||||
}
|
||||
topNamespaceFunction(){
|
||||
topNamespaceFunction(); // NOT OK
|
||||
topNamespaceFunction() {
|
||||
topNamespaceFunction(); // $ Alert
|
||||
}
|
||||
childNamespaceFunction(){
|
||||
childNamespaceFunction(); // NOT OK
|
||||
childNamespaceFunction() {
|
||||
childNamespaceFunction(); // $ Alert
|
||||
}
|
||||
}
|
||||
|
||||
namespace Top {
|
||||
class TopClass {
|
||||
globalFunction(){
|
||||
globalFunction(); // NOT OK
|
||||
globalFunction() {
|
||||
globalFunction(); // $ Alert
|
||||
}
|
||||
topNamespaceFunction(){
|
||||
topNamespaceFunction(); // OK
|
||||
topNamespaceFunction() {
|
||||
topNamespaceFunction();
|
||||
}
|
||||
childNamespaceFunction(){
|
||||
childNamespaceFunction(); // NOT OK, but not flagged since the namespace resolution is ignored
|
||||
childNamespaceFunction() {
|
||||
childNamespaceFunction(); // $ MISSING: Alert - not flagged since the namespace resolution is ignored
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
namespace Top.Child {
|
||||
class ChildClass {
|
||||
globalFunction(){
|
||||
globalFunction(); // NOT OK
|
||||
globalFunction() {
|
||||
globalFunction(); // $ Alert
|
||||
}
|
||||
topNamespaceFunction(){
|
||||
topNamespaceFunction(); // OK
|
||||
topNamespaceFunction() {
|
||||
topNamespaceFunction();
|
||||
}
|
||||
childNamespaceFunction(){
|
||||
childNamespaceFunction(); // OK
|
||||
childNamespaceFunction() {
|
||||
childNamespaceFunction();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@ function setAudioProperties(){}
|
||||
|
||||
class Audio3D {
|
||||
setAudioStream() {
|
||||
setAudioProperties(); // OK
|
||||
setAudioProperties();
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/*global NOT_setAudioProperties*/
|
||||
class Audio3D {
|
||||
setAudioStream() {
|
||||
setAudioProperties(); // NOT OK
|
||||
setAudioProperties(); // $ Alert
|
||||
}
|
||||
|
||||
setAudioProperties(){
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
class Audio3D {
|
||||
setAudioStream() {
|
||||
this.setAudioProperties(); // OK
|
||||
this.setAudioProperties();
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
class Audio3D {
|
||||
static setAudioStream() {
|
||||
this.setAudioProperties(); // OK
|
||||
this.setAudioProperties();
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -2,26 +2,23 @@ var x;
|
||||
|
||||
function f(a) {
|
||||
var sum = 0;
|
||||
// NOT OK
|
||||
for (i=0; i<a.length; ++i)
|
||||
for (i=0; i<a.length; ++i) // $ Alert
|
||||
sum += g(a[i]);
|
||||
return sum;
|
||||
}
|
||||
|
||||
function g(b) {
|
||||
var prod = 1;
|
||||
// NOT OK
|
||||
for (i=0; i<b.length; ++i)
|
||||
for (i=0; i<b.length; ++i) // $ Alert
|
||||
prod *= b[i];
|
||||
return prod;
|
||||
}
|
||||
|
||||
function h() {
|
||||
// OK: x is declared as a global in the same toplevel
|
||||
// OK - x is declared as a global in the same toplevel
|
||||
x = 23;
|
||||
// NOT OK: y is not declared as a global in the same toplevel (though it is declared in test2.js)
|
||||
y = 19;
|
||||
// OK: console is live
|
||||
y = 19; // $ Alert - y is not declared as a global in the same toplevel (though it is declared in test2.js)
|
||||
// OK - console is live
|
||||
console.log(x+y);
|
||||
}
|
||||
|
||||
@@ -29,41 +26,38 @@ function k(x) {
|
||||
try {
|
||||
return x.y;
|
||||
} catch(e) {
|
||||
// OK: Error is not reachable (in our current CFG)
|
||||
// OK - Error is not reachable (in our current CFG)
|
||||
throw new Error();
|
||||
}
|
||||
}
|
||||
|
||||
function l() {
|
||||
// OK: z is not used
|
||||
// OK - z is not used
|
||||
z = 56;
|
||||
}
|
||||
|
||||
function m() {
|
||||
// OK: z is live
|
||||
// OK - z is live
|
||||
z += 23;
|
||||
}
|
||||
|
||||
function n() {
|
||||
// OK: z is live
|
||||
// OK - z is live
|
||||
z = z + 23;
|
||||
}
|
||||
|
||||
function p() {
|
||||
// NOT OK
|
||||
return (z = a[i]) && z+23;
|
||||
return (z = a[i]) && z+23; // $ Alert
|
||||
}
|
||||
|
||||
function q() {
|
||||
// NOT OK
|
||||
var x;
|
||||
var x; // $ Alert
|
||||
y = 23,
|
||||
z = y+19;
|
||||
}
|
||||
|
||||
function r() {
|
||||
// NOT OK
|
||||
z = {};
|
||||
z = {}; // $ Alert
|
||||
for (var p in z)
|
||||
;
|
||||
}
|
||||
|
||||
@@ -3,6 +3,6 @@ abstract class Q {
|
||||
static test() {}
|
||||
|
||||
method() {
|
||||
this.test(); // OK
|
||||
this.test();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
class Foo {
|
||||
bar(){
|
||||
this.baz; // OK
|
||||
this.baz;
|
||||
}
|
||||
baz(){
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
class Foo {
|
||||
bar() {
|
||||
this.baz; // OK
|
||||
this.baz;
|
||||
}
|
||||
baz() {}
|
||||
static baz() {}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
class Foo {
|
||||
static bar(){
|
||||
this.baz; // NOT OK
|
||||
this.baz; // $ Alert
|
||||
}
|
||||
baz(){
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
class Foo {
|
||||
bar(){
|
||||
this.baz; // NOT OK
|
||||
this.baz; // $ Alert
|
||||
}
|
||||
static baz(){
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
class Foo {
|
||||
static bar(){
|
||||
this.baz; // OK
|
||||
this.baz;
|
||||
}
|
||||
static baz(){
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
class Foo {
|
||||
static bar() {
|
||||
this.baz; // OK
|
||||
this.baz;
|
||||
}
|
||||
static baz() {}
|
||||
baz() {}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
class Foo {
|
||||
bar(){
|
||||
Foo.baz; // OK
|
||||
Foo.baz;
|
||||
}
|
||||
static baz(){
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
class C1 {
|
||||
test() {
|
||||
this.f = x;
|
||||
this.f; // OK
|
||||
this.f;
|
||||
}
|
||||
|
||||
static f() {
|
||||
@@ -12,7 +12,7 @@ class C1 {
|
||||
class C2 {
|
||||
static test() {
|
||||
this.f = x;
|
||||
this.f; // OK
|
||||
this.f;
|
||||
}
|
||||
|
||||
f() {
|
||||
@@ -22,7 +22,7 @@ class C2 {
|
||||
|
||||
class C3 {
|
||||
test() {
|
||||
this.f; // OK
|
||||
this.f;
|
||||
}
|
||||
|
||||
static f() {
|
||||
@@ -33,7 +33,7 @@ new C3().f = x;
|
||||
|
||||
class C4 {
|
||||
static test() {
|
||||
this.f; // OK
|
||||
this.f;
|
||||
}
|
||||
|
||||
f() {
|
||||
@@ -52,7 +52,7 @@ class C5 extends C5_super{
|
||||
|
||||
}
|
||||
test() {
|
||||
this.f; // OK
|
||||
this.f;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -63,6 +63,6 @@ class C6_super {
|
||||
}
|
||||
class C6 extends C6_super{
|
||||
static test() {
|
||||
this.f; // NOT OK
|
||||
this.f; // $ Alert
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// OK: people sometimes use multiple declarations in an externs file to represent multiple type signatures
|
||||
// OK - people sometimes use multiple declarations in an externs file to represent multiple type signatures
|
||||
var f = function() {};
|
||||
var f = function(x) {};
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
function f() {
|
||||
// OK
|
||||
|
||||
var f;
|
||||
}
|
||||
|
||||
|
||||
@@ -8,12 +8,12 @@ namespace N2 {
|
||||
let y;
|
||||
}
|
||||
|
||||
namespace N2 { // OK
|
||||
namespace N2 {
|
||||
var w;
|
||||
}
|
||||
|
||||
function f(x: number): number;
|
||||
function f(x: string): string; // OK
|
||||
function f(x: any): any { // OK
|
||||
function f(x: string): string;
|
||||
function f(x: any): any {
|
||||
return x;
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@ function f() {
|
||||
|
||||
f();
|
||||
|
||||
function f() { // NOT OK
|
||||
function f() { // $ Alert
|
||||
console.log("first declaration");
|
||||
}
|
||||
|
||||
|
||||
@@ -1,22 +1,22 @@
|
||||
function f() {
|
||||
var x = 1;
|
||||
var x = 2; // NOT OK
|
||||
var x = 2; // $ Alert
|
||||
}
|
||||
|
||||
function g(x) {
|
||||
var x = 1; // NOT OK
|
||||
var x = 1; // $ Alert
|
||||
}
|
||||
|
||||
function h() {
|
||||
var i = 1;
|
||||
for (var i = 0; i < 10; i++) { // NOT OK
|
||||
for (var i = 0; i < 10; i++) { // $ Alert
|
||||
}
|
||||
}
|
||||
|
||||
function k() {
|
||||
var y = 1;
|
||||
var x = 2,
|
||||
y = 2; // NOT OK
|
||||
y = 2; // $ Alert
|
||||
}
|
||||
|
||||
var g;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// OK: don't report anything in .js files.
|
||||
// OK - don't report anything in .js files.
|
||||
function getStuff(number) {
|
||||
return {
|
||||
"new": function() {
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
var foo: MyInterface = 123 as any;
|
||||
|
||||
interface MyInterface {
|
||||
function (): number; // OK. Highly unlikely that it is an accident when there are other named methods in the interface.
|
||||
(): number; // OK: What was probably meant above.
|
||||
new:() => void; // OK! This is a property, not a method, we ignore those.
|
||||
constructor(): string; // NOT OK! This a called "constructor"
|
||||
new(): Date; // OK! This a constructor signature.
|
||||
function (): number; // OK - Highly unlikely that it is an accident when there are other named methods in the interface.
|
||||
(): number; // OK - What was probably meant above.
|
||||
new:() => void; // OK - This is a property, not a method, we ignore those.
|
||||
constructor(): string; // $ Alert - This a called "constructor"
|
||||
new(): Date; // OK - This a constructor signature.
|
||||
|
||||
myNumber: 123;
|
||||
}
|
||||
@@ -13,15 +13,15 @@ interface MyInterface {
|
||||
var a : MyFunction = null as any;
|
||||
|
||||
interface MyFunction {
|
||||
function(): number; // NOT OK!
|
||||
function(): number; // $ Alert
|
||||
}
|
||||
|
||||
|
||||
class Foo {
|
||||
new(): number { // OK! Highly unlikely that a developer confuses "constructor" and "new" when both are present.
|
||||
new(): number { // OK - Highly unlikely that a developer confuses "constructor" and "new" when both are present.
|
||||
return 123;
|
||||
}
|
||||
constructor() { // OK! This is a constructor.
|
||||
constructor() { // OK - This is a constructor.
|
||||
|
||||
}
|
||||
myString = "foobar"
|
||||
@@ -34,18 +34,18 @@ class Foo {
|
||||
var b : FunctionClass = new FunctionClass();
|
||||
|
||||
declare class FunctionClass {
|
||||
function(): number; // NOT OK:
|
||||
function(): number; // $ Alert
|
||||
}
|
||||
|
||||
class Baz {
|
||||
new(): Baz { // OK! When there is a method body I assume the developer knows what they are doing.
|
||||
new(): Baz { // OK - When there is a method body I assume the developer knows what they are doing.
|
||||
return null as any;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
declare class Quz {
|
||||
new(): Quz; // NOT OK! The developer likely meant to write constructor.
|
||||
new(): Quz; // $ Alert - The developer likely meant to write constructor.
|
||||
}
|
||||
|
||||
var bla = new Foo();
|
||||
|
||||
@@ -1,27 +1,26 @@
|
||||
function f() {
|
||||
// NOT OK
|
||||
s = null;
|
||||
s = null; // $ Alert
|
||||
let s = "hi";
|
||||
// OK
|
||||
|
||||
s = "hello";
|
||||
}
|
||||
|
||||
function g() {
|
||||
// OK
|
||||
|
||||
s = null;
|
||||
var s = "hi";
|
||||
// OK
|
||||
|
||||
s = "hello";
|
||||
}
|
||||
|
||||
function do_something() {
|
||||
// OK
|
||||
|
||||
let foo;
|
||||
let foo;
|
||||
}
|
||||
|
||||
function do_something() {
|
||||
// OK
|
||||
|
||||
let foo;
|
||||
foo = "bar";
|
||||
let foo;
|
||||
@@ -29,7 +28,7 @@ function do_something() {
|
||||
|
||||
if (true) { // enter new scope, TDZ starts
|
||||
const func = function () {
|
||||
console.log(myVar); // OK!
|
||||
console.log(myVar);
|
||||
};
|
||||
|
||||
function otherfunc() {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// OK: overly long parameter lists in external APIs aren't the fault of the externs definitions
|
||||
// OK - overly long parameter lists in external APIs aren't the fault of the externs definitions
|
||||
function f(a, b, c, d, e, f, g, h) {}
|
||||
|
||||
/** @externs */
|
||||
@@ -1,21 +1,21 @@
|
||||
function f(
|
||||
x,
|
||||
x, // NOT OK
|
||||
\u0078 // NOT OK
|
||||
x, // $ Alert
|
||||
\u0078 // $ Alert
|
||||
) { return; }
|
||||
|
||||
this.addPropertyListener(prop.name, function(_, _, _, a) {
|
||||
proxy.delegate = a.dao;
|
||||
});
|
||||
|
||||
// OK: for strict mode functions, duplicate parameter names are a syntax error
|
||||
// OK - for strict mode functions, duplicate parameter names are a syntax error
|
||||
function f(x, y, x) {
|
||||
'use strict';
|
||||
}
|
||||
|
||||
function f(
|
||||
x,
|
||||
x // OK: empty function
|
||||
x // OK - empty function
|
||||
) { }
|
||||
|
||||
(a, a) => a + a; // OK: for strict mode functions, duplicate parameter names are a syntax error
|
||||
(a, a) => a + a; // OK - for strict mode functions, duplicate parameter names are a syntax error
|
||||
|
||||
@@ -17,9 +17,9 @@ var accessors = {
|
||||
};
|
||||
|
||||
var clobbering = {
|
||||
x: 23, // NOT OK: clobbered by `x: 56`
|
||||
y: "hello", // NOT OK: clobbered by `"y": "world"`
|
||||
x: 42, // NOT OK: clobbered by `x: 56`
|
||||
x: 23, // $ Alert - clobbered by `x: 56`
|
||||
y: "hello", // $ Alert - clobbered by `"y": "world"`
|
||||
x: 42, // $ Alert - clobbered by `x: 56`
|
||||
x: 56,
|
||||
"y": "world"
|
||||
}
|
||||
@@ -1,30 +1,30 @@
|
||||
declare class Foobar {
|
||||
method(foo: number): string;
|
||||
method(foo: number): number; // NOT OK.
|
||||
method(foo: number): number; // $ Alert
|
||||
|
||||
types1<T>(): T[]
|
||||
types1(): any[] // NOT OK.
|
||||
types1(): any[] // $ Alert
|
||||
|
||||
types2(): any[]
|
||||
types2<T>(): T[] // OK!
|
||||
types2<T>(): T[]
|
||||
|
||||
types3<T extends Array<T>>(t: T): number;
|
||||
types3<T extends string>(t: T): number // OK!
|
||||
types3<T extends string>(t: T): number
|
||||
|
||||
on(event: string, fn?: (event?: any, ...args: any[]) => void): Function;
|
||||
on(event: string, fn?: (event?: any, ...args: any[]) => void): Function; // NOT OK.
|
||||
on(event: string, fn?: (event?: any, ...args: any[]) => void): Function; // $ Alert
|
||||
|
||||
foo(this: string): string;
|
||||
foo(this: number): number; // OK
|
||||
foo(this: number): number;
|
||||
|
||||
bar(this: number): string;
|
||||
bar(this: number): number; // NOT OK
|
||||
bar(this: number): number; // $ Alert
|
||||
|
||||
}
|
||||
|
||||
declare class Base {
|
||||
method(foo: number): string;
|
||||
method(foo: number): number; // NOT OK.
|
||||
method(foo: number): number; // $ Alert
|
||||
|
||||
overRiddenInSub(): string;
|
||||
overRiddenInSub(): number;
|
||||
@@ -49,13 +49,13 @@ interface Base2 {
|
||||
method(): "bar";
|
||||
}
|
||||
|
||||
// OK.
|
||||
|
||||
interface MultiInheritanceI extends Base1, Base2 {
|
||||
method(): "foo";
|
||||
method(): "bar";
|
||||
}
|
||||
|
||||
// OK.
|
||||
|
||||
declare class MultiInheritanceC implements Base1, Base2 {
|
||||
method(): "foo";
|
||||
method(): "bar";
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
import {B} from './B';
|
||||
|
||||
export let A: number = B+1; // NOT OK: `B` is not initialized if `B.ts` is imported first.
|
||||
export let A: number = B+1; // $ Alert - `B` is not initialized if `B.ts` is imported first.
|
||||
|
||||
@@ -2,4 +2,4 @@ import {A} from './A';
|
||||
|
||||
export let B: number = 100;
|
||||
|
||||
export let Q: number = A; // NOT OK: `A` is not initialized if `A.ts` is imported first.
|
||||
export let Q: number = A; // $ Alert - `A` is not initialized if `A.ts` is imported first.
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
import {B} from './B';
|
||||
|
||||
console.log(B) // OK: `B` does not import this file
|
||||
console.log(B) // OK - `B` does not import this file
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import {B} from './exportCycleB';
|
||||
|
||||
export var A = 100;
|
||||
export {B}; // OK: export binding does not immediately evaluate 'B'
|
||||
export {B}; // OK - export binding does not immediately evaluate 'B'
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
import {A} from './exportCycleA';
|
||||
|
||||
export let B = () => A; // OK: `A` is not used during initialization.
|
||||
export let B = () => A; // OK - `A` is not used during initialization.
|
||||
|
||||
@@ -3,5 +3,5 @@ import {B} from './safeB';
|
||||
export let A = 100;
|
||||
|
||||
export function getSum() {
|
||||
return A + B; // OK: not accessed from top-level
|
||||
return A + B; // OK - not accessed from top-level
|
||||
}
|
||||
|
||||
@@ -3,5 +3,5 @@ import {A} from './safeA';
|
||||
export let B = 20;
|
||||
|
||||
export function getProduct() {
|
||||
return A * B; // OK: not accessed from top-level
|
||||
return A * B; // OK - not accessed from top-level
|
||||
}
|
||||
|
||||
@@ -4,4 +4,4 @@ export interface TypeA {
|
||||
field: TypeB
|
||||
}
|
||||
|
||||
export let valueA = valueB; // OK: these imports are not cyclic at runtime
|
||||
export let valueA = valueB; // OK - these imports are not cyclic at runtime
|
||||
|
||||
@@ -12,10 +12,10 @@ class SingletonTreeModel implements ITreeModel {
|
||||
isLeafNode(node: Node): node is LeafNode {
|
||||
return node instanceof LeafNode;
|
||||
}
|
||||
isBranchNode(node: Node): node is BranchNode { // OK
|
||||
isBranchNode(node: Node): node is BranchNode {
|
||||
return false; // This model has no branches.
|
||||
}
|
||||
isValidNode(node: Node): boolean { // NOT OK
|
||||
isValidNode(node: Node): boolean { // $ Alert
|
||||
return Node != null; // woops
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
class C {
|
||||
constructor(public x: number) {} // OK
|
||||
constructor(public x: number) {}
|
||||
}
|
||||
|
||||
class D {
|
||||
constructor(x: number) {} // NOT OK
|
||||
constructor(x: number) {} // $ Alert
|
||||
}
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
function foo(this: void, x: number) { // OK: 'this' is not an ordinary parameter
|
||||
function foo(this: void, x: number) { // OK - 'this' is not an ordinary parameter
|
||||
return x;
|
||||
}
|
||||
|
||||
@@ -1,28 +1,26 @@
|
||||
// OK
|
||||
|
||||
[1, , 3].forEach(function(elt, idx) {
|
||||
console.log(idx + " is not omitted.");
|
||||
});
|
||||
|
||||
// NOT OK
|
||||
[1, , 3].forEach(function(elt, idx) {
|
||||
[1, , 3].forEach(function(elt, idx) { // $ Alert
|
||||
sum += elt;
|
||||
});
|
||||
|
||||
// NOT OK
|
||||
function f1(x, y) {
|
||||
function f1(x, y) { // $ Alert
|
||||
return y;
|
||||
}
|
||||
|
||||
f1(23, 42);
|
||||
|
||||
// OK
|
||||
|
||||
function f2(x, y) {
|
||||
return y;
|
||||
}
|
||||
|
||||
[].map(f2);
|
||||
|
||||
// OK
|
||||
|
||||
function f3(x, y) {
|
||||
return y;
|
||||
}
|
||||
@@ -30,11 +28,11 @@ function f3(x, y) {
|
||||
var g = f3;
|
||||
[].map(g);
|
||||
|
||||
// OK
|
||||
|
||||
define(function (require, exports, module) {
|
||||
module.x = 23;
|
||||
});
|
||||
|
||||
// OK: starts with underscore
|
||||
// OK - starts with underscore
|
||||
function f(_p) {
|
||||
}
|
||||
|
||||
@@ -1,18 +1,18 @@
|
||||
function f(x, y) { // NOT OK
|
||||
function f(x, y) { // $ Alert
|
||||
return y;
|
||||
}
|
||||
|
||||
function g(x, y) { // OK
|
||||
function g(x, y) {
|
||||
return y + arguments[0];
|
||||
}
|
||||
|
||||
function h(x) { // OK
|
||||
function h(x) {
|
||||
function inner() {
|
||||
x = 1;
|
||||
}
|
||||
}
|
||||
|
||||
// OK
|
||||
|
||||
/**
|
||||
* @param {*} x the first argument, deliberately unused
|
||||
* @param {*} y the second argument
|
||||
@@ -21,8 +21,7 @@ function K(x, y) {
|
||||
return y;
|
||||
}
|
||||
|
||||
// NOT OK
|
||||
/**
|
||||
/** // $ Alert
|
||||
* @param {*} x the first argument
|
||||
* @param {*} y the second argument
|
||||
*/
|
||||
@@ -30,7 +29,7 @@ function K(x, y) {
|
||||
return y;
|
||||
}
|
||||
|
||||
// OK
|
||||
|
||||
/**
|
||||
* @abstract
|
||||
* @param {*} x the first argument
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { h } from 'preact'; // OK - JSX element uses 'h' after babel compilation
|
||||
import { q } from 'preact'; // NOT OK - not used
|
||||
import { q } from 'preact'; // $ Alert - not used
|
||||
|
||||
export default (<div>Hello</div>);
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
function sum(xs, i) {
|
||||
var res = 0;
|
||||
for(;i++<xs.length;) // NOT OK, but flagged by js/unused-index-variable
|
||||
for(;i++<xs.length;) // $ Alert - but flagged by js/unused-index-variable
|
||||
res += xs[0];
|
||||
return res;
|
||||
}
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
import {actionHandler, actionHandlerFactory, actionHandlerFactoryProvider, actionHandlerFactoryProviderKind} from 'somewhere'; // OK: imports used as decorators
|
||||
import {actionHandler, actionHandlerFactory, actionHandlerFactoryProvider, actionHandlerFactoryProviderKind} from 'somewhere'; // OK - imports used as decorators
|
||||
|
||||
@actionHandler
|
||||
function fun() {} // OK: decorator might use the function
|
||||
function fun() {} // OK - decorator might use the function
|
||||
|
||||
@actionHandlerFactory
|
||||
class Class {} // OK: decorator might use the class
|
||||
class Class {} // OK - decorator might use the class
|
||||
|
||||
@actionHandlerFactoryProvider
|
||||
export class ExportedClass {} // OK: decorator might use the class
|
||||
export class ExportedClass {} // OK - decorator might use the class
|
||||
|
||||
@actionHandlerFactoryProviderKind
|
||||
enum Enum { plain } // OK: decorator might use the enum
|
||||
enum Enum { plain } // OK - decorator might use the enum
|
||||
|
||||
@@ -2,10 +2,9 @@
|
||||
* @externs
|
||||
*/
|
||||
|
||||
// NOT OK
|
||||
var iAmUnused;
|
||||
var iAmUnused; // $ Alert
|
||||
|
||||
// OK: used as a type
|
||||
// OK - used as a type
|
||||
/**
|
||||
* @typedef string
|
||||
*/
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
import { h } from 'preact'; // NOT OK - not in scope of .babelrc file
|
||||
import { h } from 'preact'; // $ Alert - not in scope of .babelrc file
|
||||
|
||||
export default (<div>Hello</div>);
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
// OK: `SomeInterface` is used in an `implements` clause
|
||||
// OK - `SomeInterface` is used in an `implements` clause
|
||||
import SomeInterface from 'somewhere';
|
||||
|
||||
class SomeClass implements SomeInterface {
|
||||
}
|
||||
new SomeClass();
|
||||
|
||||
import SomethingElse from 'somewhere'; // OK: SomethingElse is used in a type
|
||||
import SomethingElse from 'somewhere'; // OK - SomethingElse is used in a type
|
||||
|
||||
type T = `Now for ${SomethingElse}`;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { Foo, Bar } from "somewhere"; // OK
|
||||
import { Foo, Bar } from "somewhere";
|
||||
|
||||
type FooBar<T> =
|
||||
T extends [infer S extends Foo, ...unknown[]]
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import * as X from "x"; // OK
|
||||
import * as Y from "y"; // OK
|
||||
import * as Z from "z"; // NOT OK
|
||||
import * as X from "x";
|
||||
import * as Y from "y";
|
||||
import * as Z from "z"; // $ Alert
|
||||
|
||||
function f(x: X) {}
|
||||
function g(x: Y.T) {}
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
// OK
|
||||
|
||||
module.exports = class C {}
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
var React = x; // OK
|
||||
var React = x;
|
||||
(<e/>);
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
var React = require("probably-react"); // OK
|
||||
var React = require("probably-react");
|
||||
(<e/>);
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
var { React } = { React: require("probably-react") }; // OK
|
||||
var { React } = { React: require("probably-react") };
|
||||
(<e/>);
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
var { React } = require("probably-react"); // OK
|
||||
var { React } = require("probably-react");
|
||||
(<e/>);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
(function() {
|
||||
var React = require("probably-react"); // NOT OK
|
||||
var React = require("probably-react"); // $ Alert
|
||||
})
|
||||
(function() {
|
||||
(<e/>);
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { Foo, Bar, Baz } from "somewhere"; // OK
|
||||
import { Foo, Bar, Baz } from "somewhere";
|
||||
|
||||
export function f(this: Foo) {}
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { SomeInterface } from 'somwhere1'; // OK
|
||||
import { AnotherInterface } from 'somwhere2'; // OK
|
||||
import { foo } from 'somewhere3'; // OK
|
||||
import { SomeInterface } from 'somwhere1';
|
||||
import { AnotherInterface } from 'somwhere2';
|
||||
import { foo } from 'somewhere3';
|
||||
|
||||
let x = "world";
|
||||
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
import fs = require('fs') // OK
|
||||
import http = require('http') // OK
|
||||
import fs = require('fs')
|
||||
import http = require('http')
|
||||
|
||||
export var mockFs : typeof fs = {}
|
||||
export var mockRequest : typeof http.ServerRequest = {}
|
||||
|
||||
export function f() {
|
||||
let x = 4 // OK
|
||||
let y = 5 // NOT OK
|
||||
let x = 4
|
||||
let y = 5 // $ Alert
|
||||
var t : typeof x = 20
|
||||
return t
|
||||
}
|
||||
|
||||
@@ -1 +1 @@
|
||||
declare class UnusedClass {} // OK
|
||||
declare class UnusedClass {}
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
function f(a) {
|
||||
const [a, // OK: used
|
||||
_, // OK: starts with underscore
|
||||
_c, // OK: starts with underscore
|
||||
d, // OK: used
|
||||
e, // NOT OK
|
||||
f] // NOT OK
|
||||
const [a, // OK - used
|
||||
_, // OK - starts with underscore
|
||||
_c, // OK - starts with underscore
|
||||
d, // OK - used
|
||||
e, // $ Alert
|
||||
f] // $ Alert
|
||||
= a;
|
||||
return a + d;
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import T from 'somewhere'; // NOT OK: `T` is unused (it is shadowed by another T)
|
||||
import object from 'somewhere'; // NOT OK: `object` is unused (it is "shadowed" by a keyword)
|
||||
import * as N from 'somewhere'; // OK: N is a namespace and thus not shadowed by 'interface N'.
|
||||
import T from 'somewhere'; // $ Alert - `T` is unused (it is shadowed by another T)
|
||||
import object from 'somewhere'; // $ Alert - `object` is unused (it is "shadowed" by a keyword)
|
||||
import * as N from 'somewhere'; // OK - N is a namespace and thus not shadowed by 'interface N'.
|
||||
|
||||
{
|
||||
var x: T = {};
|
||||
|
||||
Reference in New Issue
Block a user