UNPKG

3.14 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 ErrorTolerantWalker_1 = require("./utils/ErrorTolerantWalker");
15var Rule = (function (_super) {
16 __extends(Rule, _super);
17 function Rule() {
18 return _super !== null && _super.apply(this, arguments) || this;
19 }
20 Rule.prototype.apply = function (sourceFile) {
21 if (Rule.isWarningShown === false) {
22 console.warn('Warning: no-empty-interfaces rule is deprecated. Replace your usage with the TSLint no-empty-interface rule.');
23 Rule.isWarningShown = true;
24 }
25 return this.applyWithWalker(new NoEmptyInterfacesRuleWalker(sourceFile, this.getOptions()));
26 };
27 Rule.metadata = {
28 ruleName: 'no-empty-interfaces',
29 type: 'maintainability',
30 description: 'Do not use empty interfaces.',
31 options: null,
32 optionsDescription: '',
33 typescriptOnly: true,
34 issueClass: 'Ignored',
35 issueType: 'Warning',
36 severity: 'Moderate',
37 level: 'Opportunity for Excellence',
38 group: 'Deprecated',
39 recommendation: 'false, // use tslint no-empty-interface rule instead',
40 commonWeaknessEnumeration: '398, 710'
41 };
42 Rule.FAILURE_STRING = 'Do not declare empty interfaces: ';
43 Rule.isWarningShown = false;
44 return Rule;
45}(Lint.Rules.AbstractRule));
46exports.Rule = Rule;
47var NoEmptyInterfacesRuleWalker = (function (_super) {
48 __extends(NoEmptyInterfacesRuleWalker, _super);
49 function NoEmptyInterfacesRuleWalker() {
50 return _super !== null && _super.apply(this, arguments) || this;
51 }
52 NoEmptyInterfacesRuleWalker.prototype.visitInterfaceDeclaration = function (node) {
53 if (this.isInterfaceEmpty(node) && !this.hasMultipleParents(node)) {
54 this.addFailureAt(node.getStart(), node.getWidth(), Rule.FAILURE_STRING + '\'' + node.name.getText() + '\'');
55 }
56 _super.prototype.visitInterfaceDeclaration.call(this, node);
57 };
58 NoEmptyInterfacesRuleWalker.prototype.isInterfaceEmpty = function (node) {
59 return node.members == null || node.members.length === 0;
60 };
61 NoEmptyInterfacesRuleWalker.prototype.hasMultipleParents = function (node) {
62 if (node.heritageClauses == null || node.heritageClauses.length === 0) {
63 return false;
64 }
65 return node.heritageClauses[0].types.length >= 2;
66 };
67 return NoEmptyInterfacesRuleWalker;
68}(ErrorTolerantWalker_1.ErrorTolerantWalker));
69//# sourceMappingURL=noEmptyInterfacesRule.js.map
\No newline at end of file