build(eslint): add .eslintrc.js
This commit is contained in:
parent
47c8ac2b5d
commit
8181130e63
74
.eslintrc.js
Normal file
74
.eslintrc.js
Normal file
@ -0,0 +1,74 @@
|
|||||||
|
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',
|
||||||
|
],
|
||||||
|
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',
|
||||||
|
},
|
||||||
|
// 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: {},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
13
package.json
13
package.json
@ -53,7 +53,7 @@
|
|||||||
"@dcloudio/uni-mp-toutiao": "3.0.0-3081220230817001",
|
"@dcloudio/uni-mp-toutiao": "3.0.0-3081220230817001",
|
||||||
"@dcloudio/uni-mp-weixin": "3.0.0-3081220230817001",
|
"@dcloudio/uni-mp-weixin": "3.0.0-3081220230817001",
|
||||||
"@dcloudio/uni-quickapp-webview": "3.0.0-3081220230817001",
|
"@dcloudio/uni-quickapp-webview": "3.0.0-3081220230817001",
|
||||||
"vue": "^3.2.45",
|
"vue": "3.2.47",
|
||||||
"vue-i18n": "^9.1.9"
|
"vue-i18n": "^9.1.9"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
@ -62,10 +62,19 @@
|
|||||||
"@dcloudio/uni-cli-shared": "3.0.0-3081220230817001",
|
"@dcloudio/uni-cli-shared": "3.0.0-3081220230817001",
|
||||||
"@dcloudio/uni-stacktracey": "3.0.0-3081220230817001",
|
"@dcloudio/uni-stacktracey": "3.0.0-3081220230817001",
|
||||||
"@dcloudio/vite-plugin-uni": "3.0.0-3081220230817001",
|
"@dcloudio/vite-plugin-uni": "3.0.0-3081220230817001",
|
||||||
"@vue/tsconfig": "^0.1.3",
|
"@typescript-eslint/eslint-plugin": "^6.15.0",
|
||||||
|
"@typescript-eslint/parser": "^6.15.0",
|
||||||
"@vue/runtime-core": "^3.2.45",
|
"@vue/runtime-core": "^3.2.45",
|
||||||
|
"@vue/tsconfig": "^0.1.3",
|
||||||
|
"eslint": "^8.56.0",
|
||||||
|
"eslint-config-airbnb-base": "^15.0.0",
|
||||||
|
"eslint-config-prettier": "^9.1.0",
|
||||||
|
"eslint-import-resolver-typescript": "^3.6.1",
|
||||||
|
"eslint-plugin-import": "^2.29.1",
|
||||||
|
"eslint-plugin-prettier": "^5.1.0",
|
||||||
"typescript": "^4.9.4",
|
"typescript": "^4.9.4",
|
||||||
"vite": "4.1.4",
|
"vite": "4.1.4",
|
||||||
|
"vue-global-api": "^0.4.1",
|
||||||
"vue-tsc": "^1.0.24"
|
"vue-tsc": "^1.0.24"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
1779
pnpm-lock.yaml
generated
1779
pnpm-lock.yaml
generated
File diff suppressed because it is too large
Load Diff
Loading…
x
Reference in New Issue
Block a user