-
Notifications
You must be signed in to change notification settings - Fork 234
/
useHostPropertyDecoratorRule.ts
29 lines (25 loc) · 1.19 KB
/
useHostPropertyDecoratorRule.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
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-host-property-decorator',
type: 'style',
description: `Use @HostProperty decorator rather than the \`host\` property of \`@Component\` and \`@Directive\` metadata.`,
descriptionDetails: `See more at https://angular.io/styleguide#style-06-03.`,
rationale: `The property associated with \`@HostBinding\` or the method associated with \`@HostListener\` ` +
`can be modified only in a single place: in the directive's class. If you use the \`host\` metadata ` +
`property, you must modify both the property declaration inside the controller, and the metadata ` +
`associated with the directive.`,
options: null,
optionsDescription: `Not configurable.`,
typescriptOnly: true,
};
constructor(options: IOptions) {
super({
decoratorName: ['HostBindings', 'HostListeners'],
propertyName: 'host',
errorMessage: 'Use @HostBindings and @HostListeners instead of the host property ($$06-03$$)'
}, options);
}
}