当前位置:网站首页>vscode 根据 ESLint 规范自动格式化代码
vscode 根据 ESLint 规范自动格式化代码
2022-07-01 07:11:00 【柯晓楠】
在项目根目录新建一个名为 .vscode
文件夹,在该文件夹中新建 settings.json
配置文件,具体配置如下:
{
"eslint.validate": [
"javascript",
{
"language": "html",
"autoFix": true
},
{
"language": "vue",
"autoFix": true
}
],
"editor.codeActionsOnSave": {
"source.fixAll.eslint": true,
"source.organizeImports": true
},
"eslint.format.enable": true,
"editor.defaultFormatter": "dbaeumer.vscode-eslint",
"eslint.validate": [
"javascript",
"javascriptreact",
"typescript",
"typescriptreact"
],
"editor.codeActionsOnSave": {
"source.fixAll": true,
"source.fixAll.eslint": true
}
}
配置完成后,在编辑器中直接保存代码就可以实现代码格式化,或者是按钮 shift + alt + F
格式化代码快捷键。
如果vscode本地配置不需要上传到代码库,还需要在项目根目录的
.gitignore
文件中添加上.vscode
边栏推荐
猜你喜欢
随机推荐
JSP - 分页
Solution to the problem that objects in unity2021 scene view cannot be directly selected
Summary of the concept and advantages of 5g massive MIMO
Image style migration cyclegan principle
Webapck packaging principle -- Analysis of startup process
手机开户选哪个证券公司比较好,哪个更安全
【Tikhonov】基于Tikhonov正则化的图像超分辨率重建
The programmer of Beipiao posted a post for help late at night: I am lonely when my girlfriend is gone
解决kaniko push镜像到harbor时报错(代理导致):unexpected status code 503 Service Unavailable
Figure out the difference between event coordinates screenx, clientx, pagex and offsetx
MySQL and redis consistency solution
[Electrical dielectric number] electrical dielectric number and calculation considering HVDC and facts components
如何通过cdn方式使用阿里巴巴矢量图字体文件
Rclone Chinese document: a collection of common commands
How to choose a product manager course when changing to a product manager?
Challenges faced by operation and maintenance? Intelligent operation and maintenance management system to help you
【Flutter 问题系列第 72 篇】在 Flutter 中使用 Camera 插件拍的图片被拉伸问题的解决方案
Buildreoot override mechanism
Mysql与Redis一致性解决方案
Rclone configuring Minio and basic operations