Search code examples
reactjseslinttypescript-eslint

Expected indentation of 4 spaces but found 0


ESLint warns me I should have spaces, where indentation seems normally set up:

  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 });

Error returned by eslint:

 10:1   error    Expected indentation of 4 spaces but found 0                                                       indent

My .eslintrc has:

"indent": ["error", 2],

Why is that? Can't see a reason why the object type should be indented more than its member types.


Solution

  • Solution was to use "react/jsx-indent" config option, as suggested by @visizky in the comments section:

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