You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Bug: printWidth option (or pugPrintWidth) not working #511
For some reason, the default Prettier option is not working with pug files. I tried both options printWidth and pugPrintWidth. The pug file with some long text remains unformatted.
Also, the plugin does not convert indents to tabs ("useTabs": true) on save.
For some reason, the default Prettier option is not working with pug files. I tried both options printWidth and pugPrintWidth. The pug file with some long text remains unformatted.
@Shinigami92 After diving into this issue, I found the following:
In the test example for printWidth there is long text IN THE ATTRIBUTES. In this case, it works. It just throws to a new line all attributes). But I need to control it, if I have the pug code with long text IN THE PARAGRAPH (or in any other tag) - just like plain text. Same way if there will be more large text (more than in printWidth value) in any attribute (in foo or bar - like in test) it also will be not formatted correctly. screenshot. Expected result must be like this screenshot
About useTabs. In this tests http://github.com/prettier/plugin-pug/tree/main/tests/indents it works only if there is ALL INDENTS ARE THE SAME in the pug file (for example all indents are with dots - and with "useTabs": true all of them will correctly formatted into tabs. But if there will be one tab space, this tab will fail the converting.
For second point, I think I remember that the underlying pug-compiler crashes/fails when there are mixed spaces and tabs, so we might be out of luck here and you should e.g. use http://github.com/pugjs/pug-lint for such cases.
When you try tackling these via PRs, please ensure to open separate PRs for each individual problem.
Did you know the way, how I can run fixing finding problems by http://github.com/pugjs/pug-lint on save? Because for now, I use this both 2 plugins:
@prettier/plugin-pug - to format the pug-code on save by setting "editor.defaultFormatter": "esbenp.prettier-vscode" (but I couldn't find the way, how to show all problems/errors in pug files that not matching the settings in .prettierrc)
pug-lint - to show problems/errors underline in the VS Code (but I couldn't find the way, to fix on save all finding linting problems).
Not sure that it is a proper way, but I found only this way to format code on save + show problems screenshot
Did you know the way, how I can run fixing finding problems by pugjs/pug-lint on save? Because for now, I use this both 2 plugins:
@prettier/plugin-pug - to format the pug-code on save by setting "editor.defaultFormatter": "esbenp.prettier-vscode" (but I couldn't find the way, how to show all problems/errors in pug files that not matching the settings in .prettierrc) pug-lint - to show problems/errors underline in the VS Code (but I couldn't find the way, to fix on save all finding linting problems).
Not sure that it is a proper way, but I found only this way to format code on save + show problems screenshot
As I do not have anymore an active pug project for 2 years now, TLDR: no
Activity
Shinigami92 commentedon Sep 10, 2024
There is a test for printWidth http://github.com/prettier/plugin-pug/tree/main/tests/options/printWidth
There is a whole test for this http://github.com/prettier/plugin-pug/tree/main/tests/indents
You could checkout the project and add tests for your specific case in http://github.com/prettier/plugin-pug/tree/main/tests/issues
just add a new folder issue-511 and orientate yourself on other issue tests
evgeniy-vashchuk commentedon Sep 11, 2024
Okay, thanks! Will check it.
evgeniy-vashchuk commentedon Sep 11, 2024
@Shinigami92 After diving into this issue, I found the following:
In the test example for printWidth there is long text IN THE ATTRIBUTES. In this case, it works. It just throws to a new line all attributes). But I need to control it, if I have the pug code with long text IN THE PARAGRAPH (or in any other tag) - just like plain text. Same way if there will be more large text (more than in printWidth value) in any attribute (in foo or bar - like in test) it also will be not formatted correctly. screenshot. Expected result must be like this screenshot
About useTabs. In this tests http://github.com/prettier/plugin-pug/tree/main/tests/indents it works only if there is ALL INDENTS ARE THE SAME in the pug file (for example all indents are with dots - and with "useTabs": true all of them will correctly formatted into tabs. But if there will be one tab space, this tab will fail the converting.
Shinigami92 commentedon Sep 11, 2024
For second point, I think I remember that the underlying pug-compiler crashes/fails when there are mixed spaces and tabs, so we might be out of luck here and you should e.g. use http://github.com/pugjs/pug-lint for such cases.
When you try tackling these via PRs, please ensure to open separate PRs for each individual problem.
evgeniy-vashchuk commentedon Sep 11, 2024
Did you know the way, how I can run fixing finding problems by http://github.com/pugjs/pug-lint on save? Because for now, I use this both 2 plugins:
@prettier/plugin-pug - to format the pug-code on save by setting "editor.defaultFormatter": "esbenp.prettier-vscode" (but I couldn't find the way, how to show all problems/errors in pug files that not matching the settings in .prettierrc)
pug-lint - to show problems/errors underline in the VS Code (but I couldn't find the way, to fix on save all finding linting problems).
Not sure that it is a proper way, but I found only this way to format code on save + show problems screenshot
Shinigami92 commentedon Sep 11, 2024
As I do not have anymore an active pug project for 2 years now, TLDR: no