预期缩进 4 个空格但发现 0

Expected indentation of 4 spaces but found 0

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],

这是为什么?看不出对象类型比其成员类型缩进更多的原因。

解决方案是使用“react/jsx-indent”配置选项,正如@visizky 在评论部分所建议的那样:

"react/jsx-indent": [2, 2]