Skip to content

Variable comments confuse expression comments after it #23

@bahmutov

Description

@bahmutov

Seems by inserting statements we break the expressions later

const x = 2
// x:
function add(a, b) {
  return a + b
}
add(x, 3) //>

crashes with

Error: missing line 6 for comment {
  "start": 111,
  "text": ">",
  "from": {
    "line": 7,
    "column": 10
  },
  "to": {
    "line": 7,
    "column": 13
  },
  "filename": "/Users/gleb/git/comment-value/test/combined/index.js",
  "commentStart": ">",
  "index": 0
}
    at lazyAssLogic (/Users/gleb/git/comment-value/node_modules/lazy-ass/index.js:110:14)
    at lazyAss (/Users/gleb/git/comment-value/node_modules/lazy-ass/index.js:115:28)
    at updateComment (/Users/gleb/git/comment-value/src/update.js:64:5)

Removing the variable comment from line 2 solves the crash

const x = 2
// x:
function add(a, b) {
  return a + b
}
add(x, 3) //> 5

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions