我最近升级了我的角度应用程序以使用 eslint 而不是 tslint。
我现在正在努力启用call-signature typedef
。
所以,之前,我有这个:
"typedef": [
true,
...,
"call-signature"
]
但是在 Eslint 中,我找不到对应的东西。当浏览their git page时,我看到这个:
type Options = {
arrayDestructuring?: boolean;
arrowParameter?: boolean;
memberVariableDeclaration?: boolean;
objectDestructuring?: boolean;
parameter?: boolean;
propertyDeclaration?: boolean;
variableDeclaration?: boolean;
variableDeclarationIgnoreFunction?: boolean;
};
如何启用呼号?
尽管将所有内容设置为 true,但这样做不会触发任何警告:
public someMethod() {}
这是我的 tslint 配置:
"@typescript-eslint/typedef": [
"warn",
{
"arrayDestructuring": true,
"arrowParameter": true,
"memberVariableDeclaration": true,
"objectDestructuring": true,
"parameter": true,
"propertyDeclaration": true,
"variableDeclaration": true,
"variableDeclarationIgnoreFunction": true
}
]
我尝试添加调用签名
,但没有帮助。
最佳答案
根据文档,您必须使用此规则来强制执行类型定义。
"@typescript-eslint/explicit-function-return-type": [
"error",
{
"allowExpressions": true
}
]
这将在函数、箭头函数和类方法上强制执行 TSLint 相同的返回类型定义规则集。
关于typescript - @typescript-eslint/typedef 启用调用签名,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/68374703/