visual-studio-codeprettiereditorconfig

How to propertly use global prettier config in vscode?


I have globally configured prettier settings in settings.json

"prettier.useTabs": false,
"prettier.trailingComma": "none",
"prettier.tabWidth": 4,
"prettier.bracketSpacing": true,
"prettier.singleQuote": true,
"prettier.withNodeModules": true,
"[javascript]": {
    "editor.formatOnSave": true,
    "editor.defaultFormatter": "esbenp.prettier-vscode"
},

The problem is I've cloned some opensource repository, that has .editorconfig file and project has two spaces, since i have configured onSave action all code is being formatted using prettier settings and ignores .editorconfig file settings.

What would be preferred way to configure it, so it use project configuration instead of global and is it even a good idea to use globall prettier settings or instead should i always consider to use project based .prettier file?


Solution

  • The default (in "trusted projects"):

    "prettier.useEditorConfig": true
    

    seems to work neat. It considers local .editorconfig overriding prettier (user) settings.

    prettier.useEditorConfig (default: true)

    Whether or not to take .editorconfig into account when parsing configuration. See the prettier.resolveConfig docs for details.

    Disabled on untrusted workspaces (always false)

    Refs: