ESLint报错解决方案

ESLint报错解决方案(error: No ESLint configuration found)

在项目部署中出现报错error: No ESLint configuration found,编辑器vscode。

解决办法

造成这种报错的原因是项目中缺少 .eslintrc.js文件。添加上就可以了。

添加文件方法

  1. 手动添加, 直接手动添加.eslintrc.js文件在项目中,并进行相应的配置就行了。
  2. 使用命令添加, 如果eslint是全局安装的话,使用命令eslint –init安装。

配置信息(简单版)

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
module.exports = {
root: true,
env: {
node: true
},
'extends': [
'plugin:vue/essential',
'@vue/standard'
],
rules: {
// 生产环境不能使用console
'no-console': process.env.NODE_ENV === 'production' ? 'error' : 'off',
// 生产环境不能使用debugger
'no-debugger': process.env.NODE_ENV === 'production' ? 'error' : 'off'
},
parserOptions: {
parser: 'babel-eslint'
}
}
说明:
  • "no-undef": 0,"no-undef": 'off',一样,表示关闭该功能
  • "no-undef": 1, 表示仅提示
  • "no-undef": 2, 表示报错