Vscode and atom highlight locations are unexpected when end location is not provided
See original GitHub issueSummary Many rules reports only start location and no end location. For these rules, editors often renders tildes in unexpected places.
Examples
In these examples, the rules only reports start location but no end locations. Instead of highlighting tokens like \n
, (
, or {
, the token before the said token is highlighted.
/* eslint semi: [2, 'always'] */
const a = Math.random
// ~~~~~~ actual highlight in vscode
// ~ expected highlight
// ^ reported start location
/* eslint object-curly-spacing: [2, 'always'] */
const b = {b: Math.random}
// ~~~~~~ actual highlight in vscode
// ~ expected highlight
// ^ reported start location
/* eslint space-in-parens: [2, 'never'] */
function ffff( a ) {}
// ~~~~ actual highlight in vscode
// ~ expected highlight
// ^ reported start location
There are many other rules suffering from this problem, most of them are named *space*
or *spacing*
.
How to fix The problem disappear if the both start location and end location are reported and start location is different to end location. That is, the location range is not zero-width-ed.
There are several places this can be done:
-
Modify each rules to report end location. Pros: explicit. Cons: lots of place needs change.
-
Modify ESLint core, automatically add end location when end location is missing. Cons: not explicit.
-
Modify vscode-eslint plugin to automatically add end location when end location is missing.
Issue Analytics
- State:
- Created 4 years ago
- Reactions:3
- Comments:28 (27 by maintainers)
Top GitHub Comments
This is a list of rules that reports start column but misses end column. The list is acquired by patching rule tester in a dirty way.
This is all done 🎉 .