UNPKG

2.19 kBJavaScriptView Raw
1"use strict";
2var __extends = (this && this.__extends) || (function () {
3 var extendStatics = Object.setPrototypeOf ||
4 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
5 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
6 return function (d, b) {
7 extendStatics(d, b);
8 function __() { this.constructor = d; }
9 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
10 };
11})();
12Object.defineProperty(exports, "__esModule", { value: true });
13var Lint = require("tslint");
14var FAILURE_STRING_EMPTY = 'This file is empty and should be deleted.';
15var FAILURE_STRING_COMMENTS = 'This file only contains comments and should be deleted.';
16var Rule = (function (_super) {
17 __extends(Rule, _super);
18 function Rule() {
19 return _super !== null && _super.apply(this, arguments) || this;
20 }
21 Rule.prototype.apply = function (sourceFile) {
22 var ruleFailures = [];
23 var fileContent = sourceFile.getFullText().trim();
24 var fileContentNoComments = sourceFile.getText().trim();
25 if (fileContent.length === 0) {
26 ruleFailures.push(new Lint.RuleFailure(sourceFile, 0, 0, FAILURE_STRING_EMPTY, this.getOptions().ruleName));
27 }
28 else if (fileContentNoComments.length === 0) {
29 ruleFailures.push(new Lint.RuleFailure(sourceFile, 0, 0, FAILURE_STRING_COMMENTS, this.getOptions().ruleName));
30 }
31 return ruleFailures;
32 };
33 Rule.metadata = {
34 ruleName: 'no-useless-files',
35 type: 'maintainability',
36 description: 'Locates files that only contain commented out code, whitespace characters, or have no content',
37 options: null,
38 optionsDescription: '',
39 typescriptOnly: false,
40 issueClass: 'Non-SDL',
41 issueType: 'Warning',
42 severity: 'Low',
43 level: 'Opportunity for Excellence',
44 group: 'Clarity',
45 commonWeaknessEnumeration: '398'
46 };
47 return Rule;
48}(Lint.Rules.AbstractRule));
49exports.Rule = Rule;
50//# sourceMappingURL=noUselessFilesRule.js.map
\No newline at end of file