【发布时间】:2022-01-21 15:22:52
【问题描述】:
ESLint 警告我应该有空格,缩进似乎正常设置:
5 export const TimerContext = React.createContext<{
6 totalSeconds: number | null;
7 remainingSeconds: number | null;
8 startTimer: (s: number) => void;
9 stopTimer: () => void;
10 }>({
11 totalSeconds: null,
12 remainingSeconds: null,
13 startTimer: (_: number) => {},
14 stopTimer: () => {},
15 });
eslint 返回的错误:
10:1 error Expected indentation of 4 spaces but found 0 indent
我的 .eslintrc 有:
"indent": ["error", 2],
这是为什么呢?看不出为什么对象类型应该比其成员类型缩进更多的原因。
【问题讨论】:
-
您可以尝试在 eslintrc 文件中添加 "react/jsx-indent": [2, 4]。注释掉现有的缩进配置。
-
@visizky 谢谢,它工作正常!
标签: reactjs eslint typescript-eslint