-
-
Notifications
You must be signed in to change notification settings - Fork 4.5k
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
Infer the endLocation of a problem from the reported node #8004
Comments
I was under impression that we are already doing this. But if we are not, then I definitely support this. |
I avoided it: #6640 Because some rules in core and plugin ecosystem have sometimes used big node (Program, FunctionDeclaration, Property, .*Statement, ...). I'm afraid that it fills editors with red. |
Maybe we could implement it and then try to fix rules using large nodes as reports come in? |
Personally I think the issue with filling a screen is an editor integration problem, not an ESLint problem. I'm fine with waiting until a major release, but if we do that then we might also want to give some warning so that editors can display the best possible UI. |
For example: return {
Program(node) {
context.report({ node, message: 'report message' });
}
} In this case, currently the report is at the head of the source code, but the report spans whole the source code after this change. It's a breaking change that plugin owners need to modify their plugins. |
I don't oppose this if it happens on the next major release. |
Since it looks like we're probably going ahead with this change, we should probably notify editor integrations about this in case they want to change their behavior ahead of time. I pulled the list from the integrations page:
I haven't used most of these integrations, so I'm not sure how many of them are maintained. Also, there are probably some of integrations that wouldn't be affected by this change anyway. |
At least, I think the announcement is needed for plugin's authors rather than editor integrations because this is a breaking change of |
To add to the list of Vim editor integrations, neomake is also quite popular alongside Syntastic. |
I'll add this to the TSC agenda since it's a change to core that could break things. TSC Summary: As currently implemented, the TSC Question: Should we make this change? |
Previously, rules could specify an endLine and endColumn in a report. However, when a rule reported a node without explicitly giving a location, only the start location of the node was included in the final report object. This commit updates the report-handling logic to ensure that the end location of the node is also included. This is considered a potentially-breaking change because if a rule specifies a very large node to report, the report range will be very large, which could cause a poor user experience in editor integrations (e.g. if hundreds of lines are highlighted).
In today's TSC meeting, the TSC accepted this issue. |
Problem
Currently, the
context.report
API allows rules to specify a start and end location for problems:This was added to address #3307, and it's very useful because it allows editor integrations to highlight an entire range.
However, as currently implemented this API is tedious to use, because it only works if a report includes a
loc
key. As a result, most rules don't use this API, because they report a node instead of an explicit location. (When a node is reported, only the start location of the node appears in the resulting message -- the end location does not appear.)Proposal
When a node is reported without a location, the end location of the node should be used as the end location of the report. (The start location of the node is already used for the start location of the report.)
For example, given the following node:
Suppose a rule uses
The resulting problem message currently looks like this:
With this change, the resulting problem message would look like this:
The text was updated successfully, but these errors were encountered: