-
-
Notifications
You must be signed in to change notification settings - Fork 43
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
Bug: Doesn't take the singleQuote option #45
Comments
Is it only in these code blocks? |
No, in all my pug files, single quotes are tranformed into double quotes. |
Do you have a repo that you can link? |
I can't reproduce it? I have a project with 81 pug files My {
"arrowParens": "always",
"bracketSpacing": true,
"printWidth": 120,
"semi": true,
"singleQuote": true,
"trailingComma": "none",
"tabWidth": 2,
"useTabs": false,
"overrides": [
{
"files": ["*.pug"],
"options": {
"tabWidth": 2,
"singleQuote": false
}
}
]
} |
I also have tests for this: https://github.com/prettier/plugin-pug/tree/master/test/quotes |
I have create a repo with an example of the problem. The prettier config is in the package.json. |
Ha! I got it The code in your pug file is JavaScript Just add a tag with attributes and play with the singleQuote attribute in both places |
For me, pug attributes are singleQuoted and javascript content is transformed into double quotes. |
Line 147 in b7d26c7
The quotes will always be the other way around than JavaScripts configuration |
No way to have singleQuote everywhere in my pug files ? |
Currently no. |
https://github.com/prettier/plugin-pug/blob/master/test/quotes/single-to-double/formatted.pug Here the colon prefixed values and the curly braced value are JavaScript I'm thinking about to implement options for enabling vue and angular specialized code... Is it a huge problem for you that the quotes are different for js and pug in one file? |
It's not a huge problem but I prefer to have only single quotes in all my projects. Don't have this possibility will make me use another formater for pug files but I understand why you make this choice. |
Ok, using another formatter means a huge problem 😏 So I will work on it the next days I need two things from you
|
Yeah, maybe in the future I will work with Vue and Pug. I will make you soon a sample with complex pug code. |
Sorry, but I think I will only find time next weekend |
@Applelo Ok, I have currently released a 1.0.11 |
Sorry for the delay, I have create a repository with a sample of pug code and how I format it: https://github.com/Applelo/pug-example I will update this with more example when I will have more time to do it. |
Thank you, that's something I can work with! |
No problem, take your time. Your are already nice to answer to my requests ^^ |
@Applelo I'm thinking about three ways to implement this
Currently I like option 2. the most, but it may be that someone else want very exotic configurations that allows single quote in js code, single quote for pug attributes and double quotes for code in pug 😨 |
Maybe I implemented it ... 🤔 It's really not optimized and can bleed bugs that I didn't cover |
Yeah we use Node 10 to default (webpack 5 ready :) ).
What do you mean? Do you want a automated test in my repo to compare the output? |
Nice to hear
git clone git@github.com:prettier/plugin-pug.git
cd plugin-pug
git switch issue-45
yarn
yarn build Then yarn link
cd to your project
yarn link @prettier/plugin-pug And finally https://yarnpkg.com/lang/en/docs/cli/link/ Then tell me if everything is working as expected or if there are any bugs I have a repo from my work, but there no JS in pug is used, because we're using vue (v-if, v-for and so on) |
@Applelo Could you try 1.6.0-issue-105.1 and report if it fits your need? So maybe you now need a config like {
"singleQuotes": true,
"pugSingleQuotes": true
} If this doesn't fix the problem I'm sorry to say I can't fix it, due to the technical implementation :( |
Sorry to not have test your previous answer. I was and I am currently busy at work. I test this when I have time :) |
Spolier: it won't work 😭 Need to investigate more, also maybe I need to create a breaking change 😬 |
@Applelo Thank to the lovely work of @shadowgate15 we now released https://www.npmjs.com/package/@prettier/plugin-pug/v/1.18.0 ❤️ 🙌 |
Since the 1.0.10, singlequote are transformed into double quotes even if I set singleQuote option.
I tried with the 1.0.9 and I don't have this bug.
For example:
is transformed into
The text was updated successfully, but these errors were encountered: