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.

TypeError when --cursor-offset is specified

See original GitHub issue

Metadata

Input

test.rb

puts 'hello world'

Current output

Command:

./node_modules/.bin/prettier test.rb --cursor-offset 0

Crash:

[error] test.rb: TypeError: options.locStart is not a function
[error]     at Object.findNodeAtOffset (/Users/drp/dev-environment/node_modules/prettier/bin-prettier.js:13676:23)
[error]     at coreFormat (/Users/drp/dev-environment/node_modules/prettier/bin-prettier.js:13863:32)
[error]     at format (/Users/drp/dev-environment/node_modules/prettier/bin-prettier.js:14117:73)
[error]     at formatWithCursor (/Users/drp/dev-environment/node_modules/prettier/bin-prettier.js:14133:12)
[error]     at Object.formatWithCursor (/Users/drp/dev-environment/node_modules/prettier/bin-prettier.js:42401:15)
[error]     at format$1 (/Users/drp/dev-environment/node_modules/prettier/bin-prettier.js:43770:21)
[error]     at /Users/drp/dev-environment/node_modules/prettier/bin-prettier.js:43965:16
[error]     at /Users/drp/dev-environment/node_modules/prettier/bin-prettier.js:43905:14
[error]     at Array.forEach (<anonymous>)
[error]     at eachFilename (/Users/drp/dev-environment/node_modules/prettier/bin-prettier.js:43904:15)

Expected output

puts 'hello world'

It looks like the vue plugin had a similar problem at one point (https://github.com/prettier/prettier/issues/4867) but I’m not sure whether that’s relevant.

This looks like it might be a bug in prettier itself (not the plugin), but I can’t reproduce it except on ruby files.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:2
  • Comments:6 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
kddnewtoncommented, Jun 13, 2019

@cvoege I’ve been working on it but it’s been slow going. Your idea to have them as no-ops is a very good one, and I will do that and release a new version soon.

0reactions
kddnewtoncommented, Jul 5, 2019

Okay friends - this functionality is going to go out in the next version v0.13.0. Let me know how it goes for you.

Read more comments on GitHub >

github_iconTop Results From Across the Web

formatWithCursor issue #2131 - prettier/prettier - GitHub
prettier.formatWithCursor( ` foo('bar', cb => { console.log('stuff') })`, {cursorOffset: 24}). I get the following exception. TypeError: ...
Read more >
TypeError: $(...).offset(...) is undefined and offset exists
You're calling top on offset() which is returning undefined. This leads me to believe your $(this).attr("href") value is not a valid selector, ...
Read more >
FileSystemWritableFileStream.write() - Web APIs | MDN
Returned if PermissionStatus is not granted. TypeError. Returned if data is undefined, or if position or size aren't valid.
Read more >
CursorPagination -- Classy DRF
Detailed descriptions, with full methods and attributes of CursorPagination Django REST Framework class.
Read more >
Source code for pyqtgraph.graphicsItems.ROI
The ROI class is meant to serve as the base for more specific types; ... bool): raise TypeError("Positional arguments to setPos() must be...
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