Skip to content
This repository has been archived by the owner on Feb 21, 2022. It is now read-only.

Tslint 4.0 #138

Merged
merged 15 commits into from
Nov 21, 2016
Merged
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ The following rules point out areas where you might have made mistakes.
|:white_check_mark:|[no-control-regex](http://eslint.org/docs/rules/no-control-regex)|[no-control-regex](https://github.com/buzinas/tslint-eslint-rules/blob/master/src/docs/rules/noControlRegexRule.md)|disallow control characters in regular expressions (recommended)|
|:ballot_box_with_check:|[no-debugger](http://eslint.org/docs/rules/no-debugger)|[no-debugger](http://palantir.github.io/tslint/rules/no-debugger)|disallow use of `debugger` (recommended)|
|:no_entry_sign:|[no-dupe-args](http://eslint.org/docs/rules/no-dupe-args)|Not applicable|disallow duplicate arguments in functions (recommended)|
|:ballot_box_with_check:|[no-dupe-keys](http://eslint.org/docs/rules/no-dupe-keys)|[no-duplicate-key](http://palantir.github.io/tslint/rules/no-duplicate-key)|disallow duplicate keys when creating object literals (recommended)|
|:no_entry_sign:|[no-dupe-keys](http://eslint.org/docs/rules/no-dupe-keys)|Not applicable|disallow duplicate keys when creating object literals (recommended)|
|:white_check_mark:|[no-duplicate-case](http://eslint.org/docs/rules/no-duplicate-case)|[no-duplicate-case](https://github.com/buzinas/tslint-eslint-rules/blob/master/src/docs/rules/noDuplicateCaseRule.md)|disallow a duplicate case label. (recommended)|
|:ballot_box_with_check:|[no-empty](http://eslint.org/docs/rules/no-empty)|[no-empty](http://palantir.github.io/tslint/rules/no-empty)|disallow empty statements (recommended)|
|:white_check_mark:|[no-empty-character-class](http://eslint.org/docs/rules/no-empty-character-class)|[no-empty-character-class](https://github.com/buzinas/tslint-eslint-rules/blob/master/src/docs/rules/noEmptyCharacterClassRule.md)|disallow the use of empty character classes in regular expressions (recommended)|
Expand All @@ -88,7 +88,7 @@ The following rules point out areas where you might have made mistakes.
|:white_check_mark:|[no-regex-spaces](http://eslint.org/docs/rules/no-regex-spaces)|[no-regex-spaces](https://github.com/buzinas/tslint-eslint-rules/blob/master/src/docs/rules/noRegexSpacesRule.md)|disallow multiple spaces in a regular expression literal (recommended)|
|:white_check_mark:|[no-sparse-arrays](http://eslint.org/docs/rules/no-sparse-arrays)|[no-sparse-arrays](https://github.com/buzinas/tslint-eslint-rules/blob/master/src/docs/rules/noSparseArraysRule.md)|disallow sparse arrays (recommended)|
|:white_check_mark:|[no-unexpected-multiline](http://eslint.org/docs/rules/no-unexpected-multiline)|[no-unexpected-multiline](https://github.com/buzinas/tslint-eslint-rules/blob/master/src/docs/rules/noUnexpectedMultilineRule.md)|Avoid code that looks like two expressions but is actually one|
|:ballot_box_with_check:|[no-unreachable](http://eslint.org/docs/rules/no-unreachable)|[no-unreachable](http://palantir.github.io/tslint/rules/no-unreachable)|disallow unreachable statements after a return, throw, continue, or break statement (recommended)|
|:no_entry_sign:|[no-unreachable](http://eslint.org/docs/rules/no-unreachable)|Not applicable|disallow unreachable statements after a return, throw, continue, or break statement (recommended)|
|:white_check_mark:|[use-isnan](http://eslint.org/docs/rules/use-isnan)|[use-isnan](https://github.com/buzinas/tslint-eslint-rules/blob/master/src/docs/rules/useIsnanRule.md)|disallow comparisons with the value `NaN` (recommended)|
|:white_check_mark:|[valid-jsdoc](http://eslint.org/docs/rules/valid-jsdoc)|[valid-jsdoc](https://github.com/buzinas/tslint-eslint-rules/blob/master/src/docs/rules/validJsdocRule.md)|Ensure JSDoc comments are valid|
|:white_check_mark:|[valid-typeof](http://eslint.org/docs/rules/valid-typeof)|[valid-typeof](https://github.com/buzinas/tslint-eslint-rules/blob/master/src/docs/rules/validTypeofRule.md)|Ensure that the results of typeof are compared against a valid string (recommended)|
Expand Down Expand Up @@ -171,7 +171,7 @@ These rules relate to using strict mode.

| :grey_question: | ESLint | TSLint | Description |
| :--- | :---: | :---: | :--- |
|:ballot_box_with_check:|[strict](http://eslint.org/docs/rules/strict)|[use-strict](http://palantir.github.io/tslint/rules/use-strict)|require effective use of strict mode directives|
|:no_entry_sign:|[strict](http://eslint.org/docs/rules/strict)|Not applicable|require effective use of strict mode directives|

### Variables

Expand All @@ -188,7 +188,7 @@ These rules have to do with variable declarations.
|:no_entry_sign:|[no-undef](http://eslint.org/docs/rules/no-undef)|Not applicable|disallow use of undeclared variables unless mentioned in a `/*global */` block (recommended)|
|:x:|[no-undef-init](http://eslint.org/docs/rules/no-undef-init)|no-undef-init|disallow use of undefined when initializing variables|
|:x:|[no-undefined](http://eslint.org/docs/rules/no-undefined)|no-undefined|disallow use of `undefined` variable|
|:ballot_box_with_check:|[no-unused-vars](http://eslint.org/docs/rules/no-unused-vars)|[no-unused-variable](http://palantir.github.io/tslint/rules/no-unused-variable)|disallow declaration of variables that are not used in the code (recommended)|
|:no_entry_sign:|[no-unused-vars](http://eslint.org/docs/rules/no-unused-vars)|Not applicable|[**DEPRECATED**: [no-unused-variable](https://github.com/palantir/tslint/issues/1481)] disallow declaration of variables that are not used in the code (recommended).|
|:ballot_box_with_check:|[no-use-before-define](http://eslint.org/docs/rules/no-use-before-define)|[no-use-before-declare](http://palantir.github.io/tslint/rules/no-use-before-declare)|disallow use of variables before they are defined|

### Node.js and CommonJS
Expand Down
38 changes: 28 additions & 10 deletions gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,25 +37,43 @@ gulp.task('lint', function lint() {
return gulp
.src(SRC_FOLDER)
.pipe(tslint({
tslint: require('tslint')
formatter: 'verbose',
}))
.pipe(tslint.report('prose', {
summarizeFailureOutput: false
}));
.pipe(tslint.report());
});

gulp.task('build', argv.lint === false ? [] : ['lint'], function build() {
var tsResult = tsProject
gulp.task('self-lint', function selfLint() {
return gulp
.src(SRC_FOLDER)
.pipe(tslint({
configuration: 'tslint_eslint_rules.json',
formatter: 'verbose'
}))
.pipe(tslint.report());
});

gulp.task('build', argv.lint === false ? [] : ['lint'], function build(done) {
var hasError = false;
tsProject
.src([SRC_FOLDER, DEF_FOLDER])
.pipe(sourcemaps.init())
.pipe(tsProject());

return tsResult.js
.pipe(tsProject())
.on('error', function onError() {
hasError = true;
})
.js
.pipe(sourcemaps.write({
includeContent: false,
sourceRoot: path.join(__dirname, '/src')
}))
.pipe(gulp.dest('dist'));
.pipe(gulp.dest('dist'))
.on('end', function() {
if (hasError) {
done('TypeScript has reported errors');
} else {
done();
}
});
});

gulp.task('test', ['build'], function test() {
Expand Down
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"description": "Improve your TSLint with the missing ESLint Rules",
"main": "index.js",
"scripts": {
"test": "gulp test"
"test": "gulp test && gulp self-lint"
},
"repository": {
"type": "git",
Expand All @@ -29,13 +29,13 @@
"gulp": "^3.9.1",
"gulp-sourcemaps": "^1.6.0",
"gulp-spawn-mocha": "^2.2.2",
"gulp-tslint": "^3.6.0",
"gulp-tslint": "^7.0.0",
"gulp-typescript": "^3.0.1",
"typescript": "^2.0.3",
"yargs": "^5.0.0"
},
"dependencies": {
"doctrine": "^0.7.2",
"tslint": "^3.15.1"
"tslint": "^4.0.0"
}
}
4 changes: 2 additions & 2 deletions src/readme/fetch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ function requestFromGithub(path, callback) {
}

function compareToESLint() {
return new Promise((fulfill, reject) => {
return new Promise((fulfill) => {
requestFromGithub('/repos/eslint/eslint/contents/lib/rules', (data) => {
const rules = data
.filter(obj => obj.name.endsWith('.js'))
Expand Down Expand Up @@ -71,7 +71,7 @@ function compareToESLint() {
}

function compareToTSLint() {
return new Promise((fulfill, reject) => {
return new Promise((fulfill) => {
requestFromGithub('/repos/palantir/tslint/contents/src/rules', (data) => {
const rules = data
.filter(obj => obj.name.endsWith('.ts'))
Expand Down
56 changes: 17 additions & 39 deletions src/readme/rules.ts
Original file line number Diff line number Diff line change
Expand Up @@ -128,22 +128,16 @@ const rules: IRule[] = [
category: 'Possible Errors',
description: 'disallow duplicate arguments in functions (recommended)',
eslintUrl: 'http://eslint.org/docs/rules/no-dupe-args',
tslintUrl: 'http://palantir.github.io/tslint/rules/Not applicable',
provider: 'Not applicable',
usage: ``
provider: 'Not applicable'
},
{
available: true,
available: false,
eslintRule: 'no-dupe-keys',
tslintRule: 'no-duplicate-key',
tslintRule: 'Not applicable',
category: 'Possible Errors',
description: 'disallow duplicate keys when creating object literals (recommended)',
eslintUrl: 'http://eslint.org/docs/rules/no-dupe-keys',
tslintUrl: 'http://palantir.github.io/tslint/rules/no-duplicate-key',
provider: 'native',
usage: `~~~json
"no-duplicate-key": true
~~~`
provider: 'Not applicable'
},
{
available: true,
Expand Down Expand Up @@ -356,17 +350,13 @@ const rules: IRule[] = [
~~~`
},
{
available: true,
available: false,
eslintRule: 'no-unreachable',
tslintRule: 'no-unreachable',
tslintRule: 'Not applicable',
category: 'Possible Errors',
description: 'disallow unreachable statements after a return, throw, continue, or break statement (recommended)',
eslintUrl: 'http://eslint.org/docs/rules/no-unreachable',
tslintUrl: 'http://palantir.github.io/tslint/rules/no-unreachable',
provider: 'native',
usage: `~~~json
"no-unreachable": true
~~~`
provider: 'Not applicable'
},
{
available: true,
Expand Down Expand Up @@ -960,9 +950,7 @@ const rules: IRule[] = [
category: 'Best Practices',
description: 'disallow use of octal literals (recommended)',
eslintUrl: 'http://eslint.org/docs/rules/no-octal',
tslintUrl: 'http://palantir.github.io/tslint/rules/Not applicable',
provider: 'Not applicable',
usage: ``
provider: 'Not applicable'
},
{
available: false,
Expand Down Expand Up @@ -1292,15 +1280,13 @@ const rules: IRule[] = [
~~~`
},
{
available: true,
available: false,
eslintRule: 'strict',
tslintRule: 'use-strict',
tslintRule: 'Not applicable',
category: 'Strict Mode',
description: 'require effective use of strict mode directives',
eslintUrl: 'http://eslint.org/docs/rules/strict',
tslintUrl: 'http://palantir.github.io/tslint/rules/use-strict',
provider: 'native',
usage: ''
provider: 'Not applicable'
},
{
available: false,
Expand Down Expand Up @@ -1349,9 +1335,7 @@ const rules: IRule[] = [
category: 'Variables',
description: 'disallow deletion of variables (recommended)',
eslintUrl: 'http://eslint.org/docs/rules/no-delete-var',
tslintUrl: 'http://palantir.github.io/tslint/rules/Not applicable',
provider: 'Not applicable',
usage: ``
provider: 'Not applicable'
},
{
available: false,
Expand Down Expand Up @@ -1397,9 +1381,7 @@ const rules: IRule[] = [
category: 'Variables',
description: 'disallow use of undeclared variables unless mentioned in a `/*global */` block (recommended)',
eslintUrl: 'http://eslint.org/docs/rules/no-undef',
tslintUrl: 'http://palantir.github.io/tslint/rules/Not applicable',
provider: 'Not applicable',
usage: ``
provider: 'Not applicable'
},
{
available: false,
Expand All @@ -1426,17 +1408,13 @@ const rules: IRule[] = [
~~~`
},
{
available: true,
available: false,
eslintRule: 'no-unused-vars',
tslintRule: 'no-unused-variable',
tslintRule: 'Not applicable',
category: 'Variables',
description: 'disallow declaration of variables that are not used in the code (recommended)',
description: '[**DEPRECATED**: [no-unused-variable](https://github.com/palantir/tslint/issues/1481)] disallow declaration of variables that are not used in the code (recommended).',
eslintUrl: 'http://eslint.org/docs/rules/no-unused-vars',
tslintUrl: 'http://palantir.github.io/tslint/rules/no-unused-variable',
provider: 'native',
usage: `~~~json
"no-unused-variable": true
~~~`
provider: 'Not applicable'
},
{
available: true,
Expand Down
12 changes: 11 additions & 1 deletion src/readme/unusedTSLintRules.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,16 @@
[
"adjacent-overload-signatures",
"member-access",
"member-ordering",
"no-any",
"no-inferrable-types",
"no-internal-module",
"no-namespace",
"no-reference",
"no-var-requires",
"only-arrow-functions",
"prefer-for-of",
"typedef",
"typedef-whitespace",
"no-namespace"
"max-line-length"
]
2 changes: 1 addition & 1 deletion src/rules/arrayBracketSpacingRule.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as ts from 'typescript';
import * as Lint from 'tslint/lib/lint';
import * as Lint from 'tslint';

const OPTION_ALWAYS = 'always';

Expand Down
2 changes: 1 addition & 1 deletion src/rules/blockSpacingRule.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as ts from 'typescript';
import * as Lint from 'tslint/lib/lint';
import * as Lint from 'tslint';

const OPTION_ALWAYS = 'always';

Expand Down
2 changes: 1 addition & 1 deletion src/rules/braceStyleRule.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as ts from 'typescript';
import * as Lint from 'tslint/lib/lint';
import * as Lint from 'tslint';

const OPTION_1TBS = '1tbs';
const OPTION_ALLMAN = 'allman';
Expand Down
2 changes: 1 addition & 1 deletion src/rules/handleCallbackErrRule.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as ts from 'typescript';
import * as Lint from 'tslint/lib/lint';
import * as Lint from 'tslint';

export class Rule extends Lint.Rules.AbstractRule {
public static FAILURE_STRING = 'Expected error to be handled';
Expand Down
2 changes: 1 addition & 1 deletion src/rules/noConstantConditionRule.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as ts from 'typescript';
import * as Lint from 'tslint/lib/lint';
import * as Lint from 'tslint';
import { isAssignmentToken } from '../support/token';

export class Rule extends Lint.Rules.AbstractRule {
Expand Down
2 changes: 1 addition & 1 deletion src/rules/noControlRegexRule.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as ts from 'typescript';
import * as Lint from 'tslint/lib/lint';
import * as Lint from 'tslint';

export class Rule extends Lint.Rules.AbstractRule {
public static FAILURE_STRING = 'unexpected control character in regular expression';
Expand Down
2 changes: 1 addition & 1 deletion src/rules/noDuplicateCaseRule.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as ts from 'typescript';
import * as Lint from 'tslint/lib/lint';
import * as Lint from 'tslint';

export class Rule extends Lint.Rules.AbstractRule {
public static FAILURE_STRING = 'duplicate case label';
Expand Down
2 changes: 1 addition & 1 deletion src/rules/noEmptyCharacterClassRule.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as ts from 'typescript';
import * as Lint from 'tslint/lib/lint';
import * as Lint from 'tslint';

export class Rule extends Lint.Rules.AbstractRule {
public static FAILURE_STRING = `don't use empty classes in regular expressions`;
Expand Down
2 changes: 1 addition & 1 deletion src/rules/noExAssignRule.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as ts from 'typescript';
import * as Lint from 'tslint/lib/lint';
import * as Lint from 'tslint';
import { isAssignmentToken } from '../support/token';

export class Rule extends Lint.Rules.AbstractRule {
Expand Down
2 changes: 1 addition & 1 deletion src/rules/noExtraBooleanCastRule.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as ts from 'typescript';
import * as Lint from 'tslint/lib/lint';
import * as Lint from 'tslint';

export class Rule extends Lint.Rules.AbstractRule {
public static FAILURE_STRING = {
Expand Down
2 changes: 1 addition & 1 deletion src/rules/noExtraSemiRule.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as ts from 'typescript';
import * as Lint from 'tslint/lib/lint';
import * as Lint from 'tslint';

export class Rule extends Lint.Rules.AbstractRule {
public static FAILURE_STRING = 'unnecessary semicolon';
Expand Down
2 changes: 1 addition & 1 deletion src/rules/noInnerDeclarationsRule.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as ts from 'typescript';
import * as Lint from 'tslint/lib/lint';
import * as Lint from 'tslint';

export class Rule extends Lint.Rules.AbstractRule {
public apply(sourceFile: ts.SourceFile): Lint.RuleFailure[] {
Expand Down
2 changes: 1 addition & 1 deletion src/rules/noInvalidRegexpRule.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as ts from 'typescript';
import * as Lint from 'tslint/lib/lint';
import * as Lint from 'tslint';

export class Rule extends Lint.Rules.AbstractRule {
public apply(sourceFile: ts.SourceFile): Lint.RuleFailure[] {
Expand Down
2 changes: 1 addition & 1 deletion src/rules/noIrregularWhitespaceRule.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as ts from 'typescript';
import * as Lint from 'tslint/lib/lint';
import * as Lint from 'tslint';

export class Rule extends Lint.Rules.AbstractRule {
public static RULE_NAME = 'no-irregular-whitespace';
Expand Down
2 changes: 1 addition & 1 deletion src/rules/noMultiSpacesRule.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as ts from 'typescript';
import * as Lint from 'tslint/lib/lint';
import * as Lint from 'tslint';

export class Rule extends Lint.Rules.AbstractRule {

Expand Down
2 changes: 1 addition & 1 deletion src/rules/noRegexSpacesRule.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as ts from 'typescript';
import * as Lint from 'tslint/lib/lint';
import * as Lint from 'tslint';

export class Rule extends Lint.Rules.AbstractRule {
public apply(sourceFile: ts.SourceFile): Lint.RuleFailure[] {
Expand Down
2 changes: 1 addition & 1 deletion src/rules/noSparseArraysRule.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as ts from 'typescript';
import * as Lint from 'tslint/lib/lint';
import * as Lint from 'tslint';

export class Rule extends Lint.Rules.AbstractRule {
public static FAILURE_STRING = 'unexpected comma in middle of array';
Expand Down
2 changes: 1 addition & 1 deletion src/rules/noUnexpectedMultilineRule.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as ts from 'typescript';
import * as Lint from 'tslint/lib/lint';
import * as Lint from 'tslint';

export class Rule extends Lint.Rules.AbstractRule {
public static FAILURE_STRING = {
Expand Down
Loading