我正在使用React Context,我有:
const DocumentContext = createContext<
[DocumentStateType, React.Dispatch<any>, React.Dispatch<any>]
>([initVal, () => { }, () => { }]);
但我的linter抱怨说:
Unexpected empty arrow function @typescript-eslint/no-empty-function
我知道我可以在我的linting设置中关闭它,但是有一个正确的方法来做吗?
3条答案
按热度按时间nwlls2ji1#
如果你只想隐藏linter消息,你可以声明它为:
或作为:
如果你绝对确定你不会在任何地方使用这个默认值。也就是说,你没有使用这个上下文的组件,除了这个上下文的提供者,你可以简单地将它定义为:
7qhs6swi2#
您可以使用选项
allowArrowFunctions
文档
z8dt9xmd3#
如果你使用的是lodash,你可以使用
noop
函数来绕过linting。