aboutsummaryrefslogtreecommitdiff
path: root/node_modules/tslint/lib/rules/preferConstRule.js
diff options
context:
space:
mode:
authorFlorian Dold <florian.dold@gmail.com>2017-08-14 05:01:11 +0200
committerFlorian Dold <florian.dold@gmail.com>2017-08-14 05:02:09 +0200
commit363723fc84f7b8477592e0105aeb331ec9a017af (patch)
tree29f92724f34131bac64d6a318dd7e30612e631c7 /node_modules/tslint/lib/rules/preferConstRule.js
parent5634e77ad96bfe1818f6b6ee70b7379652e5487f (diff)
node_modules
Diffstat (limited to 'node_modules/tslint/lib/rules/preferConstRule.js')
-rw-r--r--node_modules/tslint/lib/rules/preferConstRule.js53
1 files changed, 26 insertions, 27 deletions
diff --git a/node_modules/tslint/lib/rules/preferConstRule.js b/node_modules/tslint/lib/rules/preferConstRule.js
index 674a44755..1efc5b1e0 100644
--- a/node_modules/tslint/lib/rules/preferConstRule.js
+++ b/node_modules/tslint/lib/rules/preferConstRule.js
@@ -33,37 +33,36 @@ var Rule = (function (_super) {
};
Rule.prototype.apply = function (sourceFile) {
var options = {
- destructuringAll: this.ruleArguments.length !== 0 &&
- this.ruleArguments[0].destructuring === OPTION_DESTRUCTURING_ALL,
+ destructuringAll: this.ruleArguments.length !== 0 && this.ruleArguments[0].destructuring === OPTION_DESTRUCTURING_ALL,
};
var preferConstWalker = new PreferConstWalker(sourceFile, this.ruleName, options);
return this.applyWithWalker(preferConstWalker);
};
- return Rule;
-}(Lint.Rules.AbstractRule));
-/* tslint:disable:object-literal-sort-keys */
-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)),
- 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)),
- options: {
- type: "object",
- properties: {
- destructuring: {
- type: "string",
- enum: [OPTION_DESTRUCTURING_ALL, OPTION_DESTRUCTURING_ANY],
+ /* tslint:disable:object-literal-sort-keys */
+ 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)),
+ 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)),
+ options: {
+ type: "object",
+ properties: {
+ destructuring: {
+ type: "string",
+ enum: [OPTION_DESTRUCTURING_ALL, OPTION_DESTRUCTURING_ANY],
+ },
},
},
- },
- optionExamples: [
- true,
- [true, { destructuring: OPTION_DESTRUCTURING_ALL }],
- ],
- type: "maintainability",
- typescriptOnly: false,
-};
+ optionExamples: [
+ true,
+ [true, { destructuring: OPTION_DESTRUCTURING_ALL }],
+ ],
+ type: "maintainability",
+ typescriptOnly: false,
+ };
+ return Rule;
+}(Lint.Rules.AbstractRule));
exports.Rule = Rule;
var Scope = (function () {
function Scope(functionScope) {
@@ -215,7 +214,6 @@ var PreferConstWalker = (function (_super) {
this.handleExpression(property.initializer);
}
}
- break;
}
};
PreferConstWalker.prototype.handleBindingName = function (name, declarationInfo) {
@@ -248,7 +246,8 @@ var PreferConstWalker = (function (_super) {
canBeConst: true,
declarationList: declarationList,
isBlockScoped: kind === 1 /* Let */,
- isForLoop: declarationList.parent.kind === ts.SyntaxKind.ForStatement,
+ isForLoop: declarationList.parent.kind === ts.SyntaxKind.ForStatement ||
+ declarationList.parent.kind === ts.SyntaxKind.ForOfStatement,
reassignedSiblings: false,
};
}