VSCode下的文件内容基本格式配置
前提1:VSCode里面已经安装ESLint插件
前提2:在项目里配置关于格式内容的js文件。我的配置文件.eslintrc.js(见文尾)
目的:为了在保存文件的时候能够自动格式化文件(自动删除多余空格,首行缩进,自动对齐等等)
-
在VSCode界面上面,Ctrl+P打开搜索界面
-
在搜索框里面输入">settings",找到Settings(即最后一项——打开设置)
-
双击打开,将下面的配置粘贴进去,保存
-
重启项目即可使用
注意:下面的有一项(“terminal.integrated.shell.windows”: “C:\Program Files\Git\bin\bash.exe”,)需要根据自己bash.exe路径进行变更
{
/*
* vscode基础配置
*/
"editor.tabSize": 2,
"editor.fontFamily": "Fira Code",
"editor.fontLigatures": true,
"editor.fontSize": 16,
"editor.formatOnSave": false,
"editor.defaultFormatter": "esbenp.prettier-vscode",
"editor.codeActionsOnSave": {
"source.fixAll": true
},
"window.zoomLevel": 0,
"terminal.integrated.shell.windows": "C:\\Program Files\\Git\\bin\\bash.exe",
"git.autofetch": true,
"git.confirmSync": false,
/*
* javascript格式配置
*/
"javascript.format.insertSpaceBeforeFunctionParenthesis": true,
"javascript.format.insertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets": true,
"javascript.format.insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis": false,
"javascript.updateImportsOnFileMove.enabled": "always",
/*
* eslint和 prettier配置
*/
"eslint.validate": ["javascript", "javascriptreact", "vue", "html"],
"prettier.semi": false,
"prettier.singleQuote": true,
"prettier.tabWidth": 2,
"prettier.trailingComma": "none",
/*
* psi-header模板
*/
"psi-header.templates": [
{
"language": "*",
"template": [
"@created: <<dateformat('dddd, YYYY-MM-DD HH:mm: