Always use double quotes in schema.prisma with Prettier in VSCode - visual-studio-code

I use prettier to save all quotes as single quotes in my JS and TS files.
However, single quotes are not valid in schema.prisma. Can I specify within Prettier to treat specific file extensions differently?
I have the "Prisma" extension in VS Code as well and tried to enable
"editor.formatOnSave": true
"[prisma]": {
"editor.defaultFormatter": "Prisma.prisma"
},
But it's not changing the single quotes in my schema.prisma file on save. What config and/or extensions do I need to achieve this behavior?

Related

How can I selectively trim trailing whitespace in VSCode?

I generally have the Trim Trailing Whitespace setting turned on in VSCode because I want that behaviour for code files.
However, I have a folder of text resources (.txt files) that I would like to exclude from this rule. Some of the text files need trailing whitespace on the lines.
Is it possible to selectively turn this rule on/off based on file path or file extension?
I've tried having a .vscode/settings.json file at the root of my workspace turning the feature on, and another in the folder containing the text resources to turn it off and that doesn't work.
Is there an extension that enables this? I looked but wasn't able to find one.
In settings.json, insert:
"[plaintext]": {
"files.trimTrailingWhitespace": false
}

How to make vscode format SCSS calc function properly

I have an SCSS file that contains a calc() function.
When i use a calc function without spaces around the operator like so calc(var(--primary-color-h)+5) the transpiled CSS result doesn't work. Only when i set spaces around the operator does it work; like this calc(var(--primary-color-h) + 5)
How would i instruct VSCODE to created spaces around the operator upon save.
I have prettier, scss Formatter and StyleLint installed. But neither seems to fix it.
tnx,
RDG
You can use Stylelint and the following two rules:
function-calc-no-unspaced-operator
function-whitespace-after
These will flag the lack of space before and after the + operator, respectively. See this demo.
This rules are turned on the SCSS standard config, which you can extend in your Stylelint configuration object:
{
"extends": "stylelint-config-standard-scss"
}
How would i instruct VSCODE to created spaces around the operator upon save
You can use the editor.codeActionsOnSave option from the official Visual Studio Code extension for Stylelint. And the following to your VS Code settings file:
"editor.codeActionsOnSave": {
"source.fixAll.stylelint": true
}

Prettier VSCode. Single Quotes set, yet ALWAYS changes it to double

Using Prettier extension in VSCode.
Have the Single Quote set to single.
format onSave is set to true.
Still...
When I hit save, single quotes are converted to double..
WHY? WHY? WHY? WHY?
In addition...
I've set eslint to use single quotes
I've even deleted the eslint extension from VSCode.
// in .eslint file
"quotes": [2, "single", { "avoidEscape": true }],
Still...
When I hit save, single quotes are converted to double..
WHYYYY?
I've traced the source of the problem.
It appears there are levels of configuration that will be checked when VSCode attempts to reformat the text when format on save is checked.
Prettier extension config
.eslintrc
.editorconfig
I'm still not sure in what order they run in, thus who has the final say.
But in my case, a VERY basic .editorconfig was the problem. Deleting this file fixed it.
# EditorConfig https://editorconfig.org/
root = true
[*]
charset = utf-8
end_of_line = lf
insert_final_newline = true
indent_size = 2
indent_style = space
trim_trailing_whitespace = true
[*.md]
trim_trailing_whitespace = false
In the file ^^ there is no mention of spacing prefs at all. So I'm assuming there are some defaults to double quotes.

Prettier formatting with double quotes

Anyone else come across Prettier formatting code with Double quotes instead of Single even though you
explicitly set it to replace with single in the preferences?
Here is a pic:
After a recent update to VSCode I started getting this issue and it is driving me crazy.
Any ideas as to how to fix this. Am I wrong that the Prettier: Single Quote in fact does not format with single quotes instead of double?
Thanks.
Try to create file .prettierrc at package.json level with property singleQuote set to true as below:
{
"singleQuote": true
}

VSCode: Permanently change syntax highlighting on a single file or set of files?

I have a markdown file which I would like to permanently highlight using JSON syntax.
But I don't want to treat ALL .md files this way, just a few of them.
Is there a way to accomplish that, so I don't have to manually change the highlighting each time I open the file?
You can change this with the 'files.associations' setting. For example
"files.associations": {
"*.md": "json"
}