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

Plugin makes syntax invalid #27

Closed
demaisj opened this issue Oct 22, 2019 · 2 comments · Fixed by #28
Closed

Plugin makes syntax invalid #27

demaisj opened this issue Oct 22, 2019 · 2 comments · Fixed by #28
Assignees
Labels
type: bug Functionality that does not work as intended/expected

Comments

@demaisj
Copy link

demaisj commented Oct 22, 2019

Hello, today while setting up prettier + prettier-pug I encountered this problem:

The prettier-pug plugin, when ran on a pug file with the --write flag, will fix the code style and as a side-effect sometimes corrupt the syntax of the file, producing an invalid file which cannot be processed on subsequent runs.

As an example here this completely valid pug file:

tag(key='value') #{identifier}
tag
  | #{identifier}

The prettier-pug produces this output, which is invalid:

tag(key='value')#{identifier}
tag
#{identifier}

When using the pug package, it reports this error:

Error: /file.pug:1:17
  > 1| tag(key='value')#{identifier}
-----------------------^
    2| tag
    3| #{identifier}
    4| 
  
Unexpected token `interpolation` expected `text`, `interpolated-code`, `code`, `:`, `slash`, `newline` or `eos`

When running pug-prettier on the new pug file, it produces this error:

[error] /file.pug: Error: Unhandled token: {"type":"interpolation","loc":{"start":{"line":1,"column":17},"end":{"line":1,"column":30}},"val":"identifier"}
[error]     at _loop_1 (/node_modules/@prettier/plugin-pug/dist/index.js:542:35)
[error]     at Object.print (/node_modules/@prettier/plugin-pug/dist/index.js:546:21)
[error]     at callPluginPrintFunction (/node_modules/prettier/bin-prettier.js:13622:18)
[error]     at /node_modules/prettier/bin-prettier.js:13573:16
[error]     at Object.printComments (/node_modules/prettier/bin-prettier.js:13295:17)
[error]     at printGenerically (/node_modules/prettier/bin-prettier.js:13572:22)
[error]     at printAstToDoc (/node_modules/prettier/bin-prettier.js:13584:16)
[error]     at coreFormat (/node_modules/prettier/bin-prettier.js:13903:16)
[error]     at format (/node_modules/prettier/bin-prettier.js:14148:73)
[error]     at formatWithCursor (/node_modules/prettier/bin-prettier.js:14164:12)
@Shinigami92 Shinigami92 added the type: bug Functionality that does not work as intended/expected label Oct 22, 2019
@Shinigami92 Shinigami92 self-assigned this Oct 22, 2019
@Shinigami92
Copy link
Member

Shinigami92 commented Oct 22, 2019

I will work on it in two days
Currently not at home

@Shinigami92
Copy link
Member

Shinigami92 commented Oct 23, 2019

Released as 1.0.5
Thanks for using my Plugin 😃

If something is not working correctly, feel free to reply to this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug Functionality that does not work as intended/expected
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants