fix(comments): preserve comments#68
Open
Kristinita wants to merge 3 commits intoJamieMason:mainfrom
Open
Conversation
fix JamieMason#24 Signed-off-by: Kristinita <Kristinita@users.noreply.github.com>
Signed-off-by: Kristinita <Kristinita@users.noreply.github.com>
aeef4bf to
559b928
Compare
…on body test(comments): add more tests refactor(comments): refactor the methods preserving comments Signed-off-by: Kristinita <Kristinita@users.noreply.github.com>
559b928 to
c389688
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
1. Summary
eslint-plugin-prefer-arrow-functions with my changes preserves Flow comment types and their formatting.
My changes should fix the issue #24.
2. The reason for the need for the feature
Before my changes, eslint-plugin-prefer-arrow-functions removed all Flow comment types if a user ran ESLint with the argument
--fix. It’s the critical problem for users using Flow comment-based syntax. Flow checks types inside comments.I tested my changes in my real project with Flow comment types, and I can’t find cases of unexpected behavior.
3. Notes
Not solely Flow users may need to preserve comments. I don’t know all the ways users add comments. Additional pull requests may be required.
The plugin doesn’t preserve formatting if a user has a multiline comment before a fat arrow. In CoffeeScript, I use a syntax like this:
JavaScript doesn’t support this syntax:
To preserve code validity I couldn’t think of anything better than to convert multiline comments to single-line ones:
Thanks.