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

prefer-node-remove: Only fix when expression is not used #498

Merged

Conversation

brettz9
Copy link
Contributor

@brettz9 brettz9 commented Jan 17, 2020

Fixes #497

I also have a minor update and very minor refactoring included with this PR. Let me know if you need them separated out.

rules/prefer-node-remove.js Outdated Show resolved Hide resolved
Copy link
Collaborator

@fisker fisker left a comment

Choose a reason for hiding this comment

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

LGTM, one comment

@brettz9
Copy link
Contributor Author

brettz9 commented Jan 20, 2020

Applied, thanks.

Btw, I'm getting issues when running npm run lint, even before my changes. But npm test and npm run integration are working.

@fisker
Copy link
Collaborator

fisker commented Jan 20, 2020

@brettz9 If they are the some, can we add a function maybe isReturnValueUsed(or a better name) in /rules/utils?

@brettz9
Copy link
Contributor Author

brettz9 commented Jan 20, 2020

isReturnValueUsed seemed ok to me (couldn't think of anything else) so I've implemented.

I'm on a slow connection so I haven't been able to complete npm run integration locally this time, but I see it is passing on CI.

rules/prefer-node-append.js Outdated Show resolved Hide resolved
@brettz9
Copy link
Contributor Author

brettz9 commented Jan 20, 2020

actually, on further reflection, I'm thinking isValueUsed would be better, since it is not necessarily part of a return. I've added a commit to change, though feel free to revert.

rules/prefer-node-remove.js Outdated Show resolved Hide resolved
@fisker fisker changed the title Prefer node remove returns and fixer prefer-node-remove: Only fix when expression is not used Jan 20, 2020
@fisker
Copy link
Collaborator

fisker commented Jan 20, 2020

Looks great, thank you very much.

I think prefer-modern-dom-apis also missing some check #362 (comment) , If you're interested, maybe you can help, just let you know, no pressure.

I also notice, prefer-modern-dom-apis checked nodeParentType === 'AssignmentExpression' and we don't do this check here, not sure if is it needed.

@brettz9
Copy link
Contributor Author

brettz9 commented Jan 21, 2020

Yes, indeed, nodeParentType === 'AssignmentExpression' was needed. I've added that and some tests.

And thanks for the heads up on prefer-modern-dom-apis.

Copy link
Collaborator

@fisker fisker left a comment

Choose a reason for hiding this comment

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

Great, thanks again.

@sindresorhus sindresorhus merged commit b1d3f37 into sindresorhus:master Jan 21, 2020
@brettz9 brettz9 deleted the prefer-node-remove-returns-and-fixer branch January 21, 2020 07:09
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.

prefer-node-remove: prevent fixer when using return value
3 participants