diff options
Diffstat (limited to 'node_modules/tslint/lib/rules/preferConstRule.js')
-rw-r--r-- | node_modules/tslint/lib/rules/preferConstRule.js | 20 |
1 files changed, 12 insertions, 8 deletions
diff --git a/node_modules/tslint/lib/rules/preferConstRule.js b/node_modules/tslint/lib/rules/preferConstRule.js index 42f1e6ce4..5d88718de 100644 --- a/node_modules/tslint/lib/rules/preferConstRule.js +++ b/node_modules/tslint/lib/rules/preferConstRule.js @@ -43,9 +43,9 @@ var Rule = /** @class */ (function (_super) { Rule.metadata = { ruleName: "prefer-const", description: "Requires that variable declarations use `const` instead of `let` and `var` if possible.", - descriptionDetails: (_a = ["\n If a variable is only assigned to once when it is declared, it should be declared using 'const'"], _a.raw = ["\n If a variable is only assigned to once when it is declared, it should be declared using 'const'"], Lint.Utils.dedent(_a)), + descriptionDetails: Lint.Utils.dedent(templateObject_1 || (templateObject_1 = tslib_1.__makeTemplateObject(["\n If a variable is only assigned to once when it is declared, it should be declared using 'const'"], ["\n If a variable is only assigned to once when it is declared, it should be declared using 'const'"]))), hasFix: true, - optionsDescription: (_b = ["\n An optional object containing the property \"destructuring\" with two possible values:\n\n * \"", "\" (default) - If any variable in destructuring can be const, this rule warns for those variables.\n * \"", "\" - Only warns if all variables in destructuring can be const."], _b.raw = ["\n An optional object containing the property \"destructuring\" with two possible values:\n\n * \"", "\" (default) - If any variable in destructuring can be const, this rule warns for those variables.\n * \"", "\" - Only warns if all variables in destructuring can be const."], Lint.Utils.dedent(_b, OPTION_DESTRUCTURING_ANY, OPTION_DESTRUCTURING_ALL)), + optionsDescription: Lint.Utils.dedent(templateObject_2 || (templateObject_2 = tslib_1.__makeTemplateObject(["\n An optional object containing the property \"destructuring\" with two possible values:\n\n * \"", "\" (default) - If any variable in destructuring can be const, this rule warns for those variables.\n * \"", "\" - Only warns if all variables in destructuring can be const."], ["\n An optional object containing the property \"destructuring\" with two possible values:\n\n * \"", "\" (default) - If any variable in destructuring can be const, this rule warns for those variables.\n * \"", "\" - Only warns if all variables in destructuring can be const."])), OPTION_DESTRUCTURING_ANY, OPTION_DESTRUCTURING_ALL), options: { type: "object", properties: { @@ -87,7 +87,9 @@ var Scope = /** @class */ (function () { var PreferConstWalker = /** @class */ (function (_super) { tslib_1.__extends(PreferConstWalker, _super); function PreferConstWalker() { - return _super !== null && _super.apply(this, arguments) || this; + var _this = _super !== null && _super.apply(this, arguments) || this; + _this.scope = new Scope(); + return _this; } PreferConstWalker.prototype.walk = function (sourceFile) { var _this = this; @@ -146,10 +148,12 @@ var PreferConstWalker = /** @class */ (function (_super) { } } else if (node.kind === ts.SyntaxKind.Parameter) { - _this.handleBindingName(node.name, { - canBeConst: false, - isBlockScoped: true, - }); + if (node.parent.kind !== ts.SyntaxKind.IndexSignature) { + _this.handleBindingName(node.name, { + canBeConst: false, + isBlockScoped: true, + }); + } } else if (utils.isPostfixUnaryExpression(node) || utils.isPrefixUnaryExpression(node) && @@ -309,4 +313,4 @@ var PreferConstWalker = /** @class */ (function (_super) { }; return PreferConstWalker; }(Lint.AbstractWalker)); -var _a, _b; +var templateObject_1, templateObject_2; |