forked from mgechev/codelyzer
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnoInputsMetadataPropertyRule.ts
More file actions
38 lines (34 loc) · 1.38 KB
/
noInputsMetadataPropertyRule.ts
File metadata and controls
38 lines (34 loc) · 1.38 KB
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
31
32
33
34
35
36
37
38
import { IOptions, IRuleMetadata } from 'tslint/lib';
import { dedent } from 'tslint/lib/utils';
import { MetadataPropertyBase } from './metadataPropertyBase';
import { Decorators } from './util/utils';
const METADATA_PROPERTY_NAME = 'inputs';
const STYLE_GUIDE_LINK = 'https://angular.io/styleguide#style-05-12';
export class Rule extends MetadataPropertyBase {
static readonly metadata: IRuleMetadata = {
description: `Disallows usage of the \`${METADATA_PROPERTY_NAME}\` metadata property.`,
descriptionDetails: `See more at ${STYLE_GUIDE_LINK}.`,
options: null,
optionsDescription: 'Not configurable.',
rationale: dedent`
* It is easier and more readable to identify which properties in a class are ${METADATA_PROPERTY_NAME}.
* If you ever need to rename the property associated with @${Decorators.Input}, you can modify it in a single place.
* The metadata declaration attached to the directive is shorter and thus more readable.
`,
ruleName: 'no-inputs-metadata-property',
type: 'style',
typescriptOnly: true
};
static readonly FAILURE_STRING = `Use @${
Decorators.Input
} rather than the \`${METADATA_PROPERTY_NAME}\` metadata property (${STYLE_GUIDE_LINK})`;
constructor(options: IOptions) {
super(
{
errorMessage: Rule.FAILURE_STRING,
propertyName: METADATA_PROPERTY_NAME
},
options
);
}
}