aboutsummaryrefslogtreecommitdiff
path: root/node_modules/tslint/lib/rules/noEmptyRule.js
diff options
context:
space:
mode:
Diffstat (limited to 'node_modules/tslint/lib/rules/noEmptyRule.js')
-rw-r--r--node_modules/tslint/lib/rules/noEmptyRule.js35
1 files changed, 30 insertions, 5 deletions
diff --git a/node_modules/tslint/lib/rules/noEmptyRule.js b/node_modules/tslint/lib/rules/noEmptyRule.js
index 115875816..ee79f5f8b 100644
--- a/node_modules/tslint/lib/rules/noEmptyRule.js
+++ b/node_modules/tslint/lib/rules/noEmptyRule.js
@@ -21,6 +21,7 @@ var tsutils_1 = require("tsutils");
var ts = require("typescript");
var Lint = require("../index");
var ALLOW_EMPTY_CATCH = "allow-empty-catch";
+var ALLOW_EMPTY_FUNCTIONS = "allow-empty-functions";
var Rule = /** @class */ (function (_super) {
tslib_1.__extends(Rule, _super);
function Rule() {
@@ -29,6 +30,7 @@ var Rule = /** @class */ (function (_super) {
Rule.prototype.apply = function (sourceFile) {
return this.applyWithFunction(sourceFile, walk, {
allowEmptyCatch: this.ruleArguments.indexOf(ALLOW_EMPTY_CATCH) !== -1,
+ allowEmptyFunctions: this.ruleArguments.indexOf(ALLOW_EMPTY_FUNCTIONS) !== -1,
});
};
/* tslint:disable:object-literal-sort-keys */
@@ -37,12 +39,28 @@ var Rule = /** @class */ (function (_super) {
description: "Disallows empty blocks.",
descriptionDetails: "Blocks with a comment inside are not considered empty.",
rationale: "Empty blocks are often indicators of missing code.",
- optionsDescription: (_a = ["\n If `", "` is specified, then catch blocks are allowed to be empty."], _a.raw = ["\n If \\`", "\\` is specified, then catch blocks are allowed to be empty."], Lint.Utils.dedent(_a, ALLOW_EMPTY_CATCH)),
+ optionsDescription: Lint.Utils.dedent(templateObject_1 || (templateObject_1 = tslib_1.__makeTemplateObject(["\n If `", "` is specified, then catch blocks are allowed to be empty.\n If `", "` is specified, then function definitions are allowed to be empty."], ["\n If \\`", "\\` is specified, then catch blocks are allowed to be empty.\n If \\`", "\\` is specified, then function definitions are allowed to be empty."])), ALLOW_EMPTY_CATCH, ALLOW_EMPTY_FUNCTIONS),
options: {
- type: "string",
- enum: [ALLOW_EMPTY_CATCH],
+ type: "array",
+ items: {
+ anyOf: [
+ {
+ type: "string",
+ enum: [ALLOW_EMPTY_CATCH],
+ },
+ {
+ type: "string",
+ enum: [ALLOW_EMPTY_FUNCTIONS],
+ },
+ ],
+ },
},
- optionExamples: [true, [true, ALLOW_EMPTY_CATCH]],
+ optionExamples: [
+ true,
+ [true, ALLOW_EMPTY_CATCH],
+ [true, ALLOW_EMPTY_FUNCTIONS],
+ [true, ALLOW_EMPTY_CATCH, ALLOW_EMPTY_FUNCTIONS],
+ ],
type: "functionality",
typescriptOnly: false,
};
@@ -71,6 +89,13 @@ function isExcluded(node, options) {
if (options.allowEmptyCatch && node.kind === ts.SyntaxKind.CatchClause) {
return true;
}
+ if (options.allowEmptyFunctions &&
+ (node.kind === ts.SyntaxKind.MethodDeclaration ||
+ node.kind === ts.SyntaxKind.FunctionDeclaration ||
+ node.kind === ts.SyntaxKind.FunctionExpression ||
+ node.kind === ts.SyntaxKind.ArrowFunction)) {
+ return true;
+ }
return tsutils_1.isConstructorDeclaration(node) &&
(
/* If constructor is private or protected, the block is allowed to be empty.
@@ -80,4 +105,4 @@ function isExcluded(node, options) {
tsutils_1.hasModifier(node.modifiers, ts.SyntaxKind.PrivateKeyword, ts.SyntaxKind.ProtectedKeyword) ||
node.parameters.some(tsutils_1.isParameterProperty));
}
-var _a;
+var templateObject_1;