feature: 配置eslint

This commit is contained in:
zyn
2023-12-14 14:51:54 +08:00
parent 01bee9fcc8
commit 26d1af11ce
3 changed files with 96 additions and 64 deletions
+31
View File
@@ -0,0 +1,31 @@
module.exports ={
// 继承其他规则
'extends': ['eslint:recommended', 'plugin:vue/essential'],
// 解析选项
'parserOptions': {
'ecmaVersion': 6, // ES 语法版本
'sourceType': 'module', // ES 模块化
'ecmaFeatures': { // ES 其他特性
'jsx': true // 如果是 React 项目,就需要开启 jsx 语法
}
},
plugins: [
'@stylistic/js'
],
// 具体检查规则
'rules': {
'no-var': 'error', // 不能使用 var 定义变量
'eqeqeq': [
'warn', // 建议使用 === 和 !==,否则警告
'smart' // https://eslint.bootcss.com/docs/rules/eqeqeq#smart 除了少数情况下不会有警告
],
'prefer-arrow-callback': 'warn', // 建议使用箭头函数
'prefer-const': 'error', // 强制使用 const 定义常量
'indent': ['error', 2], // 缩进 2 个空格
// '@stylistic/js/indent': ['error', 2], // 缩进 2 个空格
'quotes': ['error', 'single'] // 强制使用单引号
},
env: {
node: true
}
}