VSCODE根据eslint配置进行格式化代码

大家好,我是H5女王,最近因为vscode默认格式化代码被小小的折腾了一下。

那现在教大家一个让vscode可以根据eslint的配置格式化代码的方法。这是之前版本的vscode,现针对目前使用的vscode更新一版配置。vscode版本如下:

设置方法如下:

File菜单——Preferences——Setting——Commonly used

 

 将下面的代码复制粘贴进去就可以了!


首先,在vscode下载eslint扩展和prettier扩展

其次,在vscode的user settings 中进行如下配置:

```

{

"liveServer.settings.donotShowInfoMsg": true,

"explorer.confirmDelete": false,

"vetur.validation.template": false,

"vetur.format.defaultFormatter": {

"html": "prettier",

"css": "prettier",

"postcss": "prettier",

"scss": "prettier",

"less": "prettier",

"js": "prettier",

"ts": "prettier",

"stylus": "stylus-supremacy"

},

"javascript": "javascriptreact",

"vue-html": "html",

"plaintext": "jade",

"editor.insertSpaces": true,

"git.ignoreMissingGitWarning": true,

"editor.formatOnPaste": true,

"editor.formatOnSave": true,

"files.associations": {

"*.wxml": "html"

},

"files.autoSave": "onFocusChange",

"workbench.startupEditor": "newUntitledFile",

"eslint.enable": true,

"eslint.autoFixOnSave": true,

"eslint.validate": [

"javascript",

"javascriptreact",

{

"language": "html",

"autoFix": true

},

{

"language": "vue",

"autoFix": true

}

],

"git.confirmSync": false,

"git.decorations.enabled": false,

"git.detectSubmodules": false,

"git.enabled": false,

"editor.fontSize": 18,

"editor.formatOnType": false,

"editor.tabSize": 4,

"prettier.eslintIntegration": true

}

```

这样就可以了,希望大家不再为vscode格式化代码而烦恼哦~

评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值