Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SyntaxError: Unexpected token #69

Closed
dfishburn opened this issue Oct 10, 2017 · 1 comment
Closed

SyntaxError: Unexpected token #69

dfishburn opened this issue Oct 10, 2017 · 1 comment

Comments

@dfishburn
Copy link

vim-prettier 0.2.3

I have the following JSON:

{
  "URL": { "demoVisualization_comment": "Additional parameters are included: ?tempUnit=F&edgeHost=<ip_or_host_name_of_this_machine>", "securityCertificate": "downloads/test.zip" }
}

If I simply run :Prettier, I get this correct output:

{
  "URL": {
    "demoVisualization_comment":
      "Additional parameters are included: ?tempUnit=F&edgeHost=<ip_or_host_name_of_this_machine>",
    "securityCertificate": "downloads/test.zip"
  }
}

But, if I visually select just this line:

  "URL": { "demoVisualization_comment": "Additional parameters are included: ?tempUnit=F&edgeHost=<ip_or_host_name_of_this_machine>", "securityCertificate": "downloads/test.zip" }

And run: :'<,'>Prettier, I get an error:

demoConfig.json|1 col 8| SyntaxError: Unexpected token

Prettier version:

$ npm i -g prettier
prettier@1.7.4 C:\...\npm\node_modules\prettier

$ node --version
v4.2.1

Note, it is a bit inconsistent.
If I had more lines, sometimes it formats them correctly. I was pruning my JSON lines to try to find a small reproducible example.

@mitermayer
Copy link
Member

Hi @dfishburn,

Thanks for reporting this issue, when sending the selected text to prettier and having it attempt to format it, this relies on the line being sent to be on a valid format that the parser can understand, that's why you get that error since the bellow statement is not a valid JSON format on it's own:

  "URL": { "demoVisualization_comment": "Additional parameters are included: ?tempUnit=F&edgeHost=<ip_or_host_name_of_this_machine>", "securityCertificate": "downloads/test.zip" }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants