type2docfx
Version:
A tool to convert json format output from TypeDoc to universal reference model for DocFx to consume.
60 lines (59 loc) • 2.68 kB
JavaScript
;
var __extends = (this && this.__extends) || (function () {
var extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
Object.defineProperty(exports, "__esModule", { value: true });
var Lint = require("tslint");
var sprintf_js_1 = require("sprintf-js");
var ngWalker_1 = require("./angular/ngWalker");
var Rule = (function (_super) {
__extends(Rule, _super);
function Rule() {
return _super !== null && _super.apply(this, arguments) || this;
}
Rule.prototype.apply = function (sourceFile) {
return this.applyWithWalker(new InputMetadataWalker(sourceFile, this.getOptions()));
};
Rule.metadata = {
ruleName: 'no-input-rename',
type: 'maintainability',
description: 'Disallows renaming directive inputs by providing a string to the decorator.',
descriptionDetails: 'See more at https://angular.io/styleguide#style-05-13.',
rationale: 'Two names for the same property (one private, one public) is inherently confusing.',
options: null,
optionsDescription: 'Not configurable.',
typescriptOnly: true,
};
Rule.FAILURE_STRING = 'In the class "%s", the directive input property "%s" should not be renamed.';
return Rule;
}(Lint.Rules.AbstractRule));
exports.Rule = Rule;
var InputMetadataWalker = (function (_super) {
__extends(InputMetadataWalker, _super);
function InputMetadataWalker() {
return _super !== null && _super.apply(this, arguments) || this;
}
InputMetadataWalker.prototype.visitNgDirective = function (metadata) {
this.directiveSelector =
(metadata.selector || '').replace(/[\[\]\s]/g, '').split(',');
};
InputMetadataWalker.prototype.visitNgInput = function (property, input, args) {
var className = property.parent.name.text;
var memberName = property.name.text;
if (args.length === 0 ||
(this.directiveSelector && this.directiveSelector.indexOf(memberName) !== -1)) {
return;
}
var failureConfig = [Rule.FAILURE_STRING, className, memberName];
this.addFailureAtNode(property, sprintf_js_1.sprintf.apply(this, failureConfig));
};
return InputMetadataWalker;
}(ngWalker_1.NgWalker));
exports.InputMetadataWalker = InputMetadataWalker;