-
Notifications
You must be signed in to change notification settings - Fork 47
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
Gutter highlights only show on first line #398
Comments
That's actually bad behavior of the ESLint plugin, instead of underlining just the start, it underlines the entire callback function so it ends up looking like it does |
Actually, this is the combination of a few things:
|
@Arcanemagus Good question, multi line ranges this long aren't all that common, but yeah it should mark gutter for all lines |
Thanks for the response I expected it to be the plugin. |
👋 author of |
@xjamundx Responded with my best guess over there 😉. |
@steelbrain I have same underline behavior problem even without additional plugins enabled, with rules like |
The same issue happen with the rule |
@vanduynslagerp The new behavior is definitely intentional on ESLint's part, the issue is that I'm guessing that rule is returning the function node, which is leading to that entire function being highlighted, you could try coming up with a better range to highlight and proposing it on the ESLint repo, but that already sounds like the best option for that so I'd just consider that extra motivation to fix the rule 😛. |
Filed a bug on Atom about this decoration issue, hopefully once that gets fixed it shouldn't look so bizarre. The gutter not highlighting on each line is still a bug that should be fixed here so I'm updating the labels appropriately. |
I think this is related: #381 |
#381 has nothing to do with this, this is half a bug in Atom with how it displays large range highlights, and half a bug with how |
Turns out the bizarre highlighting was actually a side effect of the hacky method used to highlight lines here. I've put up #431 in order to update to the new |
I really like that errors are underlined. I do bump into the issue of very large areas being underlined, though, especially when using linter-eslint.
Example: The entire file is underlinedThis is when using flowtype/require-valid-file-annotation. Example: A whole block is underlinedThis is when using no-constant-condition. Discussion
Thoughts? |
Fascinating, the only CLI formatters that report ranges are the ones meant to be parsed by tools. In any case, highlighting the entire file is what is being requested by the plugin. You can file an issue there and see if they have a tighter range they might be able to report, the error looks like one that should be reported on the entire file though. For a bit more detail on why this can't be easily handled in
I'm personally very much against this, the provider is giving a range, and the entire range should be marked.
The tooltip should disappear as soon as you start typing, please file a separate issue if that isn't working as it should for you. Also I could definitely see Escape being used to dismiss the tooltip, I actually thought it already did but it doesn't seem that way. With the underline issue fixed in #431, the only remaining part of this issue is the gutter highlights not showing up on each affected line... if they even should? I'm updating the title to reflect that. |
Nah, the first line would be just as correct, in my opinion.
When a whole file is underlined, or a big part of it, do you personally think that:
If you think it's kinda annoying, do you think that:
As far as I understand, ESLint seems to many times report entire AST nodes as locations for errors, which naturally can result in very large ranges. Not even ESLint's own "codeframe" formatter shows the entire ranges, only the first line (and a few surrounding lines for context):
I think it could be resonable to think of the provider giving a range telling where the erroneous code is and asking for that to be conveyed to the user in a helpful way. In other words, the provider is only saying what it knows not what it wants, and leaves it up to the UI package to decide how to display things.
Thanks, it never occurred to me to try that. Probably because I didn't know what to type because I couldn't read :) The tooltip comes back as soon as you start moving again, though. Tricky to say how it should work here. |
Correct, as I said before none of ESLint's CLI reporters meant for human consumption utilize the ranges at all.
That's what is already done: The provider gives a range and the UI conveys that range to the user.
If you feel that you have a better solution to how to display the information please file an issue or better yet a PR, or create a UI of your own. @mehcode's As I already stated though, the best place to fix this particular issue you are bringing up is to do so in the ESLint rule, that way all ways of reporting information to the user, whether that's in Atom, VS Code, ST, the CLI, etc. will show the new, better, range. Your "whole block" example is a perfect place where the range should definitely be constrained to just the part that is triggering the constant condition. The rule shouldn't be reporting the entire |
I don't consider this a bug in the CLI reporters, but a feature. I think the authors of the reporters realized that the start of the range is by far the most useful, while the rest mostly redundant, so they chose to only show the start. So I do think this is relevant to the discussion: The CLI reporters have set an example that could be followed.
True. But what about this one: That's from the consistent-return rule. Isn't it correct to report the entire I totally understand if you feel strongly about this and don't want to change/extend linter-ui-default, and that I'm free to fork it if I want to. I just have a hard time letting this discussion go because the reasons not to change anything feel a little ... artificial :) Like (if you exaggerate just a little) if linter-ui-default was made for robots, not humans. Don't get me wrong, I appreciate all the hard work that's been put down in atom-linter, and it's actually really great. This overwhelming underlining thing is just a little stumbling block I run into every now and then :) If you want to end the discussion here, that's fine. Thank you for taking the time to answer! I'll think about making a fork with the sole change that ranges are clipped to the first newline, and that otherwise tracks upstream very closely. |
I'm almost certain the reports haven't been changed since before ESLint even had range reporting, it's not that they chose this way of working, it's just that is what was available when they were designed.
I wasn't saying that all examples were things that could be better served by tighter ranges, that's one where it definitely should be the entire second
I personally like to have as much information as possible, and I like it to be correct, so making the ranges "fuzzy" or altering what is being reported as "truth" from the linter just goes against the "correctness" of things, at least as I see it. 🤖 I've actually found several bugs in linters themselves and reported them back up for all users of the linters to get the fix, all from checking that what the linters are giving is actually a real point in the document, instead of just clipping it down to a valid point.
It bugs me too sometimes when the range really shouldn't be that large, so you aren't alone there.
It's always interesting hearing "the other side", in this case it seems you are going for ease of use, which isn't a perspective I take into account as often as it should be.
@steelbrain is the one who has mainly worked on
It's likely a fork of |
Thanks for all the answers, and the pointer to the relevant linter-eslint code! I think I'll go down the path of reporting a few ESLint rules for having too broad ranges, and see what kind of responses I get. After some time I'll re-evaluate if I need to contribute to linter-eslint or fork something :) |
In case somebody finds this conversation when searching, I ended up creating this hack to make errors singleline: https://atom.io/packages/linter-patch-errors-singleline |
I think you had a positive idea @lydell @dertieran and others. The thing is, providers can do this individually, it would be amazing if they did. but Linter would be not as useful if every provider did this. I know some packages that use linter to highlight ALL the code that is not covered by flow. It would be useless if they only underlined one line because you want all the multi lines that are not covered by flow. But I would be fine by having a single provider like ESLint trim down their ranges to just one line, if that makes sense. and while we're at it, until first character instead of first full line would also be preferrable (but then again ranges won't be the real "ranges" they would be start points so I'll let the current maintainer of linter-eslint decide on that) |
Closing as external but please feel free to continue discussing, if you have any disagreements to what I said, please feel free to voice them and I'll reopen the issue |
I suggested an option to only highlight the first line :)
And linter-elm-make. And possibly others. Anyhow, I'm satisfied with my "hack" solution and shouldn't really comment more here :) |
I would be interested in a function in |
The multi-line highlighting part of this was already solved in #431, this issue is still open due to the gutter highlights only showing on the first line of a range. If you think it's fine to leave them as only showing on the first line re-close this @steelbrain 😉. |
This might not be a problem with the linter UI but with the linter/plugin itself, but I still wanted to ask here first.
I'm using
linter-eslint
and noticed some weird underline behavior for some rules.(The once I noticed are mainly from the
eslint-plugin-promise
so it could be related to that)The screenshot below shows just one warning and the gutter seems to be right,
but the underline is all over the place which is quite annoying for readability.
The text was updated successfully, but these errors were encountered: