1 | "use strict";
|
2 | var __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 | })();
|
12 | Object.defineProperty(exports, "__esModule", { value: true });
|
13 | var Lint = require("tslint");
|
14 | var ErrorTolerantWalker_1 = require("./utils/ErrorTolerantWalker");
|
15 | var 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 | return this.applyWithWalker(new NoDuplicateParameterNamesWalker(sourceFile, this.getOptions()));
|
22 | };
|
23 | Rule.metadata = {
|
24 | ruleName: 'no-duplicate-parameter-names',
|
25 | type: 'maintainability',
|
26 | description: 'Deprecated - This rule is now enforced by the TypeScript compiler',
|
27 | options: null,
|
28 | optionsDescription: '',
|
29 | typescriptOnly: true,
|
30 | issueClass: 'Ignored',
|
31 | issueType: 'Warning',
|
32 | severity: 'Low',
|
33 | level: 'Opportunity for Excellence',
|
34 | group: 'Deprecated',
|
35 | recommendation: 'false, // now supported by TypeScript compiler'
|
36 | };
|
37 | Rule.FAILURE_STRING = 'Duplicate parameter name: ';
|
38 | return Rule;
|
39 | }(Lint.Rules.AbstractRule));
|
40 | exports.Rule = Rule;
|
41 | var NoDuplicateParameterNamesWalker = (function (_super) {
|
42 | __extends(NoDuplicateParameterNamesWalker, _super);
|
43 | function NoDuplicateParameterNamesWalker() {
|
44 | return _super !== null && _super.apply(this, arguments) || this;
|
45 | }
|
46 | NoDuplicateParameterNamesWalker.prototype.visitMethodDeclaration = function (node) {
|
47 | this.validateParameterNames(node);
|
48 | _super.prototype.visitMethodDeclaration.call(this, node);
|
49 | };
|
50 | NoDuplicateParameterNamesWalker.prototype.visitConstructorDeclaration = function (node) {
|
51 | this.validateParameterNames(node);
|
52 | _super.prototype.visitConstructorDeclaration.call(this, node);
|
53 | };
|
54 | NoDuplicateParameterNamesWalker.prototype.visitArrowFunction = function (node) {
|
55 | this.validateParameterNames(node);
|
56 | _super.prototype.visitArrowFunction.call(this, node);
|
57 | };
|
58 | NoDuplicateParameterNamesWalker.prototype.visitFunctionDeclaration = function (node) {
|
59 | this.validateParameterNames(node);
|
60 | _super.prototype.visitFunctionDeclaration.call(this, node);
|
61 | };
|
62 | NoDuplicateParameterNamesWalker.prototype.visitFunctionExpression = function (node) {
|
63 | this.validateParameterNames(node);
|
64 | _super.prototype.visitFunctionExpression.call(this, node);
|
65 | };
|
66 | NoDuplicateParameterNamesWalker.prototype.validateParameterNames = function (node) {
|
67 | var _this = this;
|
68 | var seenNames = {};
|
69 | node.parameters.forEach(function (parameter) {
|
70 | var parameterName = parameter.name.text;
|
71 | if (parameterName != null) {
|
72 | if (seenNames[parameterName]) {
|
73 | _this.addFailureAt(parameter.name.getStart(), parameterName.length, Rule.FAILURE_STRING + '\'' + parameterName + '\'');
|
74 | }
|
75 | else {
|
76 | seenNames[parameterName] = true;
|
77 | }
|
78 | }
|
79 | });
|
80 | };
|
81 | return NoDuplicateParameterNamesWalker;
|
82 | }(ErrorTolerantWalker_1.ErrorTolerantWalker));
|
83 |
|
\ | No newline at end of file |