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.

Range information is inconsistent for Program nodes with leading whitespace

See original GitHub issue
// espree 3.4.3

require('espree').parse('/* foo */ bar /* baz */', { range: true })
Output
{
  "type": "Program",
  "start": 0,
  "end": 23,
  "range": [
    10,
    13
  ],
  "body": [
    {
      "type": "ExpressionStatement",
      "start": 10,
      "end": 13,
      "range": [
        10,
        13
      ],
      "expression": {
        "type": "Identifier",
        "start": 10,
        "end": 13,
        "range": [
          10,
          13
        ],
        "name": "bar"
      }
    }
  ],
  "sourceType": "script"
}

The Program node has start: 0 and end: 23, but its range is [10, 13].

This happens because espree transforms the range property to match Esprima’s behavior. The transformation is correct, but we should also update the start and end properties, since they’re equivalent in all other cases.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:8 (8 by maintainers)

github_iconTop GitHub Comments

1reaction
anikethsahacommented, Dec 4, 2020

I am working on this. This should probably be a breaking change.

0reactions
nzakascommented, Nov 25, 2020

This is already marked as accepted, so any volunteers? 😄

Read more comments on GitHub >

github_iconTop Results From Across the Web

Docstring has inconsistent leading whitespace - Stack Overflow
1 Answer 1 · right. the error is due to the fact that the \n is interpreted as part of the string thereby...
Read more >
TSC meeting 03-December-2020 · Issue #222 · eslint/tsc-meetings ...
Range information is inconsistent for Program nodes with leading whitespace espree#349 - not originally marked as breaking, but maybe should be? Breaking: acorn ......
Read more >
XSL Transformations (XSLT) Version 3.0 - W3C
Abstract. This specification defines the syntax and semantics of XSLT 3.0, a language designed primarily for transforming XML documents into ...
Read more >
5673 – header-rule whitespace munging semantics should be ...
this is a major bug Since the get("ALL") already clobbers whitespace on FWS, turning ranges of TABs, spaces and form-feeds(!?) into a single...
Read more >
IO tools (text, CSV, HDF5, …) — pandas 1.5.2 documentation
Specifies whether or not whitespace (e.g. ' ' or '\t' ) will be used as ... This ensures that the columns are taken...
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