英文:
How to propertly use global prettier config in vscode?
问题
我已在settings.json中全局配置了prettier设置。
"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"
},
问题是,我克隆了一些开源存储库,其中包含一个.editorconfig文件,并且项目使用两个空格缩进。由于我配置了保存操作,所有代码都会使用prettier设置格式化,并忽略.editorconfig文件的设置。
最好的配置方式是什么,以便它使用项目配置而不是全局配置,是否使用全局prettier设置是一个好主意,还是应该始终考虑使用基于项目的.prettier文件?
英文:
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?
答案1
得分: 1
"prettier.useEditorConfig (默认值:true)":
在“受信任的项目”中默认情况下:
英文:
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:
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论