2023-12-21 15:50:52 +08:00
|
|
|
|
module.exports = {
|
|
|
|
|
env: {
|
|
|
|
|
browser: true,
|
|
|
|
|
es2021: true,
|
|
|
|
|
node: true,
|
|
|
|
|
},
|
|
|
|
|
extends: [
|
|
|
|
|
'eslint:recommended',
|
|
|
|
|
'plugin:@typescript-eslint/recommended',
|
|
|
|
|
'plugin:vue/vue3-essential',
|
|
|
|
|
// eslint-plugin-import 插件, @see https://www.npmjs.com/package/eslint-plugin-import
|
|
|
|
|
'plugin:import/recommended',
|
|
|
|
|
// eslint-config-airbnb-base 插件, tips: 本插件也可以替换成 eslint-config-standard
|
|
|
|
|
'airbnb-base',
|
|
|
|
|
// 1. 接入 prettier 的规则
|
|
|
|
|
'prettier',
|
|
|
|
|
'plugin:prettier/recommended',
|
|
|
|
|
'vue-global-api',
|
2024-01-30 10:04:13 +08:00
|
|
|
|
'./.eslintrc-auto-import.json',
|
2023-12-21 15:50:52 +08:00
|
|
|
|
],
|
|
|
|
|
overrides: [
|
|
|
|
|
{
|
|
|
|
|
env: {
|
|
|
|
|
node: true,
|
|
|
|
|
},
|
|
|
|
|
files: ['.eslintrc.{js,cjs}'],
|
|
|
|
|
parserOptions: {
|
|
|
|
|
sourceType: 'script',
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
],
|
|
|
|
|
parserOptions: {
|
|
|
|
|
ecmaVersion: 'latest',
|
|
|
|
|
parser: '@typescript-eslint/parser',
|
|
|
|
|
sourceType: 'module',
|
|
|
|
|
},
|
|
|
|
|
plugins: [
|
|
|
|
|
'@typescript-eslint',
|
|
|
|
|
'vue',
|
|
|
|
|
// 2. 加入 prettier 的 eslint 插件
|
|
|
|
|
'prettier',
|
|
|
|
|
// eslint-import-resolver-typescript 插件,@see https://www.npmjs.com/package/eslint-import-resolver-typescript
|
|
|
|
|
'import',
|
|
|
|
|
],
|
|
|
|
|
rules: {
|
|
|
|
|
// 3. 注意要加上这一句,开启 prettier 自动修复的功能
|
|
|
|
|
'prettier/prettier': 'error',
|
|
|
|
|
// turn on errors for missing imports
|
|
|
|
|
'import/no-unresolved': 'off',
|
|
|
|
|
// 对后缀的检测,否则 import 一个ts文件也会报错,需要手动添加'.ts', 增加了下面的配置后就不用了
|
|
|
|
|
'import/extensions': [
|
|
|
|
|
'error',
|
|
|
|
|
'ignorePackages',
|
|
|
|
|
{ js: 'never', jsx: 'never', ts: 'never', tsx: 'never' },
|
|
|
|
|
],
|
|
|
|
|
// 只允许1个默认导出,关闭,否则不能随意export xxx
|
|
|
|
|
'import/prefer-default-export': ['off'],
|
|
|
|
|
'no-console': ['off'],
|
|
|
|
|
// 'no-unused-vars': ['off'],
|
|
|
|
|
// '@typescript-eslint/no-unused-vars': ['off'],
|
|
|
|
|
// 解决vite.config.ts报错问题
|
|
|
|
|
'import/no-extraneous-dependencies': 'off',
|
|
|
|
|
'no-plusplus': 'off',
|
|
|
|
|
'no-shadow': 'off',
|
2023-12-21 16:50:50 +08:00
|
|
|
|
'vue/multi-word-component-names': 'off',
|
2023-12-22 15:28:40 +08:00
|
|
|
|
'@typescript-eslint/no-explicit-any': 'off',
|
2024-01-12 11:16:49 +08:00
|
|
|
|
'no-underscore-dangle': 'off',
|
2024-02-01 15:28:24 +08:00
|
|
|
|
'no-use-before-define': 'off',
|
2024-03-09 15:02:29 +08:00
|
|
|
|
'no-undef': 'off',
|
2024-03-24 18:12:24 +08:00
|
|
|
|
'no-unused-vars': 'off',
|
|
|
|
|
'no-param-reassign': 'off',
|
|
|
|
|
'@typescript-eslint/no-unused-vars': 'off',
|
2023-12-21 15:50:52 +08:00
|
|
|
|
},
|
|
|
|
|
// eslint-import-resolver-typescript 插件,@see https://www.npmjs.com/package/eslint-import-resolver-typescript
|
|
|
|
|
settings: {
|
|
|
|
|
'import/parsers': {
|
|
|
|
|
'@typescript-eslint/parser': ['.ts', '.tsx'],
|
|
|
|
|
},
|
|
|
|
|
'import/resolver': {
|
|
|
|
|
typescript: {},
|
|
|
|
|
},
|
|
|
|
|
},
|
2023-12-22 09:36:27 +08:00
|
|
|
|
globals: {
|
2024-01-29 14:48:07 +08:00
|
|
|
|
$t: true,
|
2023-12-22 09:36:27 +08:00
|
|
|
|
uni: true,
|
2023-12-23 11:39:46 +08:00
|
|
|
|
UniApp: true,
|
2024-01-03 10:29:40 +08:00
|
|
|
|
wx: true,
|
|
|
|
|
WechatMiniprogram: true,
|
|
|
|
|
getCurrentPages: true,
|
|
|
|
|
UniHelper: true,
|
|
|
|
|
Page: true,
|
2024-01-03 10:55:45 +08:00
|
|
|
|
App: true,
|
2024-03-01 14:17:33 +08:00
|
|
|
|
NodeJS: true,
|
2023-12-22 09:36:27 +08:00
|
|
|
|
},
|
2023-12-21 15:50:52 +08:00
|
|
|
|
}
|