简体   繁体   English

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

[英]Expected indentation of 4 spaces but found 0

ESLint warns me I should have spaces, where indentation seems normally set up: 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 });

Error returned by eslint: eslint 返回的错误:

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

My.eslintrc has: My.eslintrc 有:

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

Why is that?这是为什么? Can't see a reason why the object type should be indented more than its member types.看不出 object 类型应该比其成员类型缩进更多的原因。

Solution was to use "react/jsx-indent" config option, as suggested by @visizky in the comments section:解决方案是使用“react/jsx-indent”配置选项,正如@visizky 在评论部分所建议的那样:

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何将我的所有 vscode 文件从 4 个空格缩进格式化为 2 个空格? - How to format all my vscode files from 4 space indentation to 2 spaces? “预期作业但找到了表达方式” - “Expected an assignment but found an expression” 为什么“create-react-app”总是给我 2 个而不是 4 个缩进空间? - Why 'create-react-app' always gives me 2 instead of 4 indentation spaces? React Component问题(预期为“;”,但发现为“,”) - React Component problem (';' expected, but found ',') GraphQLError:语法错误:预期的$,找到的[ - GraphQLError: Syntax Error: Expected $, found [ jscs:节点列表的预期结尾,但是找到了“ CommentBlock” - jscs : Expected end of node list but “CommentBlock” found Apollo查询返回错误“期望的字符串,找到的字符串” - Apollo query returns error “Expected String, found String” 预期换行符为“CRLF”,但发现“LF”换行符样式 - Expected linebreaks to be 'CRLF' but found 'LF' linebreak-style 元素类型无效。 需要一个字符串,发现未定义 - Element type is invalid. Expected a string, found undefined 示例代码,错误:应为“;” 但发现“类”和更多语法错误 - Code from example, error: Expected “;” but found “class” and more syntax errors
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM