[英]typescript/eslint rule for function syntax in objects implementing interface
JavaScript (and TypeScript) offers two ways to define functions when letting an object implement an interface.当让 object 实现接口时,JavaScript(和 TypeScript)提供了两种定义函数的方法。 Consider this code sample:
考虑这个代码示例:
export interface ITest {
start(): ITest;
stop(): ITest;
}
const instance: ITest = {
start: () => instance,
stop() { return this; },
}
I'd like to enforce a consistent code style and need to disable the second style (without :
).我想强制执行一致的代码样式,并且需要禁用第二种样式(不带
:
)。 Is there a typescript-eslint
rule for that?是否有
typescript-eslint
规则?
I looked through the typescript-eslint
rules list but unfortunately I couldn't identify anything from the rule names that seemed to fit what you are looking for.我查看了
typescript-eslint
规则列表,但不幸的是,我无法从规则名称中识别出任何似乎适合您正在寻找的内容。
Here's the full rules list from their repository: https://github.com/typescript-eslint/typescript-eslint/tree/master/packages/eslint-plugin/docs/rules这是他们存储库中的完整规则列表: https://github.com/typescript-eslint/typescript-eslint/tree/master/packages/eslint-plugin/docs/rules
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.