我在检查我的代码时遇到了一些问题。
现在我使用的是以下版本:
这是我的 .eslintrc.yml 文件
---
# Env Vars #
env:
es6: true
node: true
ignorePatterns:
- "!.*"
- "**/node_modules/.*"
# Parser vars #
parser: "@typescript-eslint/parser"
parserOptions:
ecmaVersion: 2018
# Plugins #
plugins:
- "@typescript-eslint"
- mongodb
extends:
- plugin:@typescript-eslint/recommended
# Rules #
rules:
indent:
- 1
- tab
- SwitchCase: 1
no-undef: 2
no-unreachable: 2
no-unused-expressions: 1
no-unused-vars: 0
comma-dangle:
- 1
- only-multiline
no-multi-spaces:
- 1
- exceptions:
VariableDeclarator: true
no-shadow-restricted-names: 0
eqeqeq:
- 1
- smart
no-dupe-keys: 2
no-duplicate-case: 2
no-extra-semi: 2
max-depth:
- 1
- 4
no-empty: 2
"@typescript-eslint/no-var-requires": off
"@typescript-eslint/explicit-function-return-type": off
"@typescript-eslint/no-explicit-any": off
"@typescript-eslint/ban-ts-ignore": off
"@typescript-eslint/interface-name-prefix": off
"@typescript-eslint/class-name-casing": off
"@typescript-eslint/no-use-before-define":
- error
- functions: false
classes: true
"@typescript-eslint/no-extra-parens": 2
"@typescript-eslint/ban-ts-comment": 0
但是当我导入 Typegoose 类型时,它会为我返回一些 linting 错误,例如:
error 'index' is defined but never used
import { index } from '@typegoose/typegoose';
@index({
user: 1,
deleted: 1,
facility: 1,
provider: 1,
}, {
background: true,
})
还有缩进
warning Expected indentation of 1 tab but found 0
这期望索引是这样的,这太糟糕了:
@index({
user: 1,
deleted: 1,
facility: 1,
provider: 1,
}, {
background: true,
})
如果有人知道发生了什么,我将不胜感激<3
我已经尝试了所有类型的 ESLint 规则,但我不想禁用
@typescript-eslint/no-unused-vars
因为它对代码的其他部分很有用