现在我正在使用React.js,Redux Saga和Typescript构建Web应用程序。
安装npm软件包时,出现这样的错误-接口名称必须以大写的I开头。
我必须更新接口名称,并在名称的开头添加I作为前缀。
类似:Props -> IProps
但是我认为这不是最好的解决方案,认为应该有解决此问题的理想方法。
这里是tslint.json。
{
"extends": [
"tslint-config-blvd",
"tslint-react"
],
"linterOptions": {
"exclude": [
"config/**/*.js",
"node_modules/**/*.ts"
]
},
"rules": {
"no-consecutive-blank-lines": true,
"no-any": false,
"no-empty-interface": true,
"curly": true,
"no-duplicate-super": true,
"no-boolean-literal-compare": false,
"max-line-length": [
true,
280
],
"jsx-no-multiline-js": false,
"no-console": false,
"quotemark": [
true,
"double"
],
"no-implicit-dependencies": false,
"no-duplicate-variable": [
true,
"check-parameters"
],
"no-empty": true,
"no-use-before-declare": false,
"no-var-keyword": true,
"switch-default": true,
"jsx-no-lambda": false,
"use-isnan": true,
"eofline": false,
"indent": [
true,
"spaces",
2
],
"no-duplicate-imports": true,
"trailing-comma": [
true,
{
"multiline": {
"objects": "never",
"arrays": "always",
"functions": "never",
"typeLiterals": "ignore"
},
"esSpecCompliant": true
}
],
"class-name": true,
"interface-name": [
true,
"always-prefix"
],
"no-irregular-whitespace": true,
"no-trailing-whitespace": true,
"number-literal-format": true,
"prefer-method-signature": true,
"semicolon": [
true,
"always"
],
"no-default-export": false,
"variable-name": [
true,
"ban-keywords",
"check-format",
"allow-pascal-case"
]
}
}
[请帮助我,让我知道出了什么问题。
问候
这可以通过tslint.json
中的这些规则(也可以解决其他问题……)解决。
"rules": {
....
"object-literal-sort-keys": false,
"interface-name": false,
"member-access": [true, "no-public"],
"ordered-imports": false,
....
},
因此您需要为[[接口名称设置false
。
tslint.json
专门告诉tslint报告此问题:"interface-name": [
true,
"always-prefix"
],
interface-name所以...如果您不喜欢该错误,请在
tslint.json
文件中将其禁用,然后消失。侧节点:tslint is deprecated in favor of eslint,因此,如果您已经在调整规则,则最好跳上该货车。