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