aboutsummaryrefslogtreecommitdiff
path: root/node_modules/tslint/lib/rules/noUnusedVariableRule.js
diff options
context:
space:
mode:
Diffstat (limited to 'node_modules/tslint/lib/rules/noUnusedVariableRule.js')
-rw-r--r--node_modules/tslint/lib/rules/noUnusedVariableRule.js15
1 files changed, 9 insertions, 6 deletions
diff --git a/node_modules/tslint/lib/rules/noUnusedVariableRule.js b/node_modules/tslint/lib/rules/noUnusedVariableRule.js
index e4fab8a3e..02506f434 100644
--- a/node_modules/tslint/lib/rules/noUnusedVariableRule.js
+++ b/node_modules/tslint/lib/rules/noUnusedVariableRule.js
@@ -22,20 +22,19 @@ var ts = require("typescript");
var Lint = require("../index");
var OPTION_CHECK_PARAMETERS = "check-parameters";
var OPTION_IGNORE_PATTERN = "ignore-pattern";
-var Rule = (function (_super) {
+var Rule = /** @class */ (function (_super) {
tslib_1.__extends(Rule, _super);
function Rule() {
return _super !== null && _super.apply(this, arguments) || this;
}
/* tslint:enable:object-literal-sort-keys */
Rule.prototype.applyWithProgram = function (sourceFile, program) {
- var _this = this;
var x = program.getCompilerOptions();
if (x.noUnusedLocals && x.noUnusedParameters) {
console.warn("WARNING: 'no-unused-variable' lint rule does not need to be set if " +
"the 'no-unused-locals' and 'no-unused-parameters' compiler options are enabled.");
}
- return this.applyWithFunction(sourceFile, function (ctx) { return walk(ctx, program, parseOptions(_this.ruleArguments)); });
+ return this.applyWithFunction(sourceFile, walk, parseOptions(this.ruleArguments), program);
};
/* tslint:disable:object-literal-sort-keys */
Rule.metadata = {
@@ -87,9 +86,8 @@ function parseOptions(options) {
}
return { checkParameters: checkParameters, ignorePattern: ignorePattern };
}
-function walk(ctx, program, _a) {
- var checkParameters = _a.checkParameters, ignorePattern = _a.ignorePattern;
- var sourceFile = ctx.sourceFile;
+function walk(ctx, program) {
+ var sourceFile = ctx.sourceFile, _a = ctx.options, checkParameters = _a.checkParameters, ignorePattern = _a.ignorePattern;
var unusedCheckedProgram = getUnusedCheckedProgram(program, checkParameters);
var diagnostics = ts.getPreEmitDiagnostics(unusedCheckedProgram, sourceFile);
var checker = unusedCheckedProgram.getTypeChecker(); // Doesn't matter which program is used for this.
@@ -207,6 +205,11 @@ function addImportSpecifierFailures(ctx, failures, sourceFile) {
function removeAll(errorNode, failure) {
var start = importNode.getStart();
var end = importNode.getEnd();
+ utils.forEachToken(importNode, function (token) {
+ ts.forEachTrailingCommentRange(ctx.sourceFile.text, token.end, function (_, commentEnd, __) {
+ end = commentEnd;
+ });
+ }, ctx.sourceFile);
if (isEntireLine(start, end)) {
end = getNextLineStart(end);
}