代码拉取完成,页面将自动刷新
/**
* @file ESLint 配置文件
* @description uni-app + Vue3 + TS 项目代码检查配置
* @see https://eslint.org/docs/latest/use/configure/ ESLint 配置文档
* @see https://typescript-eslint.io/getting-started TypeScript ESLint 文档
* @see https://eslint.vuejs.org/rules/ Vue ESLint 规则
*/
module.exports = {
root: true,
// 继承配置
extends: [
'plugin:vue/vue3-essential',
'eslint:recommended',
'@vue/eslint-config-typescript',
'@vue/eslint-config-prettier',
],
// 解析器配置
parser: 'vue-eslint-parser',
parserOptions: {
ecmaVersion: 2022,
parser: '@typescript-eslint/parser',
sourceType: 'module',
extraFileExtensions: ['.vue'],
},
// 环境配置
env: {
browser: true,
node: true,
es2022: true,
},
// 全局变量
globals: {
// uni-app 核心全局变量
uni: true, // uni-app API 对象
wx: true, // 微信小程序 API 兼容对象
WechatMiniprogram: true, // 微信小程序类型声明
getCurrentPages: true, // 获取页面栈方法
// 开发辅助
console: true, // 控制台对象
process: true, // Node.js 进程对象
setTimeout: true, // 定时器
clearTimeout: true, // 清除定时器
setInterval: true, // 定时器
clearInterval: true, // 清除定时器
// uni-app 类型相关
UniApp: true, // uni-app 类型命名空间
UniHelper: true, // uni-app 助手类型
Page: true, // 页面构造器
Component: true, // 组件构造器
AnyObject: true, // 通用对象类型
// uni-app 特定的 API
uniCloud: true, // uni-app 云开发 API
plus: true, // HTML5+ API
upx2px: true, // upx 转 px 方法
// 小程序特定
getApp: true, // 获取应用实例
App: true, // App 构造函数
Behavior: true, // 小程序 Behavior
},
// 插件配置
plugins: ['vue', '@typescript-eslint', 'prettier'],
// 规则配置
rules: {
// 关闭 Prettier 的行尾换行符检查
'prettier/prettier': ['error', { endOfLine: 'auto' }],
// * 基础规则
// 禁用未定义变量检查,避免Vue模板中的变量报错
'no-undef': 'off',
// 允许 console.warn/error,其他 console 方法警告
'no-console': ['warn', { allow: ['warn', 'error'] }],
// 警告使用 debugger
'no-debugger': 'warn',
// 最多允许一个空行
'no-multiple-empty-lines': ['warn', { max: 1 }],
// 优先使用 const
'prefer-const': 'warn',
// 禁止使用 var
'no-var': 'error',
// * TypeScript 规则
// 未使用变量显示为错误,忽略下划线开头
'@typescript-eslint/no-unused-vars': ['error', { argsIgnorePattern: '^_' }],
// 警告使用 any 类型,鼓励更严格的类型定义
'@typescript-eslint/no-explicit-any': 'warn',
// 禁止使用 require 语句
'@typescript-eslint/no-var-requires': 'error',
// 强制使用 import type 导入类型
'@typescript-eslint/consistent-type-imports': ['error', { prefer: 'type-imports' }],
// 警告空函数
'@typescript-eslint/no-empty-function': 'warn',
// 警告推断类型的显式声明
'@typescript-eslint/no-inferrable-types': 'warn',
// * Vue 规则
// 禁用组件名必须多词的规则(uni-app 页面通常是单字)
'vue/multi-word-component-names': 'off',
// 关闭defineEmits函数使用检查
'vue/valid-define-emits': 'off',
// 关闭defineProps检查
'vue/valid-define-props': 'off',
},
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。