question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Vscode and atom highlight locations are unexpected when end location is not provided

See original GitHub issue

Summary 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:

  1. Modify each rules to report end location. Pros: explicit. Cons: lots of place needs change.

  2. Modify ESLint core, automatically add end location when end location is missing. Cons: not explicit.

  3. Modify vscode-eslint plugin to automatically add end location when end location is missing.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:3
  • Comments:28 (27 by maintainers)

github_iconTop GitHub Comments

5reactions
golopotcommented, Aug 23, 2021

… Ideally, it would be nice to audit the rules and make a list we can keep track of here.

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.

  • array-callback-return (#13109)
  • arrow-body-style (#13424)
  • block-spacing (#13314)
  • consistent-return (#14798)
  • comma-style (#13111)
  • curly (#14766)
  • eol-last (#14840 )
  • func-call-spacing (#13311)
  • getter-return (#13164)
  • ~indent-legacy~ (deprecated)
  • key-spacing (#13362)
  • keyword-spacing ( #13377) (#13461)
  • linebreak-style (#13317)
  • max-len (#13458)
  • max-lines (#13318)
  • new-cap (#13136)
  • newline-per-chained-call (#13116)
  • no-empty-function (#13121)
  • no-extra-bind (#13083)
  • no-irregular-whitespace (#13462)
  • no-mixed-spaces-and-tabs (#13365)
  • no-prototype-builtins (#13087)
  • no-redeclare (#13086)
  • ~no-spaced-func~ (deprecated)
  • no-unexpected-multiline (#13142)
  • no-unneeded-ternary (#13456)
  • no-unused-vars (#13086)
  • no-useless-concat (#13110)
  • object-curly-newline (#13460)
  • object-property-newline (#13399)
  • one-var-declaration-per-line (#13326)
  • operator-linebreak (#13102)
  • padded-blocks (#13328)
  • rest-spread-spacing (#13313)
  • semi (#12380) (#14899)
  • semi-spacing (#13285)
  • space-before-function-paren (#13128)
  • template-curly-spacing (#12813)
  • template-tag-spacing (#13203)
  • unicode-bom (#14809)
4reactions
snitin315commented, Aug 23, 2021

This is all done 🎉 .

Read more comments on GitHub >

github_iconTop Results From Across the Web

May 2017 (version 1.13) - Visual Studio Code
Editor - Resizable Find widget, new folding control settings. Languages - JSX/TSX component highlighting, Markdown headers in symbol search. Debugging - Copy ...
Read more >
How to configure Prettier and VSCode - Gleb Bahmutov
Make sure local workspace settings have auto-format on save enabled. Open . vscode/settings. json file and confirm:
Read more >
Select everything between matching brackets in VS Code
Place the cursor inside the bracket (not directly next to a bracket) and execute editor.action.smartSelect.grow until everything inside the ...
Read more >
12 Favorite Atom Tips and Shortcuts to Improve Your Workflow
One annoyance I have is when I copy code from somewhere and the indentation is all over the place. Luckily, Atom has you...
Read more >
Debugging errors - dbt Developer Hub
The target/compiled directory contains select statements that you can run in ... VSCode help). ... Note: not all errors are covered here!
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found