You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
yudao/front-end/mall4uni/.eslintrc.cjs

90 lines
3.1 KiB

module.exports = {
env: {
browser: true, // 启用浏览器环境,提供全局变量如 `window` 和 `document`
es2021: true, // 启用 ES2021 语法支持
node: true // 启用 Node.js 环境,提供全局变量如 `require` 和 `module`
},
globals: {
uni: 'readonly', // 将 `uni` 定义为只读全局变量,适用于 Uni-App 框架
getApp: 'readonly', // 将 `getApp` 定义为只读全局函数,用于获取应用实例
wx: 'readonly', // 将 `wx` 定义为只读全局对象,适用于微信小程序
getCurrentPages: 'readonly', // 将 `getCurrentPages` 定义为只读全局函数,用于获取当前页面栈
plus: 'readonly' // 将 `plus` 定义为只读全局对象,适用于 5+AppHTML5+
},
extends: [
'standard', // 继承 Standard 代码风格规则集
'./.eslintrc-auto-import.json', // 继承自定义的自动导入配置文件
'plugin:vue/vue3-recommended', // 继承 Vue 3 的推荐规则集
'plugin:vue-scoped-css/vue3-recommended' // 继承 Vue 3 scoped CSS 的推荐规则集
],
overrides: [
// 用于针对特定文件或文件模式进行规则覆盖,当前为空
],
parserOptions: {
ecmaVersion: 'latest', // 使用最新的 ECMAScript 版本解析代码
sourceType: 'module' // 将代码视为 ES 模块
},
plugins: [
'vue' // 使用 `eslint-plugin-vue` 插件来支持 Vue 文件的 linting
]
};
rules: {
// Possible Errors
// 要求使用 let 或 const 而不是 var
'no-var': 'error',
// 强制 "for" 循环中更新子句的计数器朝着正确的方向移动
'for-direction': 'error',
// 强制 getter 函数中出现 return 语句
'getter-return': 'error',
// 禁止在嵌套的块中出现变量声明或 function 声明
'no-inner-declarations': 'error',
// 禁止由于 await 或 yield的使用而可能导致出现竞态条件的赋值
'require-atomic-updates': 'error',
// console 警告
'no-console': 'warn',
// 禁止出现未使用过的变量
'no-unused-vars': [
'warn',
{
args: 'all',
caughtErrors: 'none',
ignoreRestSiblings: true,
vars: 'all'
}
],
// 关闭名称校验
'vue/multi-word-component-names': 'off',
// 非生产环境启用 debugger
'no-debugger': process.env.NODE_ENV === 'production' ? 'error' : 'off',
// Best Practices
eqeqeq: 'off',
// Stylistic Issues
// 强制可嵌套的块的最大深度
'max-depth': ['error', 5],
// 强制函数最大代码行数
'max-lines-per-function': [
'error',
{
max: 150,
skipBlankLines: true
}
],
// 强制回调函数最大嵌套深度
'max-nested-callbacks': ['error', { max: 10 }],
// 强制函数定义中最多允许的参数数量
'max-params': ['error', { max: 5 }],
// 强制每一行中所允许的最大语句数量
'max-statements-per-line': ['error', { max: 1 }],
// 三目运算符换行
'multiline-ternary': ['error', 'never'],
// 传值给组件时的使用 kebab-case
'vue/v-on-event-hyphenation': ['warn', 'always', {
autofix: true,
ignore: []
}]
}
}