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

Fix prevent-abbreviations fixer bug #444

Merged
merged 3 commits into from Nov 29, 2019

Conversation

fisker
Copy link
Collaborator

@fisker fisker commented Nov 27, 2019

fixes: #443 and fixes #330

I've located the problem, in isShorthandPropertyIdentifier check function, In babel-eslint parent.key is not reference of identifier, add a extra check to make it pass

Comment on lines 373 to 378
(
identifier.parent.key.type === identifier.type &&
identifier.parent.key.name === identifier.name &&
identifier.parent.key.start === identifier.start &&
identifier.parent.key.end === identifier.end
)
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I don't have much experience on those ASTs, I'm not sure if this is good

@fisker
Copy link
Collaborator Author

fisker commented Nov 27, 2019

also there is a few other functions in this file compares parent.key === identifier, I'm not sure those logic requires modification

@fisker fisker marked this pull request as ready for review November 27, 2019 07:20
@fisker fisker requested a review from futpib November 27, 2019 07:20
identifier.parent.shorthand &&
(
identifier.parent.key === identifier ||
// In `babel-eslint` parent.key is not reference of identifier
Copy link
Owner

Choose a reason for hiding this comment

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

Can you open an issue about this on babel-eslint? The point of that package is to normalize the AST.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

you are right, we might not do this check, I've found other cases also broken, let me have a look at their repo first

Copy link
Owner

Choose a reason for hiding this comment

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

I’m ok with working around it, but we should always also try to get it fixed upstream.

Copy link
Owner

Choose a reason for hiding this comment

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

Add a code comment with a link to the Babel-eslint issue.

@fisker
Copy link
Collaborator Author

fisker commented Nov 27, 2019

i just confirmed (Property)Node.key.parent ==== Node, so it's maybe not babel-eslint bug, let me dig more deeper

@sindresorhus sindresorhus merged commit fa8c80e into sindresorhus:master Nov 29, 2019
@fisker fisker deleted the issue-443 branch November 30, 2019 09:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants