I am working on an Angular project and I started to use VSCode recently. I am using the Prettier extension (version: 1.19.1) and it works fine, the only issue is it does not allow to write needed regular expressions. Prettier changes single quotation marks to double and removes backslash marks after save.
For example:
'^[a-zA-Z \-\']+'becomes"^[a-zA-Z -']+"/^\-?\d+((\.|\,)\d+)?$/becomes/^-?d+((.|,)d+)?$/
VSCode extensions installed
- Angular Snippets (Version 9)
- Bracket Pair Colorizer
- PowerShell
- Prettier Code Formatter
- Code formatter seti-icons
I have followed many instructions such as adding .prettierrc file, changed configuration in settings.json file, but none of them were helpful.
This is my .prettierrc.json file:
{
"trailingComma": "all",
"tabWidth": 2,
"semi": false,
"singleQuote": true
}
This is settings.json file:
{
"editor.defaultFormatter": "esbenp.prettier-vscode",
"editor.formatOnSave": true,
"editor.formatOnPaste": false,
"prettier.jsxSingleQuote": true,
"prettier.singleQuote": true,
"emmet.triggerExpansionOnTab": true,
"emmet.includeLanguages": {
"javascript": "javascriptreact",
"vue-html": "html",
"razor": "html",
"plaintext": "jade"
},
"emmet.preferences": {
"css.webkitProperties": "border-right,animation",
"css.mozProperties": "",
"css.oProperties": null,
"css.msProperties": null
},
"[javascript]": {
"editor.formatOnSave": true
},
"workbench.iconTheme": "seti"
}
Here is tslint.json file:
rules : {
...
"quotemark": [true, "single"],
...
}
.editorconfig file
root = true
[*]
charset = utf-8
indent_style = space
indent_size = 2
insert_final_newline = true
trim_trailing_whitespace = true
[*.md]
max_line_length = off
trim_trailing_whitespace = false
What am I doing wrong?