ESLint使用的时候报错:error: No ESLint configuration found
问题描述:在新项目提交后,同事下载最新代码说我提交的代码格式有问题,发现是ESLint插件没有下载,下载启动后校验规则还是不对,而且报错找不到相关配置。
解决办法:1.如果项目中能找到.eslintrc.js则修改相关配置和检测规则,详细规则见链接: ESLint规则说明
2.如果项目中不存在,则按照如下配置新增.eslintrc.js文件
// https://eslint.org/docs/user-guide/configuring
module.exports = {
root: true,
parserOptions: {
parser: 'babel-eslint'
},
env: {
browser: true,
es6: true,
node: true
},
extends: [
// https://github.com/vuejs/eslint-plugin-vue#priority-a-essential-error-prevention
// consider switching to `plugin:vue/strongly-recommended` or `plugin:vue/recommended` for stricter rules.
'plugin:vue/essential',
// https://github.com/standard/standard/blob/master/docs/RULES-en.md
'standard'
],
// required to lint *.vue files
plugins: [
'vue'
],
// add your custom rules here
rules: {
// allow async-await
'generator-star-spacing': 'off',
// allow debugger during development
'no-debugger': process.env.NODE_ENV === 'production' ? 'error' : 'off'
}
}