aboutsummaryrefslogtreecommitdiff
path: root/node_modules/tslint/lib/rules/onlyArrowFunctionsRule.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/onlyArrowFunctionsRule.js
parent5634e77ad96bfe1818f6b6ee70b7379652e5487f (diff)
node_modules
Diffstat (limited to 'node_modules/tslint/lib/rules/onlyArrowFunctionsRule.js')
-rw-r--r--node_modules/tslint/lib/rules/onlyArrowFunctionsRule.js44
1 files changed, 22 insertions, 22 deletions
diff --git a/node_modules/tslint/lib/rules/onlyArrowFunctionsRule.js b/node_modules/tslint/lib/rules/onlyArrowFunctionsRule.js
index f5d8187f8..3d59a921c 100644
--- a/node_modules/tslint/lib/rules/onlyArrowFunctionsRule.js
+++ b/node_modules/tslint/lib/rules/onlyArrowFunctionsRule.js
@@ -30,29 +30,29 @@ var Rule = (function (_super) {
Rule.prototype.apply = function (sourceFile) {
return this.applyWithFunction(sourceFile, walk, parseOptions(this.ruleArguments));
};
+ /* tslint:disable:object-literal-sort-keys */
+ Rule.metadata = {
+ ruleName: "only-arrow-functions",
+ description: "Disallows traditional (non-arrow) function expressions.",
+ rationale: "Traditional functions don't bind lexical scope, which can lead to unexpected behavior when accessing 'this'.",
+ optionsDescription: (_a = ["\n Two arguments may be optionally provided:\n\n * `\"", "\"` allows standalone function declarations.\n * `\"", "\"` allows the expression `function foo() {}` but not `function() {}`.\n "], _a.raw = ["\n Two arguments may be optionally provided:\n\n * \\`\"", "\"\\` allows standalone function declarations.\n * \\`\"", "\"\\` allows the expression \\`function foo() {}\\` but not \\`function() {}\\`.\n "], Lint.Utils.dedent(_a, OPTION_ALLOW_DECLARATIONS, OPTION_ALLOW_NAMED_FUNCTIONS)),
+ options: {
+ type: "array",
+ items: {
+ type: "string",
+ enum: [OPTION_ALLOW_DECLARATIONS, OPTION_ALLOW_NAMED_FUNCTIONS],
+ },
+ minLength: 0,
+ maxLength: 1,
+ },
+ optionExamples: [true, [true, OPTION_ALLOW_DECLARATIONS, OPTION_ALLOW_NAMED_FUNCTIONS]],
+ type: "typescript",
+ typescriptOnly: false,
+ };
+ /* tslint:enable:object-literal-sort-keys */
+ Rule.FAILURE_STRING = "non-arrow functions are forbidden";
return Rule;
}(Lint.Rules.AbstractRule));
-/* tslint:disable:object-literal-sort-keys */
-Rule.metadata = {
- ruleName: "only-arrow-functions",
- description: "Disallows traditional (non-arrow) function expressions.",
- rationale: "Traditional functions don't bind lexical scope, which can lead to unexpected behavior when accessing 'this'.",
- optionsDescription: (_a = ["\n Two arguments may be optionally provided:\n\n * `\"", "\"` allows standalone function declarations.\n * `\"", "\"` allows the expression `function foo() {}` but not `function() {}`.\n "], _a.raw = ["\n Two arguments may be optionally provided:\n\n * \\`\"", "\"\\` allows standalone function declarations.\n * \\`\"", "\"\\` allows the expression \\`function foo() {}\\` but not \\`function() {}\\`.\n "], Lint.Utils.dedent(_a, OPTION_ALLOW_DECLARATIONS, OPTION_ALLOW_NAMED_FUNCTIONS)),
- options: {
- type: "array",
- items: {
- type: "string",
- enum: [OPTION_ALLOW_DECLARATIONS, OPTION_ALLOW_NAMED_FUNCTIONS],
- },
- minLength: 0,
- maxLength: 1,
- },
- optionExamples: [true, [true, OPTION_ALLOW_DECLARATIONS, OPTION_ALLOW_NAMED_FUNCTIONS]],
- type: "typescript",
- typescriptOnly: false,
-};
-/* tslint:enable:object-literal-sort-keys */
-Rule.FAILURE_STRING = "non-arrow functions are forbidden";
exports.Rule = Rule;
function parseOptions(ruleArguments) {
return {
@@ -84,7 +84,7 @@ function walk(ctx) {
}
/** Generator functions and functions using `this` are allowed. */
function functionIsExempt(node) {
- return node.asteriskToken !== undefined || hasThisParameter(node) || node.body !== undefined && usesThisInBody(node.body);
+ return node.asteriskToken !== undefined || hasThisParameter(node) || node.body !== undefined && usesThisInBody(node.body) === true;
}
function hasThisParameter(node) {
var first = node.parameters[0];