diff options
Diffstat (limited to 'node_modules/tslint/lib/rules/onlyArrowFunctionsRule.js')
-rw-r--r-- | node_modules/tslint/lib/rules/onlyArrowFunctionsRule.js | 44 |
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]; |