Eugenio Romano fe0ac0e474
move tslint ADF rules in principal repo (#3247)
* move tslint ADF rules in principal repo

* fix style issues

* change pacakge.json position

* update to angular cli 6.0.0

* reorganization package.json

* remove node modules2 folder

* exclude integration

* rollback alfresco-js-api

* solve types problems

* fix pdf test

* fix errors and exclude two tests

* fix e2e

* fix test

* copy all the new packages in node_modules

* fix test

* fix packaging script

* scss issue fix

* move test export in tools
2018-05-04 17:13:45 +01:00

35 lines
1.5 KiB
JavaScript

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const Lint = require("tslint");
const sprintf_js_1 = require("sprintf-js");
const ngWalker_1 = require("codelyzer/angular/ngWalker");
class Rule extends Lint.Rules.AbstractRule {
apply(sourceFile) {
return this.applyWithWalker(new ADFOutputPrefixNameRule(sourceFile, this.getOptions()));
}
}
Rule.metadata = {
ruleName: 'adf-prefix-name',
type: 'maintainability',
description: `Name events without the prefix on`,
descriptionDetails: `See more at https://angular.io/guide/styleguide#dont-prefix-output-properties`,
rationale: `Angular allows for an alternative syntax on-*. If the event itself was prefixed with on this would result in an on-onEvent binding expression`,
options: null,
optionsDescription: `Not configurable.`,
typescriptOnly: true,
};
Rule.FAILURE_STRING = 'In the class "%s", the output ' +
'property "%s" should not be prefixed with on';
exports.Rule = Rule;
class ADFOutputPrefixNameRule extends ngWalker_1.NgWalker {
visitNgOutput(property, output, args) {
let className = property.parent.name.text;
let memberName = property.name.text;
if (memberName && memberName.startsWith('on')) {
let failureConfig = [className, memberName];
failureConfig.unshift(Rule.FAILURE_STRING);
this.addFailure(this.createFailure(property.getStart(), property.getWidth(), sprintf_js_1.sprintf.apply(this, failureConfig)));
}
}
}