1.实现效果
Eslint校验代码语法,prettier统一格式化代码,按下保存自动修复eslint错误,自动格式化代码。
2.安装vscode插件
- Vetur
- ESLint
- Prettier - Code formatter
3.配置vscode设置
文件–首选项–设置,打开json模式,添加以下配置:
{ // 控制工作台中活动栏的可见性。 "workbench.activityBar.visible": true, //主题设置 "workbench.colorTheme": "Monokai", // 默认编辑器字号 "editor.fontSize": 14, //是否自动换行 "editor.wordWrap": "on", "workbench.editor.enablePreview": false, //打开文件不覆盖 "search.followSymlinks": false, //关闭rg.exe进程 "editor.minimap.enabled": false, //关闭迷你图快速预览 "files.autoSave": "onWindowChange", // 切换窗口时自动保存。 "editor.lineNumbers": "on", //开启行数提示 "editor.quickSuggestions": { //开启自动显示建议 "other": true, "comments": true, "strings": true }, "editor.tabSize": 2, //制表符符号eslint //.vue文件template格式化支持,并使用js-beautify-html插件 "vetur.format.defaultFormatter.html": "js-beautify-html", //js-beautify-html格式化配置,属性强制换行 "vetur.format.defaultFormatterOptions": { "js-beautify-html": { "wrap_attributes": "force-aligned" } }, //根据文件后缀名定义vue文件类型 "files.associations": { "*.vue": "vue" }, //配置 ESLint 检查的文件类型 "eslint.validate": [ "javascript", "javascriptreact", { "language": "vue", "autoFix": true } ], //保存时eslint自动修复错误 "eslint.autoFixOnSave": true, //保存自动格式化 "editor.formatOnSave": true }
4.配置.eslintrc.js
module.exports = { root: true, env: { node: true }, extends: ['plugin:vue/essential', 'eslint:recommended'], rules: { 'no-console': process.env.NODE_ENV === 'production' "color: #ff0000">5.配置.prettierrc
{ "eslintIntegration": true, "singleQuote": true, "semi": false }
免责声明:本站文章均来自网站采集或用户投稿,网站不提供任何软件下载或自行开发的软件!
如有用户或公司发现本站内容信息存在侵权行为,请邮件告知! 858582#qq.com
暂无“eslint+prettier统一代码风格的实现方法”评论...
更新动态
2024年04月29日
2024年04月29日
- 原画壁纸及美图第205期,无水印可自取
- 向蕙玲.2016-女人心事【豪记】【WAV+CUE】
- 徐若瑄.2024-先听我说完Its.My.Turn【SONY】【FLAC分轨】
- 林子祥.2016-最爱40周年MY.BELOVED.4CD【华纳】【WAV+CUE】
- 群星《古惑仔 电影原声大碟》香港首版4CD [WAV+CUE][893M]
- 无期迷途《完美投票 游戏原声OST》[320K/MP3][36.18MB]
- 无期迷途《完美投票 游戏原声OST》[FLAC/分轨][110.46MB]
- dnf深邃深渊之鳞有必要吗
- dnf狂战士110版本平民装备搭配
- dnf登录黑屏时间太久无响应
- 很明显喷人比浇花更快乐 动图 妖精的身份被你发现了
- 电路规划+牌组构筑!《末日电涌》即将于5.10发售!
- 才刚经历过大更新的星露谷物语,怎么就惹到国内玩家了?
- 【爵士沙发】VA-2024-BarLoungeCostesVol.8(FLAC)
- 【布鲁斯摇滚】DavidePannozzo-2024-RoomforJoy(FLAC)