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
Update: add comment to message in no-warning-comments (fixes #12327) #13522
Conversation
Should we avoid linebreaks in multiline comments, for example for this one in linter.js the rule would output: 542:5 error Unexpected 'todo' comment: * TODO: @aladdin-add
* 1... no-warning-comments Also, if it isn't too difficult, it might be nice to avoid cutting words, surrogate pairs, and composite characters? |
Or can we add
I didn't get this |
Sorry, I didn't understand this, how would the output look like? I think we're usually trying to avoid linebreaks in final messages. In this case, the final message has a linebreak taken from the source code.
For example, for this comment, should the message be:
or
Also, "👍".slice(0, 1) // � |
like this I meant comment.replace('\n', '\\n') So it will be like
WDYT ?
OKay, I will try to implement the same without slice |
Maybe we could split the comment by whitespace, and then concatenate the parts with 1 space as a separator while the total length doesn't exceed the max? I guess that would solve all problems with linebreaks, breaking words, surrogate pairs, etc. The comment wouldn't look exactly like in the source code, but the significant content would be shown. |
yes, I have the similar thought. WDYT ? |
I don't have a strong opinion on this. It might be useful for someone (though we also report comment's line), but it might be seen as extra characters that negatively affect readability by someone else. |
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.
Looks great, thanks!
Thanks for contributing! |
Awesome! |
Prerequisites checklist
What is the purpose of this pull request? (put an "X" next to an item)
[ ] Documentation update
[ ] Bug fix (template)
[ ] New rule (template)
[X] Changes an existing rule (template)
[ ] Add autofixing to a rule
[ ] Add a CLI option
[ ] Add something to the core
[ ] Other, please explain:
What changes did you make? (Give an overview)
Added data in the error message which will show the comment itself.
It will only show till 30 characters
Is there anything you'd like reviewers to focus on?
Is
30
is fine ? after30
char it will be truncated.