question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

"prettier.singleQuote: true" not being honored for vanilla javascript files

See original GitHub issue

I am having an issue getting the vscode prettier extension to convert my javascript documents correctly. I am running VSCode 1.22.2 with version 1.3.1 of the Prettier extension.

I have a prettier configuration set to convert double quotes to single quotes using the "prettier.singleQuotes": true setting. I have this setting set in both visual studio’s user setting in .prettierrc within my project.

When I format my VueJS files, this setting is getting honored for any javascript contained in my <script> body in those files. But for vanilla javascript module files, my single quotes are getting replaced with double quotes. I do not have any other code formatters installed. Here is a snippet of my User configuration:

    // Force single quotes
    "prettier.singleQuote": true,

Here is my code before I click on “Format document”:

console.log('Hello World');

Here is what it looks like afterwards:

console.log("Hello World");

This breaks our organization’s linting standards, which is forcing me to manually search/replace all occurrences of an errant double quote with single quotes, so any pointers would be greatly appreciated. Thanks!

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

3reactions
dfintoncommented, Apr 26, 2018

Did a bit more testing. As it turns out, it looks like all my formatting rules are being ignored for javascript files, not just the single quote rule. I do not have any languages or extensions disabled in my prettier config.

0reactions
github-actions[bot]commented, Apr 13, 2020

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Prettier single quote setting not respected in .tsx files (VS Code)
The solution is to set the jsxSingleQuote setting to true as well. This will change all double quotes in your .tsx files to...
Read more >
Prettier not changing to single quotes HTML on formatting ...
As title says, when I format HTML files using prettier all my single quotes change to double quotes, but it works well in...
Read more >
lint-staged - npm
Lint files staged by git. Latest version: 13.1.0, last published: 22 days ago. Start using lint-staged in your project by running `npm i ......
Read more >
Guidelines for styling JavaScript code examples
On MDN Web Docs, we use Prettier as a code formatter to keep the code style consistent (and to avoid off-topic discussions). You...
Read more >
prettierx | Yarn - Package Manager
(with some prettierX language-js updates now based on Prettier 2.3.2). with some updates including: switch to pure CSS parser using PostCSS 8 (see...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found