Skip to content

Commit ceaefa6

Browse files
committed
fix: parameter -> property
1 parent bf78d22 commit ceaefa6

8 files changed

+27
-28
lines changed

README.md

+2-3
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,8 @@ Below you can find a recommended configuration which is based on the [Angular 2
3131
"component-selector-type": [true, "element"],
3232
"directive-selector-prefix": [true, "sg"],
3333
"component-selector-prefix": [true, "sg"],
34-
"use-host-parameter-decorator": true,
35-
"use-input-parameter-decorator": true,
36-
"use-output-parameter-decorator": true,
34+
"use-input-property-decorator": true,
35+
"use-output-property-decorator": true,
3736
"no-attribute-parameter-decorator": true,
3837
"no-input-rename": true,
3938
"no-output-rename": true,

src/parameterDecoratorBase.ts renamed to src/propertyDecoratorBase.ts

+7-7
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,17 @@ import {sprintf} from 'sprintf-js';
44

55
import SyntaxKind = require('./util/syntaxKind');
66

7-
export interface IUseParameterDecoratorConfig {
7+
export interface IUsePropertyDecoratorConfig {
88
propertyName: string;
99
decoratorName: string | string[];
1010
errorMessage: string;
1111
}
1212

13-
export class UseParameterDecorator extends Lint.Rules.AbstractRule {
13+
export class UsePropertyDecorator extends Lint.Rules.AbstractRule {
1414
private static FAILURE_STRING = 'In the "@%s" class decorator of the class "%s"' +
1515
' you are using the "%s" property, this is considered bad practice. Use %s property decorator instead.';
1616

17-
public static formatFailureString(config: IUseParameterDecoratorConfig, decoratorName: string, className: string) {
17+
public static formatFailureString(config: IUsePropertyDecoratorConfig, decoratorName: string, className: string) {
1818
let decorators = config.decoratorName;
1919
if (decorators instanceof Array) {
2020
decorators = (<string[]>decorators).map(d => `"@${d}"`).join(', ');
@@ -24,9 +24,9 @@ export class UseParameterDecorator extends Lint.Rules.AbstractRule {
2424
return sprintf(config.errorMessage, decoratorName, className, config.propertyName, decorators);
2525
}
2626

27-
constructor(private config: IUseParameterDecoratorConfig, ruleName: string, value: any, disabledIntervals: Lint.IDisabledInterval[]) {
27+
constructor(private config: IUsePropertyDecoratorConfig, ruleName: string, value: any, disabledIntervals: Lint.IDisabledInterval[]) {
2828
super(ruleName, value, disabledIntervals);
29-
config.errorMessage = config.errorMessage || UseParameterDecorator.FAILURE_STRING;
29+
config.errorMessage = config.errorMessage || UsePropertyDecorator.FAILURE_STRING;
3030
}
3131

3232
public apply(sourceFile: ts.SourceFile): Lint.RuleFailure[] {
@@ -44,7 +44,7 @@ class DirectiveMetadataWalker extends Lint.RuleWalker {
4444
private typeChecker : ts.TypeChecker;
4545

4646
constructor(sourceFile: ts.SourceFile, options: Lint.IOptions,
47-
languageService : ts.LanguageService, private config: IUseParameterDecoratorConfig) {
47+
languageService : ts.LanguageService, private config: IUsePropertyDecoratorConfig) {
4848
super(sourceFile, options);
4949
this.languageService = languageService;
5050
this.typeChecker = languageService.getProgram().getTypeChecker();
@@ -75,7 +75,7 @@ class DirectiveMetadataWalker extends Lint.RuleWalker {
7575
this.createFailure(
7676
p.getStart(),
7777
p.getWidth(),
78-
UseParameterDecorator.formatFailureString(this.config, decoratorName, className)));
78+
UsePropertyDecorator.formatFailureString(this.config, decoratorName, className)));
7979
});
8080
}
8181
}

src/useHostParameterDecoratorRule.ts renamed to src/useHostPropertyDecoratorRule.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import * as Lint from 'tslint/lib/lint';
22

3-
import {UseParameterDecorator} from './parameterDecoratorBase';
3+
import {UsePropertyDecorator} from './propertyDecoratorBase';
44

5-
export class Rule extends UseParameterDecorator {
5+
export class Rule extends UsePropertyDecorator {
66
constructor(ruleName: string, value: any, disabledIntervals: Lint.IDisabledInterval[]) {
77
super({
88
decoratorName: ['HostBindings', 'HostListeners'],

src/useInputParameterDecoratorRule.ts renamed to src/useInputPropertyDecoratorRule.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import * as Lint from 'tslint/lib/lint';
22

3-
import {UseParameterDecorator} from './parameterDecoratorBase';
3+
import {UsePropertyDecorator} from './propertyDecoratorBase';
44

5-
export class Rule extends UseParameterDecorator {
5+
export class Rule extends UsePropertyDecorator {
66
constructor(ruleName: string, value: any, disabledIntervals: Lint.IDisabledInterval[]) {
77
super({
88
decoratorName: 'Input',

src/useOutputParameterDecoratorRule.ts renamed to src/useOutputPropertyDecoratorRule.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import * as Lint from 'tslint/lib/lint';
22

3-
import {UseParameterDecorator} from './parameterDecoratorBase';
3+
import {UsePropertyDecorator} from './propertyDecoratorBase';
44

5-
export class Rule extends UseParameterDecorator {
5+
export class Rule extends UsePropertyDecorator {
66
constructor(ruleName: string, value: any, disabledIntervals: Lint.IDisabledInterval[]) {
77
super({
88
decoratorName: 'Output',

test/useHostParameterDecoratorRule.spec.ts renamed to test/useHostPropertyDecoratorRule.spec.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import {assertFailure, assertSuccess} from './testHelper';
22

3-
describe('use-host-parameter-decorator', () => {
3+
describe('use-host-property-decorator', () => {
44
it('should fail when "host" is used in @Component', () => {
55
let source = `
66
@Component({
@@ -10,7 +10,7 @@ describe('use-host-parameter-decorator', () => {
1010
})
1111
class Bar {}
1212
`;
13-
assertFailure('use-host-parameter-decorator', source, {
13+
assertFailure('use-host-property-decorator', source, {
1414
message: 'In the "@Component" class decorator of the class "Bar" you are using the "host" property, this is considered bad practice. Use "@HostBindings", "@HostListeners" property decorator instead.',
1515
startPosition: {
1616
line: 2,
@@ -29,7 +29,7 @@ describe('use-host-parameter-decorator', () => {
2929
})
3030
class Bar {}
3131
`;
32-
assertSuccess('use-host-parameter-decorator', source);
32+
assertSuccess('use-host-property-decorator', source);
3333
});
3434
it('should fail when "host" is used in @Directive', () => {
3535
let source = `
@@ -40,7 +40,7 @@ describe('use-host-parameter-decorator', () => {
4040
})
4141
class Baz {}
4242
`;
43-
assertFailure('use-host-parameter-decorator', source, {
43+
assertFailure('use-host-property-decorator', source, {
4444
message: 'In the "@Directive" class decorator of the class "Baz" you are using the "host" property, this is considered bad practice. Use "@HostBindings", "@HostListeners" property decorator instead.',
4545
startPosition: {
4646
line: 2,

test/useInputParameterDecoratorRule.spec.ts renamed to test/useInputPropertyDecoratorRule.spec.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import {assertFailure, assertSuccess} from './testHelper';
22

3-
describe('use-input-parameter-decorator', () => {
3+
describe('use-input-property-decorator', () => {
44
it('should fail when "inputs" is used in @Component', () => {
55
let source = `
66
@Component({
@@ -10,7 +10,7 @@ describe('use-input-parameter-decorator', () => {
1010
})
1111
class Bar {}
1212
`;
13-
assertFailure('use-input-parameter-decorator', source, {
13+
assertFailure('use-input-property-decorator', source, {
1414
message: 'In the "@Component" class decorator of the class "Bar" you are using the "inputs" property, this is considered bad practice. Use "@Input" property decorator instead.',
1515
startPosition: {
1616
line: 2,
@@ -29,7 +29,7 @@ describe('use-input-parameter-decorator', () => {
2929
})
3030
class Bar {}
3131
`;
32-
assertSuccess('use-input-parameter-decorator', source);
32+
assertSuccess('use-input-property-decorator', source);
3333
});
3434
it('should fail when "inputs" is used in @Directive', () => {
3535
let source = `
@@ -40,7 +40,7 @@ describe('use-input-parameter-decorator', () => {
4040
})
4141
class Baz {}
4242
`;
43-
assertFailure('use-input-parameter-decorator', source, {
43+
assertFailure('use-input-property-decorator', source, {
4444
message: 'In the "@Directive" class decorator of the class "Baz" you are using the "inputs" property, this is considered bad practice. Use "@Input" property decorator instead.',
4545
startPosition: {
4646
line: 2,

test/useOutputParameterDecoratorRule.spec.ts renamed to test/useOutputPropertyDecoratorRule.spec.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import {assertFailure, assertSuccess} from './testHelper';
22

3-
describe('use-output-parameter-decorator', () => {
3+
describe('use-output-property-decorator', () => {
44
it('should fail when "outputs" is used in @Component', () => {
55
let source = `
66
@Component({
@@ -10,7 +10,7 @@ describe('use-output-parameter-decorator', () => {
1010
})
1111
class Bar {}
1212
`;
13-
assertFailure('use-output-parameter-decorator', source, {
13+
assertFailure('use-output-property-decorator', source, {
1414
message: 'In the "@Component" class decorator of the class "Bar" you are using the "outputs" property, this is considered bad practice. Use "@Output" property decorator instead.',
1515
startPosition: {
1616
line: 2,
@@ -29,7 +29,7 @@ describe('use-output-parameter-decorator', () => {
2929
})
3030
class Bar {}
3131
`;
32-
assertSuccess('use-output-parameter-decorator', source);
32+
assertSuccess('use-output-property-decorator', source);
3333
});
3434
it('should fail when "outputs" is used in @Directive', () => {
3535
let source = `
@@ -40,7 +40,7 @@ describe('use-output-parameter-decorator', () => {
4040
})
4141
class Baz {}
4242
`;
43-
assertFailure('use-output-parameter-decorator', source, {
43+
assertFailure('use-output-property-decorator', source, {
4444
message: 'In the "@Directive" class decorator of the class "Baz" you are using the "outputs" property, this is considered bad practice. Use "@Output" property decorator instead.',
4545
startPosition: {
4646
line: 2,

0 commit comments

Comments
 (0)