Skip to content
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

(implements #323) Add require-prop-type-constructor rule #546

Merged
merged 4 commits into from
Aug 13, 2018

Conversation

michalsnik
Copy link
Member

This PR implements rule proposed in #323.

Unfortunately we can't detect all possible scenarios, hence I focused on those that are trivial and should catch most commonly made mistakes. We still allow CallExpressions and MemberExpressions, as we cannot assume those will not represent or return constructor implicitly.

create (context) {
const fix = node => fixer => {
if (node.type === 'Literal') {
return fixer.replaceText(node, node.value)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is need to check if the value type is string.
Hexadecimal literals such as 0xF are converted to numeric literals like 15.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't consider this case, as it seems extremely rare and nearly impossible to get unless you really want to break it.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

extremely rare and nearly impossible to get unless you really want to break it.

I think that you are right. I do not think it is necessary to take time and fix it.

@michalsnik michalsnik merged commit 47cc8d3 into master Aug 13, 2018
@michalsnik michalsnik deleted the add-no-string-prop-type-rule branch August 13, 2018 21:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants