41 lines
1.7 KiB
JavaScript
41 lines
1.7 KiB
JavaScript
|
"use strict";
|
||
|
var __extends = (this && this.__extends) || function (d, b) {
|
||
|
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
|
||
|
function __() { this.constructor = d; }
|
||
|
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
||
|
};
|
||
|
var Lint = require('tslint/lib/lint');
|
||
|
var sprintf_js_1 = require('sprintf-js');
|
||
|
var ng2Walker_1 = require("./util/ng2Walker");
|
||
|
var Rule = (function (_super) {
|
||
|
__extends(Rule, _super);
|
||
|
function Rule() {
|
||
|
_super.apply(this, arguments);
|
||
|
}
|
||
|
Rule.prototype.apply = function (sourceFile) {
|
||
|
return this.applyWithWalker(new InputMetadataWalker(sourceFile, this.getOptions()));
|
||
|
};
|
||
|
Rule.FAILURE_STRING = 'In the class "%s", the directive ' +
|
||
|
'input property "%s" should not be renamed.' +
|
||
|
'Please, consider the following use "@Input() %s: string"';
|
||
|
return Rule;
|
||
|
}(Lint.Rules.AbstractRule));
|
||
|
exports.Rule = Rule;
|
||
|
var InputMetadataWalker = (function (_super) {
|
||
|
__extends(InputMetadataWalker, _super);
|
||
|
function InputMetadataWalker() {
|
||
|
_super.apply(this, arguments);
|
||
|
}
|
||
|
InputMetadataWalker.prototype.visitNg2Input = function (property, input, args) {
|
||
|
var className = property.parent.name.text;
|
||
|
var memberName = property.name.text;
|
||
|
if (args.length != 0 && memberName != args[0]) {
|
||
|
var failureConfig = [className, memberName, memberName];
|
||
|
failureConfig.unshift(Rule.FAILURE_STRING);
|
||
|
this.addFailure(this.createFailure(property.getStart(), property.getWidth(), sprintf_js_1.sprintf.apply(this, failureConfig)));
|
||
|
}
|
||
|
};
|
||
|
return InputMetadataWalker;
|
||
|
}(ng2Walker_1.Ng2Walker));
|
||
|
exports.InputMetadataWalker = InputMetadataWalker;
|