diff options
Diffstat (limited to 'node_modules/tslint/lib/rules/noVoidExpressionRule.js')
-rw-r--r-- | node_modules/tslint/lib/rules/noVoidExpressionRule.js | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/node_modules/tslint/lib/rules/noVoidExpressionRule.js b/node_modules/tslint/lib/rules/noVoidExpressionRule.js index daaded82d..96742a87d 100644 --- a/node_modules/tslint/lib/rules/noVoidExpressionRule.js +++ b/node_modules/tslint/lib/rules/noVoidExpressionRule.js @@ -17,9 +17,9 @@ */ Object.defineProperty(exports, "__esModule", { value: true }); var tslib_1 = require("tslib"); +var tsutils_1 = require("tsutils"); var ts = require("typescript"); var Lint = require("../index"); -var utils_1 = require("../language/utils"); var OPTION_IGNORE_ARROW_FUNCTION_SHORTHAND = "ignore-arrow-function-shorthand"; var Rule = /** @class */ (function (_super) { tslib_1.__extends(Rule, _super); @@ -34,7 +34,7 @@ var Rule = /** @class */ (function (_super) { Rule.metadata = { ruleName: "no-void-expression", description: "Requires expressions of type `void` to appear in statement position.", - optionsDescription: (_a = ["\n If `", "` is provided, `() => returnsVoid()` will be allowed.\n Otherwise, it must be written as `() => { returnsVoid(); }`."], _a.raw = ["\n If \\`", "\\` is provided, \\`() => returnsVoid()\\` will be allowed.\n Otherwise, it must be written as \\`() => { returnsVoid(); }\\`."], Lint.Utils.dedent(_a, OPTION_IGNORE_ARROW_FUNCTION_SHORTHAND)), + optionsDescription: Lint.Utils.dedent(templateObject_1 || (templateObject_1 = tslib_1.__makeTemplateObject(["\n If `", "` is provided, `() => returnsVoid()` will be allowed.\n Otherwise, it must be written as `() => { returnsVoid(); }`."], ["\n If \\`", "\\` is provided, \\`() => returnsVoid()\\` will be allowed.\n Otherwise, it must be written as \\`() => { returnsVoid(); }\\`."])), OPTION_IGNORE_ARROW_FUNCTION_SHORTHAND), options: { type: "array", items: { @@ -44,6 +44,7 @@ var Rule = /** @class */ (function (_super) { minLength: 0, maxLength: 1, }, + rationale: Lint.Utils.dedent(templateObject_2 || (templateObject_2 = tslib_1.__makeTemplateObject(["\n It's misleading returning the results of an expression whose type is `void`.\n Attempting to do so is likely a symptom of expecting a different return type from a function.\n For example, the following code will log `undefined` but looks like it logs a value:\n\n ```\n const performWork = (): void => {\n workFirst();\n workSecond();\n };\n\n console.log(performWork());\n ```\n "], ["\n It's misleading returning the results of an expression whose type is \\`void\\`.\n Attempting to do so is likely a symptom of expecting a different return type from a function.\n For example, the following code will log \\`undefined\\` but looks like it logs a value:\n\n \\`\\`\\`\n const performWork = (): void => {\n workFirst();\n workSecond();\n };\n\n console.log(performWork());\n \\`\\`\\`\n "]))), requiresTypeInfo: true, type: "functionality", typescriptOnly: false, @@ -58,7 +59,7 @@ function walk(ctx, checker) { return ts.forEachChild(sourceFile, function cb(node) { if (isPossiblyVoidExpression(node) && !isParentAllowedVoid(node) - && utils_1.isTypeFlagSet(checker.getTypeAtLocation(node), ts.TypeFlags.Void)) { + && tsutils_1.isTypeFlagSet(checker.getTypeAtLocation(node), ts.TypeFlags.Void)) { ctx.addFailureAtNode(node, Rule.FAILURE_STRING); } return ts.forEachChild(node, cb); @@ -84,4 +85,4 @@ function isPossiblyVoidExpression(node) { return false; } } -var _a; +var templateObject_1, templateObject_2; |