3
0
Fork 0

chore(lint): add lint

This commit is contained in:
woody 2025-05-23 17:38:55 +08:00
parent a25c956424
commit af8f0487cb
3 changed files with 75 additions and 0 deletions

12
.editorconfig Normal file
View File

@ -0,0 +1,12 @@
root = true
[*]
indent_style = space
indent_size = 2
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true
[*.md]
trim_trailing_whitespace = false

39
.eslintrc.js Normal file
View File

@ -0,0 +1,39 @@
module.exports = {
env: {
browser: true,
es2021: true,
node: true,
},
extends: ['eslint:recommended', '@vue/eslint-config-prettier'],
parserOptions: {
ecmaVersion: 2021,
sourceType: 'module',
},
globals: {
uni: 'readonly',
wx: 'readonly',
plus: 'readonly',
getCurrentPages: 'readonly',
getApp: 'readonly',
},
rules: {
// Vue规则
'vue/multi-word-component-names': 'off',
'vue/no-unused-vars': 'error',
'vue/valid-v-for': 'error',
'vue/require-v-for-key': 'error',
'vue/no-deprecated-filter': 'error',
// JavaScript规则
'no-unused-vars': 'warn',
'no-console': process.env.NODE_ENV === 'production' ? 'warn' : 'off',
'no-debugger': process.env.NODE_ENV === 'production' ? 'warn' : 'off',
// 代码风格
semi: ['error', 'never'],
quotes: ['error', 'single'],
'comma-dangle': ['error', 'only-multiline'],
indent: ['error', 2],
'eol-last': ['error', 'always'],
},
}

24
.vscode/settings.json vendored Normal file
View File

@ -0,0 +1,24 @@
{
"editor.formatOnSave": true,
"editor.codeActionsOnSave": {
"source.fixAll.eslint": true,
"source.organizeImports": true
},
"editor.defaultFormatter": "esbenp.prettier-vscode",
"[vue]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"[javascript]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"[json]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"eslint.validate": ["javascript", "vue"],
"prettier.requireConfig": true,
"editor.tabSize": 2,
"editor.insertSpaces": true,
"files.eol": "\n",
"files.insertFinalNewline": true,
"files.trimTrailingWhitespace": true
}