diff --git a/gulpfile.js b/gulpfile.js index f318f51e..636e71e7 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -2,9 +2,10 @@ var gulp = require('gulp'); var rename = require('gulp-rename'); var install = require('gulp-install'); -var tslint = require('gulp-tslint'); +var gulpTsLint = require('gulp-tslint'); var filter = require('gulp-filter'); var ts = require('gulp-typescript'); +var tslint = require('tslint'); var tsProject = ts.createProject('tsconfig.json'); var del = require('del'); var srcmap = require('gulp-sourcemaps'); @@ -24,15 +25,17 @@ require('./tasks/htmltasks') require('./tasks/packagetasks') gulp.task('ext:lint', () => { + var program = tslint.Linter.createProgram('tsconfig.json'); return gulp.src([ config.paths.project.root + '/src/**/*.ts', '!' + config.paths.project.root + '/src/views/htmlcontent/**/*', config.paths.project.root + '/test/**/*.ts' ]) - .pipe((tslint({ + .pipe((gulpTsLint({ + program, formatter: "verbose" }))) - .pipe(tslint.report()); + .pipe(gulpTsLint.report()); }); gulp.task('ext:compile-src', (done) => { @@ -139,3 +142,5 @@ gulp.task('install', function() { gulp.task('watch', function(){ return gulp.watch(config.paths.project.root + '/src/**/*', gulp.series('build')) }); + +gulp.task('lint', gulp.series('ext:lint', 'html:lint')); diff --git a/npm-shrinkwrap.json b/npm-shrinkwrap.json index 1f6a243d..259eb7a2 100644 --- a/npm-shrinkwrap.json +++ b/npm-shrinkwrap.json @@ -4,6 +4,69 @@ "lockfileVersion": 1, "requires": true, "dependencies": { + "@babel/code-frame": { + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.0.0.tgz", + "integrity": "sha512-OfC2uemaknXr87bdLUkWog7nYuliM9Ij5HUcajsVcMCpQrcLmtxRbVFTIqmcSkSeYRBFBRxs2FiUqFJDLdiebA==", + "dev": true, + "requires": { + "@babel/highlight": "^7.0.0" + } + }, + "@babel/highlight": { + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/@babel/highlight/-/highlight-7.0.0.tgz", + "integrity": "sha512-UFMC4ZeFC48Tpvj7C8UgLvtkaUuovQX+5xNWrsIoMG8o2z+XFKjKaN9iVmS84dPwVN00W4wPmqvYoZF3EGAsfw==", + "dev": true, + "requires": { + "chalk": "^2.0.0", + "esutils": "^2.0.2", + "js-tokens": "^4.0.0" + }, + "dependencies": { + "ansi-styles": { + "version": "3.2.1", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-3.2.1.tgz", + "integrity": "sha512-VT0ZI6kZRdTh8YyJw3SMbYm/u+NqfsAxEpWO0Pf9sq8/e94WxxOpPKx9FR1FlyCtOVDNOQ+8ntlqFxiRc+r5qA==", + "dev": true, + "requires": { + "color-convert": "^1.9.0" + } + }, + "chalk": { + "version": "2.4.2", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-2.4.2.tgz", + "integrity": "sha512-Mti+f9lpJNcwF4tWV8/OrTTtF1gZi+f8FqlyAdouralcFWFQWF2+NgCHShjkCb+IFBLq9buZwE1xckQU4peSuQ==", + "dev": true, + "requires": { + "ansi-styles": "^3.2.1", + "escape-string-regexp": "^1.0.5", + "supports-color": "^5.3.0" + } + }, + "has-flag": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-3.0.0.tgz", + "integrity": "sha1-tdRU3CGZriJWmfNGfloH87lVuv0=", + "dev": true + }, + "js-tokens": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-4.0.0.tgz", + "integrity": "sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ==", + "dev": true + }, + "supports-color": { + "version": "5.5.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.5.0.tgz", + "integrity": "sha512-QjVjwdXIt408MIiAqCX4oUKsgU2EqAGzs2Ppkm4aQYbjm+ZEWEcW4SfFNTr4uMNZma0ey4f5lgLrkB0aX0QMow==", + "dev": true, + "requires": { + "has-flag": "^3.0.0" + } + } + } + }, "@gulp-sourcemaps/map-sources": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/@gulp-sourcemaps/map-sources/-/map-sources-1.0.0.tgz", @@ -14,6 +77,12 @@ "through2": "^2.0.3" } }, + "@types/fancy-log": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/@types/fancy-log/-/fancy-log-1.3.0.tgz", + "integrity": "sha512-mQjDxyOM1Cpocd+vm1kZBP7smwKZ4TNokFeds9LV7OZibmPJFEzY3+xZMrKfUdNT71lv8GoCPD6upKwHxubClw==", + "dev": true + }, "@types/node": { "version": "10.12.11", "resolved": "https://registry.npmjs.org/@types/node/-/node-10.12.11.tgz", @@ -1128,14 +1197,14 @@ }, "dependencies": { "fsevents": { - "version": "1.2.7", - "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-1.2.7.tgz", - "integrity": "sha512-Pxm6sI2MeBD7RdD12RYsqaP0nMiwx8eZBXCa6z2L+mRHm2DYrOYwihmhjpkdjUHwQhslWQjRpEgNq4XvBmaAuw==", + "version": "1.2.8", + "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-1.2.8.tgz", + "integrity": "sha512-tPvHgPGB7m40CZ68xqFGkKuzN+RnpGmSV+hgeKxhRpbxdqKXUFJGC3yonBOLzQBcJyGpdZFDfCsdOC2KFsXzeA==", "dev": true, "optional": true, "requires": { - "nan": "^2.9.2", - "node-pre-gyp": "^0.10.0" + "nan": "^2.12.1", + "node-pre-gyp": "^0.12.0" }, "dependencies": { "abbrev": { @@ -1213,12 +1282,12 @@ "optional": true }, "debug": { - "version": "2.6.9", + "version": "4.1.1", "bundled": true, "dev": true, "optional": true, "requires": { - "ms": "2.0.0" + "ms": "^2.1.1" } }, "deep-extend": { @@ -1389,24 +1458,24 @@ } }, "ms": { - "version": "2.0.0", + "version": "2.1.1", "bundled": true, "dev": true, "optional": true }, "needle": { - "version": "2.2.4", + "version": "2.3.0", "bundled": true, "dev": true, "optional": true, "requires": { - "debug": "^2.1.2", + "debug": "^4.1.0", "iconv-lite": "^0.4.4", "sax": "^1.2.4" } }, "node-pre-gyp": { - "version": "0.10.3", + "version": "0.12.0", "bundled": true, "dev": true, "optional": true, @@ -1434,13 +1503,13 @@ } }, "npm-bundled": { - "version": "1.0.5", + "version": "1.0.6", "bundled": true, "dev": true, "optional": true }, "npm-packlist": { - "version": "1.2.0", + "version": "1.4.1", "bundled": true, "dev": true, "optional": true, @@ -1579,7 +1648,7 @@ "optional": true }, "semver": { - "version": "5.6.0", + "version": "5.7.0", "bundled": true, "dev": true, "optional": true @@ -1675,6 +1744,13 @@ } } }, + "nan": { + "version": "2.13.2", + "resolved": "https://registry.npmjs.org/nan/-/nan-2.13.2.tgz", + "integrity": "sha512-TghvYc72wlMGMVMluVo9WRJc0mB8KxxF/gZ4YYFy7V2ZQX9l7rgbPg7vjS9mt6U5HXODVFVI2bOduCzwOMv/lw==", + "dev": true, + "optional": true + }, "normalize-path": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/normalize-path/-/normalize-path-3.0.0.tgz", @@ -3547,9 +3623,9 @@ } }, "fined": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/fined/-/fined-1.1.1.tgz", - "integrity": "sha512-jQp949ZmEbiYHk3gkbdtpJ0G1+kgtLQBNdP5edFP7Fh+WAYceLQz6yO1SBj72Xkg8GVyTB3bBzAYrHJVh5Xd5g==", + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/fined/-/fined-1.2.0.tgz", + "integrity": "sha512-ZYDqPLGxDkDhDZBjZBb+oD1+j0rA4E0pXY50eplAAOPg2N/gUBSSk5IM1/QhPfyVo19lJ+CvXpqfvk+b2p/8Ng==", "dev": true, "requires": { "expand-tilde": "^2.0.2", @@ -3572,13 +3648,13 @@ "dev": true }, "flush-write-stream": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/flush-write-stream/-/flush-write-stream-1.0.3.tgz", - "integrity": "sha512-calZMC10u0FMUqoiunI2AiGIIUtUIvifNwkHhNupZH4cbNnW1Itkoh/Nf5HFYmDrwWPjrUxpkZT0KhuCq0jmGw==", + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/flush-write-stream/-/flush-write-stream-1.1.1.tgz", + "integrity": "sha512-3Z4XhFZ3992uIq0XOqb9AreonueSYphE6oYbpt5+3u06JWklbsPkNv3ZKkP9Bz/r+1MWCaMoSQ28P85+1Yc77w==", "dev": true, "requires": { - "inherits": "^2.0.1", - "readable-stream": "^2.0.4" + "inherits": "^2.0.3", + "readable-stream": "^2.3.6" } }, "follow-redirects": { @@ -3930,7 +4006,7 @@ "dev": true, "optional": true, "requires": { - "brace-expansion": "1.1.11" + "brace-expansion": "^1.1.7" } }, "minimist": { @@ -4504,9 +4580,9 @@ }, "dependencies": { "gulp-cli": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/gulp-cli/-/gulp-cli-2.1.0.tgz", - "integrity": "sha512-txzgdFVlEPShBZus6JJyGyKJoBVDq6Do0ZQgIgx5RAsmhNVTDjymmOxpQvo3c20m66FldilS68ZXj2Q9w5dKbA==", + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/gulp-cli/-/gulp-cli-2.2.0.tgz", + "integrity": "sha512-rGs3bVYHdyJpLqR0TUBnlcZ1O5O++Zs4bA0ajm+zr3WFCfiSLjGwoCBqFs18wzN+ZxahT9DkOK5nDf26iDsWjA==", "dev": true, "requires": { "ansi-colors": "^1.0.1", @@ -5024,14 +5100,37 @@ } }, "gulp-tslint": { - "version": "6.1.3", - "resolved": "https://registry.npmjs.org/gulp-tslint/-/gulp-tslint-6.1.3.tgz", - "integrity": "sha1-cq02j0JEXyqs+v0vd/oZFm7eeVg=", + "version": "8.1.4", + "resolved": "https://registry.npmjs.org/gulp-tslint/-/gulp-tslint-8.1.4.tgz", + "integrity": "sha512-wBoZIEMJRz9urHwolsvQpngA9l931p6g/Liwz1b/KrsVP6jEBFZv/o0NS1TFCQZi/l8mXxz8+v3twhf4HOXxPQ==", "dev": true, "requires": { - "gulp-util": "~3.0.7", - "map-stream": "~0.1.0", + "@types/fancy-log": "1.3.0", + "ansi-colors": "^1.0.1", + "fancy-log": "1.3.3", + "map-stream": "~0.0.7", + "plugin-error": "1.0.1", "through": "~2.3.8" + }, + "dependencies": { + "map-stream": { + "version": "0.0.7", + "resolved": "https://registry.npmjs.org/map-stream/-/map-stream-0.0.7.tgz", + "integrity": "sha1-ih8HiW2CsQkmvTdEokIACfiJdKg=", + "dev": true + }, + "plugin-error": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/plugin-error/-/plugin-error-1.0.1.tgz", + "integrity": "sha512-L1zP0dk7vGweZME2i+EeakvUNqSrdiI3F91TwEoYiGrAfUXmVv6fJIq4g82PAXxNsWOp0J7ZqQy/3Szz0ajTxA==", + "dev": true, + "requires": { + "ansi-colors": "^1.0.1", + "arr-diff": "^4.0.0", + "arr-union": "^3.1.0", + "extend-shallow": "^3.0.2" + } + } } }, "gulp-typescript": { @@ -7468,9 +7567,9 @@ } }, "now-and-later": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/now-and-later/-/now-and-later-2.0.0.tgz", - "integrity": "sha1-vGHLtFbXnLMiB85HygUTb/Ln1u4=", + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/now-and-later/-/now-and-later-2.0.1.tgz", + "integrity": "sha512-KGvQ0cB70AQfg107Xvs/Fbu+dGmZoTRJp2TaPwcwQm3/7PteUyN2BCgk8KBMPGBUXZdVwyWS8fDCGFygBm19UQ==", "dev": true, "requires": { "once": "^1.3.2" @@ -7545,9 +7644,9 @@ } }, "object-keys": { - "version": "1.0.12", - "resolved": "https://registry.npmjs.org/object-keys/-/object-keys-1.0.12.tgz", - "integrity": "sha512-FTMyFUm2wBcGHnH2eXmz7tC6IwlqQZ6mVZ+6dm6vZ4IQIHjs6FdNsQBuKGPuUUUY6NfJw2PshC08Tn6LzLDOag==", + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/object-keys/-/object-keys-1.1.1.tgz", + "integrity": "sha512-NuAESUOUMrlIXOfHKzD6bpPu3tYt3xvjNdRIQ+FeT0lNb4K8WR70CaDxhuNguS2XG+GjkyMwOzsN5ZktImfhLA==", "dev": true }, "object-visit": { @@ -9702,53 +9801,131 @@ "integrity": "sha1-yy4SAwZ+DI3h9hQJS5/kVwTqYAM=", "dev": true }, + "tslib": { + "version": "1.9.3", + "resolved": "https://registry.npmjs.org/tslib/-/tslib-1.9.3.tgz", + "integrity": "sha512-4krF8scpejhaOgqzBEcGM7yDIEfi0/8+8zDRZhNZZ2kjmHJ4hv3zCbQWxoJGz1iw5U0Jl0nma13xzHXcncMavQ==", + "dev": true + }, "tslint": { - "version": "3.15.1", - "resolved": "https://registry.npmjs.org/tslint/-/tslint-3.15.1.tgz", - "integrity": "sha1-2hZcqT2P3CwIa1EWXuG6y0jJjqU=", + "version": "5.16.0", + "resolved": "https://registry.npmjs.org/tslint/-/tslint-5.16.0.tgz", + "integrity": "sha512-UxG2yNxJ5pgGwmMzPMYh/CCnCnh0HfPgtlVRDs1ykZklufFBL1ZoTlWFRz2NQjcoEiDoRp+JyT0lhBbbH/obyA==", "dev": true, "requires": { - "colors": "^1.1.2", - "diff": "^2.2.1", - "findup-sync": "~0.3.0", - "glob": "^7.0.3", - "optimist": "~0.6.0", - "resolve": "^1.1.7", - "underscore.string": "^3.3.4" + "@babel/code-frame": "^7.0.0", + "builtin-modules": "^1.1.1", + "chalk": "^2.3.0", + "commander": "^2.12.1", + "diff": "^3.2.0", + "glob": "^7.1.1", + "js-yaml": "^3.13.0", + "minimatch": "^3.0.4", + "mkdirp": "^0.5.1", + "resolve": "^1.3.2", + "semver": "^5.3.0", + "tslib": "^1.8.0", + "tsutils": "^2.29.0" }, "dependencies": { - "diff": { - "version": "2.2.3", - "resolved": "https://registry.npmjs.org/diff/-/diff-2.2.3.tgz", - "integrity": "sha1-YOr9DSjukG5Oj/ClLBIpUhAzv5k=", - "dev": true - }, - "findup-sync": { - "version": "0.3.0", - "resolved": "https://registry.npmjs.org/findup-sync/-/findup-sync-0.3.0.tgz", - "integrity": "sha1-N5MKpdgWt3fANEXhlmzGeQpMCxY=", + "ansi-styles": { + "version": "3.2.1", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-3.2.1.tgz", + "integrity": "sha512-VT0ZI6kZRdTh8YyJw3SMbYm/u+NqfsAxEpWO0Pf9sq8/e94WxxOpPKx9FR1FlyCtOVDNOQ+8ntlqFxiRc+r5qA==", "dev": true, "requires": { - "glob": "~5.0.0" - }, - "dependencies": { - "glob": { - "version": "5.0.15", - "resolved": "https://registry.npmjs.org/glob/-/glob-5.0.15.tgz", - "integrity": "sha1-G8k2ueAvSmA/zCIuz3Yz0wuLk7E=", - "dev": true, - "requires": { - "inflight": "^1.0.4", - "inherits": "2", - "minimatch": "2 || 3", - "once": "^1.3.0", - "path-is-absolute": "^1.0.0" - } - } + "color-convert": "^1.9.0" + } + }, + "chalk": { + "version": "2.4.2", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-2.4.2.tgz", + "integrity": "sha512-Mti+f9lpJNcwF4tWV8/OrTTtF1gZi+f8FqlyAdouralcFWFQWF2+NgCHShjkCb+IFBLq9buZwE1xckQU4peSuQ==", + "dev": true, + "requires": { + "ansi-styles": "^3.2.1", + "escape-string-regexp": "^1.0.5", + "supports-color": "^5.3.0" + } + }, + "commander": { + "version": "2.20.0", + "resolved": "https://registry.npmjs.org/commander/-/commander-2.20.0.tgz", + "integrity": "sha512-7j2y+40w61zy6YC2iRNpUe/NwhNyoXrYpHMrSunaMG64nRnaf96zO/KMQR4OyN/UnE5KLyEBnKHd4aG3rskjpQ==", + "dev": true + }, + "diff": { + "version": "3.5.0", + "resolved": "https://registry.npmjs.org/diff/-/diff-3.5.0.tgz", + "integrity": "sha512-A46qtFgd+g7pDZinpnwiRJtxbC1hpgf0uzP3iG89scHk0AUC7A1TGxf5OiiOUv/JMZR8GOt8hL900hV0bOy5xA==", + "dev": true + }, + "esprima": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/esprima/-/esprima-4.0.1.tgz", + "integrity": "sha512-eGuFFw7Upda+g4p+QHvnW0RyTX/SVeJBDM/gCtMARO0cLuT2HcEKnTPvhjV6aGeqrCB/sbNop0Kszm0jsaWU4A==", + "dev": true + }, + "has-flag": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-3.0.0.tgz", + "integrity": "sha1-tdRU3CGZriJWmfNGfloH87lVuv0=", + "dev": true + }, + "js-yaml": { + "version": "3.13.1", + "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-3.13.1.tgz", + "integrity": "sha512-YfbcO7jXDdyj0DGxYVSlSeQNHbD7XPWvrVWeVUujrQEoZzWJIRrCPoyk6kL6IAjAG2IolMK4T0hNUe0HOUs5Jw==", + "dev": true, + "requires": { + "argparse": "^1.0.7", + "esprima": "^4.0.0" + } + }, + "semver": { + "version": "5.7.0", + "resolved": "https://registry.npmjs.org/semver/-/semver-5.7.0.tgz", + "integrity": "sha512-Ya52jSX2u7QKghxeoFGpLwCtGlt7j0oY9DYb5apt9nPlJ42ID+ulTXESnt/qAQcoSERyZ5sl3LDIOw0nAn/5DA==", + "dev": true + }, + "supports-color": { + "version": "5.5.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.5.0.tgz", + "integrity": "sha512-QjVjwdXIt408MIiAqCX4oUKsgU2EqAGzs2Ppkm4aQYbjm+ZEWEcW4SfFNTr4uMNZma0ey4f5lgLrkB0aX0QMow==", + "dev": true, + "requires": { + "has-flag": "^3.0.0" + } + }, + "tsutils": { + "version": "2.29.0", + "resolved": "https://registry.npmjs.org/tsutils/-/tsutils-2.29.0.tgz", + "integrity": "sha512-g5JVHCIJwzfISaXpXE1qvNalca5Jwob6FjI4AoPlqMusJ6ftFE7IkkFoMhVLRgK+4Kx3gkzb8UZK5t5yTTvEmA==", + "dev": true, + "requires": { + "tslib": "^1.8.1" } } } }, + "tslint-microsoft-contrib": { + "version": "5.2.0", + "resolved": "https://registry.npmjs.org/tslint-microsoft-contrib/-/tslint-microsoft-contrib-5.2.0.tgz", + "integrity": "sha512-gHVEIkTcMB9lS6UPEgEznV5ZmyhDs/aHyBS9E89S8aJiK1qLv22DmfCcda53S024T+WQkGAhLHUQF4Qn4nzCAA==", + "dev": true, + "requires": { + "tsutils": "^2.12.1 <2.29.0" + } + }, + "tsutils": { + "version": "2.28.0", + "resolved": "https://registry.npmjs.org/tsutils/-/tsutils-2.28.0.tgz", + "integrity": "sha512-bh5nAtW0tuhvOJnx1GLRn5ScraRLICGyJV5wJhtRWOLsxW70Kk5tZtpK3O/hW6LDnqKS9mlUMPZj9fEMJ0gxqA==", + "dev": true, + "requires": { + "tslib": "^1.8.1" + } + }, "tunnel": { "version": "0.0.4", "resolved": "https://registry.npmjs.org/tunnel/-/tunnel-0.0.4.tgz", @@ -9955,16 +10132,6 @@ "resolved": "https://registry.npmjs.org/underscore/-/underscore-1.9.1.tgz", "integrity": "sha512-5/4etnCkd9c8gwgowi5/om/mYO5ajCaOgdzj/oW+0eQV9WxKBDZw5+ycmKmeaTXjInS/W0BzpGLo2xR2aBwZdg==" }, - "underscore.string": { - "version": "3.3.5", - "resolved": "https://registry.npmjs.org/underscore.string/-/underscore.string-3.3.5.tgz", - "integrity": "sha512-g+dpmgn+XBneLmXXo+sGlW5xQEt4ErkS3mgeN2GFbremYeMBSJKr9Wf2KJplQVaiPY/f7FN6atosWYNm9ovrYg==", - "dev": true, - "requires": { - "sprintf-js": "^1.0.3", - "util-deprecate": "^1.0.2" - } - }, "undertaker": { "version": "1.2.1", "resolved": "https://registry.npmjs.org/undertaker/-/undertaker-1.2.1.tgz", diff --git a/package.json b/package.json index 78bd36d3..c06d7473 100644 --- a/package.json +++ b/package.json @@ -69,7 +69,7 @@ "gulp-rename": "^1.2.2", "gulp-shell": "^0.5.2", "gulp-sourcemaps": "^1.6.0", - "gulp-tslint": "^6.1.3", + "gulp-tslint": "^8.1.4", "gulp-typescript": "^3.1.4", "gulp-uglify": "^2.0.0", "istanbul": "^0.4.5", @@ -85,7 +85,8 @@ "pm-mocha-jenkins-reporter": "^0.2.6", "remap-istanbul": "^0.6.4", "systemjs-builder": "^0.15.32", - "tslint": "^3.14.0", + "tslint": "^5.16.0", + "tslint-microsoft-contrib": "^5.2.0", "typemoq": "^1.7.0", "typescript": "2.3.4", "uglify-js": "mishoo/UglifyJS2#harmony-v2.8.22", diff --git a/src/controllers/connectionManager.ts b/src/controllers/connectionManager.ts index 9d7442b6..cccc699c 100644 --- a/src/controllers/connectionManager.ts +++ b/src/controllers/connectionManager.ts @@ -331,7 +331,7 @@ export default class ConnectionManager { connection.errorNumber = result.errorNumber; connection.errorMessage = result.errorMessage; } else { - PlatformInformation.GetCurrent().then( platformInfo => { + PlatformInformation.getCurrent().then( platformInfo => { if (!platformInfo.isWindows() && result.errorMessage && result.errorMessage.includes('Kerberos')) { this.vscodeWrapper.showErrorMessage( Utils.formatString(LocalizedConstants.msgConnectionError2, result.errorMessage), diff --git a/src/controllers/localWebService.ts b/src/controllers/localWebService.ts index 438d750c..2c40e652 100644 --- a/src/controllers/localWebService.ts +++ b/src/controllers/localWebService.ts @@ -1,6 +1,6 @@ 'use strict'; import path = require('path'); -import * as ws from 'ws'; +import * as WebSocket from 'ws'; import url = require('url'); import querystring = require('querystring'); import Utils = require('../models/utils'); @@ -9,10 +9,10 @@ import Interfaces = require('../models/interfaces'); import http = require('http'); const bodyParser = require('body-parser'); const express = require('express'); -const WebSocketServer = ws.Server; +const webSocketServer = WebSocket.Server; class WebSocketMapping { - public webSocketServer: ws; + public webSocketServer: WebSocket; public pendingMessages: Array = []; } @@ -24,7 +24,7 @@ class WebSocketMessage { export default class LocalWebService { private app = express(); private server = http.createServer(); - private wss = new WebSocketServer({ server: this.server}); + private wss = new webSocketServer({ server: this.server}); private wsMap = new Map(); static _servicePort: string; static _vscodeExtensionPath: string; @@ -78,7 +78,7 @@ export default class LocalWebService { } static getEndpointUri(type: Interfaces.ContentType): string { - return this.serviceUrl + '/' + Interfaces.ContentTypes[type]; + return this.serviceUrl + '/' + Interfaces.contentTypes[type]; } broadcast(uri: string, event: string, data?: any): void { @@ -98,7 +98,7 @@ export default class LocalWebService { this.wsMap.set(uri, mapping); } else { // Make sure the web socket server is open, then fire away - if (mapping.webSocketServer && mapping.webSocketServer.readyState === ws.OPEN) { + if (mapping.webSocketServer && mapping.webSocketServer.readyState === WebSocket.OPEN) { mapping.webSocketServer.send(JSON.stringify(message)); } } @@ -118,12 +118,12 @@ export default class LocalWebService { } addHandler(type: Interfaces.ContentType, handler: (req, res) => void): void { - let segment = '/' + Interfaces.ContentTypes[type]; + let segment = '/' + Interfaces.contentTypes[type]; this.app.get(segment, handler); } addPostHandler(type: Interfaces.ContentType, handler: (req, res) => void): void { - let segment = '/' + Interfaces.ContentTypes[type]; + let segment = '/' + Interfaces.contentTypes[type]; this.app.post(segment, handler); } diff --git a/src/controllers/queryRunner.ts b/src/controllers/queryRunner.ts index d212839d..d394f0ad 100644 --- a/src/controllers/queryRunner.ts +++ b/src/controllers/queryRunner.ts @@ -33,8 +33,6 @@ export default class QueryRunner { // MEMBER VARIABLES //////////////////////////////////////////////////// private _batchSets: BatchSummary[] = []; private _isExecuting: boolean; - private _uri: string; - private _title: string; private _resultLineOffset: number; private _totalElapsedMilliseconds: number; private _hasCompleted: boolean; @@ -61,8 +59,6 @@ export default class QueryRunner { } // Store the state - this._uri = _ownerUri; - this._title = _editorTitle; this._isExecuting = false; this._totalElapsedMilliseconds = 0; this._hasCompleted = false; @@ -71,19 +67,19 @@ export default class QueryRunner { // PROPERTIES ////////////////////////////////////////////////////////// get uri(): string { - return this._uri; + return this._ownerUri; } set uri(uri: string) { - this._uri = uri; + this._ownerUri = uri; } get title(): string { - return this._title; + return this._editorTitle; } set title(title: string) { - this._title = title; + this._editorTitle = title; } get batchSets(): BatchSummary[] { @@ -106,7 +102,7 @@ export default class QueryRunner { public cancel(): Thenable { // Make the request to cancel the query - let cancelParams: QueryCancelParams = { ownerUri: this._uri }; + let cancelParams: QueryCancelParams = { ownerUri: this._ownerUri }; return this._client.sendRequest(QueryCancelRequest.type, cancelParams); } @@ -117,7 +113,7 @@ export default class QueryRunner { (onSuccess, onError) => { // Put together the request let queryDetails: QueryExecuteStatementParams = { - ownerUri: this._uri, + ownerUri: this._ownerUri, line: line, column: column }; @@ -134,7 +130,7 @@ export default class QueryRunner { (onSuccess, onError) => { // Put together the request let queryDetails: QueryExecuteParams = { - ownerUri: this._uri, + ownerUri: this._ownerUri, querySelection: selection }; @@ -146,7 +142,7 @@ export default class QueryRunner { // Pulls the query text from the current document/selection and initiates the query private doRunQuery(selection: ISelectionData, queryCallback: any): Thenable { const self = this; - this._vscodeWrapper.logToOutputChannel(Utils.formatString(LocalizedConstants.msgStartedExecute, this._uri)); + this._vscodeWrapper.logToOutputChannel(Utils.formatString(LocalizedConstants.msgStartedExecute, this._ownerUri)); // Update internal state to show that we're executing the query this._resultLineOffset = selection ? selection.startLine : 0; @@ -157,7 +153,7 @@ export default class QueryRunner { let onSuccess = (result) => { // The query has started, so lets fire up the result pane self.eventEmitter.emit('start'); - self._notificationHandler.registerRunner(self, self._uri); + self._notificationHandler.registerRunner(self, self._ownerUri); }; let onError = (error) => { self._statusView.executedQuery(self.uri); @@ -171,7 +167,7 @@ export default class QueryRunner { // handle the result of the notification public handleQueryComplete(result: QueryExecuteCompleteNotificationResult): void { - this._vscodeWrapper.logToOutputChannel(Utils.formatString(LocalizedConstants.msgFinishedExecute, this._uri)); + this._vscodeWrapper.logToOutputChannel(Utils.formatString(LocalizedConstants.msgFinishedExecute, this._ownerUri)); // Store the batch sets we got back as a source of "truth" this._isExecuting = false; @@ -422,7 +418,7 @@ export default class QueryRunner { } // public for testing only - used to mock handleQueryComplete - public _setHasCompleted(): void { + public setHasCompleted(): void { this._hasCompleted = true; } diff --git a/src/languageservice/proxy.ts b/src/languageservice/proxy.ts index 4e560187..53f90e04 100644 --- a/src/languageservice/proxy.ts +++ b/src/languageservice/proxy.ts @@ -6,8 +6,8 @@ 'use strict'; import { Url, parse as parseUrl } from 'url'; -let HttpProxyAgent = require('http-proxy-agent'); -let HttpsProxyAgent = require('https-proxy-agent'); +let httpProxyAgent = require('http-proxy-agent'); +let httpsProxyAgent = require('https-proxy-agent'); function getSystemProxyURL(requestURL: Url): string { if (requestURL.protocol === 'http:') { @@ -46,5 +46,5 @@ export function getProxyAgent(requestURL: Url, proxy?: string, strictSSL?: boole rejectUnauthorized: isBoolean(strictSSL) ? strictSSL : true }; - return requestURL.protocol === 'http:' ? new HttpProxyAgent(opts) : new HttpsProxyAgent(opts); + return requestURL.protocol === 'http:' ? new httpProxyAgent(opts) : new httpsProxyAgent(opts); } diff --git a/src/languageservice/serverStatus.ts b/src/languageservice/serverStatus.ts index 9104e00e..7cb844eb 100644 --- a/src/languageservice/serverStatus.ts +++ b/src/languageservice/serverStatus.ts @@ -22,11 +22,11 @@ export class ServerInitializationResult { } - public Clone(): ServerInitializationResult { + public clone(): ServerInitializationResult { return new ServerInitializationResult(this.installedBeforeInitializing, this.isRunning, this.serverPath); } - public WithRunning(isRunning: Boolean): ServerInitializationResult { + public withRunning(isRunning: Boolean): ServerInitializationResult { return new ServerInitializationResult(this.installedBeforeInitializing, isRunning, this.serverPath); } } diff --git a/src/languageservice/serviceDownloadProvider.ts b/src/languageservice/serviceDownloadProvider.ts index 3dbc9477..dfa530fb 100644 --- a/src/languageservice/serviceDownloadProvider.ts +++ b/src/languageservice/serviceDownloadProvider.ts @@ -128,12 +128,12 @@ export default class ServiceDownloadProvider { private createTempFile(pkg: IPackage): Promise { return new Promise((resolve, reject) => { - tmp.file({ prefix: 'package-' }, (err, path, fd, cleanupCallback) => { + tmp.file({ prefix: 'package-' }, (err, filePath, fd, cleanupCallback) => { if (err) { return reject(new PackageError('Error from tmp.file', pkg, err)); } - resolve({ name: path, fd: fd, removeCallback: cleanupCallback }); + resolve({ name: filePath, fd: fd, removeCallback: cleanupCallback }); }); }); } diff --git a/src/languageservice/serviceInstallerUtil.ts b/src/languageservice/serviceInstallerUtil.ts index 38089e78..a7dcec23 100644 --- a/src/languageservice/serviceInstallerUtil.ts +++ b/src/languageservice/serviceInstallerUtil.ts @@ -63,7 +63,7 @@ let serverProvider = new ServerProvider(downloadProvider, config, statusView); */ export function installService(runtime: Runtime): Promise { if (runtime === undefined) { - return PlatformInformation.GetCurrent().then( platformInfo => { + return PlatformInformation.getCurrent().then( platformInfo => { if (platformInfo.isValidRuntime()) { return serverProvider.getOrDownloadServer(platformInfo.runtimeId); } else { @@ -81,7 +81,7 @@ export function installService(runtime: Runtime): Promise { export function getServiceInstallDirectory(runtime: Runtime): Promise { return new Promise((resolve, reject) => { if (runtime === undefined) { - PlatformInformation.GetCurrent().then( platformInfo => { + PlatformInformation.getCurrent().then( platformInfo => { if (platformInfo.isValidRuntime()) { resolve(downloadProvider.getInstallDirectory(platformInfo.runtimeId)); } else { diff --git a/src/languageservice/serviceclient.ts b/src/languageservice/serviceclient.ts index 5eb7df4f..bae4523f 100644 --- a/src/languageservice/serviceclient.ts +++ b/src/languageservice/serviceclient.ts @@ -151,7 +151,7 @@ export default class SqlToolsServiceClient { public initialize(context: ExtensionContext): Promise { this._logger.appendLine(Constants.serviceInitializing); - return PlatformInformation.GetCurrent().then( platformInfo => { + return PlatformInformation.getCurrent().then( platformInfo => { return this.initializeForPlatform(platformInfo, context); }); } @@ -346,6 +346,7 @@ export default class SqlToolsServiceClient { * @param params The params to pass with the request * @returns A thenable object for when the request receives a response */ + // tslint:disable-next-line:no-unused-variable public sendRequest(type: RequestType, params?: P): Thenable { if (this.client !== undefined) { return this.client.sendRequest(type, params); @@ -356,6 +357,7 @@ export default class SqlToolsServiceClient { * Send a notification to the service client * @param params The params to pass with the notification */ + // tslint:disable-next-line:no-unused-variable public sendNotification(type: NotificationType, params?: P): void { if (this.client !== undefined) { this.client.sendNotification(type, params); @@ -367,6 +369,7 @@ export default class SqlToolsServiceClient { * @param type The notification type to register the handler for * @param handler The handler to register */ + // tslint:disable-next-line:no-unused-variable public onNotification(type: NotificationType, handler: NotificationHandler

): void { if (this._client !== undefined) { return this.client.onNotification(type, handler); diff --git a/src/models/connectionStore.ts b/src/models/connectionStore.ts index eabc9030..f113cc4e 100644 --- a/src/models/connectionStore.ts +++ b/src/models/connectionStore.ts @@ -43,8 +43,8 @@ export class ConnectionStore { public static get CRED_DB_PREFIX(): string { return 'db:'; } public static get CRED_USER_PREFIX(): string { return 'user:'; } public static get CRED_ITEMTYPE_PREFIX(): string { return 'itemtype:'; } - public static get CRED_PROFILE_USER(): string { return CredentialsQuickPickItemType[CredentialsQuickPickItemType.Profile]; }; - public static get CRED_MRU_USER(): string { return CredentialsQuickPickItemType[CredentialsQuickPickItemType.Mru]; }; + public static get CRED_PROFILE_USER(): string { return CredentialsQuickPickItemType[CredentialsQuickPickItemType.Profile]; } + public static get CRED_MRU_USER(): string { return CredentialsQuickPickItemType[CredentialsQuickPickItemType.Mru]; } public static formatCredentialIdForCred(creds: IConnectionCredentials, itemType?: CredentialsQuickPickItemType): string { if (Utils.isEmpty(creds)) { diff --git a/src/models/interfaces.ts b/src/models/interfaces.ts index 6fd63706..9546c565 100644 --- a/src/models/interfaces.ts +++ b/src/models/interfaces.ts @@ -17,7 +17,7 @@ export enum ContentType { ShowWarning = 10, Config = 11, LocalizedTexts = 12 -}; +} export interface ISlickRange { fromCell: number; @@ -32,7 +32,7 @@ export enum AuthenticationTypes { ActiveDirectoryUniversal = 3 } -export const ContentTypes = [ +export const contentTypes = [ Constants.outputContentTypeRoot, Constants.outputContentTypeMessages, Constants.outputContentTypeResultsetMeta, @@ -212,14 +212,14 @@ export enum CredentialsQuickPickItemType { export interface IConnectionCredentialsQuickPickItem extends vscode.QuickPickItem { connectionCreds: IConnectionCredentials; quickPickItemType: CredentialsQuickPickItemType; -}; +} // Obtained from an active connection to show in the status bar export interface IConnectionProperties { serverVersion: string; currentUser: string; currentDatabase: string; -}; +} export interface IDbColumn { allowDBNull?: boolean; diff --git a/src/models/logger.ts b/src/models/logger.ts index 08ec4269..6b28e4de 100644 --- a/src/models/logger.ts +++ b/src/models/logger.ts @@ -26,7 +26,7 @@ export class Logger implements ILogger { Utils.logDebug(message); } - private _appendCore(message: string): void { + private appendCore(message: string): void { if (this._atLineStart) { if (this._indentLevel > 0) { const indent = ' '.repeat(this._indentLevel * this._indentSize); @@ -55,12 +55,12 @@ export class Logger implements ILogger { public append(message?: string): void { message = message || ''; - this._appendCore(message); + this.appendCore(message); } public appendLine(message?: string): void { message = message || ''; - this._appendCore(message + os.EOL); + this.appendCore(message + os.EOL); this._atLineStart = true; } } diff --git a/src/models/platform.ts b/src/models/platform.ts index cb01444e..340ee886 100644 --- a/src/models/platform.ts +++ b/src/models/platform.ts @@ -58,6 +58,80 @@ export function getRuntimeDisplayName(runtime: Runtime): string { } } +/** + * There is no standard way on Linux to find the distribution name and version. + * Recently, systemd has pushed to standardize the os-release file. This has + * seen adoption in "recent" versions of all major distributions. + * https://www.freedesktop.org/software/systemd/man/os-release.html + */ +export class LinuxDistribution { + public constructor( + public name: string, + public version: string, + public idLike?: string[]) { } + + public static getCurrent(): Promise { + // Try /etc/os-release and fallback to /usr/lib/os-release per the synopsis + // at https://www.freedesktop.org/software/systemd/man/os-release.html. + return LinuxDistribution.fromFilePath('/etc/os-release') + .catch(() => LinuxDistribution.fromFilePath('/usr/lib/os-release')) + .catch(() => Promise.resolve(new LinuxDistribution(unknown, unknown))); + } + + public toString(): string { + return `name=${this.name}, version=${this.version}`; + } + + private static fromFilePath(filePath: string): Promise { + return new Promise((resolve, reject) => { + fs.readFile(filePath, 'utf8', (error, data) => { + if (error) { + reject(error); + } else { + resolve(LinuxDistribution.fromReleaseInfo(data)); + } + }); + }); + } + + public static fromReleaseInfo(releaseInfo: string, eol: string = os.EOL): LinuxDistribution { + let name = unknown; + let version = unknown; + let idLike: string[] = undefined; + + const lines = releaseInfo.split(eol); + for (let line of lines) { + line = line.trim(); + + let equalsIndex = line.indexOf('='); + if (equalsIndex >= 0) { + let key = line.substring(0, equalsIndex); + let value = line.substring(equalsIndex + 1); + + // Strip quotes if necessary + if (value.length > 1 && value.startsWith('"') && value.endsWith('"')) { + value = value.substring(1, value.length - 1); + } else if (value.length > 1 && value.startsWith('\'') && value.endsWith('\'')) { + value = value.substring(1, value.length - 1); + } + + if (key === 'ID') { + name = value; + } else if (key === 'VERSION_ID') { + version = value; + } else if (key === 'ID_LIKE') { + idLike = value.split(' '); + } + + if (name !== unknown && version !== unknown && idLike !== undefined) { + break; + } + } + } + + return new LinuxDistribution(name, version, idLike); + } +} export class PlatformInformation { public runtimeId: Runtime; @@ -128,25 +202,25 @@ export class PlatformInformation { return result; } - public static GetCurrent(): Promise { + public static getCurrent(): Promise { let platform = os.platform(); let architecturePromise: Promise; let distributionPromise: Promise; switch (platform) { case 'win32': - architecturePromise = PlatformInformation.GetWindowsArchitecture(); + architecturePromise = PlatformInformation.getWindowsArchitecture(); distributionPromise = Promise.resolve(undefined); break; case 'darwin': - architecturePromise = PlatformInformation.GetUnixArchitecture(); + architecturePromise = PlatformInformation.getUnixArchitecture(); distributionPromise = Promise.resolve(undefined); break; case 'linux': - architecturePromise = PlatformInformation.GetUnixArchitecture(); - distributionPromise = LinuxDistribution.GetCurrent(); + architecturePromise = PlatformInformation.getUnixArchitecture(); + distributionPromise = LinuxDistribution.getCurrent(); break; default: @@ -160,7 +234,7 @@ export class PlatformInformation { }); } - private static GetWindowsArchitecture(): Promise { + private static getWindowsArchitecture(): Promise { return new Promise((resolve, reject) => { if (process.env.PROCESSOR_ARCHITECTURE === 'x86' && process.env.PROCESSOR_ARCHITEW6432 === undefined) { resolve('x86'); @@ -170,7 +244,7 @@ export class PlatformInformation { }); } - private static GetUnixArchitecture(): Promise { + private static getUnixArchitecture(): Promise { return this.execChildProcess('uname -m') .then(architecture => { if (architecture) { @@ -320,78 +394,3 @@ export class PlatformInformation { } } -/** - * There is no standard way on Linux to find the distribution name and version. - * Recently, systemd has pushed to standardize the os-release file. This has - * seen adoption in "recent" versions of all major distributions. - * https://www.freedesktop.org/software/systemd/man/os-release.html - */ -export class LinuxDistribution { - public constructor( - public name: string, - public version: string, - public idLike?: string[]) { } - - public static GetCurrent(): Promise { - // Try /etc/os-release and fallback to /usr/lib/os-release per the synopsis - // at https://www.freedesktop.org/software/systemd/man/os-release.html. - return LinuxDistribution.FromFilePath('/etc/os-release') - .catch(() => LinuxDistribution.FromFilePath('/usr/lib/os-release')) - .catch(() => Promise.resolve(new LinuxDistribution(unknown, unknown))); - } - - public toString(): string { - return `name=${this.name}, version=${this.version}`; - } - - private static FromFilePath(filePath: string): Promise { - return new Promise((resolve, reject) => { - fs.readFile(filePath, 'utf8', (error, data) => { - if (error) { - reject(error); - } else { - resolve(LinuxDistribution.FromReleaseInfo(data)); - } - }); - }); - } - - public static FromReleaseInfo(releaseInfo: string, eol: string = os.EOL): LinuxDistribution { - let name = unknown; - let version = unknown; - let idLike: string[] = undefined; - - const lines = releaseInfo.split(eol); - for (let line of lines) { - line = line.trim(); - - let equalsIndex = line.indexOf('='); - if (equalsIndex >= 0) { - let key = line.substring(0, equalsIndex); - let value = line.substring(equalsIndex + 1); - - // Strip quotes if necessary - if (value.length > 1 && value.startsWith('"') && value.endsWith('"')) { - value = value.substring(1, value.length - 1); - } else if (value.length > 1 && value.startsWith('\'') && value.endsWith('\'')) { - value = value.substring(1, value.length - 1); - } - - if (key === 'ID') { - name = value; - } else if (key === 'VERSION_ID') { - version = value; - } else if (key === 'ID_LIKE') { - idLike = value.split(' '); - } - - if (name !== unknown && version !== unknown && idLike !== undefined) { - break; - } - } - } - - return new LinuxDistribution(name, version, idLike); - } -} - diff --git a/src/models/propertyUpdater.ts b/src/models/propertyUpdater.ts index db312817..29890f5f 100644 --- a/src/models/propertyUpdater.ts +++ b/src/models/propertyUpdater.ts @@ -13,7 +13,7 @@ export class PropertyUpdater { private propertySetter: (obj: T, input: string) => void) { } - public static CreateQuickPickUpdater( + public static createQuickPickUpdater( quickPickOptions: QuickPickOptions, propertyChecker: (obj: T) => boolean, propertySetter: (obj: T, input: string) => void): PropertyUpdater { @@ -21,7 +21,7 @@ export class PropertyUpdater { return new PropertyUpdater(undefined, quickPickOptions, propertyChecker, propertySetter); } - public static CreateInputBoxUpdater( + public static createInputBoxUpdater( inputBoxOptions: InputBoxOptions, propertyChecker: (obj: T) => boolean, propertySetter: (obj: T, input: string) => void): PropertyUpdater { diff --git a/src/models/sqlOutputContentProvider.ts b/src/models/sqlOutputContentProvider.ts index aed988ba..6d888367 100644 --- a/src/models/sqlOutputContentProvider.ts +++ b/src/models/sqlOutputContentProvider.ts @@ -610,7 +610,7 @@ export class SqlOutputContentProvider { viewColumn = vscode.ViewColumn.Two; } else { viewColumn = vscode.ViewColumn.Three; - }; + } } return viewColumn; diff --git a/src/models/telemetry.ts b/src/models/telemetry.ts index 0ac117d9..4e93d8ec 100644 --- a/src/models/telemetry.ts +++ b/src/models/telemetry.ts @@ -31,7 +31,7 @@ export namespace Telemetry { return Promise.resolve(platformInformation); } else { return new Promise(resolve => { - PlatformInformation.GetCurrent().then(info => { + PlatformInformation.getCurrent().then(info => { platformInformation = info; resolve(platformInformation); }); @@ -73,7 +73,7 @@ export namespace Telemetry { /** * Filters error paths to only include source files. Exported to support testing */ - export function FilterErrorPath(line: string): string { + export function filterErrorPath(line: string): string { if (line) { let values: string[] = line.split('/out/'); if (values.length <= 1) { @@ -97,7 +97,7 @@ export namespace Telemetry { stackArray = err.stack.split('\n'); if (stackArray !== undefined && stackArray.length >= 2) { firstLine = stackArray[1]; // The fist line is the error message and we don't want to send that telemetry event - firstLine = FilterErrorPath(firstLine); + firstLine = filterErrorPath(firstLine); } } diff --git a/src/prompts/progressIndicator.ts b/src/prompts/progressIndicator.ts index f7f1e385..85c06ae4 100644 --- a/src/prompts/progressIndicator.ts +++ b/src/prompts/progressIndicator.ts @@ -49,22 +49,22 @@ export default class ProgressIndicator { clearInterval(this._interval); this._interval = undefined; } - this.ProgressCounter = 0; + this.progressCounter = 0; } - private ProgressText = ['|', '/', '-', '\\', '|', '/', '-', '\\']; - private ProgressCounter = 0; + private progressText = ['|', '/', '-', '\\', '|', '/', '-', '\\']; + private progressCounter = 0; private onDisplayProgressIndicator(): void { if (this._tasks.length === 0) { return; } - let txt = this.ProgressText[this.ProgressCounter]; + let txt = this.progressText[this.progressCounter]; this._statusBarItem.text = this._tasks[this._tasks.length - 1] + ' ' + txt; - this.ProgressCounter++; + this.progressCounter++; - if (this.ProgressCounter >= this.ProgressText.length - 1) { - this.ProgressCounter = 0; + if (this.progressCounter >= this.progressText.length - 1) { + this.progressCounter = 0; } } } diff --git a/src/views/htmlcontent/src/js/components/app.component.ts b/src/views/htmlcontent/src/js/components/app.component.ts index 947acb95..a8e56767 100644 --- a/src/views/htmlcontent/src/js/components/app.component.ts +++ b/src/views/htmlcontent/src/js/components/app.component.ts @@ -28,11 +28,6 @@ enableProdMode(); // text selection helper library declare let rangy; -enum SelectedTab { - Results = 0, - Messages = 1, -} - interface IGridDataSet { dataRows: IObservableCollection; columnDefinitions: IColumnDefinition[]; @@ -342,7 +337,7 @@ export class AppComponent implements OnInit, AfterViewChecked { self.totalElapsedTimeSpan = event.data; self.complete = true; self.messagesAdded = true; - break; + break; case 'message': self.messages.push(event.data); break; @@ -350,7 +345,7 @@ export class AppComponent implements OnInit, AfterViewChecked { let resultSet = event.data; // Setup a function for generating a promise to lookup result subsets - let loadDataFunction = (offset: number, count: number) : Promise => { + let loadDataFunction = (offset: number, count: number): Promise => { return new Promise((resolve, reject) => { self.dataService.getRows(offset, count, resultSet.batchId, resultSet.id).subscribe(rows => { let gridData: IGridDataRow[] = []; @@ -411,10 +406,10 @@ export class AppComponent implements OnInit, AfterViewChecked { self.placeHolderDataSets.push(undefinedDataSet); self.messagesAdded = true; self.onScroll(0); - break; + break; default: console.error('Unexpected web socket event type "' + event.type + '" sent'); - break; + break; } }); } diff --git a/src/views/htmlcontent/src/js/slick.autosizecolumn.ts b/src/views/htmlcontent/src/js/slick.autosizecolumn.ts index 5babdb8e..9d820655 100644 --- a/src/views/htmlcontent/src/js/slick.autosizecolumn.ts +++ b/src/views/htmlcontent/src/js/slick.autosizecolumn.ts @@ -4,11 +4,11 @@ $.extend(true, window, { 'Slick': { - 'AutoColumnSize': AutoColumnSize + 'AutoColumnSize': autoColumnSize } }); - function AutoColumnSize(maxWidth): any { + function autoColumnSize(maxWidth): any { let grid: any; let $container: JQuery; diff --git a/src/views/htmlcontent/src/js/slick.dragrowselector.ts b/src/views/htmlcontent/src/js/slick.dragrowselector.ts index b34b53fc..be02f653 100644 --- a/src/views/htmlcontent/src/js/slick.dragrowselector.ts +++ b/src/views/htmlcontent/src/js/slick.dragrowselector.ts @@ -6,11 +6,11 @@ declare let Slick; // register namespace $.extend(true, window, { 'Slick': { - 'DragRowSelectionModel': DragRowSelectionModel + 'DragRowSelectionModel': dragRowSelectionModel } }); - function DragRowSelectionModel(): any { + function dragRowSelectionModel(): any { const keyColResizeIncr = 5; let _grid; diff --git a/src/views/htmlcontent/test/dragrowselection.spec.ts b/src/views/htmlcontent/test/dragrowselection.spec.ts index 24060591..444913a2 100644 --- a/src/views/htmlcontent/test/dragrowselection.spec.ts +++ b/src/views/htmlcontent/test/dragrowselection.spec.ts @@ -2,10 +2,6 @@ import { TestBed, ComponentFixture, async } from '@angular/core/testing'; import { Component, OnInit, ViewChild } from '@angular/core'; import { SlickGrid, VirtualizedCollection, IGridDataRow, IColumnDefinition, FieldType } from 'angular2-slickgrid'; -import * as TestUtils from './testUtils'; - -declare let Slick; - @Component({ template: ` { + var program = tslint.Linter.createProgram(config.paths.html.root + '/tsconfig.json'); return gulp.src([ - config.paths.html.root + '/src/**/*.ts' + config.paths.html.root + '/src/**/*.ts', + config.paths.html.root + '/test/**/*.ts' ]) - .pipe((tslint({ + .pipe((gulpTsLint({ + program, formatter: "verbose" }))) - .pipe(tslint.report()); + .pipe(gulpTsLint.report()); }); // Compile TypeScript to JS diff --git a/test/connectionStore.test.ts b/test/connectionStore.test.ts index 5d3b78db..250decf6 100644 --- a/test/connectionStore.test.ts +++ b/test/connectionStore.test.ts @@ -124,8 +124,8 @@ suite('ConnectionStore tests', () => { let connectionStore = new ConnectionStore(context.object, credentialStore.object, connectionConfig.object); // When SaveProfile is called with savePassword false - let profile: interfaces.IConnectionProfile = Object.assign(new ConnectionProfile(), defaultNamedProfile, { savePassword: false }); - return connectionStore.saveProfile(profile) + let connectionProfile: interfaces.IConnectionProfile = Object.assign(new ConnectionProfile(), defaultNamedProfile, { savePassword: false }); + return connectionStore.saveProfile(connectionProfile) .then(savedProfile => { // Then expect password not saved in either the context object or the credential store assert.ok(credsToSave !== undefined && credsToSave.length === 1); @@ -163,9 +163,9 @@ suite('ConnectionStore tests', () => { let connectionStore = new ConnectionStore(context.object, credentialStore.object, connectionConfig.object); // When SaveProfile is called with savePassword true - let profile: interfaces.IConnectionProfile = Object.assign(new ConnectionProfile(), defaultNamedProfile, { savePassword: true }); + let connectionProfile: interfaces.IConnectionProfile = Object.assign(new ConnectionProfile(), defaultNamedProfile, { savePassword: true }); - connectionStore.saveProfile(profile) + connectionStore.saveProfile(connectionProfile) .then(savedProfile => { // Then expect password saved in the credential store assert.ok(credsToSave !== undefined && credsToSave.length === 1); @@ -509,23 +509,23 @@ suite('ConnectionStore tests', () => { assert.equal(items.length, expectedCount); // Then expect recent items first - let i = 0; + let idx = 0; for (let recentItem of recentlyUsed) { - assert.equal(items[i].connectionCreds, recentItem); - assert.equal(items[i].quickPickItemType, interfaces.CredentialsQuickPickItemType.Mru); - i++; + assert.equal(items[idx].connectionCreds, recentItem); + assert.equal(items[idx].quickPickItemType, interfaces.CredentialsQuickPickItemType.Mru); + idx++; } // Then profile items (that aren't already in MRU) for (let profile of profiles) { if (profile.profileName === defaultNamedProfile.profileName) { continue; } - assert.equal(items[i].connectionCreds, profile); - assert.equal(items[i].quickPickItemType, interfaces.CredentialsQuickPickItemType.Profile); - i++; + assert.equal(items[idx].connectionCreds, profile); + assert.equal(items[idx].quickPickItemType, interfaces.CredentialsQuickPickItemType.Profile); + idx++; } // then new connection - assert.equal(items[i].quickPickItemType, interfaces.CredentialsQuickPickItemType.NewConnection); + assert.equal(items[idx].quickPickItemType, interfaces.CredentialsQuickPickItemType.NewConnection); // Then test is complete done(); diff --git a/test/istanbultestrunner.ts b/test/istanbultestrunner.ts index 010f603d..2b58a4ff 100644 --- a/test/istanbultestrunner.ts +++ b/test/istanbultestrunner.ts @@ -32,74 +32,12 @@ function configure(mochaOpts, testOpts): void { } exports.configure = configure; -function _mkDirIfExists(dir: string): void { +function mkDirIfExists(dir: string): void { if (!fs.existsSync(dir)) { fs.mkdirSync(dir); } } -function _readCoverOptions(testsRoot: string): ITestRunnerOptions { - let coverConfigPath = paths.join(testsRoot, testOptions.coverConfig); - let coverConfig: ITestRunnerOptions = undefined; - if (fs.existsSync(coverConfigPath)) { - let configContent = fs.readFileSync(coverConfigPath); - coverConfig = JSON.parse(configContent); - } - return coverConfig; -} - -function run(testsRoot, clb): any { - // Enable source map support - require('source-map-support').install(); - - // Read configuration for the coverage file - let coverOptions: ITestRunnerOptions = _readCoverOptions(testsRoot); - if (coverOptions && coverOptions.enabled) { - // Setup coverage pre-test, including post-test hook to report - let coverageRunner = new CoverageRunner(coverOptions, testsRoot, clb); - coverageRunner.setupCoverage(); - } - - // Force the extension to activate by running one of our commands - vscode.commands.executeCommand('extension.connect').then(() => { - // Glob test files - glob('**/**.test.js', { cwd: testsRoot }, function (error, files): any { - if (error) { - return clb(error); - } - try { - // Fill into Mocha - files.forEach(function (f): Mocha { - return mocha.addFile(paths.join(testsRoot, f)); - }); - // Run the tests - let failureCount = 0; - - mocha.run() - .on('fail', function (test, err): void { - failureCount++; - }) - .on('end', function (): void { - clb(undefined, failureCount); - }); - } catch (error) { - return clb(error); - } - }); -}); -} -exports.run = run; - -interface ITestRunnerOptions { - enabled?: boolean; - relativeCoverageDir: string; - relativeSourcePath: string; - ignorePatterns: string[]; - includePid?: boolean; - reports?: string[]; - verbose?: boolean; -} - class CoverageRunner { private coverageVar: string = '$$cov_' + new Date().getTime() + '$$'; @@ -107,7 +45,7 @@ class CoverageRunner { private matchFn: any = undefined; private instrumenter: any = undefined; - constructor(private options: ITestRunnerOptions, private testsRoot: string, private endRunCallback: any) { + constructor(private options: ITestRunnerOptions, private testsRoot: string, endRunCallback: any) { if (!options.relativeSourcePath) { return endRunCallback('Error - relativeSourcePath must be defined for code coverage to work'); } @@ -205,7 +143,7 @@ class CoverageRunner { let pidExt = includePid ? ('-' + process.pid) : '', coverageFile = paths.resolve(reportingDir, 'coverage' + pidExt + '.json'); - _mkDirIfExists(reportingDir); // yes, do this again since some test runners could clean the dir initially created + mkDirIfExists(reportingDir); // yes, do this again since some test runners could clean the dir initially created fs.writeFileSync(coverageFile, JSON.stringify(cov), 'utf8'); @@ -226,3 +164,65 @@ class CoverageRunner { } } +function readCoverOptions(testsRoot: string): ITestRunnerOptions { + let coverConfigPath = paths.join(testsRoot, testOptions.coverConfig); + let coverConfig: ITestRunnerOptions = undefined; + if (fs.existsSync(coverConfigPath)) { + let configContent = fs.readFileSync(coverConfigPath); + coverConfig = JSON.parse(configContent); + } + return coverConfig; +} + +function run(testsRoot, clb): any { + // Enable source map support + require('source-map-support').install(); + + // Read configuration for the coverage file + let coverOptions: ITestRunnerOptions = readCoverOptions(testsRoot); + if (coverOptions && coverOptions.enabled) { + // Setup coverage pre-test, including post-test hook to report + let coverageRunner = new CoverageRunner(coverOptions, testsRoot, clb); + coverageRunner.setupCoverage(); + } + + // Force the extension to activate by running one of our commands + vscode.commands.executeCommand('extension.connect').then(() => { + // Glob test files + glob('**/**.test.js', { cwd: testsRoot }, function (error, files): any { + if (error) { + return clb(error); + } + try { + // Fill into Mocha + files.forEach(function (f): Mocha { + return mocha.addFile(paths.join(testsRoot, f)); + }); + // Run the tests + let failureCount = 0; + + mocha.run() + .on('fail', function (test, err): void { + failureCount++; + }) + .on('end', function (): void { + clb(undefined, failureCount); + }); + } catch (error) { + return clb(error); + } + }); +}); +} +exports.run = run; + +interface ITestRunnerOptions { + enabled?: boolean; + relativeCoverageDir: string; + relativeSourcePath: string; + ignorePatterns: string[]; + includePid?: boolean; + reports?: string[]; + verbose?: boolean; +} + diff --git a/test/platform.test.ts b/test/platform.test.ts index 81cdf34b..cd631f30 100644 --- a/test/platform.test.ts +++ b/test/platform.test.ts @@ -4,7 +4,7 @@ import {Runtime, PlatformInformation, LinuxDistribution} from '../src/models/pla import Telemetry from '../src/models/telemetry'; function getPlatform(): Promise { - return PlatformInformation.GetCurrent().then (platformInfo => { + return PlatformInformation.getCurrent().then (platformInfo => { return platformInfo.runtimeId; }); } @@ -141,7 +141,7 @@ HOME_URL="http://www.ubuntu.com/" SUPPORT_URL="http://help.ubuntu.com/" BUG_REPORT_URL="http://bugs.launchpad.net/ubuntu/"`; - return LinuxDistribution.FromReleaseInfo(input, '\n'); + return LinuxDistribution.fromReleaseInfo(input, '\n'); } function distro_ubuntu_14_04_with_quotes(): LinuxDistribution { @@ -157,7 +157,7 @@ HOME_URL='http://www.ubuntu.com/' SUPPORT_URL='http://help.ubuntu.com/' BUG_REPORT_URL='http://bugs.launchpad.net/ubuntu/'`; - return LinuxDistribution.FromReleaseInfo(input, '\n'); + return LinuxDistribution.fromReleaseInfo(input, '\n'); } function distro_fedora_23(): LinuxDistribution { @@ -180,7 +180,7 @@ PRIVACY_POLICY_URL=https://fedoraproject.org/wiki/Legal:PrivacyPolicy VARIANT="Workstation Edition" VARIANT_ID=workstation`; - return LinuxDistribution.FromReleaseInfo(input, '\n'); + return LinuxDistribution.fromReleaseInfo(input, '\n'); } function distro_debian_8(): LinuxDistribution { @@ -195,7 +195,7 @@ HOME_URL="http://www.debian.org/" SUPPORT_URL="http://www.debian.org/support" BUG_REPORT_URL="https://bugs.debian.org/"`; - return LinuxDistribution.FromReleaseInfo(input, '\n'); + return LinuxDistribution.fromReleaseInfo(input, '\n'); } function distro_centos_7(): LinuxDistribution { @@ -217,7 +217,7 @@ CENTOS_MANTISBT_PROJECT_VERSION="7" REDHAT_SUPPORT_PRODUCT="centos" REDHAT_SUPPORT_PRODUCT_VERSION="7"`; - return LinuxDistribution.FromReleaseInfo(input, '\n'); + return LinuxDistribution.fromReleaseInfo(input, '\n'); } function distro_kde_neon_5_8(): LinuxDistribution { @@ -235,7 +235,7 @@ BUG_REPORT_URL="http://bugs.kde.org/" VERSION_CODENAME=xenial UBUNTU_CODENAME=xenial`; - return LinuxDistribution.FromReleaseInfo(input, '\n'); + return LinuxDistribution.fromReleaseInfo(input, '\n'); } function distro_unknown_no_id_like(): LinuxDistribution { @@ -246,5 +246,5 @@ VERSION_ID="1.0" VERSION="1.0 (rogers)" ID=MakeBelieve`; - return LinuxDistribution.FromReleaseInfo(input, '\n'); + return LinuxDistribution.fromReleaseInfo(input, '\n'); } diff --git a/test/queryNotificationHandler.test.ts b/test/queryNotificationHandler.test.ts index e48f2a19..b8117558 100644 --- a/test/queryNotificationHandler.test.ts +++ b/test/queryNotificationHandler.test.ts @@ -44,7 +44,7 @@ suite('QueryNotificationHandler tests', () => { }); runnerMock.setup(x => x.handleQueryComplete(TypeMoq.It.isAny())).callback((event) => { queryCompleteHandlerCalled = true; - runnerMock.object._setHasCompleted(); + runnerMock.object.setHasCompleted(); }); // Get handlers diff --git a/test/stubs.ts b/test/stubs.ts index fc2cd0bf..76b9958f 100644 --- a/test/stubs.ts +++ b/test/stubs.ts @@ -39,11 +39,11 @@ class TestTextEditor implements vscode.TextEditor { viewColumn: vscode.ViewColumn; visibleRanges: vscode.Range[]; - edit(callback: (editBuilder: vscode.TextEditorEdit) => void): Thenable { return undefined; }; - setDecorations(decorationType: vscode.TextEditorDecorationType, rangesOrOptions: vscode.Range[] | vscode.DecorationOptions[]): void { return undefined; }; - revealRange(range: vscode.Range, revealType?: vscode.TextEditorRevealType): void { return undefined; }; - show(column?: vscode.ViewColumn): void { return undefined; }; - hide(): void { return undefined; }; + edit(callback: (editBuilder: vscode.TextEditorEdit) => void): Thenable { return undefined; } + setDecorations(decorationType: vscode.TextEditorDecorationType, rangesOrOptions: vscode.Range[] | vscode.DecorationOptions[]): void { return undefined; } + revealRange(range: vscode.Range, revealType?: vscode.TextEditorRevealType): void { return undefined; } + show(column?: vscode.ViewColumn): void { return undefined; } + hide(): void { return undefined; } insertSnippet(snippet: vscode.SnippetString, location?: vscode.Position | vscode.Range | vscode.Position[] | vscode.Range[], options?: { undoStopBefore: boolean; undoStopAfter: boolean; }): Thenable { return undefined; @@ -146,7 +146,7 @@ class ExpressRequest { startLine?: number, startColumn?: number, endLine?: number, - endColumn?: number, + endColumn?: number }; public body: any; diff --git a/test/telemetry.test.ts b/test/telemetry.test.ts index 62f01d37..17871f2a 100644 --- a/test/telemetry.test.ts +++ b/test/telemetry.test.ts @@ -5,13 +5,13 @@ suite('Telemetry Tests', () => { test('Path before /out/ is stripped', () => { let errorString = '/User/myuser/vscode/extensions/ms-mssql.mssql-0.1.5/out/src/controller/mainController.js:216.45'; let expectedErrorString = 'src/controller/mainController.js:216.45'; - let actualErrorString = Telemetry.FilterErrorPath(errorString); + let actualErrorString = Telemetry.filterErrorPath(errorString); assert.equal(actualErrorString, expectedErrorString); }); test('Path without /out/ is retained', () => { let errorString = '/User/should/never/happen/src/controller/mainController.js:216.45'; - let actualErrorString = Telemetry.FilterErrorPath(errorString); + let actualErrorString = Telemetry.filterErrorPath(errorString); assert.equal(actualErrorString, errorString); }); }); diff --git a/tsconfig.json b/tsconfig.json index acbb5dc5..195ec9cb 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -5,6 +5,7 @@ "target": "ES6", "lib": [ "es6" ], "sourceMap": true, + "allowUnusedLabels": false, "emitDecoratorMetadata": true, "experimentalDecorators": true, "rootDir": ".", diff --git a/tslint.json b/tslint.json index 06a17fbd..7e335464 100644 --- a/tslint.json +++ b/tslint.json @@ -1,4 +1,5 @@ { + "extends": "./tslint.mssdl.required.json", "rules": { "align": [ true, @@ -14,6 +15,11 @@ "curly": true, "eofline": true, "forin": true, + "function-name": [ + true, { + "static-method-regex": "^[a-z][\\w\\d]+$" + } + ], "indent": [ true, "spaces" @@ -21,17 +27,12 @@ "interface-name": true, "jsdoc-format": true, "label-position": true, - "label-undefined": true, "max-line-length": [ true, 160 ], "member-access": false, - "member-ordering": [ - false, - "static-before-instance", - "variables-before-functions" - ], + "member-ordering": false, "no-any": false, "no-arg": true, "no-bitwise": true, @@ -48,10 +49,8 @@ "no-construct": true, "no-constructor-vars": false, "no-debugger": true, - "no-duplicate-key": true, "no-duplicate-variable": true, "no-empty": true, - "no-eval": true, "no-inferrable-types": false, "no-internal-module": true, "no-null-keyword": true, @@ -60,7 +59,6 @@ "no-string-literal": false, "no-switch-case-fall-through": false, "no-trailing-whitespace": true, - "no-unreachable": true, "no-unused-expression": false, "no-unused-variable": true, "no-use-before-declare": true, @@ -113,7 +111,8 @@ "variable-name": [ true, "allow-leading-underscore", - "ban-keywords" + "ban-keywords", + "check-format" ], "whitespace": [ true, diff --git a/tslint.mssdl.required.json b/tslint.mssdl.required.json new file mode 100644 index 00000000..5c898a73 --- /dev/null +++ b/tslint.mssdl.required.json @@ -0,0 +1,24 @@ +{ + "rulesDirectory": "node_modules/tslint-microsoft-contrib", + "rules": { + "no-banned-terms": true, + "no-delete-expression": true, + "no-disable-auto-sanitization": true, + "no-document-domain": true, + "no-duplicate-parameter-names": true, + "no-eval": true, + "no-exec-script": true, + "no-function-constructor-with-string-args": true, + "no-octal-literal": true, + // The actual SDL list includes no-reserved-keywords currently but this has been deprecated + // in tslint-microsoft-contrib in favor of using the ban-keywords option below. So to avoid + // making many unnecessary changes we just use ban-keywords here instead + "no-reserved-keywords": false, + "variable-name": { + "options": ["ban-keywords"] + }, + "no-string-based-set-immediate": true, + "no-string-based-set-interval": true, + "no-string-based-set-timeout": true + } +} \ No newline at end of file