关于规范化:前端规范elint代码格式化

前端-标准-elint代码格式化

eslint配置文件

// .eslintignore文件

// 不检测iconfont.js文件
**/iconfont.js

root = true
 
[*]
charset = utf-8
end_of_line = lf
indent_size = 2
indent_style = space
insert_final_newline = true
trim_trailing_whitespace = true

常见命令

  • 主动格式化修复src文件夹下文件:eslint --fix src
  • 自动检测并列举不合乎的格局:eslint src
  • 检测指定文件夹下的.js和.vue文件:eslint --ext .js,.vue src
  • 依据配置文件检测指定类型文件:eslint --config .eslintrc.js --ext .js,.vue src

设置代码跳过eslint检测

  • 不检测当行:// eslint-disable-line
  • 不检测下一行:// eslint-disable-next-line
  • 整个文件不检测:头部放/* eslint-disable */
  • 跳过多行:

    /* eslint-disable */
    function a() {
        return this;
    }
    /* eslint-enable */

评论

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注

这个站点使用 Akismet 来减少垃圾评论。了解你的评论数据如何被处理