mirror of
https://github.com/BTMuli/TeyvatGuide.git
synced 2025-12-12 09:18:14 +08:00
🔧 优化 eslint 配置
This commit is contained in:
211
.eslintrc.yml
211
.eslintrc.yml
@@ -3,39 +3,192 @@ env:
|
||||
browser: true
|
||||
es2021: true
|
||||
extends:
|
||||
- plugin:vue/vue3-recommended
|
||||
- standard-with-typescript
|
||||
- plugin:vue/vue3-essential
|
||||
- prettier
|
||||
- plugin:prettier/recommended
|
||||
parser: vue-eslint-parser
|
||||
- plugin:yml/standard
|
||||
- plugin:jsonc/recommended-with-json
|
||||
parserOptions:
|
||||
extraFileExtensions:
|
||||
- .vue
|
||||
parser: "@typescript-eslint/parser"
|
||||
project:
|
||||
- tsconfig.json
|
||||
- tsconfig.node.json
|
||||
ecmaVersion: latest
|
||||
sourceType: module
|
||||
tsconfigRootDir: .
|
||||
project: ./tsconfig.json
|
||||
globals:
|
||||
TGApp: readonly
|
||||
window: readonly
|
||||
plugins:
|
||||
- vue
|
||||
- prettier
|
||||
rules:
|
||||
# normal
|
||||
array-callback-return: warn
|
||||
# TypeScript
|
||||
"@typescript-eslint/strict-boolean-expressions": off
|
||||
"@typescript-eslint/consistent-type-assertions":
|
||||
- warn
|
||||
- assertionStyle: angle-bracket # 使用尖括号
|
||||
"@typescript-eslint/naming-convention":
|
||||
- warn
|
||||
- selector: variableLike
|
||||
format: ["camelCase", "UPPER_CASE", "PascalCase", "snake_case"]
|
||||
leadingUnderscore: "allow"
|
||||
trailingUnderscore: "allow"
|
||||
"@typescript-eslint/no-non-null-assertion": warn
|
||||
"@typescript-eslint/no-misused-promises": warn
|
||||
# Vue
|
||||
"vue/multi-word-component-names": off
|
||||
vue/multi-word-component-names: warn
|
||||
overrides:
|
||||
- files: ["*.ts"]
|
||||
extends: standard-with-typescript
|
||||
# 将此处规则 copy 到下面的 .vue 文件的 rules 中
|
||||
rules:
|
||||
import/order:
|
||||
- error
|
||||
- groups:
|
||||
- builtin
|
||||
- external
|
||||
- [internal, parent, sibling, index]
|
||||
- unknown
|
||||
newlines-between: always
|
||||
alphabetize:
|
||||
order: asc
|
||||
caseInsensitive: true
|
||||
"@typescript-eslint/indent":
|
||||
- warn
|
||||
- 2
|
||||
"@typescript-eslint/quotes":
|
||||
- error
|
||||
- double
|
||||
"@typescript-eslint/semi":
|
||||
- error
|
||||
- always
|
||||
"@typescript-eslint/comma-dangle":
|
||||
- error
|
||||
- always-multiline
|
||||
"@typescript-eslint/space-before-function-paren":
|
||||
- error
|
||||
- anonymous: always
|
||||
named: never
|
||||
asyncArrow: always
|
||||
"@typescript-eslint/member-delimiter-style":
|
||||
- error
|
||||
- multiline:
|
||||
delimiter: semi
|
||||
requireLast: true
|
||||
"@typescript-eslint/no-import-type-side-effects": error
|
||||
"@typescript-eslint/strict-boolean-expressions":
|
||||
- warn
|
||||
- allowString: false
|
||||
allowNumber: false
|
||||
allowNullableObject: false
|
||||
allowNullableBoolean: false
|
||||
allowNullableString: false
|
||||
allowNullableNumber: false
|
||||
allowAny: false
|
||||
"@typescript-eslint/consistent-type-assertions":
|
||||
- warn
|
||||
- assertionStyle: angle-bracket # 使用尖括号
|
||||
"@typescript-eslint/naming-convention":
|
||||
- warn
|
||||
- selector: variableLike
|
||||
format: ["camelCase", "UPPER_CASE", "PascalCase", "snake_case"]
|
||||
leadingUnderscore: "allow"
|
||||
trailingUnderscore: "allow"
|
||||
"@typescript-eslint/no-non-null-assertion": warn
|
||||
"@typescript-eslint/no-misused-promises": warn
|
||||
- files: ["*.vue"]
|
||||
parser: vue-eslint-parser
|
||||
parserOptions:
|
||||
parser: "@typescript-eslint/parser"
|
||||
extraFileExtensions: [".vue"]
|
||||
rules:
|
||||
import/order:
|
||||
- error
|
||||
- groups:
|
||||
- builtin
|
||||
- external
|
||||
- [internal, parent, sibling, index]
|
||||
- unknown
|
||||
newlines-between: always
|
||||
alphabetize:
|
||||
order: asc
|
||||
caseInsensitive: true
|
||||
"@typescript-eslint/indent":
|
||||
- warn
|
||||
- 2
|
||||
"@typescript-eslint/quotes":
|
||||
- error
|
||||
- double
|
||||
"@typescript-eslint/semi":
|
||||
- error
|
||||
- always
|
||||
"@typescript-eslint/comma-dangle":
|
||||
- error
|
||||
- always-multiline
|
||||
"@typescript-eslint/space-before-function-paren":
|
||||
- error
|
||||
- anonymous: always
|
||||
named: never
|
||||
asyncArrow: always
|
||||
"@typescript-eslint/member-delimiter-style":
|
||||
- error
|
||||
- multiline:
|
||||
delimiter: semi
|
||||
requireLast: true
|
||||
"@typescript-eslint/no-import-type-side-effects": error
|
||||
"@typescript-eslint/strict-boolean-expressions":
|
||||
- warn
|
||||
- allowString: false
|
||||
allowNumber: false
|
||||
allowNullableObject: false
|
||||
allowNullableBoolean: false
|
||||
allowNullableString: false
|
||||
allowNullableNumber: false
|
||||
allowAny: false
|
||||
"@typescript-eslint/consistent-type-assertions":
|
||||
- warn
|
||||
- assertionStyle: angle-bracket # 使用尖括号
|
||||
"@typescript-eslint/naming-convention":
|
||||
- warn
|
||||
- selector: variableLike
|
||||
format: ["camelCase", "UPPER_CASE", "PascalCase", "snake_case"]
|
||||
leadingUnderscore: "allow"
|
||||
trailingUnderscore: "allow"
|
||||
"@typescript-eslint/no-non-null-assertion": warn
|
||||
"@typescript-eslint/no-misused-promises": warn
|
||||
- files: ["*.json"]
|
||||
parser: jsonc-eslint-parser
|
||||
rules:
|
||||
jsonc/sort-array-values:
|
||||
- error
|
||||
- pathPattern: .*
|
||||
order:
|
||||
type: asc
|
||||
jsonc/sort-keys:
|
||||
- error
|
||||
- pathPattern: ^$
|
||||
order:
|
||||
- name
|
||||
- version
|
||||
- description
|
||||
- private
|
||||
- packageManager
|
||||
- scripts
|
||||
- lint-staged
|
||||
- keywords
|
||||
- author
|
||||
- license
|
||||
- repository
|
||||
- homepage
|
||||
- bugs
|
||||
- dependencies
|
||||
- devDependencies
|
||||
- files: ["*.yaml", "*.yml"]
|
||||
parser: yaml-eslint-parser
|
||||
parserOptions:
|
||||
defaultYAMLVersion: "1.2"
|
||||
rules:
|
||||
yml/indent:
|
||||
- error
|
||||
- 2
|
||||
yml/no-multiple-empty-lines: error
|
||||
yml/key-spacing: error
|
||||
yml/quotes:
|
||||
- error
|
||||
- prefer: double
|
||||
avoidEscape: true
|
||||
yml/sort-keys:
|
||||
- error
|
||||
- pathPattern: ^$
|
||||
order:
|
||||
- root
|
||||
- env
|
||||
- extends
|
||||
- parserOptions
|
||||
- globals
|
||||
- rules
|
||||
- overrides
|
||||
- pathPattern: ^rules$
|
||||
order:
|
||||
type: asc
|
||||
|
||||
Reference in New Issue
Block a user