1 | var __extends = (this && this.__extends) || function (d, b) {
|
2 | for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
|
3 | function __() { this.constructor = d; }
|
4 | __.prototype = b.prototype;
|
5 | d.prototype = new __();
|
6 | };
|
7 | var SyntaxKind = require('./utils/SyntaxKind');
|
8 | var ErrorTolerantWalker = require('./utils/ErrorTolerantWalker');
|
9 | var Rule = (function (_super) {
|
10 | __extends(Rule, _super);
|
11 | function Rule() {
|
12 | _super.apply(this, arguments);
|
13 | }
|
14 | Rule.prototype.apply = function (sourceFile) {
|
15 | return this.applyWithWalker(new NoIncrementDecrementWalker(sourceFile, this.getOptions()));
|
16 | };
|
17 | return Rule;
|
18 | })(Lint.Rules.AbstractRule);
|
19 | exports.Rule = Rule;
|
20 | var NoIncrementDecrementWalker = (function (_super) {
|
21 | __extends(NoIncrementDecrementWalker, _super);
|
22 | function NoIncrementDecrementWalker() {
|
23 | _super.apply(this, arguments);
|
24 | }
|
25 | NoIncrementDecrementWalker.prototype.visitPostfixUnaryExpression = function (node) {
|
26 | this.validateUnaryExpression(node);
|
27 | _super.prototype.visitPostfixUnaryExpression.call(this, node);
|
28 | };
|
29 | NoIncrementDecrementWalker.prototype.visitPrefixUnaryExpression = function (node) {
|
30 | this.validateUnaryExpression(node);
|
31 | _super.prototype.visitPrefixUnaryExpression.call(this, node);
|
32 | };
|
33 | NoIncrementDecrementWalker.prototype.validateUnaryExpression = function (node) {
|
34 | if (node.operator === SyntaxKind.current().PlusPlusToken) {
|
35 | this.addFailure(this.createFailure(node.getStart(), node.getWidth(), 'Forbidden ++ operator'));
|
36 | }
|
37 | else if (node.operator === SyntaxKind.current().MinusMinusToken) {
|
38 | this.addFailure(this.createFailure(node.getStart(), node.getWidth(), 'Forbidden -- operator'));
|
39 | }
|
40 | };
|
41 | return NoIncrementDecrementWalker;
|
42 | })(ErrorTolerantWalker);
|
43 |
|
\ | No newline at end of file |