From 56111c9cc6b1d8035f54f25ae1f2312c835636e1 Mon Sep 17 00:00:00 2001 From: Erich Gamma Date: Tue, 7 Nov 2017 11:53:59 +0100 Subject: [PATCH] update to tslint5 --- .vscode/tasks.json | 6 ++-- build/gulpfile.hygiene.js | 29 ++++++++++--------- .../lib/tslint/noUnexternalizedStringsRule.js | 14 +++++---- .../lib/tslint/noUnexternalizedStringsRule.ts | 14 +++++---- package.json | 4 +-- tslint.json | 7 +++-- 6 files changed, 40 insertions(+), 34 deletions(-) diff --git a/.vscode/tasks.json b/.vscode/tasks.json index 45d4995aa65..2239597b1f3 100644 --- a/.vscode/tasks.json +++ b/.vscode/tasks.json @@ -33,11 +33,11 @@ "task": "tslint", "label": "Run tslint", "problemMatcher": [ - "$tslint4" + "$tslint5" ] }, { - "taskName": "Run tests", + "label": "Run tests", "type": "shell", "command": "./scripts/test.sh", "windows": { @@ -50,7 +50,7 @@ } }, { - "taskName": "Run Dev", + "label": "Run Dev", "type": "shell", "command": "./scripts/code.sh", "windows": { diff --git a/build/gulpfile.hygiene.js b/build/gulpfile.hygiene.js index 27137a20781..056dc86065e 100644 --- a/build/gulpfile.hygiene.js +++ b/build/gulpfile.hygiene.js @@ -123,7 +123,8 @@ const tslintFilter = [ '!**/node_modules/**', '!extensions/typescript/test/colorize-fixtures/**', '!extensions/vscode-api-tests/testWorkspace/**', - '!extensions/**/*.test.ts' + '!extensions/**/*.test.ts', + '!extensions/html/server/lib/jquery.d.ts' ]; const copyrightHeader = [ @@ -133,17 +134,6 @@ const copyrightHeader = [ ' *--------------------------------------------------------------------------------------------*/' ].join('\n'); -function reportFailures(failures) { - failures.forEach(failure => { - const name = failure.name || failure.fileName; - const position = failure.startPosition; - const line = position.lineAndCharacter ? position.lineAndCharacter.line : position.line; - const character = position.lineAndCharacter ? position.lineAndCharacter.character : position.character; - - console.error(`${name}:${line + 1}:${character + 1}:${failure.failure}`); - }); -} - gulp.task('eslint', () => { return vfs.src(all, { base: '.', follow: true, allowEmpty: true }) .pipe(filter(eslintFilter)) @@ -153,12 +143,12 @@ gulp.task('eslint', () => { }); gulp.task('tslint', () => { - const options = { summarizeFailureOutput: true }; + const options = { emitError: false }; return vfs.src(all, { base: '.', follow: true, allowEmpty: true }) .pipe(filter(tslintFilter)) .pipe(gulptslint({ rulesDirectory: 'build/lib/tslint' })) - .pipe(gulptslint.report(reportFailures, options)); + .pipe(gulptslint.report(options)); }); const hygiene = exports.hygiene = (some, options) => { @@ -219,6 +209,17 @@ const hygiene = exports.hygiene = (some, options) => { cb(err); }); }); + + function reportFailures(failures) { + failures.forEach(failure => { + const name = failure.name || failure.fileName; + const position = failure.startPosition; + const line = position.lineAndCharacter ? position.lineAndCharacter.line : position.line; + const character = position.lineAndCharacter ? position.lineAndCharacter.character : position.character; + + console.error(`${name}:${line + 1}:${character + 1}:${failure.failure}`); + }); + } const tsl = es.through(function (file) { const configuration = tslint.Configuration.findConfiguration(null, '.'); diff --git a/build/lib/tslint/noUnexternalizedStringsRule.js b/build/lib/tslint/noUnexternalizedStringsRule.js index d1d3c76b8ea..2925f0a0c63 100644 --- a/build/lib/tslint/noUnexternalizedStringsRule.js +++ b/build/lib/tslint/noUnexternalizedStringsRule.js @@ -88,10 +88,11 @@ var NoUnexternalizedStringsRuleWalker = /** @class */ (function (_super) { var info = this.findDescribingParent(node); // Ignore strings in import and export nodes. if (info && info.isImport && doubleQuoted) { - this.addFailureAtNode(node, NoUnexternalizedStringsRuleWalker.ImportFailureMessage, new Lint.Fix(NoUnexternalizedStringsRuleWalker.ImportFailureMessage, [ - this.createReplacement(node.getStart(), 1, '\''), - this.createReplacement(node.getStart() + text.length - 1, 1, '\''), - ])); + var fix = [ + Lint.Replacement.replaceFromTo(node.getStart(), 1, '\''), + Lint.Replacement.replaceFromTo(node.getStart() + text.length - 1, 1, '\''), + ]; + this.addFailureAtNode(node, NoUnexternalizedStringsRuleWalker.ImportFailureMessage, fix); return; } var callInfo = info ? info.callInfo : null; @@ -101,8 +102,9 @@ var NoUnexternalizedStringsRuleWalker = /** @class */ (function (_super) { } if (doubleQuoted && (!callInfo || callInfo.argIndex === -1 || !this.signatures[functionName])) { var s = node.getText(); - var replacement = new Lint.Replacement(node.getStart(), node.getWidth(), "nls.localize('KEY-" + s.substring(1, s.length - 1) + "', " + s + ")"); - var fix = new Lint.Fix('Unexternalitzed string', [replacement]); + var fix = [ + Lint.Replacement.replaceFromTo(node.getStart(), node.getWidth(), "nls.localize('KEY-" + s.substring(1, s.length - 1) + "', " + s + ")"), + ]; this.addFailure(this.createFailure(node.getStart(), node.getWidth(), "Unexternalized string found: " + node.getText(), fix)); return; } diff --git a/build/lib/tslint/noUnexternalizedStringsRule.ts b/build/lib/tslint/noUnexternalizedStringsRule.ts index 172db4d6b12..7b12df97596 100644 --- a/build/lib/tslint/noUnexternalizedStringsRule.ts +++ b/build/lib/tslint/noUnexternalizedStringsRule.ts @@ -104,13 +104,14 @@ class NoUnexternalizedStringsRuleWalker extends Lint.RuleWalker { let info = this.findDescribingParent(node); // Ignore strings in import and export nodes. if (info && info.isImport && doubleQuoted) { + const fix = [ + Lint.Replacement.replaceFromTo(node.getStart(), 1, '\''), + Lint.Replacement.replaceFromTo(node.getStart() + text.length - 1, 1, '\''), + ]; this.addFailureAtNode( node, NoUnexternalizedStringsRuleWalker.ImportFailureMessage, - new Lint.Fix(NoUnexternalizedStringsRuleWalker.ImportFailureMessage, [ - this.createReplacement(node.getStart(), 1, '\''), - this.createReplacement(node.getStart() + text.length - 1, 1, '\''), - ]) + fix ); return; } @@ -122,8 +123,9 @@ class NoUnexternalizedStringsRuleWalker extends Lint.RuleWalker { if (doubleQuoted && (!callInfo || callInfo.argIndex === -1 || !this.signatures[functionName])) { const s = node.getText(); - const replacement = new Lint.Replacement(node.getStart(), node.getWidth(), `nls.localize('KEY-${s.substring(1, s.length - 1)}', ${s})`); - const fix = new Lint.Fix('Unexternalitzed string', [replacement]); + const fix = [ + Lint.Replacement.replaceFromTo(node.getStart(), node.getWidth(), `nls.localize('KEY-${s.substring(1, s.length - 1)}', ${s})`), + ]; this.addFailure(this.createFailure(node.getStart(), node.getWidth(), `Unexternalized string found: ${node.getText()}`, fix)); return; } diff --git a/package.json b/package.json index bf4175a7465..97d41337a00 100644 --- a/package.json +++ b/package.json @@ -85,7 +85,7 @@ "gulp-shell": "^0.5.2", "gulp-sourcemaps": "^1.11.0", "gulp-tsb": "2.0.4", - "gulp-tslint": "^7.0.1", + "gulp-tslint": "^8.1.2", "gulp-uglify": "^3.0.0", "gulp-util": "^3.0.6", "gulp-vinyl-zip": "^1.2.2", @@ -107,7 +107,7 @@ "rimraf": "^2.2.8", "sinon": "^1.17.2", "source-map": "^0.4.4", - "tslint": "^4.3.1", + "tslint": "^5.8.0", "typescript": "2.6.1", "typescript-formatter": "4.0.1", "uglify-es": "^3.0.18", diff --git a/tslint.json b/tslint.json index a1d03a430f6..e5f6005ed78 100644 --- a/tslint.json +++ b/tslint.json @@ -6,7 +6,7 @@ "no-string-throw": true, "no-unused-expression": true, "no-duplicate-variable": true, - "no-unused-variable": true, + // "no-unused-variable": true, // requires type information in tslint > v4 "curly": true, "class-name": true, "semicolon": [ @@ -430,5 +430,6 @@ ], "duplicate-imports": true, "translation-remind": true - } -} + }, + "defaultSeverity": "warning" +} \ No newline at end of file -- GitLab