eslint是一个代码检测工具。官网如下http://eslint.cn/npminstalleslint--save-dev需要这些npm包:eslinteslint-loadereslint-plugin-html(对于Lint,一些js代码被脚本包裹在html文件中,默认匹配规则是没有type属性的,或者/^(application|text)/(x-)?(javascript|babel|ecmascript-6)$/i,具体内容请参考相关文档。通过cli,定义文件扩展名时eslint--ext.html,.js)eslint-config-standard(和?这两个包是javascript-style-standard指南需要的包)eslint-plugin-promiseeslint-plugin-standarddeslint-friendly-formatter(生成的报告格式)eslint--init//初始化配置eslint--initESLint支持多种格式的配置文件:JavaScript-使用.eslintrc。js然后输出一个配置对象。YAML-使用.eslintrc.yaml或.eslintrc.yml来定义配置结构。JSON-使用.eslintrc.json定义配置结构。ESLint的JSON文件允许JavaScript风格的注释。已弃用-JSON也可以是使用.eslintrc的YAML。package.json-在package.json中创建一个eslintConfig属性并在那里定义你的lint。如果同一个目录下有多个配置文件,ESLint只会使用一个。优先顺序如下:**1。.eslintrc.js.eslintrc.yaml.eslintrc.yml.eslintrc.json.eslintrcpackage.json**配置示例evn设置环境定义预定义全局变量http://eslint.cn/docs/user-gu...parsersetinterpreterhttp://eslint.cn/docs/user-gu...global设置全局变量http://eslint.cn/docs/user-gu...rules自定义规则http://eslint.cn/docs/user-gu..."off"or0-关闭规则"warn"or1-打开规则,使用警告级别error:warn(doesnotcausetheprogramtoexit)"error"or2-enablerule,使用错误级别error:error(当被触发时,程序将退出)module.exports={"parser":"babel-eslint","extends":"eslint:recommended","plugins":["html"],“env”:{“浏览器”:真实,“节点”:真实,“es6”:真实,“jquery”:真实},“globals”:{“Vue”:真实,“AMap”:真实,“tdist”:true,"EXIF":true,"j_body":true,"native":true,"VueRouter":true,"pocketPost":true,"aliCnCityList":true,},"rules":{"no-unused-vars":["off",{"vars":"all","args":"after-used","ignoreRestSiblings":false}],"no-debugger":["off"],"no-unreachable":["off"],"no-console":["off"],"no-extra-semi":["off"],}};eslint在webpack2中配置如下,我在vue中设置为noinclude:[path.join(__dirname,'src')],options:{formatter:require('eslint-friendly-formatter')//错误输出格式}}]}相关参考文档https://segmentfault.com/a/11...http://eslint.cn/docs/user-gu...http://eslint.cn/docs/rules/vue-loaderhttps://vue-loader.vuejs.org/...https://vue-loader.vuejs.org/...小五路博客:https://56way.com
