HBuilderX代码校验及代码格式化

HBuilderX代码校验及代码格式化

2023年7月18日发(作者:)

HBuilderX代码校验及代码格式化⼀、添加 EditorConfig 代码风格统⼀⼯具EditorConfig 有助于维护跨多个编辑器和 IDE 从事同⼀项⽬的多个开发⼈员的⼀致编码风格,团队必备神器。在项⽬根⽬录创建.editorconfig并加⼊以下内容.editorconfig# # 告诉EditorConfig插件,这是根⽂件,不⽤继续往上查找root = true# 匹配全部⽂件[*]# 结尾换⾏符,可选"lf"、"cr"、"crlf"end_of_line = lf# 在⽂件结尾插⼊新⾏insert_final_newline = true# 删除⼀⾏中的前后空格trim_trailing_whitespace = true# 匹配js和py结尾的⽂件[*.{js,py}]# 设置字符集charset = utf-8# 匹配py结尾的⽂件[*.py]# 缩进风格,可选"space"、"tab"indent_style = space# 缩进的空格数indent_size = 2# 以下匹配,类同[Makefile]indent_style = tab# tab的宽度tab_width = 4# 以下匹配,类同[lib/**.js]indent_style = spaceindent_size = 2[{,.}]indent_style = spaceindent_size = 2⼆、安装eslint-plugin-vue插件,vue语法校验1. DCLOUD插件市场搜索eslint-plugin-vue,使⽤HBuilderX导⼊2. 配置步骤:3. .//更详细的配置⽂档请参考:/vuejs/eslint-plugin-vue#s = { "extends": "plugin:vue/base", parserOptions: { ecmaVersion: 2017, sourceType: 'module' }, 'settings': { 'html/html-extensions': [ ".erb", ".handlebars", ".hbs", ".htm", ".html", ".mustache", ".nunjucks", ".php", ".tag", ".twig", ".wxml", ".we", ".we", ] }, "rules": { //在computed properties中禁⽤异步actions 'vue/no-async-in-computed-properties': 'error', //不允许重复的keys 'vue/no-dupe-keys': 'error', //不允许重复的attributes 'vue/no-duplicate-attributes': 'warn', //在