UNPKG

3.9 kBJavaScriptView Raw
1"use strict";
2var __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})();
15Object.defineProperty(exports, "__esModule", { value: true });
16var Lint = require("tslint");
17var BannedTermWalker_1 = require("./utils/BannedTermWalker");
18var TypeGuard_1 = require("./utils/TypeGuard");
19var 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 if (Rule.isWarningShown === false) {
26 console.warn('Warning: no-reserved-keywords rule is deprecated. Replace your usage with the TSLint variable-name rule.');
27 Rule.isWarningShown = true;
28 }
29 return this.applyWithFunction(sourceFile, BannedTermWalker_1.bannedTermWalker, this.parseOptions(this.getOptions()));
30 };
31 Rule.prototype.parseOptions = function (options) {
32 var allowQuotedProperties = false;
33 if (options.ruleArguments instanceof Array) {
34 options.ruleArguments.forEach(function (opt) {
35 if (TypeGuard_1.isObject(opt)) {
36 allowQuotedProperties = opt['allow-quoted-properties'] === true;
37 }
38 });
39 }
40 return {
41 failureString: Rule.FAILURE_STRING,
42 bannedTerms: Rule.BANNED_TERMS,
43 allowQuotedProperties: allowQuotedProperties
44 };
45 };
46 Rule.metadata = {
47 ruleName: 'no-reserved-keywords',
48 type: 'maintainability',
49 description: 'Do not use reserved keywords as names of local variables, fields, functions, or other identifiers.',
50 options: null,
51 optionsDescription: '',
52 typescriptOnly: true,
53 issueClass: 'SDL',
54 issueType: 'Error',
55 recommendation: 'false',
56 severity: 'Critical',
57 level: 'Mandatory',
58 group: 'Deprecated',
59 commonWeaknessEnumeration: '398'
60 };
61 Rule.FAILURE_STRING = 'Forbidden reference to reserved keyword: ';
62 Rule.BANNED_TERMS = [
63 'break',
64 'case',
65 'catch',
66 'class',
67 'const',
68 'continue',
69 'debugger',
70 'default',
71 'delete',
72 'do',
73 'else',
74 'enum',
75 'export',
76 'extends',
77 'false',
78 'finally',
79 'for',
80 'function',
81 'if',
82 'import',
83 'in',
84 'instanceof',
85 'new',
86 'null',
87 'return',
88 'super',
89 'switch',
90 'this',
91 'throw',
92 'true',
93 'try',
94 'typeof',
95 'var',
96 'void',
97 'while',
98 'with',
99 'as',
100 'implements',
101 'interface',
102 'let',
103 'package',
104 'private',
105 'protected',
106 'public',
107 'static',
108 'yield',
109 'any',
110 'boolean',
111 'constructor',
112 'declare',
113 'get',
114 'module',
115 'require',
116 'number',
117 'set',
118 'string',
119 'symbol',
120 'type',
121 'from',
122 'of'
123 ];
124 Rule.isWarningShown = false;
125 return Rule;
126}(Lint.Rules.AbstractRule));
127exports.Rule = Rule;
128//# sourceMappingURL=noReservedKeywordsRule.js.map
\No newline at end of file