-
Notifications
You must be signed in to change notification settings - Fork 234
/
useInputPropertyDecoratorRule.ts
31 lines (26 loc) · 1.26 KB
/
useInputPropertyDecoratorRule.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
import * as Lint from 'tslint';
import {UsePropertyDecorator} from './propertyDecoratorBase';
import { IOptions } from 'tslint';
export class Rule extends UsePropertyDecorator {
public static metadata: Lint.IRuleMetadata = {
ruleName: 'use-input-property-decorator',
type: 'style',
description: `Use \`@Input\` decorator rather than the \`inputs\` property of \`@Component\` and \`@Directive\` metadata.`,
descriptionDetails: `See more at https://angular.io/styleguide#style-05-12.`,
rationale: Lint.Utils.dedent`
* It is easier and more readable to identify which properties in a class are inputs.
* If you ever need to rename the property name associated with \`@Input\`, you can modify it in a single place.
* The metadata declaration attached to the directive is shorter and thus more readable.
* Placing the decorator on the same line usually makes for shorter code and still easily identifies the property as an input.`,
options: null,
optionsDescription: `Not configurable.`,
typescriptOnly: true,
};
constructor(options: IOptions) {
super({
decoratorName: 'Input',
propertyName: 'inputs',
errorMessage: 'Use the @Input property decorator instead of the inputs property ($$05-12$$)'
}, options);
}
}