Converted 16 rules to tslint --test (end of the alphabet) (#633)
* Converted 16 rules to tslint --test (end of the alphabet) * `no-unnecessary-bind` * `no-unnecessary-field-initialization` * `no-unnecessary-override` * `no-uselessFiles` * `no-var-self` * `no-with-statementtests.ts` * `non-literal-fs-path-rule-test.ts` * `non-literal-require` * `possible-timing-attack` * `prefer-array-literal` * `promise-must-complete` * `react-tsx-curly-spacing` * `underscore-consistent-invocation` * `unnecessary-local-variable` * `use-named-parameter` * `valid-typeof` * .travis.yml changes to fix endlines? * How about .gitattributes?
This commit is contained in:
Родитель
39c7ce8566
Коммит
63477f2fba
|
@ -1,4 +1,6 @@
|
|||
*.csv eol=lf
|
||||
*.js eol=lf
|
||||
*.jsx eol=lf
|
||||
*.lint eol=lf
|
||||
*.ts eol=lf
|
||||
*.tsx eol=lf
|
||||
|
|
|
@ -1,358 +0,0 @@
|
|||
import { Utils } from '../utils/Utils';
|
||||
import { TestHelper } from './TestHelper';
|
||||
|
||||
describe('noUnnecessaryBindRule', (): void => {
|
||||
const ruleName: string = 'no-unnecessary-bind';
|
||||
|
||||
describe('should pass', (): void => {
|
||||
it('should pass on function/lambda literals with multiple parameters', (): void => {
|
||||
const script: string = `
|
||||
_.bind(function() {}, this, someArg);
|
||||
(function() {}).bind(this, someArg);
|
||||
(() => {}).bind(this, someArg);
|
||||
(someReference).bind(this, someArg);
|
||||
`;
|
||||
|
||||
TestHelper.assertViolations(ruleName, script, []);
|
||||
});
|
||||
|
||||
it('should pass on function/lambda literals with non-this parameter', (): void => {
|
||||
const script: string = `
|
||||
(function() {}).bind(context);
|
||||
(() => {}).bind(context);
|
||||
(someReference).bind(context);
|
||||
`;
|
||||
|
||||
TestHelper.assertViolations(ruleName, script, []);
|
||||
});
|
||||
|
||||
it('should pass on underscore static invocation with no context', (): void => {
|
||||
const script: string = `
|
||||
_.forEach(list, function() {});
|
||||
_.forEach(list, () => {});
|
||||
_.forEach(list, someReference);
|
||||
`;
|
||||
|
||||
TestHelper.assertViolations(ruleName, script, []);
|
||||
});
|
||||
|
||||
it('should pass on underscore invocation with no context', (): void => {
|
||||
const script: string = `
|
||||
_(list).collect(function() {});
|
||||
_(list).collect(() => {});
|
||||
_(list).collect(someReference);
|
||||
`;
|
||||
|
||||
TestHelper.assertViolations(ruleName, script, []);
|
||||
});
|
||||
|
||||
it('should pass on underscore static invocation with context', (): void => {
|
||||
const script: string = `
|
||||
_.bind(function() {}, context);
|
||||
_.map(list, function() {}, context);
|
||||
_.map(list, () => {}, context);
|
||||
_.map(list, someReference, context);
|
||||
`;
|
||||
|
||||
TestHelper.assertViolations(ruleName, script, []);
|
||||
});
|
||||
|
||||
it('should pass on underscore invocation with context', (): void => {
|
||||
const script: string = `
|
||||
_(list).map(function() {}, context);
|
||||
_(list).map(() => {}, context);
|
||||
_(list).map(someReference, context);
|
||||
`;
|
||||
|
||||
TestHelper.assertViolations(ruleName, script, []);
|
||||
});
|
||||
|
||||
it('should pass on "this" context with non-literal function', (): void => {
|
||||
const script: string = `
|
||||
(someReference).bind(this);
|
||||
_(list).reject(someReference, this);
|
||||
_.reject(list, someReference, this);
|
||||
`;
|
||||
|
||||
TestHelper.assertViolations(ruleName, script, []);
|
||||
});
|
||||
|
||||
it('should pass on _.sortedIndex', (): void => {
|
||||
// sortedIndex is unique because the function parameter is the 2nd in the list
|
||||
const script: string = `
|
||||
_(list).sortedIndex(value, someReference, this);
|
||||
_.sortedIndex(list, value, someReference, this);
|
||||
|
||||
_(list).sortedIndex(() => {}, someReference, this);
|
||||
_.sortedIndex(function () {}, value, someReference, this);
|
||||
`;
|
||||
|
||||
TestHelper.assertViolations(ruleName, script, []);
|
||||
});
|
||||
|
||||
it('should pass on underscore static invocation with unknown method', (): void => {
|
||||
const script: string = `
|
||||
_.not_an_underscore_function(list, function() {}, this);
|
||||
_.not_an_underscore_function(list, () => {}, this);
|
||||
`;
|
||||
|
||||
TestHelper.assertViolations(ruleName, script, []);
|
||||
});
|
||||
|
||||
it('should pass on underscore invocation with unknown method', (): void => {
|
||||
const script: string = `
|
||||
_(list).not_an_underscore_function(function() {}, context);
|
||||
_(list).not_an_underscore_function(() => {}, context);
|
||||
`;
|
||||
TestHelper.assertViolations(ruleName, script, []);
|
||||
});
|
||||
});
|
||||
|
||||
describe('should fail', (): void => {
|
||||
it('should fail on binding this on function literal', (): void => {
|
||||
const script: string = `
|
||||
(function() {}).bind(this);
|
||||
`;
|
||||
|
||||
TestHelper.assertViolations(ruleName, script, [
|
||||
{
|
||||
failure: "Binding function literal with 'this' context. Use lambdas instead",
|
||||
name: Utils.absolutePath('file.ts'),
|
||||
ruleName: 'no-unnecessary-bind',
|
||||
startPosition: { character: 13, line: 2 }
|
||||
}
|
||||
]);
|
||||
});
|
||||
|
||||
it('should fail on binding this on lambda', (): void => {
|
||||
const script: string = `
|
||||
(() => {}).bind(this);
|
||||
`;
|
||||
|
||||
TestHelper.assertViolations(ruleName, script, [
|
||||
{
|
||||
failure: "Binding lambda with 'this' context. Lambdas already have 'this' bound",
|
||||
name: Utils.absolutePath('file.ts'),
|
||||
ruleName: 'no-unnecessary-bind',
|
||||
startPosition: { character: 13, line: 2 }
|
||||
}
|
||||
]);
|
||||
});
|
||||
|
||||
it('should fail on underscore static invocation with this as context and function', (): void => {
|
||||
const script: string = `
|
||||
_.map(list, function() {}, this);
|
||||
`;
|
||||
|
||||
TestHelper.assertViolations(ruleName, script, [
|
||||
{
|
||||
failure: "Binding function literal with 'this' context. Use lambdas instead",
|
||||
name: Utils.absolutePath('file.ts'),
|
||||
ruleName: 'no-unnecessary-bind',
|
||||
startPosition: { character: 17, line: 2 }
|
||||
}
|
||||
]);
|
||||
});
|
||||
|
||||
it('should fail on underscore static invocation with this as context and lambda', (): void => {
|
||||
const script: string = `
|
||||
_.map(list, () => {}, this);
|
||||
`;
|
||||
|
||||
TestHelper.assertViolations(ruleName, script, [
|
||||
{
|
||||
failure: "Binding lambda with 'this' context. Lambdas already have 'this' bound",
|
||||
name: Utils.absolutePath('file.ts'),
|
||||
ruleName: 'no-unnecessary-bind',
|
||||
startPosition: { character: 17, line: 2 }
|
||||
}
|
||||
]);
|
||||
});
|
||||
|
||||
it('should fail on underscore instance invocation with this as context and function', (): void => {
|
||||
const script: string = `
|
||||
_(list).forEach(function() {}, this);
|
||||
`;
|
||||
TestHelper.assertViolations(ruleName, script, [
|
||||
{
|
||||
failure: "Binding function literal with 'this' context. Use lambdas instead",
|
||||
name: Utils.absolutePath('file.ts'),
|
||||
ruleName: 'no-unnecessary-bind',
|
||||
startPosition: { character: 17, line: 2 }
|
||||
}
|
||||
]);
|
||||
});
|
||||
|
||||
it('should fail on underscore instance invocation with this as context and lambda', (): void => {
|
||||
const script: string = `
|
||||
_(list).every(() => {}, this);
|
||||
`;
|
||||
TestHelper.assertViolations(ruleName, script, [
|
||||
{
|
||||
failure: "Binding lambda with 'this' context. Lambdas already have 'this' bound",
|
||||
name: Utils.absolutePath('file.ts'),
|
||||
ruleName: 'no-unnecessary-bind',
|
||||
startPosition: { character: 17, line: 2 }
|
||||
}
|
||||
]);
|
||||
});
|
||||
|
||||
it('fail on _.reduce - static invocation - function parameter', (): void => {
|
||||
// reduce is a special case because the 2nd parameter in the list is a value
|
||||
const script: string = `
|
||||
_.reduce(list, function () {}, memo, this);
|
||||
`;
|
||||
|
||||
TestHelper.assertViolations(ruleName, script, [
|
||||
{
|
||||
failure: "Binding function literal with 'this' context. Use lambdas instead",
|
||||
name: Utils.absolutePath('file.ts'),
|
||||
ruleName: 'no-unnecessary-bind',
|
||||
startPosition: { character: 17, line: 2 }
|
||||
}
|
||||
]);
|
||||
});
|
||||
|
||||
it('fail on _.reduce - static invocation - lambda parameter', (): void => {
|
||||
// reduce is a special case because the 2nd parameter in the list is a value
|
||||
const script: string = `
|
||||
_.reduce(list, () => {}, memo, this);
|
||||
`;
|
||||
|
||||
TestHelper.assertViolations(ruleName, script, [
|
||||
{
|
||||
failure: "Binding lambda with 'this' context. Lambdas already have 'this' bound",
|
||||
name: Utils.absolutePath('file.ts'),
|
||||
ruleName: 'no-unnecessary-bind',
|
||||
startPosition: { character: 17, line: 2 }
|
||||
}
|
||||
]);
|
||||
});
|
||||
|
||||
it('fail on _.reduce - instance invocation - function parameter', (): void => {
|
||||
// reduce is a special case because the 2nd parameter in the list is a value
|
||||
const script: string = `
|
||||
_(list).reduce(function () {}, memo, this);
|
||||
`;
|
||||
|
||||
TestHelper.assertViolations(ruleName, script, [
|
||||
{
|
||||
failure: "Binding function literal with 'this' context. Use lambdas instead",
|
||||
name: Utils.absolutePath('file.ts'),
|
||||
ruleName: 'no-unnecessary-bind',
|
||||
startPosition: { character: 17, line: 2 }
|
||||
}
|
||||
]);
|
||||
});
|
||||
|
||||
it('fail on _.reduce - instance invocation - lambda parameter', (): void => {
|
||||
// reduce is a special case because the 2nd parameter in the list is a value
|
||||
const script: string = `
|
||||
_(list).reduce(() => {}, memo, this);
|
||||
`;
|
||||
|
||||
TestHelper.assertViolations(ruleName, script, [
|
||||
{
|
||||
failure: "Binding lambda with 'this' context. Lambdas already have 'this' bound",
|
||||
name: Utils.absolutePath('file.ts'),
|
||||
ruleName: 'no-unnecessary-bind',
|
||||
startPosition: { character: 17, line: 2 }
|
||||
}
|
||||
]);
|
||||
});
|
||||
|
||||
it('fail on _.sortedIndex - static invocation - function literal', (): void => {
|
||||
// sortedIndex is special case because the 2nd parameter in the list is a value
|
||||
const script: string = `
|
||||
_.sortedIndex(list, value, function () {}, this);
|
||||
`;
|
||||
|
||||
TestHelper.assertViolations(ruleName, script, [
|
||||
{
|
||||
failure: "Binding function literal with 'this' context. Use lambdas instead",
|
||||
name: Utils.absolutePath('file.ts'),
|
||||
ruleName: 'no-unnecessary-bind',
|
||||
startPosition: { character: 17, line: 2 }
|
||||
}
|
||||
]);
|
||||
});
|
||||
|
||||
it('fail on _.sortedIndex - static invocation - lambda', (): void => {
|
||||
// sortedIndex is special case because the 2nd parameter in the list is a value
|
||||
const script: string = `
|
||||
_.sortedIndex(list, value, () => {}, this);
|
||||
`;
|
||||
|
||||
TestHelper.assertViolations(ruleName, script, [
|
||||
{
|
||||
failure: "Binding lambda with 'this' context. Lambdas already have 'this' bound",
|
||||
name: Utils.absolutePath('file.ts'),
|
||||
ruleName: 'no-unnecessary-bind',
|
||||
startPosition: { character: 17, line: 2 }
|
||||
}
|
||||
]);
|
||||
});
|
||||
|
||||
it('fail on _.sortedIndex - instance invocation - function literal', (): void => {
|
||||
// sortedIndex is special case because the 2nd parameter in the list is a value
|
||||
const script: string = `
|
||||
_(list).sortedIndex(value, function () {}, this);
|
||||
`;
|
||||
|
||||
TestHelper.assertViolations(ruleName, script, [
|
||||
{
|
||||
failure: "Binding function literal with 'this' context. Use lambdas instead",
|
||||
name: Utils.absolutePath('file.ts'),
|
||||
ruleName: 'no-unnecessary-bind',
|
||||
startPosition: { character: 17, line: 2 }
|
||||
}
|
||||
]);
|
||||
});
|
||||
|
||||
it('fail on _.sortedIndex - instance invocation - lambda', (): void => {
|
||||
// sortedIndex is special case because the 2nd parameter in the list is a value
|
||||
const script: string = `
|
||||
_(list).sortedIndex(value, () => {}, this);
|
||||
`;
|
||||
|
||||
TestHelper.assertViolations(ruleName, script, [
|
||||
{
|
||||
failure: "Binding lambda with 'this' context. Lambdas already have 'this' bound",
|
||||
name: Utils.absolutePath('file.ts'),
|
||||
ruleName: 'no-unnecessary-bind',
|
||||
startPosition: { character: 17, line: 2 }
|
||||
}
|
||||
]);
|
||||
});
|
||||
|
||||
it('fail on _.bind - function literal', (): void => {
|
||||
const script: string = `
|
||||
_.bind(function () {}, this);
|
||||
`;
|
||||
|
||||
TestHelper.assertViolations(ruleName, script, [
|
||||
{
|
||||
failure: "Binding function literal with 'this' context. Use lambdas instead",
|
||||
name: Utils.absolutePath('file.ts'),
|
||||
ruleName: 'no-unnecessary-bind',
|
||||
startPosition: { character: 17, line: 2 }
|
||||
}
|
||||
]);
|
||||
});
|
||||
|
||||
it('fail on _.bind - lambda', (): void => {
|
||||
const script: string = `
|
||||
_.bind(() => {}, this);
|
||||
`;
|
||||
|
||||
TestHelper.assertViolations(ruleName, script, [
|
||||
{
|
||||
failure: "Binding lambda with 'this' context. Lambdas already have 'this' bound",
|
||||
name: Utils.absolutePath('file.ts'),
|
||||
ruleName: 'no-unnecessary-bind',
|
||||
startPosition: { character: 17, line: 2 }
|
||||
}
|
||||
]);
|
||||
});
|
||||
});
|
||||
});
|
|
@ -1,241 +0,0 @@
|
|||
import { Utils } from '../utils/Utils';
|
||||
import { TestHelper } from './TestHelper';
|
||||
|
||||
describe('noUnnecessaryOverrideRule', (): void => {
|
||||
const ruleName: string = 'no-unnecessary-override';
|
||||
|
||||
describe('should pass', (): void => {
|
||||
it('when adding a parameter', (): void => {
|
||||
const script: string = `
|
||||
class MyClass {
|
||||
private myField;
|
||||
myMethod1() {
|
||||
super.myMethod1(this.myField);
|
||||
}
|
||||
myMethod2() {
|
||||
return super.myMethod2(this.myField);
|
||||
}
|
||||
}
|
||||
`;
|
||||
|
||||
TestHelper.assertViolations(ruleName, script, []);
|
||||
});
|
||||
|
||||
it('when negating result', (): void => {
|
||||
const script: string = `
|
||||
class MyClass {
|
||||
myMethod() {
|
||||
-super.myMethod();
|
||||
}
|
||||
}
|
||||
`;
|
||||
|
||||
TestHelper.assertViolations(ruleName, script, []);
|
||||
});
|
||||
|
||||
it('when removing a parameter', (): void => {
|
||||
const script: string = `
|
||||
class MyClass {
|
||||
myMethod1(arg1, arg2) {
|
||||
super.myMethod1(arg1);
|
||||
}
|
||||
myMethod2(arg1, arg2) {
|
||||
return super.myMethod2(arg1);
|
||||
}
|
||||
}
|
||||
`;
|
||||
|
||||
TestHelper.assertViolations(ruleName, script, []);
|
||||
});
|
||||
|
||||
it('when transposing parameters', (): void => {
|
||||
const script: string = `
|
||||
class MyClass {
|
||||
myMethod(arg1, arg2) {
|
||||
super.myMethod(arg2, arg1);
|
||||
}
|
||||
}
|
||||
`;
|
||||
|
||||
TestHelper.assertViolations(ruleName, script, []);
|
||||
});
|
||||
|
||||
it('when changing a parameter', (): void => {
|
||||
const script: string = `
|
||||
class MyClass {
|
||||
myMethod(arg1, arg2) {
|
||||
super.myMethod(arg1, arg2 * 2);
|
||||
}
|
||||
}
|
||||
`;
|
||||
|
||||
TestHelper.assertViolations(ruleName, script, []);
|
||||
});
|
||||
|
||||
it('when adding statements before ', (): void => {
|
||||
const script: string = `
|
||||
class MyClass {
|
||||
myMethod() {
|
||||
console.log('some logging...');
|
||||
super.myMethod();
|
||||
}
|
||||
}
|
||||
`;
|
||||
|
||||
TestHelper.assertViolations(ruleName, script, []);
|
||||
});
|
||||
|
||||
it('when adding statements after', (): void => {
|
||||
const script: string = `
|
||||
class MyClass {
|
||||
myMethod() {
|
||||
super.myMethod();
|
||||
console.log('some logging...');
|
||||
}
|
||||
}
|
||||
`;
|
||||
|
||||
TestHelper.assertViolations(ruleName, script, []);
|
||||
});
|
||||
|
||||
it('when calling different methods', (): void => {
|
||||
const script: string = `
|
||||
class MyClass {
|
||||
myMethod() {
|
||||
super.notMyMethod();
|
||||
}
|
||||
}
|
||||
`;
|
||||
|
||||
TestHelper.assertViolations(ruleName, script, []);
|
||||
});
|
||||
});
|
||||
|
||||
describe('should fail', (): void => {
|
||||
it('should fail on calling super with 0 args and no return', (): void => {
|
||||
const script: string = `
|
||||
class MyClass {
|
||||
myMethod() {
|
||||
super.myMethod();
|
||||
}
|
||||
}
|
||||
`;
|
||||
|
||||
TestHelper.assertViolations(ruleName, script, [
|
||||
{
|
||||
failure: 'Unnecessary method override. A method that only calls super can be removed: myMethod',
|
||||
name: Utils.absolutePath('file.ts'),
|
||||
ruleName: 'no-unnecessary-override',
|
||||
startPosition: { character: 21, line: 3 }
|
||||
}
|
||||
]);
|
||||
});
|
||||
|
||||
it('should fail on calling super with 0 args and return', (): void => {
|
||||
const script: string = `
|
||||
class MyClass {
|
||||
myMethod() {
|
||||
return super.myMethod();
|
||||
}
|
||||
}
|
||||
`;
|
||||
|
||||
TestHelper.assertViolations(ruleName, script, [
|
||||
{
|
||||
failure: 'Unnecessary method override. A method that only calls super can be removed: myMethod',
|
||||
name: Utils.absolutePath('file.ts'),
|
||||
ruleName: 'no-unnecessary-override',
|
||||
startPosition: { character: 21, line: 3 }
|
||||
}
|
||||
]);
|
||||
});
|
||||
|
||||
it('should fail on calling super with argument', (): void => {
|
||||
const script: string = `
|
||||
class MyClass {
|
||||
myMethod(arg1) {
|
||||
super.myMethod(arg1);
|
||||
}
|
||||
}
|
||||
`;
|
||||
|
||||
TestHelper.assertViolations(ruleName, script, [
|
||||
{
|
||||
failure: 'Unnecessary method override. A method that only calls super can be removed: myMethod',
|
||||
name: Utils.absolutePath('file.ts'),
|
||||
ruleName: 'no-unnecessary-override',
|
||||
startPosition: { character: 21, line: 3 }
|
||||
}
|
||||
]);
|
||||
});
|
||||
|
||||
it('should fail on calling super with two arguments', (): void => {
|
||||
const script: string = `
|
||||
class MyClass {
|
||||
myMethod(arg1, arg2) {
|
||||
super.myMethod(arg1, arg2);
|
||||
}
|
||||
}
|
||||
`;
|
||||
|
||||
TestHelper.assertViolations(ruleName, script, [
|
||||
{
|
||||
failure: 'Unnecessary method override. A method that only calls super can be removed: myMethod',
|
||||
name: Utils.absolutePath('file.ts'),
|
||||
ruleName: 'no-unnecessary-override',
|
||||
startPosition: { character: 21, line: 3 }
|
||||
}
|
||||
]);
|
||||
});
|
||||
|
||||
it('should fail on calling super with default arguments', (): void => {
|
||||
const script: string = `
|
||||
class MyClass {
|
||||
myMethod(arg1 = true, arg2 = false) {
|
||||
super.myMethod(arg1, arg2);
|
||||
}
|
||||
}
|
||||
`;
|
||||
|
||||
TestHelper.assertViolations(ruleName, script, [
|
||||
{
|
||||
failure: 'Unnecessary method override. A method that only calls super can be removed: myMethod',
|
||||
name: Utils.absolutePath('file.ts'),
|
||||
ruleName: 'no-unnecessary-override',
|
||||
startPosition: { character: 21, line: 3 }
|
||||
}
|
||||
]);
|
||||
});
|
||||
|
||||
it('should fail on calling super with comments involved', (): void => {
|
||||
const script: string = `
|
||||
class MyClass {
|
||||
myMethod() {
|
||||
// here is a line comment
|
||||
return super.myMethod();
|
||||
// here is another line comment
|
||||
}
|
||||
}
|
||||
`;
|
||||
|
||||
TestHelper.assertViolations(ruleName, script, [
|
||||
{
|
||||
failure: 'Unnecessary method override. A method that only calls super can be removed: myMethod',
|
||||
name: Utils.absolutePath('file.ts'),
|
||||
ruleName: 'no-unnecessary-override',
|
||||
startPosition: { character: 21, line: 3 }
|
||||
}
|
||||
]);
|
||||
});
|
||||
|
||||
it('should not fail on empty void method', (): void => {
|
||||
const script: string = `
|
||||
class BaseComponent {
|
||||
public function1(): void { return; }
|
||||
}
|
||||
`;
|
||||
|
||||
TestHelper.assertViolations(ruleName, script, []);
|
||||
});
|
||||
});
|
||||
});
|
|
@ -1,103 +0,0 @@
|
|||
import { Utils } from '../utils/Utils';
|
||||
import { TestHelper } from './TestHelper';
|
||||
|
||||
describe('noUselessFilesRule', (): void => {
|
||||
const ruleName: string = 'no-useless-files';
|
||||
|
||||
it('should pass on a normal file that contains code', (): void => {
|
||||
const script: string = `
|
||||
export class MyClass {
|
||||
constructor () {
|
||||
console.log("foo");
|
||||
}
|
||||
}`;
|
||||
|
||||
TestHelper.assertViolations(ruleName, script, []);
|
||||
});
|
||||
|
||||
it('should fail on a file that only contains single-line comments', (): void => {
|
||||
const script: string = `// This is the only comment in this file`;
|
||||
|
||||
TestHelper.assertViolations(ruleName, script, [
|
||||
{
|
||||
failure: 'This file only contains comments and should be deleted.',
|
||||
name: Utils.absolutePath('file.ts'),
|
||||
ruleName: ruleName,
|
||||
startPosition: { character: 1, line: 1 }
|
||||
}
|
||||
]);
|
||||
});
|
||||
|
||||
it('should fail on a file that only contains multi-line comments', (): void => {
|
||||
const script: string = `/*
|
||||
export class MyClass {
|
||||
constructor () {
|
||||
console.log("foo");
|
||||
}
|
||||
}
|
||||
*/`;
|
||||
|
||||
TestHelper.assertViolations(ruleName, script, [
|
||||
{
|
||||
failure: 'This file only contains comments and should be deleted.',
|
||||
name: Utils.absolutePath('file.ts'),
|
||||
ruleName: ruleName,
|
||||
startPosition: { character: 1, line: 1 }
|
||||
}
|
||||
]);
|
||||
});
|
||||
|
||||
it('should fail on a file that only contains several comments', (): void => {
|
||||
const script: string = `/*
|
||||
export class MyClass {
|
||||
constructor () {
|
||||
console.log("foo");
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
// here is a single line comment
|
||||
|
||||
/* and another
|
||||
multline comment */`;
|
||||
|
||||
TestHelper.assertViolations(ruleName, script, [
|
||||
{
|
||||
failure: 'This file only contains comments and should be deleted.',
|
||||
name: Utils.absolutePath('file.ts'),
|
||||
ruleName: ruleName,
|
||||
startPosition: { character: 1, line: 1 }
|
||||
}
|
||||
]);
|
||||
});
|
||||
|
||||
it('should fail on a file that only contains whitespace', (): void => {
|
||||
//The below string contains spaces, tabs, and linebreaks
|
||||
const script: string = `
|
||||
|
||||
|
||||
`;
|
||||
|
||||
TestHelper.assertViolations(ruleName, script, [
|
||||
{
|
||||
failure: 'This file is empty and should be deleted.',
|
||||
name: Utils.absolutePath('file.ts'),
|
||||
ruleName: ruleName,
|
||||
startPosition: { character: 1, line: 1 }
|
||||
}
|
||||
]);
|
||||
});
|
||||
|
||||
it('should fail on a file that has no content', (): void => {
|
||||
const script: string = ``;
|
||||
|
||||
TestHelper.assertViolations(ruleName, script, [
|
||||
{
|
||||
failure: 'This file is empty and should be deleted.',
|
||||
name: Utils.absolutePath('file.ts'),
|
||||
ruleName: ruleName,
|
||||
startPosition: { character: 1, line: 1 }
|
||||
}
|
||||
]);
|
||||
});
|
||||
});
|
|
@ -1,151 +0,0 @@
|
|||
import { Utils } from '../utils/Utils';
|
||||
import { TestHelper } from './TestHelper';
|
||||
|
||||
describe('noVarSelfRule', (): void => {
|
||||
const ruleName: string = 'no-var-self';
|
||||
|
||||
it('should pass on other variables named self', (): void => {
|
||||
const script: string = `
|
||||
var self = other;
|
||||
`;
|
||||
|
||||
TestHelper.assertViolations(ruleName, script, []);
|
||||
});
|
||||
|
||||
it('should fail on variables set to this', (): void => {
|
||||
const script: string = `
|
||||
var other = this;
|
||||
`;
|
||||
|
||||
TestHelper.assertViolations(ruleName, script, [
|
||||
{
|
||||
failure: 'Assigning this reference to local variable: other = this',
|
||||
name: Utils.absolutePath('file.ts'),
|
||||
ruleName: 'no-var-self',
|
||||
startPosition: { character: 17, line: 2 }
|
||||
}
|
||||
]);
|
||||
});
|
||||
|
||||
it('should fail on let statements set to this', (): void => {
|
||||
const script: string = `
|
||||
let other = this;
|
||||
`;
|
||||
|
||||
TestHelper.assertViolations(ruleName, script, [
|
||||
{
|
||||
failure: 'Assigning this reference to local variable: other = this',
|
||||
name: Utils.absolutePath('file.ts'),
|
||||
ruleName: 'no-var-self',
|
||||
startPosition: { character: 17, line: 2 }
|
||||
}
|
||||
]);
|
||||
});
|
||||
|
||||
it('should fail on let statements set to this', (): void => {
|
||||
const script: string = `
|
||||
const other = this;
|
||||
`;
|
||||
|
||||
TestHelper.assertViolations(ruleName, script, [
|
||||
{
|
||||
failure: 'Assigning this reference to local variable: other = this',
|
||||
name: Utils.absolutePath('file.ts'),
|
||||
ruleName: 'no-var-self',
|
||||
startPosition: { character: 19, line: 2 }
|
||||
}
|
||||
]);
|
||||
});
|
||||
|
||||
it('should fail on var self = this starting a chain', (): void => {
|
||||
const script: string = `
|
||||
var self = this,
|
||||
foo = bar;
|
||||
`;
|
||||
|
||||
TestHelper.assertViolations(ruleName, script, [
|
||||
{
|
||||
failure: 'Assigning this reference to local variable: self = this',
|
||||
name: Utils.absolutePath('file.ts'),
|
||||
ruleName: 'no-var-self',
|
||||
startPosition: { character: 17, line: 2 }
|
||||
}
|
||||
]);
|
||||
});
|
||||
|
||||
it('should fail on var self = this in a chain', (): void => {
|
||||
const script: string = `
|
||||
var foo = bar,
|
||||
self = this,
|
||||
baz = qux;
|
||||
`;
|
||||
|
||||
TestHelper.assertViolations(ruleName, script, [
|
||||
{
|
||||
failure: 'Assigning this reference to local variable: self = this',
|
||||
name: Utils.absolutePath('file.ts'),
|
||||
ruleName: 'no-var-self',
|
||||
startPosition: { character: 17, line: 3 }
|
||||
}
|
||||
]);
|
||||
});
|
||||
|
||||
it('should fail on var that = this ending a chain', (): void => {
|
||||
const script: string = `
|
||||
var foo = bar,
|
||||
that = this;
|
||||
`;
|
||||
|
||||
TestHelper.assertViolations(ruleName, script, [
|
||||
{
|
||||
failure: 'Assigning this reference to local variable: that = this',
|
||||
name: Utils.absolutePath('file.ts'),
|
||||
ruleName: 'no-var-self',
|
||||
startPosition: { character: 17, line: 3 }
|
||||
}
|
||||
]);
|
||||
});
|
||||
|
||||
it('should respect any parameters passed', (): void => {
|
||||
const script: string = `
|
||||
let xself = this; // this one is OK
|
||||
let selfx = this; // this one is OK
|
||||
let xselfx = this; // this one is OK
|
||||
let self = this; // this one is not OK
|
||||
`;
|
||||
|
||||
// self is specifically banned
|
||||
TestHelper.assertViolationsWithOptions(ruleName, ['^self$'], script, [
|
||||
{
|
||||
failure: 'Assigning this reference to local variable: self = this',
|
||||
name: Utils.absolutePath('file.ts'),
|
||||
ruleName: 'no-var-self',
|
||||
startPosition: { character: 17, line: 5 }
|
||||
}
|
||||
]);
|
||||
});
|
||||
|
||||
it('should respect any parameters passed with regex negation', (): void => {
|
||||
const script: string = `
|
||||
let xself = this; // this one is OK
|
||||
let selfx = this; // this one is OK
|
||||
let self = this; // this one is not OK
|
||||
`;
|
||||
|
||||
// anything *but* self is specifically banned
|
||||
TestHelper.assertViolationsWithOptions(ruleName, ['^(?!self$)'], script, [
|
||||
{
|
||||
failure: 'Assigning this reference to local variable: xself = this',
|
||||
name: Utils.absolutePath('file.ts'),
|
||||
ruleName: 'no-var-self',
|
||||
startPosition: { character: 17, line: 2 }
|
||||
},
|
||||
{
|
||||
failure: 'Assigning this reference to local variable: selfx = this',
|
||||
name: Utils.absolutePath('file.ts'),
|
||||
ruleName: 'no-var-self',
|
||||
startPosition: { character: 17, line: 3 }
|
||||
}
|
||||
]);
|
||||
});
|
||||
});
|
|
@ -1,22 +0,0 @@
|
|||
import { Utils } from '../utils/Utils';
|
||||
import { TestHelper } from './TestHelper';
|
||||
|
||||
describe('noWithStatementsRule', (): void => {
|
||||
it('should produce violations', (): void => {
|
||||
const ruleName: string = 'no-with-statement';
|
||||
const script: string = `
|
||||
with ({}) {
|
||||
a = 1;
|
||||
b = 2;
|
||||
}
|
||||
`;
|
||||
TestHelper.assertViolations(ruleName, script, [
|
||||
{
|
||||
failure: 'Forbidden with statement',
|
||||
name: Utils.absolutePath('file.ts'),
|
||||
ruleName: 'no-with-statement',
|
||||
startPosition: { character: 13, line: 2 }
|
||||
}
|
||||
]);
|
||||
});
|
||||
});
|
|
@ -1,44 +0,0 @@
|
|||
import { Utils } from '../utils/Utils';
|
||||
import { TestHelper } from './TestHelper';
|
||||
|
||||
describe('nonLiteralFsPathRule', (): void => {
|
||||
const ruleName: string = 'non-literal-fs-path';
|
||||
|
||||
it('should pass on literal path', (): void => {
|
||||
const script: string = `
|
||||
const fs = require('fs');
|
||||
|
||||
fs.existsSync('file');
|
||||
`;
|
||||
|
||||
TestHelper.assertViolations(ruleName, script, []);
|
||||
});
|
||||
|
||||
it('should pass on non related fs functions', (): void => {
|
||||
const script: string = `
|
||||
const fs = require('fs');
|
||||
|
||||
fs.fsyncSync(-1);
|
||||
`;
|
||||
|
||||
TestHelper.assertViolations(ruleName, script, []);
|
||||
});
|
||||
|
||||
it('should fail on non literal path', (): void => {
|
||||
const script: string = `
|
||||
const fs = require('fs');
|
||||
const path = 'file';
|
||||
|
||||
fs.existsSync(path);
|
||||
`;
|
||||
|
||||
TestHelper.assertViolations(ruleName, script, [
|
||||
{
|
||||
failure: 'Non-literal (insecure) path passed to fs.existsSync: path',
|
||||
name: Utils.absolutePath('file.ts'),
|
||||
ruleName: 'non-literal-fs-path',
|
||||
startPosition: { character: 27, line: 5 }
|
||||
}
|
||||
]);
|
||||
});
|
||||
});
|
|
@ -1,79 +0,0 @@
|
|||
import { Utils } from '../utils/Utils';
|
||||
import { TestHelper } from './TestHelper';
|
||||
|
||||
describe('nonLiteralRequireRule', (): void => {
|
||||
const ruleName: string = 'non-literal-require';
|
||||
|
||||
it('should pass on imports', (): void => {
|
||||
const script: string = `
|
||||
import React = require('react');
|
||||
`;
|
||||
|
||||
TestHelper.assertViolations(ruleName, script, []);
|
||||
});
|
||||
|
||||
it('should pass on string literals', (): void => {
|
||||
const script: string = `
|
||||
const myModule = require('myModule');
|
||||
`;
|
||||
|
||||
TestHelper.assertViolations(ruleName, script, []);
|
||||
});
|
||||
|
||||
it('should pass on empty array', (): void => {
|
||||
const script: string = `
|
||||
const myModule = require([]);
|
||||
`;
|
||||
|
||||
TestHelper.assertViolations(ruleName, script, []);
|
||||
});
|
||||
|
||||
it('should pass on array of strings', (): void => {
|
||||
const script: string = `
|
||||
const myModule = require(['myModule']);
|
||||
`;
|
||||
|
||||
TestHelper.assertViolations(ruleName, script, []);
|
||||
});
|
||||
|
||||
it('should fail on non string literal', (): void => {
|
||||
const script: string = `
|
||||
const moduleName = 'myModule';
|
||||
const myModule = require(moduleName);`;
|
||||
|
||||
TestHelper.assertViolations(ruleName, script, [
|
||||
{
|
||||
failure: 'Non-literal (insecure) parameter passed to require(): moduleName',
|
||||
name: Utils.absolutePath('file.ts'),
|
||||
ruleName: 'non-literal-require',
|
||||
startPosition: { character: 38, line: 3 }
|
||||
}
|
||||
]);
|
||||
});
|
||||
|
||||
it('should fail on non-string array element', (): void => {
|
||||
const script: string = `
|
||||
let myModule = require([
|
||||
'myModule',
|
||||
somethingElse,
|
||||
'otherModule',
|
||||
getModuleName()
|
||||
]);
|
||||
`;
|
||||
|
||||
TestHelper.assertViolations(ruleName, script, [
|
||||
{
|
||||
failure: 'Non-literal (insecure) parameter passed to require(): somethingElse',
|
||||
name: Utils.absolutePath('file.ts'),
|
||||
ruleName: 'non-literal-require',
|
||||
startPosition: { character: 17, line: 4 }
|
||||
},
|
||||
{
|
||||
failure: 'Non-literal (insecure) parameter passed to require(): getModuleName()',
|
||||
name: Utils.absolutePath('file.ts'),
|
||||
ruleName: 'non-literal-require',
|
||||
startPosition: { character: 17, line: 6 }
|
||||
}
|
||||
]);
|
||||
});
|
||||
});
|
|
@ -1,133 +0,0 @@
|
|||
import { Utils } from '../utils/Utils';
|
||||
import { TestHelper } from './TestHelper';
|
||||
|
||||
describe('possibleTimingAttackRule', (): void => {
|
||||
const ruleName: string = 'possible-timing-attack';
|
||||
|
||||
it('should pass on non-direct comparisons', (): void => {
|
||||
const script: string = `
|
||||
const a = password < secret;
|
||||
const b = secret > api;
|
||||
const c = api <= apiKey
|
||||
const d = apiKey >= token;
|
||||
const e = token < hash;
|
||||
const f = auth > hash;
|
||||
const g = pass <= hash;
|
||||
const h = hash >= secret;
|
||||
`;
|
||||
|
||||
TestHelper.assertViolations(ruleName, script, []);
|
||||
});
|
||||
|
||||
it('should pass on null and undefined comparisons', (): void => {
|
||||
const script: string = `
|
||||
const a1 = password === null;
|
||||
const a2 = password == null;
|
||||
const a3 = password !== null;
|
||||
const a4 = password != null;
|
||||
const a5 = null === secret;
|
||||
const a6 = null == secret;
|
||||
const a7 = null !== secret;
|
||||
const a8 = null != secret;
|
||||
|
||||
const b1 = apiKey === undefined;
|
||||
const b2 = apiKey == undefined;
|
||||
const b3 = apiKey !== undefined;
|
||||
const b4 = apiKey != undefined;
|
||||
const b5 = undefined === token;
|
||||
const b6 = undefined == token;
|
||||
const b7 = undefined !== token;
|
||||
const b8 = undefined != token;
|
||||
`;
|
||||
|
||||
TestHelper.assertViolations(ruleName, script, []);
|
||||
});
|
||||
|
||||
it('should fail on == comparisons', (): void => {
|
||||
const script: string = `
|
||||
const a = password == secret;
|
||||
const b = secret == api;
|
||||
`;
|
||||
|
||||
TestHelper.assertViolations(ruleName, script, [
|
||||
{
|
||||
failure: 'Possible timing attack detected. Direct comparison found: password == secret',
|
||||
name: Utils.absolutePath('file.ts'),
|
||||
ruleName: 'possible-timing-attack',
|
||||
startPosition: { character: 23, line: 2 }
|
||||
},
|
||||
{
|
||||
failure: 'Possible timing attack detected. Direct comparison found: secret == api',
|
||||
name: Utils.absolutePath('file.ts'),
|
||||
ruleName: 'possible-timing-attack',
|
||||
startPosition: { character: 23, line: 3 }
|
||||
}
|
||||
]);
|
||||
});
|
||||
|
||||
it('should fail on === comparisons', (): void => {
|
||||
const script: string = `
|
||||
const c = api === apiKey
|
||||
const d = apiKey === token;
|
||||
`;
|
||||
|
||||
TestHelper.assertViolations(ruleName, script, [
|
||||
{
|
||||
failure: 'Possible timing attack detected. Direct comparison found: api === apiKey',
|
||||
name: Utils.absolutePath('file.ts'),
|
||||
ruleName: 'possible-timing-attack',
|
||||
startPosition: { character: 23, line: 2 }
|
||||
},
|
||||
{
|
||||
failure: 'Possible timing attack detected. Direct comparison found: apiKey === token',
|
||||
name: Utils.absolutePath('file.ts'),
|
||||
ruleName: 'possible-timing-attack',
|
||||
startPosition: { character: 23, line: 3 }
|
||||
}
|
||||
]);
|
||||
});
|
||||
|
||||
it('should fail on != comparisons', (): void => {
|
||||
const script: string = `
|
||||
const e = token != hash;
|
||||
const f = auth != hash;
|
||||
`;
|
||||
|
||||
TestHelper.assertViolations(ruleName, script, [
|
||||
{
|
||||
failure: 'Possible timing attack detected. Direct comparison found: token != hash',
|
||||
name: Utils.absolutePath('file.ts'),
|
||||
ruleName: 'possible-timing-attack',
|
||||
startPosition: { character: 23, line: 2 }
|
||||
},
|
||||
{
|
||||
failure: 'Possible timing attack detected. Direct comparison found: auth != hash',
|
||||
name: Utils.absolutePath('file.ts'),
|
||||
ruleName: 'possible-timing-attack',
|
||||
startPosition: { character: 23, line: 3 }
|
||||
}
|
||||
]);
|
||||
});
|
||||
|
||||
it('should fail on !== comparisons', (): void => {
|
||||
const script: string = `
|
||||
const g = pass !== hash;
|
||||
const h = hash !== secret;
|
||||
`;
|
||||
|
||||
TestHelper.assertViolations(ruleName, script, [
|
||||
{
|
||||
failure: 'Possible timing attack detected. Direct comparison found: pass !== hash',
|
||||
name: Utils.absolutePath('file.ts'),
|
||||
ruleName: 'possible-timing-attack',
|
||||
startPosition: { character: 23, line: 2 }
|
||||
},
|
||||
{
|
||||
failure: 'Possible timing attack detected. Direct comparison found: hash !== secret',
|
||||
name: Utils.absolutePath('file.ts'),
|
||||
ruleName: 'possible-timing-attack',
|
||||
startPosition: { character: 23, line: 3 }
|
||||
}
|
||||
]);
|
||||
});
|
||||
});
|
|
@ -1,440 +0,0 @@
|
|||
import { Utils } from '../utils/Utils';
|
||||
import { TestHelper } from './TestHelper';
|
||||
|
||||
describe('promiseMustCompleteRule', (): void => {
|
||||
const ruleName: string = 'promise-must-complete';
|
||||
|
||||
describe('should pass', (): void => {
|
||||
it('when promise completes', (): void => {
|
||||
const script: string = `
|
||||
new Promise<string>((resolve, reject) => {
|
||||
if (something) {
|
||||
resolve('value');
|
||||
} else {
|
||||
if (somethingElse) {
|
||||
resolve('value');
|
||||
} else {
|
||||
reject();
|
||||
}
|
||||
}
|
||||
})`;
|
||||
|
||||
TestHelper.assertViolations(ruleName, script, []);
|
||||
});
|
||||
|
||||
it('on resolve - lambda', (): void => {
|
||||
const script: string = `
|
||||
new Promise<string>((resolve, reject) => {
|
||||
resolve('value');
|
||||
})`;
|
||||
|
||||
TestHelper.assertViolations(ruleName, script, []);
|
||||
});
|
||||
|
||||
it('on resolve - function', (): void => {
|
||||
const script: string = `
|
||||
new Promise<string>(function (resolve, reject) {
|
||||
resolve('value');
|
||||
})`;
|
||||
|
||||
TestHelper.assertViolations(ruleName, script, []);
|
||||
});
|
||||
|
||||
it('on resolve - alternative name', (): void => {
|
||||
const script: string = `
|
||||
new Promise<string>((someOtherName, reject) => {
|
||||
someOtherName('value');
|
||||
})`;
|
||||
|
||||
TestHelper.assertViolations(ruleName, script, []);
|
||||
});
|
||||
|
||||
it('on reject', (): void => {
|
||||
const script: string = `
|
||||
new Promise<string>((resolve, reject) => {
|
||||
reject('value);
|
||||
})`;
|
||||
|
||||
TestHelper.assertViolations(ruleName, script, []);
|
||||
});
|
||||
|
||||
it('on reject - function', (): void => {
|
||||
const script: string = `
|
||||
new Promise<string>(function (resolve, reject) {
|
||||
reject('value);
|
||||
})`;
|
||||
|
||||
TestHelper.assertViolations(ruleName, script, []);
|
||||
});
|
||||
|
||||
it('on reject - alternative name', (): void => {
|
||||
const script: string = `
|
||||
new Promise<string>((resolve, someOtherName) => {
|
||||
someOtherName('value);
|
||||
})`;
|
||||
|
||||
TestHelper.assertViolations(ruleName, script, []);
|
||||
});
|
||||
|
||||
it('when single branch is completed - with if-statement', (): void => {
|
||||
const script: string = `
|
||||
new Promise<string>((resolve, reject) => {
|
||||
if (something) {
|
||||
resolve('value');
|
||||
}
|
||||
})`;
|
||||
|
||||
TestHelper.assertViolations(ruleName, script, []);
|
||||
});
|
||||
|
||||
it('when single branch is completed - with if-else-statement', (): void => {
|
||||
const script: string = `
|
||||
new Promise<string>((resolve, reject) => {
|
||||
if (something) {
|
||||
resolve('value');
|
||||
} else {
|
||||
resolve('value');
|
||||
}
|
||||
})`;
|
||||
|
||||
TestHelper.assertViolations(ruleName, script, []);
|
||||
});
|
||||
|
||||
it('when single branch is completed - with if-else-statement', (): void => {
|
||||
const script: string = `
|
||||
new Promise<string>((resolve, reject) => {
|
||||
if (something) {
|
||||
if (somethingElse) {
|
||||
resolve('value');
|
||||
} else {
|
||||
reject();
|
||||
}
|
||||
} else {
|
||||
if (somethingElse) {
|
||||
resolve('value');
|
||||
} else {
|
||||
reject();
|
||||
}
|
||||
}
|
||||
})`;
|
||||
TestHelper.assertViolations(ruleName, script, []);
|
||||
});
|
||||
|
||||
it('with nested if-else statement', (): void => {
|
||||
const script: string = `
|
||||
new Promise<string>((resolve, reject) => {
|
||||
if (something) {
|
||||
if (somethingElse) {
|
||||
resolve('value');
|
||||
} else {
|
||||
reject();
|
||||
}
|
||||
} else {
|
||||
if (somethingElse) {
|
||||
somethingElse();
|
||||
} else {
|
||||
reject();
|
||||
}
|
||||
reject(); // branches are not even analyzed when main thread resolves
|
||||
}
|
||||
})`;
|
||||
TestHelper.assertViolations(ruleName, script, []);
|
||||
});
|
||||
|
||||
it('when resolved within a function', (): void => {
|
||||
const script: string = `
|
||||
new Promise<string>((resolve, reject) => {
|
||||
someCall(function () {
|
||||
resolve('value');
|
||||
});
|
||||
})`;
|
||||
TestHelper.assertViolations(ruleName, script, []);
|
||||
});
|
||||
|
||||
it('when resolved within a lambda', (): void => {
|
||||
const script: string = `
|
||||
new Promise<string>((resolve, reject) => {
|
||||
someCall(() => {
|
||||
resolve();
|
||||
});
|
||||
})`;
|
||||
TestHelper.assertViolations(ruleName, script, []);
|
||||
});
|
||||
|
||||
it('when resolved within a lambda - with extra parameter', (): void => {
|
||||
const script: string = `
|
||||
new Promise<string>((resolve, reject) => {
|
||||
someCall((someParm) => {
|
||||
resolve('value');
|
||||
});
|
||||
})`;
|
||||
TestHelper.assertViolations(ruleName, script, []);
|
||||
});
|
||||
|
||||
it('when resolved within a for loop', (): void => {
|
||||
const script: string = `
|
||||
new Promise<string>((resolve, reject) => {
|
||||
for(var x = 0; x < something.length; x++) {
|
||||
resolve('value');
|
||||
}
|
||||
})`;
|
||||
TestHelper.assertViolations(ruleName, script, []);
|
||||
});
|
||||
|
||||
it('when resolved within a for in loop', (): void => {
|
||||
const script: string = `
|
||||
new Promise<string>((resolve, reject) => {
|
||||
for(var x in something) {
|
||||
resolve('value');
|
||||
}
|
||||
})`;
|
||||
TestHelper.assertViolations(ruleName, script, []);
|
||||
});
|
||||
|
||||
it('when resolved within a while loop', (): void => {
|
||||
const script: string = `
|
||||
new Promise<string>((resolve, reject) => {
|
||||
while (something) {
|
||||
resolve();
|
||||
}
|
||||
})`;
|
||||
TestHelper.assertViolations(ruleName, script, []);
|
||||
});
|
||||
|
||||
it('when resolve reference escaped into a function call', (): void => {
|
||||
const script: string = `
|
||||
new Promise<string>((resolve, reject) => {
|
||||
doSomething(resolve); // reference escapes and we assume it resolves
|
||||
})`;
|
||||
TestHelper.assertViolations(ruleName, script, []);
|
||||
});
|
||||
|
||||
it('when reject reference escaped into a function call', (): void => {
|
||||
const script: string = `
|
||||
new Promise<string>((resolve, reject) => {
|
||||
doSomething(reject); // reference escapes and we assume it resolves
|
||||
})`;
|
||||
TestHelper.assertViolations(ruleName, script, []);
|
||||
});
|
||||
|
||||
it('when non-shadowed parameter resolves within a function', (): void => {
|
||||
const script: string = `
|
||||
new Promise<string>((resolve, reject) => {
|
||||
someCall(function (arg1, reject) {
|
||||
resolve('value');
|
||||
});
|
||||
})`;
|
||||
TestHelper.assertViolations(ruleName, script, []);
|
||||
});
|
||||
|
||||
it('when non-shadowed parameter rejects within a function', (): void => {
|
||||
const script: string = `
|
||||
new Promise<string>((resolve, reject) => {
|
||||
someCall(function (resolve, arg2) {
|
||||
reject();
|
||||
});
|
||||
})`;
|
||||
TestHelper.assertViolations(ruleName, script, []);
|
||||
});
|
||||
|
||||
it('when non-shadowed parameter resolves within a lambda', (): void => {
|
||||
const script: string = `
|
||||
new Promise<string>((resolve, reject) => {
|
||||
someCall((arg1, reject) => {
|
||||
resolve('value');
|
||||
});
|
||||
})`;
|
||||
TestHelper.assertViolations(ruleName, script, []);
|
||||
});
|
||||
|
||||
it('when non-shadowed parameter rejects within a lambda', (): void => {
|
||||
const script: string = `
|
||||
new Promise<string>((resolve, reject) => {
|
||||
someCall((resolve, arg2) => {
|
||||
reject();
|
||||
});
|
||||
})`;
|
||||
TestHelper.assertViolations(ruleName, script, []);
|
||||
});
|
||||
});
|
||||
|
||||
describe('should fail', (): void => {
|
||||
it('when empty lambda', (): void => {
|
||||
const script: string = `
|
||||
new Promise<string>(() => {
|
||||
})`;
|
||||
|
||||
TestHelper.assertViolations(ruleName, script, [
|
||||
{
|
||||
failure: 'A Promise was found that appears to not have resolve or reject invoked on all code paths',
|
||||
name: Utils.absolutePath('file.ts'),
|
||||
ruleName: 'promise-must-complete',
|
||||
startPosition: { character: 17, line: 2 }
|
||||
}
|
||||
]);
|
||||
});
|
||||
|
||||
it('when empty function', (): void => {
|
||||
const script: string = `
|
||||
new Promise<string>(function {
|
||||
})`;
|
||||
|
||||
TestHelper.assertViolations(ruleName, script, [
|
||||
{
|
||||
failure: 'A Promise was found that appears to not have resolve or reject invoked on all code paths',
|
||||
name: Utils.absolutePath('file.ts'),
|
||||
ruleName: 'promise-must-complete',
|
||||
startPosition: { character: 17, line: 2 }
|
||||
}
|
||||
]);
|
||||
});
|
||||
|
||||
it('when has no complete', (): void => {
|
||||
const script: string = `
|
||||
new Promise<string>((resolve, reject) => {
|
||||
})`;
|
||||
|
||||
TestHelper.assertViolations(ruleName, script, [
|
||||
{
|
||||
failure: 'A Promise was found that appears to not have resolve or reject invoked on all code paths',
|
||||
name: Utils.absolutePath('file.ts'),
|
||||
ruleName: 'promise-must-complete',
|
||||
startPosition: { character: 17, line: 2 }
|
||||
}
|
||||
]);
|
||||
});
|
||||
|
||||
it('when single branch is missing complete - with if-statement', (): void => {
|
||||
const script: string = `
|
||||
new Promise<string>((resolve, reject) => {
|
||||
if (something) {
|
||||
someOtherFunction();
|
||||
}
|
||||
})`;
|
||||
|
||||
TestHelper.assertViolations(ruleName, script, [
|
||||
{
|
||||
failure: 'A Promise was found that appears to not have resolve or reject invoked on all code paths',
|
||||
name: Utils.absolutePath('file.ts'),
|
||||
ruleName: 'promise-must-complete',
|
||||
startPosition: { character: 17, line: 2 }
|
||||
}
|
||||
]);
|
||||
});
|
||||
|
||||
it('when single branch is missing complete - with if-else-statement', (): void => {
|
||||
const script: string = `
|
||||
new Promise<string>((resolve, reject) => {
|
||||
if (something) {
|
||||
resolve('value');
|
||||
} else {
|
||||
someOtherFunction()
|
||||
}
|
||||
})`;
|
||||
|
||||
TestHelper.assertViolations(ruleName, script, [
|
||||
{
|
||||
failure: 'A Promise was found that appears to not have resolve or reject invoked on all code paths',
|
||||
name: Utils.absolutePath('file.ts'),
|
||||
ruleName: 'promise-must-complete',
|
||||
startPosition: { character: 17, line: 2 }
|
||||
}
|
||||
]);
|
||||
});
|
||||
|
||||
it('with nested if-else statement', (): void => {
|
||||
const script: string = `
|
||||
new Promise<string>((resolve, reject) => {
|
||||
if (something) {
|
||||
if (somethingElse) {
|
||||
resolve('value');
|
||||
} else {
|
||||
reject();
|
||||
}
|
||||
} else {
|
||||
if (somethingElse) {
|
||||
somethingElse();
|
||||
} else {
|
||||
reject();
|
||||
}
|
||||
}
|
||||
})`;
|
||||
TestHelper.assertViolations(ruleName, script, [
|
||||
{
|
||||
failure: 'A Promise was found that appears to not have resolve or reject invoked on all code paths',
|
||||
name: Utils.absolutePath('file.ts'),
|
||||
ruleName: 'promise-must-complete',
|
||||
startPosition: { character: 17, line: 2 }
|
||||
}
|
||||
]);
|
||||
});
|
||||
|
||||
it('when shadowed parameter resolved within a function', (): void => {
|
||||
const script: string = `
|
||||
new Promise<string>((resolve, reject) => {
|
||||
someCall(function (resolve) { // this parameter actually shadows the one in the enclosing scope
|
||||
resolve();
|
||||
});
|
||||
})`;
|
||||
TestHelper.assertViolations(ruleName, script, [
|
||||
{
|
||||
failure: 'A Promise was found that appears to not have resolve or reject invoked on all code paths',
|
||||
name: Utils.absolutePath('file.ts'),
|
||||
ruleName: 'promise-must-complete',
|
||||
startPosition: { character: 17, line: 2 }
|
||||
}
|
||||
]);
|
||||
});
|
||||
|
||||
it('when shadowed parameter rejects within a function', (): void => {
|
||||
const script: string = `
|
||||
new Promise<string>((resolve, reject) => {
|
||||
someCall(function (reject) { // this parameter actually shadows the one in the enclosing scope
|
||||
reject();
|
||||
});
|
||||
})`;
|
||||
TestHelper.assertViolations(ruleName, script, [
|
||||
{
|
||||
failure: 'A Promise was found that appears to not have resolve or reject invoked on all code paths',
|
||||
name: Utils.absolutePath('file.ts'),
|
||||
ruleName: 'promise-must-complete',
|
||||
startPosition: { character: 17, line: 2 }
|
||||
}
|
||||
]);
|
||||
});
|
||||
|
||||
it('when shadowed parameter resolved within a lambda', (): void => {
|
||||
const script: string = `
|
||||
new Promise<string>((resolve, reject) => {
|
||||
someCall((arg1, resolve) => { // this parameter actually shadows the one in the enclosing scope
|
||||
resolve('value');
|
||||
});
|
||||
})`;
|
||||
TestHelper.assertViolations(ruleName, script, [
|
||||
{
|
||||
failure: 'A Promise was found that appears to not have resolve or reject invoked on all code paths',
|
||||
name: Utils.absolutePath('file.ts'),
|
||||
ruleName: 'promise-must-complete',
|
||||
startPosition: { character: 17, line: 2 }
|
||||
}
|
||||
]);
|
||||
});
|
||||
|
||||
it('when shadowed parameter rejects within a lambda', (): void => {
|
||||
const script: string = `
|
||||
new Promise<string>((resolve, reject) => {
|
||||
someCall((reject) => { // this parameter actually shadows the one in the enclosing scope
|
||||
reject();
|
||||
});
|
||||
})`;
|
||||
TestHelper.assertViolations(ruleName, script, [
|
||||
{
|
||||
failure: 'A Promise was found that appears to not have resolve or reject invoked on all code paths',
|
||||
name: Utils.absolutePath('file.ts'),
|
||||
ruleName: 'promise-must-complete',
|
||||
startPosition: { character: 17, line: 2 }
|
||||
}
|
||||
]);
|
||||
});
|
||||
});
|
||||
});
|
|
@ -1,166 +0,0 @@
|
|||
import { Utils } from '../utils/Utils';
|
||||
import { TestHelper } from './TestHelper';
|
||||
|
||||
describe('reactTsxCurlySpacing', () => {
|
||||
const ruleName: string = 'react-tsx-curly-spacing';
|
||||
|
||||
describe('should pass', () => {
|
||||
describe('on single line expressions', () => {
|
||||
it('when always set', () => {
|
||||
const script: string = `
|
||||
import React = require('react');
|
||||
const a = <Hello name={ firstname } />;
|
||||
`;
|
||||
TestHelper.assertNoViolation(ruleName, script);
|
||||
});
|
||||
|
||||
it('when never set', () => {
|
||||
const script: string = `
|
||||
import React = require('react');
|
||||
const a = <Hello name={firstname} />;
|
||||
const b = <div>{/* comment */}</div>;
|
||||
`;
|
||||
TestHelper.assertViolationsWithOptions(ruleName, ['never'], script, []);
|
||||
});
|
||||
});
|
||||
|
||||
describe('on multi-line expressions', () => {
|
||||
it('when always set', () => {
|
||||
const script: string = `
|
||||
import React = require('react');
|
||||
<Hello name={
|
||||
firstname
|
||||
} />
|
||||
`;
|
||||
TestHelper.assertViolationsWithOptions(ruleName, ['always', { allowMultiline: true }], script, []);
|
||||
});
|
||||
|
||||
it('when never set', () => {
|
||||
const script: string = `
|
||||
import React = require('react');
|
||||
<Hello name={
|
||||
firstname
|
||||
} />
|
||||
`;
|
||||
TestHelper.assertViolationsWithOptions(ruleName, ['never', { allowMultiline: true }], script, []);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('should fail', () => {
|
||||
describe('on single line expressions', () => {
|
||||
it('when always set', () => {
|
||||
const script: string = `
|
||||
import React = require('react');
|
||||
|
||||
const a = <Hello name={firstname} />;
|
||||
const b = <Hello name={ firstname} />;
|
||||
const c = <Hello name={firstname } />;
|
||||
`;
|
||||
TestHelper.assertViolations(ruleName, script, [
|
||||
{
|
||||
failure: "A space is required after '{'",
|
||||
name: Utils.absolutePath('file.tsx'),
|
||||
ruleName: 'react-tsx-curly-spacing',
|
||||
startPosition: { character: 43, line: 4 }
|
||||
},
|
||||
{
|
||||
failure: "A space is required before '}'",
|
||||
name: Utils.absolutePath('file.tsx'),
|
||||
ruleName: 'react-tsx-curly-spacing',
|
||||
startPosition: { character: 43, line: 4 }
|
||||
},
|
||||
{
|
||||
failure: "A space is required before '}'",
|
||||
name: Utils.absolutePath('file.tsx'),
|
||||
ruleName: 'react-tsx-curly-spacing',
|
||||
startPosition: { character: 43, line: 5 }
|
||||
},
|
||||
{
|
||||
failure: "A space is required after '{'",
|
||||
name: Utils.absolutePath('file.tsx'),
|
||||
ruleName: 'react-tsx-curly-spacing',
|
||||
startPosition: { character: 43, line: 6 }
|
||||
}
|
||||
]);
|
||||
});
|
||||
|
||||
it('when never set', () => {
|
||||
const script: string = `
|
||||
import React = require('react');
|
||||
const a = <Hello name={ firstname} />;
|
||||
const b = <Hello name={firstname } />;
|
||||
const c = <Hello name={ firstname} />;
|
||||
`;
|
||||
TestHelper.assertViolationsWithOptions(ruleName, ['never'], script, [
|
||||
{
|
||||
failure: "There should be no space after '{'",
|
||||
name: Utils.absolutePath('file.tsx'),
|
||||
ruleName: 'react-tsx-curly-spacing',
|
||||
startPosition: { character: 43, line: 3 }
|
||||
},
|
||||
{
|
||||
failure: "There should be no space before '}'",
|
||||
name: Utils.absolutePath('file.tsx'),
|
||||
ruleName: 'react-tsx-curly-spacing',
|
||||
startPosition: { character: 43, line: 4 }
|
||||
},
|
||||
{
|
||||
failure: "There should be no space after '{'",
|
||||
name: Utils.absolutePath('file.tsx'),
|
||||
ruleName: 'react-tsx-curly-spacing',
|
||||
startPosition: { character: 43, line: 5 }
|
||||
}
|
||||
]);
|
||||
});
|
||||
});
|
||||
|
||||
describe('on multi-line expressions', () => {
|
||||
it('when always set', () => {
|
||||
const script: string = `
|
||||
import React = require('react');
|
||||
<Hello name={
|
||||
firstname
|
||||
} />
|
||||
`;
|
||||
TestHelper.assertViolationsWithOptions(ruleName, ['always', { allowMultiline: false }], script, [
|
||||
{
|
||||
failure: "There should be no newline after '{'",
|
||||
name: Utils.absolutePath('file.tsx'),
|
||||
ruleName: 'react-tsx-curly-spacing',
|
||||
startPosition: { character: 33, line: 3 }
|
||||
},
|
||||
{
|
||||
failure: "There should be no newline before '}'",
|
||||
name: Utils.absolutePath('file.tsx'),
|
||||
ruleName: 'react-tsx-curly-spacing',
|
||||
startPosition: { character: 33, line: 3 }
|
||||
}
|
||||
]);
|
||||
});
|
||||
|
||||
it('when never set', () => {
|
||||
const script: string = `
|
||||
import React = require('react');
|
||||
<Hello name={
|
||||
firstname
|
||||
} />
|
||||
`;
|
||||
TestHelper.assertViolationsWithOptions(ruleName, ['never'], script, [
|
||||
{
|
||||
failure: "There should be no newline after '{'",
|
||||
name: Utils.absolutePath('file.tsx'),
|
||||
ruleName: 'react-tsx-curly-spacing',
|
||||
startPosition: { character: 33, line: 3 }
|
||||
},
|
||||
{
|
||||
failure: "There should be no newline before '}'",
|
||||
name: Utils.absolutePath('file.tsx'),
|
||||
ruleName: 'react-tsx-curly-spacing',
|
||||
startPosition: { character: 33, line: 3 }
|
||||
}
|
||||
]);
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
|
@ -1,151 +0,0 @@
|
|||
import { Utils } from '../utils/Utils';
|
||||
import { TestHelper } from './TestHelper';
|
||||
|
||||
describe('unnecessaryLocalVariableRule', (): void => {
|
||||
const ruleName: string = 'no-unnecessary-local-variable';
|
||||
|
||||
it('should pass on good usages', (): void => {
|
||||
const script: string = `
|
||||
class MyClass {
|
||||
private myMethod1() {
|
||||
let x = 1;
|
||||
return y;
|
||||
}
|
||||
private myMethod2() {
|
||||
let y = 1;
|
||||
return x;
|
||||
}
|
||||
}
|
||||
`;
|
||||
|
||||
TestHelper.assertViolations(ruleName, script, []);
|
||||
});
|
||||
|
||||
// issue #381
|
||||
it('should pass on recursive variables', (): void => {
|
||||
const script: string = `
|
||||
const balls = {
|
||||
foo: 'foo',
|
||||
bar: () => balls.foo
|
||||
};
|
||||
return balls;
|
||||
`;
|
||||
|
||||
TestHelper.assertViolations(ruleName, script, []);
|
||||
});
|
||||
|
||||
it('should fail on class function', (): void => {
|
||||
const script: string = `
|
||||
class MyClass {
|
||||
private myMethod() {
|
||||
let x = 1;
|
||||
return x;
|
||||
}
|
||||
}
|
||||
`;
|
||||
|
||||
TestHelper.assertViolations(ruleName, script, [
|
||||
{
|
||||
failure: 'Unnecessary local variable: x',
|
||||
name: Utils.absolutePath('file.ts'),
|
||||
ruleName: 'no-unnecessary-local-variable',
|
||||
startPosition: { character: 21, line: 4 }
|
||||
}
|
||||
]);
|
||||
});
|
||||
|
||||
it('should fail on if statement inside function', (): void => {
|
||||
const script: string = `
|
||||
class MyClass {
|
||||
private myMethod() {
|
||||
if (foo) {
|
||||
let x = 1;
|
||||
return x;
|
||||
}
|
||||
return x;
|
||||
}
|
||||
}
|
||||
`;
|
||||
|
||||
TestHelper.assertViolations(ruleName, script, [
|
||||
{
|
||||
failure: 'Unnecessary local variable: x',
|
||||
name: Utils.absolutePath('file.ts'),
|
||||
ruleName: 'no-unnecessary-local-variable',
|
||||
startPosition: { character: 25, line: 5 }
|
||||
}
|
||||
]);
|
||||
});
|
||||
|
||||
it('should fail on statements inside source file', (): void => {
|
||||
const script: string = `
|
||||
let x = 1;
|
||||
return x;
|
||||
`;
|
||||
|
||||
TestHelper.assertViolations(ruleName, script, [
|
||||
{
|
||||
failure: 'Unnecessary local variable: x',
|
||||
name: Utils.absolutePath('file.ts'),
|
||||
ruleName: 'no-unnecessary-local-variable',
|
||||
startPosition: { character: 13, line: 2 }
|
||||
}
|
||||
]);
|
||||
});
|
||||
|
||||
it('should fail on statements inside module', (): void => {
|
||||
const script: string = `
|
||||
module MyModule {
|
||||
let x = 1;
|
||||
return x;
|
||||
}
|
||||
`;
|
||||
|
||||
TestHelper.assertViolations(ruleName, script, [
|
||||
{
|
||||
failure: 'Unnecessary local variable: x',
|
||||
name: Utils.absolutePath('file.ts'),
|
||||
ruleName: 'no-unnecessary-local-variable',
|
||||
startPosition: { character: 17, line: 3 }
|
||||
}
|
||||
]);
|
||||
});
|
||||
|
||||
it('should fail on statements inside case clause', (): void => {
|
||||
const script: string = `
|
||||
switch (whatever) {
|
||||
case 1:
|
||||
let x = 1;
|
||||
return x;
|
||||
}
|
||||
`;
|
||||
|
||||
TestHelper.assertViolations(ruleName, script, [
|
||||
{
|
||||
failure: 'Unnecessary local variable: x',
|
||||
name: Utils.absolutePath('file.ts'),
|
||||
ruleName: 'no-unnecessary-local-variable',
|
||||
startPosition: { character: 21, line: 4 }
|
||||
}
|
||||
]);
|
||||
});
|
||||
|
||||
it('should fail on statements inside default clause of switch statement', (): void => {
|
||||
const script: string = `
|
||||
switch (whatever) {
|
||||
default:
|
||||
let x = 1;
|
||||
return x;
|
||||
}
|
||||
`;
|
||||
|
||||
TestHelper.assertViolations(ruleName, script, [
|
||||
{
|
||||
failure: 'Unnecessary local variable: x',
|
||||
name: Utils.absolutePath('file.ts'),
|
||||
ruleName: 'no-unnecessary-local-variable',
|
||||
startPosition: { character: 21, line: 4 }
|
||||
}
|
||||
]);
|
||||
});
|
||||
});
|
|
@ -1,36 +0,0 @@
|
|||
import { Utils } from '../utils/Utils';
|
||||
import { TestHelper } from './TestHelper';
|
||||
|
||||
describe('useNamedParameterRule', (): void => {
|
||||
const ruleName: string = 'use-named-parameter';
|
||||
|
||||
it('should ban referencing arguments by numeric index', (): void => {
|
||||
const inputScript: string = `
|
||||
function add() {
|
||||
return arguments[0] + arguments[1];
|
||||
}`;
|
||||
|
||||
TestHelper.assertViolations(ruleName, inputScript, [
|
||||
{
|
||||
failure: "Use a named parameter instead: 'arguments[0]'",
|
||||
name: Utils.absolutePath('file.ts'),
|
||||
ruleName: 'use-named-parameter',
|
||||
startPosition: { character: 12, line: 3 }
|
||||
},
|
||||
{
|
||||
failure: "Use a named parameter instead: 'arguments[1]'",
|
||||
name: Utils.absolutePath('file.ts'),
|
||||
ruleName: 'use-named-parameter',
|
||||
startPosition: { character: 27, line: 3 }
|
||||
}
|
||||
]);
|
||||
});
|
||||
|
||||
it('should allow referencing arguments by variable index', (): void => {
|
||||
const inputScript: string = `
|
||||
function add() {
|
||||
return arguments[whatever()] + arguments[n];
|
||||
}`;
|
||||
TestHelper.assertViolations(ruleName, inputScript, []);
|
||||
});
|
||||
});
|
|
@ -1,119 +0,0 @@
|
|||
import { Utils } from '../utils/Utils';
|
||||
import { TestHelper } from './TestHelper';
|
||||
|
||||
describe('validTypeofRule', (): void => {
|
||||
const ruleName: string = 'valid-typeof';
|
||||
|
||||
it('should pass on valid typeofs', (): void => {
|
||||
const script: string = `
|
||||
typeof bar === "undefined"
|
||||
typeof bar == "undefined"
|
||||
typeof bar !== "undefined"
|
||||
typeof bar != "undefined"
|
||||
"undefined" === typeof bar
|
||||
typeof foo === "object"
|
||||
typeof foo === "boolean"
|
||||
typeof foo === "number"
|
||||
typeof foo === "string"
|
||||
"function" === typeof foo
|
||||
typeof foo == baz
|
||||
typeof bar === typeof qux
|
||||
typeof Symbol() === "symbol"
|
||||
typeof Symbol("foo") === "symbol"
|
||||
typeof Symbol.iterator === "symbol"
|
||||
`;
|
||||
|
||||
TestHelper.assertViolations(ruleName, script, []);
|
||||
});
|
||||
|
||||
it('should fail on invalid string with ===', (): void => {
|
||||
const script: string = `
|
||||
typeof foo === "strnig"
|
||||
"strnig" === typeof foo
|
||||
`;
|
||||
|
||||
TestHelper.assertViolations(ruleName, script, [
|
||||
{
|
||||
failure: 'Invalid comparison in typeof. Did you mean string?',
|
||||
name: Utils.absolutePath('file.ts'),
|
||||
ruleName: 'valid-typeof',
|
||||
startPosition: { character: 28, line: 2 }
|
||||
},
|
||||
{
|
||||
failure: 'Invalid comparison in typeof. Did you mean string?',
|
||||
name: Utils.absolutePath('file.ts'),
|
||||
ruleName: 'valid-typeof',
|
||||
startPosition: {
|
||||
character: 13,
|
||||
line: 3
|
||||
}
|
||||
}
|
||||
]);
|
||||
});
|
||||
|
||||
it('should fail on invalid string with ==', (): void => {
|
||||
const script: string = `
|
||||
typeof foo == "funcion"
|
||||
"fction" == typeof foo
|
||||
`;
|
||||
|
||||
TestHelper.assertViolations(ruleName, script, [
|
||||
{
|
||||
failure: 'Invalid comparison in typeof. Did you mean function?',
|
||||
name: Utils.absolutePath('file.ts'),
|
||||
ruleName: 'valid-typeof',
|
||||
startPosition: { character: 27, line: 2 }
|
||||
},
|
||||
{
|
||||
failure: 'Invalid comparison in typeof. Did you mean function?',
|
||||
name: Utils.absolutePath('file.ts'),
|
||||
ruleName: 'valid-typeof',
|
||||
startPosition: { character: 13, line: 3 }
|
||||
}
|
||||
]);
|
||||
});
|
||||
|
||||
it('should fail on invalid string with !==', (): void => {
|
||||
const script: string = `
|
||||
typeof foo !== "undfind"
|
||||
"ndefined" !== typeof foo
|
||||
`;
|
||||
|
||||
TestHelper.assertViolations(ruleName, script, [
|
||||
{
|
||||
failure: 'Invalid comparison in typeof. Did you mean undefined?',
|
||||
name: Utils.absolutePath('file.ts'),
|
||||
ruleName: 'valid-typeof',
|
||||
startPosition: { character: 28, line: 2 }
|
||||
},
|
||||
{
|
||||
failure: 'Invalid comparison in typeof. Did you mean undefined?',
|
||||
name: Utils.absolutePath('file.ts'),
|
||||
ruleName: 'valid-typeof',
|
||||
startPosition: { character: 13, line: 3 }
|
||||
}
|
||||
]);
|
||||
});
|
||||
|
||||
it('should fail on invalid string with !=', (): void => {
|
||||
const script: string = `
|
||||
typeof foo != "bollean"
|
||||
"bollen" != typeof foo
|
||||
`;
|
||||
|
||||
TestHelper.assertViolations(ruleName, script, [
|
||||
{
|
||||
failure: 'Invalid comparison in typeof. Did you mean boolean?',
|
||||
name: Utils.absolutePath('file.ts'),
|
||||
ruleName: 'valid-typeof',
|
||||
startPosition: { character: 27, line: 2 }
|
||||
},
|
||||
{
|
||||
failure: 'Invalid comparison in typeof. Did you mean boolean?',
|
||||
name: Utils.absolutePath('file.ts'),
|
||||
ruleName: 'valid-typeof',
|
||||
startPosition: { character: 13, line: 3 }
|
||||
}
|
||||
]);
|
||||
});
|
||||
});
|
|
@ -0,0 +1,96 @@
|
|||
declare const _: any;
|
||||
const list = [];
|
||||
const someArg = true;
|
||||
const someReference = function () { };
|
||||
const memo = function (a, b) { return { a, b } };
|
||||
const value = 1;
|
||||
|
||||
_.bind(function () { }, this, someArg);
|
||||
(function () { }).bind(this, someArg);
|
||||
(() => { }).bind(this, someArg);
|
||||
(someReference).bind(this, someArg);
|
||||
|
||||
(function () { }).bind(context);
|
||||
(() => { }).bind(context);
|
||||
(someReference).bind(context);
|
||||
|
||||
_.forEach(list, function () { });
|
||||
_.forEach(list, () => { });
|
||||
_.forEach(list, someReference);
|
||||
|
||||
|
||||
_(list).collect(function () { });
|
||||
_(list).collect(() => { });
|
||||
_(list).collect(someReference);
|
||||
|
||||
_.bind(function () { }, context);
|
||||
_.map(list, function () { }, context);
|
||||
_.map(list, () => { }, context);
|
||||
_.map(list, someReference, context);
|
||||
|
||||
_(list).map(function() {}, context);
|
||||
_(list).map(() => {}, context);
|
||||
_(list).map(someReference, context);
|
||||
|
||||
(someReference).bind(this);
|
||||
_(list).reject(someReference, this);
|
||||
_.reject(list, someReference, this);
|
||||
|
||||
_(list).sortedIndex(value, someReference, this);
|
||||
_.sortedIndex(list, value, someReference, this);
|
||||
|
||||
_(list).sortedIndex(() => {}, someReference, this);
|
||||
_.sortedIndex(function () {}, value, someReference, this);
|
||||
|
||||
_.not_an_underscore_function(list, function() {}, this);
|
||||
_.not_an_underscore_function(list, () => {}, this);
|
||||
|
||||
_(list).not_an_underscore_function(function() {}, context);
|
||||
_(list).not_an_underscore_function(() => {}, context);
|
||||
(function() {}).bind(this);
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~ [Binding function literal with 'this' context. Use lambdas instead]
|
||||
|
||||
(() => {}).bind(this);
|
||||
~~~~~~~~~~~~~~~~~~~~~ [Binding lambda with 'this' context. Lambdas already have 'this' bound]
|
||||
|
||||
_.map(list, function() {}, this);
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [Binding function literal with 'this' context. Use lambdas instead]
|
||||
|
||||
_.map(list, () => {}, this);
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~ [Binding lambda with 'this' context. Lambdas already have 'this' bound]
|
||||
|
||||
_(list).forEach(function() {}, this);
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [Binding function literal with 'this' context. Use lambdas instead]
|
||||
|
||||
_(list).every(() => {}, this);
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [Binding lambda with 'this' context. Lambdas already have 'this' bound]
|
||||
|
||||
_.reduce(list, function () {}, memo, this);
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [Binding function literal with 'this' context. Use lambdas instead]
|
||||
|
||||
_.reduce(list, () => {}, memo, this);
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [Binding lambda with 'this' context. Lambdas already have 'this' bound]
|
||||
|
||||
_(list).reduce(function () {}, memo, this);
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [Binding function literal with 'this' context. Use lambdas instead]
|
||||
|
||||
_(list).reduce(() => {}, memo, this);
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [Binding lambda with 'this' context. Lambdas already have 'this' bound]
|
||||
|
||||
_.sortedIndex(list, value, function () {}, this);
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [Binding function literal with 'this' context. Use lambdas instead]
|
||||
|
||||
_.sortedIndex(list, value, () => {}, this);
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [Binding lambda with 'this' context. Lambdas already have 'this' bound]
|
||||
|
||||
_(list).sortedIndex(value, function () {}, this);
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [Binding function literal with 'this' context. Use lambdas instead]
|
||||
|
||||
_(list).sortedIndex(value, () => {}, this);
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [Binding lambda with 'this' context. Lambdas already have 'this' bound]
|
||||
|
||||
_.bind(function () {}, this);
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [Binding function literal with 'this' context. Use lambdas instead]
|
||||
|
||||
_.bind(() => {}, this);
|
||||
~~~~~~~~~~~~~~~~~~~~~~ [Binding lambda with 'this' context. Lambdas already have 'this' bound]
|
|
@ -0,0 +1,5 @@
|
|||
{
|
||||
"rules": {
|
||||
"no-unnecessary-bind": true
|
||||
}
|
||||
}
|
|
@ -0,0 +1,45 @@
|
|||
class Class1 {
|
||||
private myField1;
|
||||
private myField2 = 'value';
|
||||
private myField3 = null;
|
||||
|
||||
constructor() {
|
||||
this.myField1 = 'something';
|
||||
this.myField2 = undefined;
|
||||
this.myField3 = undefined;
|
||||
}
|
||||
}
|
||||
|
||||
class Class2 {
|
||||
private myField = undefined;
|
||||
~~~~~~~~~ [Unnecessary field initialization. Field explicitly initialized to undefined: myField]
|
||||
}
|
||||
|
||||
class Class3 {
|
||||
private myField;
|
||||
constructor() {
|
||||
this.myField = undefined;
|
||||
~~~~~~~~~~~~ [Unnecessary field initialization. Field explicitly initialized to undefined: this.myField]
|
||||
}
|
||||
}
|
||||
|
||||
class Class4 {
|
||||
private myField1 = null;
|
||||
private myField2 = 'value';
|
||||
private myField3 = 12345;
|
||||
private myField4 = true;
|
||||
private myField5 = false;
|
||||
|
||||
constructor() {
|
||||
this.myField1 = null;
|
||||
~~~~~~~~~~~~~~~~~~~~ [Unnecessary field initialization. Field value already initialized in declaration: this.myField1 = null]
|
||||
this.myField2 = 'value';
|
||||
~~~~~~~~~~~~~~~~~~~~~~~ [Unnecessary field initialization. Field value already initialized in declaration: this.myField2 = 'value']
|
||||
this.myField3 = 12345;
|
||||
~~~~~~~~~~~~~~~~~~~~~ [Unnecessary field initialization. Field value already initialized in declaration: this.myField3 = 12345]
|
||||
this.myField4 = true;
|
||||
~~~~~~~~~~~~~~~~~~~~ [Unnecessary field initialization. Field value already initialized in declaration: this.myField4 = true]
|
||||
this.myField5 = false;
|
||||
~~~~~~~~~~~~~~~~~~~~~ [Unnecessary field initialization. Field value already initialized in declaration: this.myField5 = false]
|
||||
}
|
||||
}
|
|
@ -0,0 +1,5 @@
|
|||
{
|
||||
"rules": {
|
||||
"no-unnecessary-field-initialization": true
|
||||
}
|
||||
}
|
|
@ -0,0 +1,58 @@
|
|||
class Class1 {
|
||||
public myMethod() {
|
||||
let x = 1;
|
||||
~~~~~~~~~~ [Unnecessary local variable: x]
|
||||
return x;
|
||||
}
|
||||
}
|
||||
|
||||
class Class2 {
|
||||
public myMethod() {
|
||||
if (foo) {
|
||||
let x = 1;
|
||||
~~~~~~~~~~ [Unnecessary local variable: x]
|
||||
return x;
|
||||
}
|
||||
return x;
|
||||
}
|
||||
}
|
||||
|
||||
const x = 1;
|
||||
const y = 1
|
||||
|
||||
class Class3 {
|
||||
public myMethod1() {
|
||||
let x = 1;
|
||||
return y;
|
||||
}
|
||||
|
||||
public myMethod2() {
|
||||
let y = 1;
|
||||
return x;
|
||||
}
|
||||
}
|
||||
|
||||
(() => {
|
||||
const balls = {
|
||||
foo: 'foo',
|
||||
bar: () => balls.foo
|
||||
};
|
||||
|
||||
return balls;
|
||||
})();
|
||||
|
||||
(() => {
|
||||
const whatever = 1;
|
||||
|
||||
switch (whatever) {
|
||||
case 1:
|
||||
let a = 1;
|
||||
~~~~~~~~~~ [Unnecessary local variable: a]
|
||||
return a;
|
||||
|
||||
default:
|
||||
let b = 1;
|
||||
~~~~~~~~~~ [Unnecessary local variable: b]
|
||||
return b;
|
||||
}
|
||||
})();
|
|
@ -0,0 +1,5 @@
|
|||
{
|
||||
"rules": {
|
||||
"no-unnecessary-local-variable": true
|
||||
}
|
||||
}
|
|
@ -0,0 +1,116 @@
|
|||
class Class1 {
|
||||
private myField;
|
||||
myMethod1() {
|
||||
super.myMethod1(this.myField);
|
||||
}
|
||||
|
||||
myMethod2() {
|
||||
return super.myMethod2(this.myField);
|
||||
}
|
||||
}
|
||||
|
||||
class Class2 {
|
||||
myMethod() {
|
||||
-super.myMethod();
|
||||
}
|
||||
}
|
||||
|
||||
class Class3 {
|
||||
myMethod1(arg1, arg2) {
|
||||
super.myMethod1(arg1);
|
||||
}
|
||||
|
||||
myMethod2(arg1, arg2) {
|
||||
return super.myMethod2(arg1);
|
||||
}
|
||||
}
|
||||
|
||||
class Class4 {
|
||||
myMethod(arg1, arg2) {
|
||||
super.myMethod(arg2, arg1);
|
||||
}
|
||||
}
|
||||
|
||||
class Class5 {
|
||||
myMethod(arg1, arg2) {
|
||||
super.myMethod(arg1, arg2 * 2);
|
||||
}
|
||||
}
|
||||
|
||||
class Class6 {
|
||||
myMethod() {
|
||||
console.log('some logging...');
|
||||
super.myMethod();
|
||||
}
|
||||
}
|
||||
|
||||
class Class7 {
|
||||
myMethod() {
|
||||
super.myMethod();
|
||||
console.log('some logging...');
|
||||
}
|
||||
}
|
||||
|
||||
class Class8 {
|
||||
myMethod() {
|
||||
super.notMyMethod();
|
||||
}
|
||||
}
|
||||
|
||||
class Class9 {
|
||||
myMethod() {
|
||||
~~~~~~~~~~~~~
|
||||
super.myMethod();
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
}
|
||||
~~~~~ [Unnecessary method override. A method that only calls super can be removed: myMethod]
|
||||
}
|
||||
|
||||
class Class10 {
|
||||
myMethod() {
|
||||
~~~~~~~~~~~~~
|
||||
return super.myMethod();
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
}
|
||||
~~~~~ [Unnecessary method override. A method that only calls super can be removed: myMethod]
|
||||
}
|
||||
|
||||
class Class11 {
|
||||
myMethod(arg1) {
|
||||
~~~~~~~~~~~~~~~~~
|
||||
super.myMethod(arg1);
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
}
|
||||
~~~~~ [Unnecessary method override. A method that only calls super can be removed: myMethod]
|
||||
}
|
||||
|
||||
class Class12 {
|
||||
myMethod(arg1, arg2) {
|
||||
~~~~~~~~~~~~~~~~~~~~~~~
|
||||
super.myMethod(arg1, arg2);
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
}
|
||||
~~~~~ [Unnecessary method override. A method that only calls super can be removed: myMethod]
|
||||
}
|
||||
|
||||
class Class13 {
|
||||
myMethod(arg1 = true, arg2 = false) {
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
super.myMethod(arg1, arg2);
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
}
|
||||
~~~~~ [Unnecessary method override. A method that only calls super can be removed: myMethod]
|
||||
}
|
||||
|
||||
class Class14 {
|
||||
myMethod() {
|
||||
~~~~~~~~~~~~~
|
||||
// here is a line comment
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
return super.myMethod();
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
// here is another line comment
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
}
|
||||
~~~~~ [Unnecessary method override. A method that only calls super can be removed: myMethod]
|
||||
}
|
|
@ -0,0 +1,5 @@
|
|||
{
|
||||
"rules": {
|
||||
"no-unnecessary-override": true
|
||||
}
|
||||
}
|
|
@ -0,0 +1,145 @@
|
|||
class Passing {
|
||||
// Browser Specific: Chrome 49
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [Unsupported browser: Chrome]
|
||||
sayHey() {
|
||||
console.log('hey');
|
||||
}
|
||||
|
||||
// browser specific: IE 10
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~ [Unsupported browser: IE]
|
||||
sayHello() {
|
||||
console.log('hello');
|
||||
}
|
||||
|
||||
/**
|
||||
~~~~
|
||||
* Says hi
|
||||
~~~~~~~~~~~~~~~~~~
|
||||
*
|
||||
~~~~~~~~~~
|
||||
* @browserspecific Firefox 48
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
*/
|
||||
~~~~~~~~~~ [Unsupported browser: Firefox]
|
||||
sayHi() {
|
||||
console.log('hi');
|
||||
}
|
||||
|
||||
// Browser specific: firefox
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [Unsupported browser: firefox]
|
||||
sayBye() {
|
||||
console.log('bye');
|
||||
}
|
||||
|
||||
/**
|
||||
~~~~
|
||||
~~~~
|
||||
* goes boom
|
||||
~~~~~~~~~~~~~~~~~~~~
|
||||
~~~~~~~~~~~~~~~~~~~~
|
||||
*
|
||||
~~~~~~~~~~
|
||||
~~~~~~~~~~
|
||||
* @browserspecific mobile safari 9
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
* @browserspecific IE 10
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
*/
|
||||
~~~~~~~~~~ [Unsupported browser: IE]
|
||||
~~~~~~~~~~ [Unsupported browser: mobile safari]
|
||||
goBoom() {
|
||||
throw new Error('boom');
|
||||
}
|
||||
|
||||
/**
|
||||
~~~~
|
||||
* goes vroom
|
||||
~~~~~~~~~~~~~~~~~~~~~
|
||||
*
|
||||
~~~~~~~~~~
|
||||
* @browserspecific mobile ie 10
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
*/
|
||||
~~~~~~~~~~ [Unsupported browser: mobile ie]
|
||||
goVroom() {
|
||||
console.log('vroom');
|
||||
}
|
||||
}
|
||||
|
||||
class Failing {
|
||||
// Browser Specific: Netscape 2
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [Unsupported browser: Netscape]
|
||||
sayHey() {
|
||||
console.log('hey');
|
||||
}
|
||||
|
||||
// browser specific: Chrome
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~ [Unsupported browser: Chrome]
|
||||
sayHello() {
|
||||
console.log('hello');
|
||||
}
|
||||
|
||||
/**
|
||||
~~~~
|
||||
* @browserspecific IE 8
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
*/
|
||||
~~~~~~~~~~ [Unsupported browser: IE]
|
||||
sayHi() {
|
||||
console.log('hi');
|
||||
}
|
||||
|
||||
// Browser specific: aquaman
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [Unsupported browser: aquaman]
|
||||
sayBye() {
|
||||
console.log('bye');
|
||||
}
|
||||
|
||||
/**
|
||||
~~~~
|
||||
~~~~
|
||||
~~~~
|
||||
* goes boom
|
||||
~~~~~~~~~~~~~~~~~~~~
|
||||
~~~~~~~~~~~~~~~~~~~~
|
||||
~~~~~~~~~~~~~~~~~~~~
|
||||
*
|
||||
~~~~~~~~~~
|
||||
~~~~~~~~~~
|
||||
~~~~~~~~~~
|
||||
* @browserspecific mobile safari 10
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
* @browserspecific IE 8
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
* @browserspecific IE
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
*/
|
||||
~~~~~~~~~~ [Unsupported browser: IE]
|
||||
~~~~~~~~~~ [Unsupported browser: IE]
|
||||
~~~~~~~~~~ [Unsupported browser: mobile safari]
|
||||
goBoom() {
|
||||
throw new Error('boom');
|
||||
}
|
||||
|
||||
/**
|
||||
~~~~
|
||||
* goes vroom
|
||||
~~~~~~~~~~~~~~~~~~~~~
|
||||
*
|
||||
~~~~~~~~~~
|
||||
* @browserspecific mobile ie 9
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
*/
|
||||
~~~~~~~~~~ [Unsupported browser: mobile ie]
|
||||
goVroom() {
|
||||
console.log('vroom');
|
||||
}
|
||||
}
|
|
@ -0,0 +1,5 @@
|
|||
{
|
||||
"rules": {
|
||||
"no-unsupported-browser-code": true
|
||||
}
|
||||
}
|
|
@ -0,0 +1,5 @@
|
|||
export class MyClass {
|
||||
constructor () {
|
||||
console.log("foo");
|
||||
}
|
||||
}
|
|
@ -0,0 +1,5 @@
|
|||
{
|
||||
"rules": {
|
||||
"no-useless-files": true
|
||||
}
|
||||
}
|
|
@ -0,0 +1,3 @@
|
|||
|
||||
~nil [This file is empty and should be deleted.]
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
{
|
||||
"rules": {
|
||||
"no-useless-files": true
|
||||
}
|
||||
}
|
|
@ -0,0 +1,4 @@
|
|||
// A single line comment
|
||||
~nil [This file only contains comments and should be deleted.]
|
||||
|
||||
/* A multi line comment */
|
|
@ -0,0 +1,5 @@
|
|||
{
|
||||
"rules": {
|
||||
"no-useless-files": true
|
||||
}
|
||||
}
|
|
@ -0,0 +1,4 @@
|
|||
/*
|
||||
~nil [This file only contains comments and should be deleted.]
|
||||
This is the only comment in this file.
|
||||
*/
|
|
@ -0,0 +1,5 @@
|
|||
{
|
||||
"rules": {
|
||||
"no-useless-files": true
|
||||
}
|
||||
}
|
|
@ -0,0 +1,2 @@
|
|||
// This is the only comment in this file
|
||||
~nil [This file only contains comments and should be deleted.]
|
|
@ -0,0 +1,5 @@
|
|||
{
|
||||
"rules": {
|
||||
"no-useless-files": true
|
||||
}
|
||||
}
|
|
@ -0,0 +1,37 @@
|
|||
(function (this: any) {
|
||||
var self = other;
|
||||
})();
|
||||
|
||||
(function (this: any) {
|
||||
var other = this;
|
||||
~~~~~~~~~~~~ [Assigning this reference to local variable: other = this]
|
||||
})();
|
||||
|
||||
(function (this: any) {
|
||||
let other = this;
|
||||
~~~~~~~~~~~~ [Assigning this reference to local variable: other = this]
|
||||
})();
|
||||
|
||||
(function (this: any) {
|
||||
const other = this;
|
||||
~~~~~~~~~~~~ [Assigning this reference to local variable: other = this]
|
||||
})();
|
||||
|
||||
(function (this: any) {
|
||||
var self = this,
|
||||
~~~~~~~~~~~ [Assigning this reference to local variable: self = this]
|
||||
foo = bar;
|
||||
})();
|
||||
|
||||
(function (this: any) {
|
||||
var foo = bar,
|
||||
self = this,
|
||||
~~~~~~~~~~~ [Assigning this reference to local variable: self = this]
|
||||
baz = qux;
|
||||
})();
|
||||
|
||||
(function (this: any) {
|
||||
var foo = bar,
|
||||
that = this;
|
||||
~~~~~~~~~~~ [Assigning this reference to local variable: that = this]
|
||||
})();
|
|
@ -0,0 +1,5 @@
|
|||
{
|
||||
"rules": {
|
||||
"no-var-self": true
|
||||
}
|
||||
}
|
|
@ -0,0 +1,7 @@
|
|||
(function (this: any) {
|
||||
let xself = this;
|
||||
~~~~~~~~~~~~ [Assigning this reference to local variable: xself = this]
|
||||
let selfx = this;
|
||||
~~~~~~~~~~~~ [Assigning this reference to local variable: selfx = this]
|
||||
let self = this;
|
||||
})();
|
|
@ -0,0 +1,5 @@
|
|||
{
|
||||
"rules": {
|
||||
"no-var-self": [true, "^(?!self$)"]
|
||||
}
|
||||
}
|
|
@ -0,0 +1,7 @@
|
|||
(function (this: any) {
|
||||
let xself = this;
|
||||
let selfx = this;
|
||||
let xselfx = this;
|
||||
let self = this;
|
||||
~~~~~~~~~~~ [Assigning this reference to local variable: self = this]
|
||||
})();
|
|
@ -0,0 +1,5 @@
|
|||
{
|
||||
"rules": {
|
||||
"no-var-self": [true, "^self$"]
|
||||
}
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
let a;
|
||||
let b;
|
||||
|
||||
with({}) {
|
||||
~~~~~~~~~~~
|
||||
a = 1;
|
||||
~~~~~~~~~~~
|
||||
b = 2;
|
||||
~~~~~~~~~~~
|
||||
}
|
||||
~ [Forbidden with statement]
|
|
@ -0,0 +1,5 @@
|
|||
{
|
||||
"rules": {
|
||||
"no-with-statement": true
|
||||
}
|
||||
}
|
|
@ -0,0 +1,10 @@
|
|||
const fs = require('fs');
|
||||
|
||||
fs.existsSync('file');
|
||||
fs.existsSync(-1);
|
||||
~~ [Non-literal (insecure) path passed to fs.existsSync: -1]
|
||||
|
||||
fs.existsSync(path);
|
||||
~~~~ [Non-literal (insecure) path passed to fs.existsSync: path]
|
||||
fs.existsSync(path);
|
||||
~~~~ [Non-literal (insecure) path passed to fs.existsSync: path]
|
|
@ -0,0 +1,5 @@
|
|||
{
|
||||
"rules": {
|
||||
"non-literal-fs-path": true
|
||||
}
|
||||
}
|
|
@ -0,0 +1,24 @@
|
|||
import * as a from 'a';
|
||||
|
||||
import b = require('b');
|
||||
|
||||
import c from 'c';
|
||||
|
||||
const d = require('d');
|
||||
|
||||
const e = require([]);
|
||||
|
||||
const f = require(['f']);
|
||||
|
||||
const g = 'myModule';
|
||||
const h = require(moduleName);
|
||||
~~~~~~~~~~ [Non-literal (insecure) parameter passed to require(): moduleName]
|
||||
|
||||
let myModule = require([
|
||||
'myModule',
|
||||
somethingElse,
|
||||
~~~~~~~~~~~~~ [Non-literal (insecure) parameter passed to require(): somethingElse]
|
||||
'otherModule',
|
||||
getModuleName()
|
||||
~~~~~~~~~~~~~~~ [Non-literal (insecure) parameter passed to require(): getModuleName()]
|
||||
]);
|
|
@ -0,0 +1,5 @@
|
|||
{
|
||||
"rules": {
|
||||
"non-literal-require": true
|
||||
}
|
||||
}
|
|
@ -0,0 +1,47 @@
|
|||
|
||||
const a = password < secret;
|
||||
const b = secret > api;
|
||||
const c = api <= apiKey
|
||||
const d = apiKey >= token;
|
||||
const e = token < hash;
|
||||
const f = auth > hash;
|
||||
const g = pass <= hash;
|
||||
const h = hash >= secret;
|
||||
|
||||
const a1 = password === null;
|
||||
const a2 = password == null;
|
||||
const a3 = password !== null;
|
||||
const a4 = password != null;
|
||||
const a5 = null === secret;
|
||||
const a6 = null == secret;
|
||||
const a7 = null !== secret;
|
||||
const a8 = null != secret;
|
||||
|
||||
const b1 = apiKey === undefined;
|
||||
const b2 = apiKey == undefined;
|
||||
const b3 = apiKey !== undefined;
|
||||
const b4 = apiKey != undefined;
|
||||
const b5 = undefined === token;
|
||||
const b6 = undefined == token;
|
||||
const b7 = undefined !== token;
|
||||
const b8 = undefined != token;
|
||||
|
||||
const c1 = password == secret;
|
||||
~~~~~~~~~~~~~~~~~~ [Possible timing attack detected. Direct comparison found: password == secret]
|
||||
const c2 = secret == api;
|
||||
~~~~~~~~~~~~~ [Possible timing attack detected. Direct comparison found: secret == api]
|
||||
|
||||
const d1 = api === apiKey
|
||||
~~~~~~~~~~~~~~ [Possible timing attack detected. Direct comparison found: api === apiKey]
|
||||
const d2 = apiKey === token;
|
||||
~~~~~~~~~~~~~~~~ [Possible timing attack detected. Direct comparison found: apiKey === token]
|
||||
|
||||
const e1 = token != hash;
|
||||
~~~~~~~~~~~~~ [Possible timing attack detected. Direct comparison found: token != hash]
|
||||
const e2 = auth != hash;
|
||||
~~~~~~~~~~~~ [Possible timing attack detected. Direct comparison found: auth != hash]
|
||||
|
||||
const f1 = pass !== hash;
|
||||
~~~~~~~~~~~~~ [Possible timing attack detected. Direct comparison found: pass !== hash]
|
||||
const f2 = hash !== secret;
|
||||
~~~~~~~~~~~~~~~ [Possible timing attack detected. Direct comparison found: hash !== secret]
|
|
@ -0,0 +1,5 @@
|
|||
{
|
||||
"rules": {
|
||||
"possible-timing-attack": true
|
||||
}
|
||||
}
|
|
@ -0,0 +1,24 @@
|
|||
let a: string[];
|
||||
|
||||
let b: Array<string> = [];
|
||||
~~~~~~~~~~~~~ [Replace generic-typed Array with array literal: Array<string>]
|
||||
|
||||
interface C {
|
||||
myArray: Array<string>;
|
||||
~~~~~~~~~~~~~ [Replace generic-typed Array with array literal: Array<string>]
|
||||
}
|
||||
|
||||
var d: Array<string>;
|
||||
~~~~~~~~~~~~~ [Replace generic-typed Array with array literal: Array<string>]
|
||||
|
||||
function e(param: Array<number>) { }
|
||||
~~~~~~~~~~~~~ [Replace generic-typed Array with array literal: Array<number>]
|
||||
|
||||
var f = new Array();
|
||||
~~~~~~~~~~~ [Replace Array constructor with an array literal: new Array()]
|
||||
|
||||
var g = new Array(4, 5);
|
||||
~~~~~~~~~~~~~~~ [Replace Array constructor with an array literal: new Array(4, 5)]
|
||||
|
||||
var h = new Array(4);
|
||||
~~~~~~~~~~~~ [Replace Array constructor with an array literal: new Array(4)]
|
|
@ -0,0 +1,5 @@
|
|||
{
|
||||
"rules": {
|
||||
"prefer-array-literal": [true, "allow-type-parameters"]
|
||||
}
|
||||
}
|
|
@ -0,0 +1,24 @@
|
|||
let a: string[];
|
||||
|
||||
let b: Array<string> = [];
|
||||
~~~~~~~~~~~~~ [Replace generic-typed Array with array literal: Array<string>]
|
||||
|
||||
interface C {
|
||||
myArray: Array<string>;
|
||||
~~~~~~~~~~~~~ [Replace generic-typed Array with array literal: Array<string>]
|
||||
}
|
||||
|
||||
var d: Array<string>;
|
||||
~~~~~~~~~~~~~ [Replace generic-typed Array with array literal: Array<string>]
|
||||
|
||||
function e(param: Array<number>) { }
|
||||
~~~~~~~~~~~~~ [Replace generic-typed Array with array literal: Array<number>]
|
||||
|
||||
var f = new Array();
|
||||
~~~~~~~~~~~ [Replace Array constructor with an array literal: new Array()]
|
||||
|
||||
var g = new Array(4, 5);
|
||||
~~~~~~~~~~~~~~~ [Replace Array constructor with an array literal: new Array(4, 5)]
|
||||
|
||||
var h = new Array(4);
|
||||
~~~~~~~~~~~~ [Replace Array constructor with an array literal: new Array(4)]
|
|
@ -0,0 +1,5 @@
|
|||
{
|
||||
"rules": {
|
||||
"prefer-array-literal": true
|
||||
}
|
||||
}
|
|
@ -0,0 +1,267 @@
|
|||
let something: boolean;
|
||||
let somethingArray: boolean[];
|
||||
let somethingCall: (method: (_: any) => void) => any;
|
||||
let somethingElse: boolean;
|
||||
let somethingElseGet: () => boolean;
|
||||
let someOtherFunction: () => void;
|
||||
|
||||
new Promise<string>((resolve, reject) => {
|
||||
if (something) {
|
||||
resolve('value');
|
||||
} else {
|
||||
if (somethingElse) {
|
||||
resolve('value');
|
||||
} else {
|
||||
reject();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
new Promise<string>((resolve, reject) => {
|
||||
resolve('value');
|
||||
});
|
||||
|
||||
new Promise<string>(function (resolve, reject) {
|
||||
resolve('value');
|
||||
});
|
||||
|
||||
new Promise<string>((someOtherName, reject) => {
|
||||
someOtherName('value');
|
||||
});
|
||||
|
||||
new Promise<string>((resolve, reject) => {
|
||||
reject('value');
|
||||
});
|
||||
|
||||
new Promise<string>(function (resolve, reject) {
|
||||
reject('value');
|
||||
});
|
||||
|
||||
new Promise<string>((resolve, someOtherName) => {
|
||||
someOtherName('value');
|
||||
});
|
||||
|
||||
new Promise<string>((resolve, reject) => {
|
||||
if (something) {
|
||||
resolve('value');
|
||||
}
|
||||
});
|
||||
|
||||
new Promise<string>((resolve, reject) => {
|
||||
if (something) {
|
||||
resolve('value');
|
||||
} else {
|
||||
resolve('value');
|
||||
}
|
||||
})
|
||||
|
||||
new Promise<string>((resolve, reject) => {
|
||||
if (something) {
|
||||
if (somethingElse) {
|
||||
resolve('value');
|
||||
} else {
|
||||
reject();
|
||||
}
|
||||
} else {
|
||||
if (somethingElse) {
|
||||
resolve('value');
|
||||
} else {
|
||||
reject();
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
new Promise<string>((resolve, reject) => {
|
||||
if (something) {
|
||||
if (somethingElse) {
|
||||
resolve('value');
|
||||
} else {
|
||||
reject();
|
||||
}
|
||||
} else {
|
||||
if (somethingElseGet) {
|
||||
somethingElseGet();
|
||||
} else {
|
||||
reject();
|
||||
}
|
||||
reject(); // branches are not even analyzed when main thread resolves
|
||||
}
|
||||
})
|
||||
|
||||
new Promise<string>((resolve, reject) => {
|
||||
somethingCall(function () {
|
||||
resolve('value');
|
||||
});
|
||||
})
|
||||
|
||||
new Promise<string>((resolve, reject) => {
|
||||
somethingCall(() => {
|
||||
resolve();
|
||||
});
|
||||
})
|
||||
|
||||
new Promise<string>((resolve, reject) => {
|
||||
somethingCall((_) => {
|
||||
resolve('value');
|
||||
});
|
||||
})
|
||||
|
||||
new Promise<string>((resolve, reject) => {
|
||||
for (var x = 0; x < somethingArray.length; x++) {
|
||||
resolve('value');
|
||||
}
|
||||
})
|
||||
|
||||
new Promise<string>((resolve, reject) => {
|
||||
for (var x in somethingArray) {
|
||||
resolve('value');
|
||||
}
|
||||
})
|
||||
|
||||
new Promise<string>((resolve, reject) => {
|
||||
while (something) {
|
||||
resolve();
|
||||
}
|
||||
})
|
||||
|
||||
new Promise<string>((resolve, reject) => {
|
||||
somethingCall(resolve); // reference escapes and we assume it resolves
|
||||
})
|
||||
|
||||
new Promise<string>((resolve, reject) => {
|
||||
somethingCall(reject); // reference escapes and we assume it resolves
|
||||
})
|
||||
|
||||
new Promise<string>((resolve, reject) => {
|
||||
somethingCall(function (arg1, reject) {
|
||||
resolve('value');
|
||||
});
|
||||
})
|
||||
|
||||
new Promise<string>((resolve, reject) => {
|
||||
somethingCall(function (resolve, arg2) {
|
||||
reject();
|
||||
});
|
||||
})
|
||||
|
||||
new Promise<string>((resolve, reject) => {
|
||||
somethingCall((arg1, reject) => {
|
||||
resolve('value');
|
||||
});
|
||||
})
|
||||
|
||||
new Promise<string>((resolve, reject) => {
|
||||
somethingCall((resolve, arg2) => {
|
||||
reject();
|
||||
});
|
||||
})
|
||||
|
||||
new Promise<string>(() => { })
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [A Promise was found that appears to not have resolve or reject invoked on all code paths]
|
||||
|
||||
new Promise<string>(function { })
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [A Promise was found that appears to not have resolve or reject invoked on all code paths]
|
||||
|
||||
new Promise<string>((resolve, reject) => { })
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [A Promise was found that appears to not have resolve or reject invoked on all code paths]
|
||||
|
||||
new Promise<string>((resolve, reject) => {
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
if (something) {
|
||||
~~~~~~~~~~~~~~~~~~~~
|
||||
someOtherFunction();
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
}
|
||||
~~~~~
|
||||
})
|
||||
~~ [A Promise was found that appears to not have resolve or reject invoked on all code paths]
|
||||
|
||||
new Promise<string>((resolve, reject) => {
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
if (something) {
|
||||
~~~~~~~~~~~~~~~~~~~~
|
||||
resolve('value');
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
} else {
|
||||
~~~~~~~~~~~~
|
||||
someOtherFunction()
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
}
|
||||
~~~~~
|
||||
})
|
||||
~~ [A Promise was found that appears to not have resolve or reject invoked on all code paths]
|
||||
|
||||
new Promise<string>((resolve, reject) => {
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
if (something) {
|
||||
~~~~~~~~~~~~~~~~~~~~
|
||||
if (somethingElse) {
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
resolve('value');
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
} else {
|
||||
~~~~~~~~~~~~~~~~
|
||||
reject();
|
||||
~~~~~~~~~~~~~~~~~~~~~
|
||||
}
|
||||
~~~~~~~~~
|
||||
} else {
|
||||
~~~~~~~~~~~~
|
||||
if (somethingElseGet) {
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
somethingElseGet();
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
} else {
|
||||
~~~~~~~~~~~~~~~~
|
||||
reject();
|
||||
~~~~~~~~~~~~~~~~~~~~~
|
||||
}
|
||||
~~~~~~~~~
|
||||
}
|
||||
~~~~~
|
||||
})
|
||||
~~ [A Promise was found that appears to not have resolve or reject invoked on all code paths]
|
||||
|
||||
new Promise<string>((resolve, reject) => {
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
somethingCall(function (resolve) { // this parameter actually shadows the one in the enclosing scope
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
resolve();
|
||||
~~~~~~~~~~~~~~~~~~
|
||||
});
|
||||
~~~~~~~
|
||||
})
|
||||
~~ [A Promise was found that appears to not have resolve or reject invoked on all code paths]
|
||||
|
||||
new Promise<string>((resolve, reject) => {
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
somethingCall(function (reject) { // this parameter actually shadows the one in the enclosing scope
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
reject();
|
||||
~~~~~~~~~~~~~~~~~
|
||||
});
|
||||
~~~~~~~
|
||||
})
|
||||
~~ [A Promise was found that appears to not have resolve or reject invoked on all code paths]
|
||||
|
||||
new Promise<string>((resolve, reject) => {
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
somethingCall((arg1, resolve) => { // this parameter actually shadows the one in the enclosing scope
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
resolve('value');
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
});
|
||||
~~~~~~~
|
||||
})
|
||||
~~ [A Promise was found that appears to not have resolve or reject invoked on all code paths]
|
||||
|
||||
new Promise<string>((resolve, reject) => {
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
somethingCall((reject) => { // this parameter actually shadows the one in the enclosing scope
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
reject();
|
||||
~~~~~~~~~~~~~~~~~
|
||||
});
|
||||
~~~~~~~
|
||||
})
|
||||
~~ [A Promise was found that appears to not have resolve or reject invoked on all code paths]
|
|
@ -0,0 +1,5 @@
|
|||
{
|
||||
"rules": {
|
||||
"promise-must-complete": true
|
||||
}
|
||||
}
|
|
@ -0,0 +1,183 @@
|
|||
declare const _: any;
|
||||
|
||||
_(list).each(() => { return undefined; });
|
||||
_(list).forEach(() => { return undefined; });
|
||||
_(list).map(() => { return undefined; });
|
||||
_(list).collect(() => { return undefined; });
|
||||
_(list).reduce(() => { return undefined; });
|
||||
_(list).inject(() => { return undefined; });
|
||||
_(list).foldl(() => { return undefined; });
|
||||
_(list).reduceRight(() => { return undefined; });
|
||||
_(list).foldr(() => { return undefined; });
|
||||
_(list).find(() => { return undefined; });
|
||||
_(list).detect(() => { return undefined; });
|
||||
_(list).filter(() => { return undefined; });
|
||||
_(list).select(() => { return undefined; });
|
||||
_(list).where(() => { return undefined; });
|
||||
_(list).findWhere(() => { return undefined; });
|
||||
_(list).reject(() => { return undefined; });
|
||||
_(list).every(() => { return undefined; });
|
||||
_(list).all(() => { return undefined; });
|
||||
_(list).some(() => { return undefined; });
|
||||
_(list).any(() => { return undefined; });
|
||||
_(list).contains(() => { return undefined; });
|
||||
_(list).include(() => { return undefined; });
|
||||
_(list).invoke(() => { return undefined; });
|
||||
_(list).pluck(() => { return undefined; });
|
||||
_(list).max(() => { return undefined; });
|
||||
_(list).min(() => { return undefined; });
|
||||
_(list).sortBy(() => { return undefined; });
|
||||
_(list).groupBy(() => { return undefined; });
|
||||
_(list).indexBy(() => { return undefined; });
|
||||
_(list).countBy(() => { return undefined; });
|
||||
_(list).shuffle(() => { return undefined; });
|
||||
_(list).sample(() => { return undefined; });
|
||||
_(list).toArray(() => { return undefined; });
|
||||
_(list).size(() => { return undefined; });
|
||||
_(list).partition(() => { return undefined; });
|
||||
_(list).first(() => { return undefined; });
|
||||
_(list).head(() => { return undefined; });
|
||||
_(list).take(() => { return undefined; });
|
||||
_(list).initial(() => { return undefined; });
|
||||
_(list).last(() => { return undefined; });
|
||||
_(list).rest(() => { return undefined; });
|
||||
_(list).tail(() => { return undefined; });
|
||||
_(list).drop(() => { return undefined; });
|
||||
_(list).compact(() => { return undefined; });
|
||||
_(list).flatten(() => { return undefined; });
|
||||
_(list).without(() => { return undefined; });
|
||||
_(list).union(() => { return undefined; });
|
||||
_(list).intersection(() => { return undefined; });
|
||||
_(list).difference(() => { return undefined; });
|
||||
_(list).uniq(() => { return undefined; });
|
||||
_(list).unique(() => { return undefined; });
|
||||
_(list).object(() => { return undefined; });
|
||||
_(list).zip(() => { return undefined; });
|
||||
_(list).unzip(() => { return undefined; });
|
||||
_(list).indexOf(() => { return undefined; });
|
||||
_(list).findIndex(() => { return undefined; });
|
||||
_(list).lastIndexOf(() => { return undefined; });
|
||||
_(list).findLastIndex(() => { return undefined; });
|
||||
_(list).sortedIndex(() => { return undefined; });
|
||||
_(list).range(() => { return undefined; });
|
||||
|
||||
_.each(list, () => { return undefined; });
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [Static invocation of underscore function found. Prefer instance version instead: _.each]
|
||||
_.forEach(list, () => { return undefined; });
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [Static invocation of underscore function found. Prefer instance version instead: _.forEach]
|
||||
_.map(list, () => { return undefined; });
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [Static invocation of underscore function found. Prefer instance version instead: _.map]
|
||||
_.collect(list, () => { return undefined; });
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [Static invocation of underscore function found. Prefer instance version instead: _.collect]
|
||||
_.reduce(list, () => { return undefined; });
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [Static invocation of underscore function found. Prefer instance version instead: _.reduce]
|
||||
_.inject(list, () => { return undefined; });
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [Static invocation of underscore function found. Prefer instance version instead: _.inject]
|
||||
_.foldl(list, () => { return undefined; });
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [Static invocation of underscore function found. Prefer instance version instead: _.foldl]
|
||||
_.reduceRight(list, () => { return undefined; });
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [Static invocation of underscore function found. Prefer instance version instead: _.reduceRight]
|
||||
_.foldr(list, () => { return undefined; });
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [Static invocation of underscore function found. Prefer instance version instead: _.foldr]
|
||||
_.find(list, () => { return undefined; });
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [Static invocation of underscore function found. Prefer instance version instead: _.find]
|
||||
_.detect(list, () => { return undefined; });
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [Static invocation of underscore function found. Prefer instance version instead: _.detect]
|
||||
_.filter(list, () => { return undefined; });
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [Static invocation of underscore function found. Prefer instance version instead: _.filter]
|
||||
_.select(list, () => { return undefined; });
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [Static invocation of underscore function found. Prefer instance version instead: _.select]
|
||||
_.where(list, () => { return undefined; });
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [Static invocation of underscore function found. Prefer instance version instead: _.where]
|
||||
_.findWhere(list, () => { return undefined; });
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [Static invocation of underscore function found. Prefer instance version instead: _.findWhere]
|
||||
_.reject(list, () => { return undefined; });
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [Static invocation of underscore function found. Prefer instance version instead: _.reject]
|
||||
_.every(list, () => { return undefined; });
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [Static invocation of underscore function found. Prefer instance version instead: _.every]
|
||||
_.all(list, () => { return undefined; });
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [Static invocation of underscore function found. Prefer instance version instead: _.all]
|
||||
_.some(list, () => { return undefined; });
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [Static invocation of underscore function found. Prefer instance version instead: _.some]
|
||||
_.any(list, () => { return undefined; });
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [Static invocation of underscore function found. Prefer instance version instead: _.any]
|
||||
_.contains(list, () => { return undefined; });
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [Static invocation of underscore function found. Prefer instance version instead: _.contains]
|
||||
_.include(list, () => { return undefined; });
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [Static invocation of underscore function found. Prefer instance version instead: _.include]
|
||||
_.invoke(list, () => { return undefined; });
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [Static invocation of underscore function found. Prefer instance version instead: _.invoke]
|
||||
_.pluck(list, () => { return undefined; });
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [Static invocation of underscore function found. Prefer instance version instead: _.pluck]
|
||||
_.max(list, () => { return undefined; });
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [Static invocation of underscore function found. Prefer instance version instead: _.max]
|
||||
_.min(list, () => { return undefined; });
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [Static invocation of underscore function found. Prefer instance version instead: _.min]
|
||||
_.sortBy(list, () => { return undefined; });
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [Static invocation of underscore function found. Prefer instance version instead: _.sortBy]
|
||||
_.groupBy(list, () => { return undefined; });
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [Static invocation of underscore function found. Prefer instance version instead: _.groupBy]
|
||||
_.indexBy(list, () => { return undefined; });
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [Static invocation of underscore function found. Prefer instance version instead: _.indexBy]
|
||||
_.countBy(list, () => { return undefined; });
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [Static invocation of underscore function found. Prefer instance version instead: _.countBy]
|
||||
_.shuffle(list, () => { return undefined; });
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [Static invocation of underscore function found. Prefer instance version instead: _.shuffle]
|
||||
_.sample(list, () => { return undefined; });
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [Static invocation of underscore function found. Prefer instance version instead: _.sample]
|
||||
_.toArray(list, () => { return undefined; });
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [Static invocation of underscore function found. Prefer instance version instead: _.toArray]
|
||||
_.size(list, () => { return undefined; });
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [Static invocation of underscore function found. Prefer instance version instead: _.size]
|
||||
_.partition(list, () => { return undefined; });
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [Static invocation of underscore function found. Prefer instance version instead: _.partition]
|
||||
_.first(list, () => { return undefined; });
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [Static invocation of underscore function found. Prefer instance version instead: _.first]
|
||||
_.head(list, () => { return undefined; });
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [Static invocation of underscore function found. Prefer instance version instead: _.head]
|
||||
_.take(list, () => { return undefined; });
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [Static invocation of underscore function found. Prefer instance version instead: _.take]
|
||||
_.initial(list, () => { return undefined; });
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [Static invocation of underscore function found. Prefer instance version instead: _.initial]
|
||||
_.last(list, () => { return undefined; });
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [Static invocation of underscore function found. Prefer instance version instead: _.last]
|
||||
_.rest(list, () => { return undefined; });
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [Static invocation of underscore function found. Prefer instance version instead: _.rest]
|
||||
_.tail(list, () => { return undefined; });
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [Static invocation of underscore function found. Prefer instance version instead: _.tail]
|
||||
_.drop(list, () => { return undefined; });
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [Static invocation of underscore function found. Prefer instance version instead: _.drop]
|
||||
_.compact(list, () => { return undefined; });
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [Static invocation of underscore function found. Prefer instance version instead: _.compact]
|
||||
_.flatten(list, () => { return undefined; });
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [Static invocation of underscore function found. Prefer instance version instead: _.flatten]
|
||||
_.without(list, () => { return undefined; });
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [Static invocation of underscore function found. Prefer instance version instead: _.without]
|
||||
_.union(list, () => { return undefined; });
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [Static invocation of underscore function found. Prefer instance version instead: _.union]
|
||||
_.intersection(list, () => { return undefined; });
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [Static invocation of underscore function found. Prefer instance version instead: _.intersection]
|
||||
_.difference(list, () => { return undefined; });
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [Static invocation of underscore function found. Prefer instance version instead: _.difference]
|
||||
_.uniq(list, () => { return undefined; });
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [Static invocation of underscore function found. Prefer instance version instead: _.uniq]
|
||||
_.unique(list, () => { return undefined; });
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [Static invocation of underscore function found. Prefer instance version instead: _.unique]
|
||||
_.object(list, () => { return undefined; });
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [Static invocation of underscore function found. Prefer instance version instead: _.object]
|
||||
_.zip(list, () => { return undefined; });
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [Static invocation of underscore function found. Prefer instance version instead: _.zip]
|
||||
_.unzip(list, () => { return undefined; });
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [Static invocation of underscore function found. Prefer instance version instead: _.unzip]
|
||||
_.indexOf(list, () => { return undefined; });
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [Static invocation of underscore function found. Prefer instance version instead: _.indexOf]
|
||||
_.findIndex(list, () => { return undefined; });
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [Static invocation of underscore function found. Prefer instance version instead: _.findIndex]
|
||||
_.lastIndexOf(list, () => { return undefined; });
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [Static invocation of underscore function found. Prefer instance version instead: _.lastIndexOf]
|
||||
_.findLastIndex(list, () => { return undefined; });
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [Static invocation of underscore function found. Prefer instance version instead: _.findLastIndex]
|
||||
_.sortedIndex(list, () => { return undefined; });
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [Static invocation of underscore function found. Prefer instance version instead: _.sortedIndex]
|
||||
_.range(list, () => { return undefined; });
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [Static invocation of underscore function found. Prefer instance version instead: _.range]
|
|
@ -0,0 +1,5 @@
|
|||
{
|
||||
"rules": {
|
||||
"underscore-consistent-invocation": true
|
||||
}
|
||||
}
|
|
@ -0,0 +1,184 @@
|
|||
declare const _: any;
|
||||
|
||||
_.each(list, () => { return undefined; });
|
||||
_.forEach(list, () => { return undefined; });
|
||||
_.map(list, () => { return undefined; });
|
||||
_.collect(list, () => { return undefined; });
|
||||
_.reduce(list, () => { return undefined; });
|
||||
_.inject(list, () => { return undefined; });
|
||||
_.foldl(list, () => { return undefined; });
|
||||
_.reduceRight(list, () => { return undefined; });
|
||||
_.foldr(list, () => { return undefined; });
|
||||
_.find(list, () => { return undefined; });
|
||||
_.detect(list, () => { return undefined; });
|
||||
_.filter(list, () => { return undefined; });
|
||||
_.select(list, () => { return undefined; });
|
||||
_.where(list, () => { return undefined; });
|
||||
_.findWhere(list, () => { return undefined; });
|
||||
_.reject(list, () => { return undefined; });
|
||||
_.every(list, () => { return undefined; });
|
||||
_.all(list, () => { return undefined; });
|
||||
_.some(list, () => { return undefined; });
|
||||
_.any(list, () => { return undefined; });
|
||||
_.contains(list, () => { return undefined; });
|
||||
_.include(list, () => { return undefined; });
|
||||
_.invoke(list, () => { return undefined; });
|
||||
_.pluck(list, () => { return undefined; });
|
||||
_.max(list, () => { return undefined; });
|
||||
_.min(list, () => { return undefined; });
|
||||
_.sortBy(list, () => { return undefined; });
|
||||
_.groupBy(list, () => { return undefined; });
|
||||
_.indexBy(list, () => { return undefined; });
|
||||
_.countBy(list, () => { return undefined; });
|
||||
_.shuffle(list, () => { return undefined; });
|
||||
_.sample(list, () => { return undefined; });
|
||||
_.toArray(list, () => { return undefined; });
|
||||
_.size(list, () => { return undefined; });
|
||||
_.partition(list, () => { return undefined; });
|
||||
_.first(list, () => { return undefined; });
|
||||
_.head(list, () => { return undefined; });
|
||||
_.take(list, () => { return undefined; });
|
||||
_.initial(list, () => { return undefined; });
|
||||
_.last(list, () => { return undefined; });
|
||||
_.rest(list, () => { return undefined; });
|
||||
_.tail(list, () => { return undefined; });
|
||||
_.drop(list, () => { return undefined; });
|
||||
_.compact(list, () => { return undefined; });
|
||||
_.flatten(list, () => { return undefined; });
|
||||
_.without(list, () => { return undefined; });
|
||||
_.union(list, () => { return undefined; });
|
||||
_.intersection(list, () => { return undefined; });
|
||||
_.difference(list, () => { return undefined; });
|
||||
_.uniq(list, () => { return undefined; });
|
||||
_.unique(list, () => { return undefined; });
|
||||
_.object(list, () => { return undefined; });
|
||||
_.zip(list, () => { return undefined; });
|
||||
_.unzip(list, () => { return undefined; });
|
||||
_.indexOf(list, () => { return undefined; });
|
||||
_.findIndex(list, () => { return undefined; });
|
||||
_.lastIndexOf(list, () => { return undefined; });
|
||||
_.findLastIndex(list, () => { return undefined; });
|
||||
_.sortedIndex(list, () => { return undefined; });
|
||||
_.range(list, () => { return undefined; });
|
||||
|
||||
_(list).each(() => { return undefined; });
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [Underscore instance wrapping of variable found. Prefer underscore static functions instead: _(list).each]
|
||||
_(list).forEach(() => { return undefined; });
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [Underscore instance wrapping of variable found. Prefer underscore static functions instead: _(list).forEach]
|
||||
_(list).map(() => { return undefined; });
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [Underscore instance wrapping of variable found. Prefer underscore static functions instead: _(list).map]
|
||||
_(list).collect(() => { return undefined; });
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [Underscore instance wrapping of variable found. Prefer underscore static functions instead: _(list).collect]
|
||||
_(list).reduce(() => { return undefined; });
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [Underscore instance wrapping of variable found. Prefer underscore static functions instead: _(list).reduce]
|
||||
_(list).inject(() => { return undefined; });
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [Underscore instance wrapping of variable found. Prefer underscore static functions instead: _(list).inject]
|
||||
_(list).foldl(() => { return undefined; });
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [Underscore instance wrapping of variable found. Prefer underscore static functions instead: _(list).foldl]
|
||||
_(list).reduceRight(() => { return undefined; });
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [Underscore instance wrapping of variable found. Prefer underscore static functions instead: _(list).reduceRight]
|
||||
_(list).foldr(() => { return undefined; });
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [Underscore instance wrapping of variable found. Prefer underscore static functions instead: _(list).foldr]
|
||||
_(list).find(() => { return undefined; });
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [Underscore instance wrapping of variable found. Prefer underscore static functions instead: _(list).find]
|
||||
_(list).detect(() => { return undefined; });
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [Underscore instance wrapping of variable found. Prefer underscore static functions instead: _(list).detect]
|
||||
_(list).filter(() => { return undefined; });
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [Underscore instance wrapping of variable found. Prefer underscore static functions instead: _(list).filter]
|
||||
_(list).select(() => { return undefined; });
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [Underscore instance wrapping of variable found. Prefer underscore static functions instead: _(list).select]
|
||||
_(list).where(() => { return undefined; });
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [Underscore instance wrapping of variable found. Prefer underscore static functions instead: _(list).where]
|
||||
_(list).findWhere(() => { return undefined; });
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [Underscore instance wrapping of variable found. Prefer underscore static functions instead: _(list).findWhere]
|
||||
_(list).reject(() => { return undefined; });
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [Underscore instance wrapping of variable found. Prefer underscore static functions instead: _(list).reject]
|
||||
_(list).every(() => { return undefined; });
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [Underscore instance wrapping of variable found. Prefer underscore static functions instead: _(list).every]
|
||||
_(list).all(() => { return undefined; });
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [Underscore instance wrapping of variable found. Prefer underscore static functions instead: _(list).all]
|
||||
_(list).some(() => { return undefined; });
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [Underscore instance wrapping of variable found. Prefer underscore static functions instead: _(list).some]
|
||||
_(list).any(() => { return undefined; });
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [Underscore instance wrapping of variable found. Prefer underscore static functions instead: _(list).any]
|
||||
_(list).contains(() => { return undefined; });
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [Underscore instance wrapping of variable found. Prefer underscore static functions instead: _(list).contains]
|
||||
_(list).include(() => { return undefined; });
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [Underscore instance wrapping of variable found. Prefer underscore static functions instead: _(list).include]
|
||||
_(list).invoke(() => { return undefined; });
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [Underscore instance wrapping of variable found. Prefer underscore static functions instead: _(list).invoke]
|
||||
_(list).pluck(() => { return undefined; });
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [Underscore instance wrapping of variable found. Prefer underscore static functions instead: _(list).pluck]
|
||||
_(list).max(() => { return undefined; });
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [Underscore instance wrapping of variable found. Prefer underscore static functions instead: _(list).max]
|
||||
_(list).min(() => { return undefined; });
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [Underscore instance wrapping of variable found. Prefer underscore static functions instead: _(list).min]
|
||||
_(list).sortBy(() => { return undefined; });
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [Underscore instance wrapping of variable found. Prefer underscore static functions instead: _(list).sortBy]
|
||||
_(list).groupBy(() => { return undefined; });
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [Underscore instance wrapping of variable found. Prefer underscore static functions instead: _(list).groupBy]
|
||||
_(list).indexBy(() => { return undefined; });
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [Underscore instance wrapping of variable found. Prefer underscore static functions instead: _(list).indexBy]
|
||||
_(list).countBy(() => { return undefined; });
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [Underscore instance wrapping of variable found. Prefer underscore static functions instead: _(list).countBy]
|
||||
_(list).shuffle(() => { return undefined; });
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [Underscore instance wrapping of variable found. Prefer underscore static functions instead: _(list).shuffle]
|
||||
_(list).sample(() => { return undefined; });
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [Underscore instance wrapping of variable found. Prefer underscore static functions instead: _(list).sample]
|
||||
_(list).toArray(() => { return undefined; });
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [Underscore instance wrapping of variable found. Prefer underscore static functions instead: _(list).toArray]
|
||||
_(list).size(() => { return undefined; });
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [Underscore instance wrapping of variable found. Prefer underscore static functions instead: _(list).size]
|
||||
_(list).partition(() => { return undefined; });
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [Underscore instance wrapping of variable found. Prefer underscore static functions instead: _(list).partition]
|
||||
_(list).first(() => { return undefined; });
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [Underscore instance wrapping of variable found. Prefer underscore static functions instead: _(list).first]
|
||||
_(list).head(() => { return undefined; });
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [Underscore instance wrapping of variable found. Prefer underscore static functions instead: _(list).head]
|
||||
_(list).take(() => { return undefined; });
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [Underscore instance wrapping of variable found. Prefer underscore static functions instead: _(list).take]
|
||||
_(list).initial(() => { return undefined; });
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [Underscore instance wrapping of variable found. Prefer underscore static functions instead: _(list).initial]
|
||||
_(list).last(() => { return undefined; });
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [Underscore instance wrapping of variable found. Prefer underscore static functions instead: _(list).last]
|
||||
_(list).rest(() => { return undefined; });
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [Underscore instance wrapping of variable found. Prefer underscore static functions instead: _(list).rest]
|
||||
_(list).tail(() => { return undefined; });
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [Underscore instance wrapping of variable found. Prefer underscore static functions instead: _(list).tail]
|
||||
_(list).drop(() => { return undefined; });
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [Underscore instance wrapping of variable found. Prefer underscore static functions instead: _(list).drop]
|
||||
_(list).compact(() => { return undefined; });
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [Underscore instance wrapping of variable found. Prefer underscore static functions instead: _(list).compact]
|
||||
_(list).flatten(() => { return undefined; });
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [Underscore instance wrapping of variable found. Prefer underscore static functions instead: _(list).flatten]
|
||||
_(list).without(() => { return undefined; });
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [Underscore instance wrapping of variable found. Prefer underscore static functions instead: _(list).without]
|
||||
_(list).union(() => { return undefined; });
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [Underscore instance wrapping of variable found. Prefer underscore static functions instead: _(list).union]
|
||||
_(list).intersection(() => { return undefined; });
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [Underscore instance wrapping of variable found. Prefer underscore static functions instead: _(list).intersection]
|
||||
_(list).difference(() => { return undefined; });
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [Underscore instance wrapping of variable found. Prefer underscore static functions instead: _(list).difference]
|
||||
_(list).uniq(() => { return undefined; });
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [Underscore instance wrapping of variable found. Prefer underscore static functions instead: _(list).uniq]
|
||||
_(list).unique(() => { return undefined; });
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [Underscore instance wrapping of variable found. Prefer underscore static functions instead: _(list).unique]
|
||||
_(list).object(() => { return undefined; });
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [Underscore instance wrapping of variable found. Prefer underscore static functions instead: _(list).object]
|
||||
_(list).zip(() => { return undefined; });
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [Underscore instance wrapping of variable found. Prefer underscore static functions instead: _(list).zip]
|
||||
_(list).unzip(() => { return undefined; });
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [Underscore instance wrapping of variable found. Prefer underscore static functions instead: _(list).unzip]
|
||||
_(list).indexOf(() => { return undefined; });
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [Underscore instance wrapping of variable found. Prefer underscore static functions instead: _(list).indexOf]
|
||||
_(list).findIndex(() => { return undefined; });
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [Underscore instance wrapping of variable found. Prefer underscore static functions instead: _(list).findIndex]
|
||||
_(list).lastIndexOf(() => { return undefined; });
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [Underscore instance wrapping of variable found. Prefer underscore static functions instead: _(list).lastIndexOf]
|
||||
_(list).findLastIndex(() => { return undefined; });
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [Underscore instance wrapping of variable found. Prefer underscore static functions instead: _(list).findLastIndex]
|
||||
_(list).sortedIndex(() => { return undefined; });
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [Underscore instance wrapping of variable found. Prefer underscore static functions instead: _(list).sortedIndex]
|
||||
_(list).range(() => { return undefined; });
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [Underscore instance wrapping of variable found. Prefer underscore static functions instead: _(list).range]
|
||||
tests/use-named-parameter/test.js.lint: Passed
|
|
@ -0,0 +1,7 @@
|
|||
{
|
||||
"rules": {
|
||||
"underscore-consistent-invocation": [true, {
|
||||
"style": "static"
|
||||
}]
|
||||
}
|
||||
}
|
|
@ -0,0 +1,15 @@
|
|||
function add1(a, b) {
|
||||
return a + b;
|
||||
}
|
||||
|
||||
function add2() {
|
||||
return arguments[0] + arguments[1];
|
||||
~~~~~~~~~~~~ [Use a named parameter instead: 'arguments[0]']
|
||||
~~~~~~~~~~~~ [Use a named parameter instead: 'arguments[1]']
|
||||
|
||||
const n = 1;
|
||||
const whatever = () => 0;
|
||||
|
||||
function add3() {
|
||||
return arguments[whatever()] + arguments[n];
|
||||
}
|
|
@ -0,0 +1,8 @@
|
|||
{
|
||||
"rules": {
|
||||
"use-named-parameter": true
|
||||
},
|
||||
"jsRules": {
|
||||
"use-named-parameter": true
|
||||
}
|
||||
}
|
|
@ -0,0 +1,38 @@
|
|||
declare const foo: any;
|
||||
declare const bar: any;
|
||||
|
||||
typeof bar === "undefined"
|
||||
typeof bar == "undefined"
|
||||
typeof bar !== "undefined"
|
||||
typeof bar != "undefined"
|
||||
"undefined" === typeof bar
|
||||
typeof foo === "object"
|
||||
typeof foo === "boolean"
|
||||
typeof foo === "number"
|
||||
typeof foo === "string"
|
||||
"function" === typeof foo
|
||||
typeof foo == baz
|
||||
typeof bar === typeof qux
|
||||
typeof Symbol() === "symbol"
|
||||
typeof Symbol("foo") === "symbol"
|
||||
typeof Symbol.iterator === "symbol"
|
||||
|
||||
typeof foo === "strnig"
|
||||
~~~~~~~~ [Invalid comparison in typeof. Did you mean string?]
|
||||
"strnig" === typeof foo
|
||||
~~~~~~~~ [Invalid comparison in typeof. Did you mean string?]
|
||||
|
||||
typeof foo == "funcion"
|
||||
~~~~~~~~~ [Invalid comparison in typeof. Did you mean function?]
|
||||
"fction" == typeof foo
|
||||
~~~~~~~~ [Invalid comparison in typeof. Did you mean function?]
|
||||
|
||||
typeof foo !== "undfind"
|
||||
~~~~~~~~~ [Invalid comparison in typeof. Did you mean undefined?]
|
||||
"ndefined" !== typeof foo
|
||||
~~~~~~~~~~ [Invalid comparison in typeof. Did you mean undefined?]
|
||||
|
||||
typeof foo != "bollean"
|
||||
~~~~~~~~~ [Invalid comparison in typeof. Did you mean boolean?]
|
||||
"bollen" != typeof foo
|
||||
~~~~~~~~ [Invalid comparison in typeof. Did you mean boolean?]
|
|
@ -0,0 +1,5 @@
|
|||
{
|
||||
"rules": {
|
||||
"valid-typeof": true
|
||||
}
|
||||
}
|
Загрузка…
Ссылка в новой задаче