New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix noInputRenameRule #585
Conversation
test/noInputRenameRule.spec.ts
Outdated
source | ||
}); | ||
}); | ||
it('should fail when a input property has the same name that the alias', () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: break line before it
. Also, shouldn't it be ...an input...
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
test/noInputRenameRule.spec.ts
Outdated
@@ -56,19 +66,35 @@ describe(ruleName, () => { | |||
}); | |||
}); | |||
|
|||
it("should fail when input property is renamed and it's different from directive's selector", () => { | |||
it('should fail when a input property has the same name that the alias', () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
an input
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
src/noInputRenameRule.ts
Outdated
if ( | ||
args.length === 0 || | ||
(this.directiveSelector && | ||
(input.expression as any).arguments.some(arg => this.directiveSelector.indexOf(arg.text) !== -1 && memberName !== arg.text)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of casting to any
, what about (input.expression as ts.CallExpression)
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
test/noInputRenameRule.spec.ts
Outdated
@@ -3,18 +3,24 @@ import { assertSuccess, assertAnnotated } from './testHelper'; | |||
const ruleName = 'no-input-rename'; | |||
|
|||
const getMessage = (className: string, propertyName: string): string => { | |||
return `In the class "${className}", the directive input property "${propertyName}" should not be renamed.`; | |||
return ( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To be always sync with the rule's name and also metadata, I'd refactor it to:
const { FAILURE_STRING, metadata: { ruleName } } = Rule;
const getFailureMessage = (className: string, propertyName: string): string => {
sprintf(FAILURE_STRING, className, propertyName);
};
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
In the hope that it clarifies things:
Fixes #580