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 ts = require("typescript");
|
17 | var Lint = require("tslint");
|
18 | var Rule = (function (_super) {
|
19 | __extends(Rule, _super);
|
20 | function Rule() {
|
21 | return _super !== null && _super.apply(this, arguments) || this;
|
22 | }
|
23 | Rule.prototype.apply = function (sourceFile) {
|
24 | return this.applyWithFunction(sourceFile, walk);
|
25 | };
|
26 | Rule.metadata = {
|
27 | ruleName: 'no-with-statement',
|
28 | type: 'maintainability',
|
29 | description: 'Do not use with statements. Assign the item to a new variable instead',
|
30 | options: null,
|
31 | optionsDescription: '',
|
32 | typescriptOnly: true,
|
33 | issueClass: 'Non-SDL',
|
34 | issueType: 'Warning',
|
35 | severity: 'Important',
|
36 | level: 'Opportunity for Excellence',
|
37 | group: 'Correctness',
|
38 | commonWeaknessEnumeration: '398, 710'
|
39 | };
|
40 | Rule.FAILURE_STRING = 'Forbidden with statement';
|
41 | return Rule;
|
42 | }(Lint.Rules.AbstractRule));
|
43 | exports.Rule = Rule;
|
44 | function walk(ctx) {
|
45 | function cb(node) {
|
46 | if (node.kind === ts.SyntaxKind.WithStatement) {
|
47 | ctx.addFailureAt(node.getStart(), node.getWidth(), Rule.FAILURE_STRING);
|
48 | }
|
49 | }
|
50 | return ts.forEachChild(ctx.sourceFile, cb);
|
51 | }
|
52 |
|
\ | No newline at end of file |