ESLint的官方链接

ESLint配置示例

项目根目录的.eslintrc.cjs/.eslintrc.js文件的配置示例,更多选项可在官网github上查看

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
module.exports = {
// 根目录标识
root: true,
// 环境变量
env: {
browser: true,
es2021: true,
node: true,
commonjs: true,
},
// 忽略文件
ignorePatterns: ['**/public/**/*.js'],
// 解析器选项
parserOptions: {
sourceType: 'module',
},
// 插件
plugins: [],
// 配置继承
extends: ['eslint:recommended', 'prettier'],
// 规则定义
rules: {
'no-undef': 'off', // 未声明变量
'no-unused-vars': 'off', // 未使用过的变量
},
};