-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Detect erroneous multi-line strings. #4979
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
Comments
Also it might be a good idea to do different syntax highlighting so that these strings stick out. |
Added this to the M2 milestone. |
Set owner to @bwilkerson. |
Set owner to @bwilkerson. |
Added Analyzer-Hint label. |
Removed this from the Later milestone. |
Removed Oldschool-Milestone-Later label. |
I don't think the analyzer is going to do either of the suggestions:
|
A request for this same functionality was just added to the linter project. It appears that it is a fairly common mistake, and we ought to provide support. |
Ah. #57318. The list literal case. I think we have to be careful in what we're fixing, to avoid generating noise warnings. Should there just be a hint in List literals to never use "space"-concatenated String literals? I think the request in #57318 is based on the idea that trailing plus signs are much more visible than trailing (or missing) commas. |
That seems reasonable to me, although I'd make it a lint rather than a hint. |
This is now implemented as a lint: no_adjacent_strings_in_list, and the formatter also indents such that the error is noticeable. |
It is a (relatively) common error to forgot commas between two items of a string list:
var a = ["foo",
"bar" // <===
"gee"];
In this case "bar" and "gee" will be concatenated without any warning.
It would be nice if the editor offered some kind of warning for this.
In general this is difficult, but the following heuristics could potentially work:
The text was updated successfully, but these errors were encountered: