prettier / prettier-vscode

Visual Studio Code extension for Prettier
https://marketplace.visualstudio.com/items?itemName=esbenp.prettier-vscode
MIT License
5.04k stars 446 forks source link

singleQuote config is not respected #206

Closed capaj closed 6 years ago

capaj commented 6 years ago

I always get my code with double quotes, even when I have image set.

RobinMalfait commented 6 years ago

Do you have other formatters enabled or eslint integration?

CiGit commented 6 years ago

Is there a single quote in your string ? 'it\'s' prettier avoids escaping.

capaj commented 6 years ago

I do have eslint and Standard style enabled: image but I don't have .eslintrc anywhere in my project

@CiGit no it changes all strings, no matter if they have a single quote or not

CiGit commented 6 years ago

Try disabling those extensions.

capaj commented 6 years ago

disabled both, I still get this when I format: image

CiGit commented 6 years ago

JSX props are always double quoted. see https://github.com/prettier/prettier/issues/656

capaj commented 6 years ago

@CiGit thanks :pensive:

ArmanNisch commented 6 years ago

Hi, Im getting this issue however in my case double quotes are also being applied to normal javascript/ .js files too.

I have disabled eslint but no change to the behaviour.

My prettier .prettierrc config:

{
  "singleQuote": true,
  "trailingComma": "all",
  "parser": "flow"
}

I have also tried moving the prettier config setting into the package.json file to see if it gets picked up from there, but no effect.

I also noticed that on save trailingComma are also being removed.

It seems like prettier-vscode is not reading the config setting...

My VS Code Version: 1.17.0

rc-chandan commented 6 years ago

I am also facing the same problem, .prettierrc config file is not getting read from vscode. But if I put the same configurations in vscode's USER SETTINGS then it works fine.

dfinton commented 6 years ago

vscode is not honoring the "singleQuote": true option for me (it used to last week). I have this setting set both in .prettierrc and in the user settings. I'm not sure what broke. I'm stuck with manually converting double quotes to single quotes because it conflicts with our linting configuration. Based on this and some other issues with prettier we've been encountering I may just abandon it entirely.

CiGit commented 6 years ago

@rc-chandan Can you open a new issue ? this seems not related to this one.

@dfinton singleQuote has some rules see https://prettier.io/docs/en/options.html#quotes

divyamamgai commented 5 years ago

This really bugs me, why won't they allow devs to configure the way they want. Makes me want to make a whole new plugin just because of this one issue, which they won't fix.

hallya commented 4 years ago

@divyamamgai problem is still actual...

JollyGrin commented 4 years ago

I'm having this same issue. I have enabled single quote everywhere I can: prettier, eslint, tslint, vscode user settings... yet it STILL converts the single quote to double. It even underlines the doublequote as incorrect.

asegarra commented 4 years ago

@JollyGrin Creating a .prettierrc.json got it working for me, looks like it isn't respecting this setting from vscode settings.

{ "singleQuote": true, }

ntotten commented 4 years ago

The behavior of using the values of prettier config or editor config INSTEAD of VS Code settings is BY DESIGN. Please see discussion here on why it wouldn't make sense to do merge the settings: https://github.com/prettier/prettier-vscode/issues/1099#issuecomment-558636346

asegarra commented 4 years ago

@ntotten Don't know who you are replying to but in my case I had no prettier config or editorconfig, only vscode settings and prettier was converting all my single quotes to double quotes, moving this config to prettier config worked for me. I never said anything about merging settings.

ntotten commented 4 years ago

@asegarra Please open a new issue with the log and such if you can. I'd like to figure out what is happening.

PerpetualWar commented 4 years ago

Same here.... since Prettier updated, double quotes everywhere, even though in user settings I have set up singleQuote: true.

willbeaufoy commented 4 years ago

I have the same problem, in that single quotes are converted to double despite my prettier vscode settings being for single quotes. @asegarra's solution worked for me.

PerpetualWar commented 4 years ago

I have the same problem, in that single quotes are converted to double despite my prettier vscode settings being for single quotes. @asegarra's solution worked for me.

Well, in this project I cannot use prettier config, and I would prefer to have my code settings affect prettier setup. Hopefully it can be fixed by prettier team.

edit: In the end, I put .prettierrc in parent folder so I don't have to commit, and it works.

ntotten commented 4 years ago

@PerpetualWar if you can’t use a prettier config, one option in addition to what you did is to disable using editorconfig. In which case no project config should be detected and the VSCode settings will be used. That being said, the route you took is also a good option.

PerpetualWar commented 4 years ago

@PerpetualWar if you can’t use a prettier config, one option in addition to what you did is to disable using editorconfig. In which case no project config should be detected and the VSCode settings will be used. That being said, the route you too is also a good option.

Oh, I haven't realized it's the editorconfig that is taking priority ... It must be new addition, since it wasn't affecting codebase before latest update... but now I'm fine when I know where the problem is. Thanks!

eshunnar commented 4 years ago

Fixed by adding "typescript.preferences.quoteStyle": "single" to global vscode settings.json on React Native .TSX project.

DanKaplanSES commented 4 years ago

Fixed by adding "typescript.preferences.quoteStyle": "single" to global vscode settings.json on React Native .TSX project.

I already have this property in my settings.json and it still isn't respecting it

eshunnar commented 4 years ago

Fixed by adding "typescript.preferences.quoteStyle": "single" to global vscode settings.json on React Native .TSX project.

I already have this property in my settings.json and it still isn't respecting it

Combine it with "prettier.singleQuote": true on the global vs code file. Also in your workspace look for tslint.json and tsconfig.json then look in there for the "quotemark": "double" and make it "quotemark": "single" on both files.

DanKaplanSES commented 4 years ago

Combine it with "prettier.singleQuote": true on the global vs code file. Also in your workspace look for tslint.json and tsconfig.json then look in there for the "quotemark": "double" and make it "quotemark": "single" on both files.

I am using typescript-eslint. Isn't that more modern?

Either way, I discovered my problem was with the Prettier extension. It doesn't work in a way that eslint's rules will accept. More context on that here: https://stackoverflow.com/questions/60821494/visual-studio-code-does-not-respect-my-eslint-quote-rules

stoplion commented 3 years ago

I deleted .editorconfig and that fixed it.