简体   繁体   English

用链式方法缩进

[英]Eslint indent with chained methods

How do I configure eslint to: 如何将eslint配置为:

Promise.all(promises)
.then(() => {
  myExampleFunction()
})

instead of: 代替:

Promise.all(promises)
    .then(() => {
      myExampleFunction()
    })

We are using the following eslint packages: 我们正在使用以下eslint软件包:

"eslint": "4.12.0",
"eslint-plugin-promise": "3.6.0",
"eslint-plugin-react": "7.5.1",
"eslint-plugin-react-native": "3.2.0",

You can set MemberExpression to 0 as per documentation 您可以根据文档将MemberExpression设置为0

"Indent of 2 spaces with MemberExpression set to 0 will indent the multi-line property chains with 0 spaces." “将MemberExpression设置为0的2个空格的缩进将使带有0个空格的多行属性链缩进。” - indent - Rules - 缩进-规则

as inline comment /*eslint indent: ["error", 2, { "MemberExpression": 0 }]*/ 作为内联注释/*eslint indent: ["error", 2, { "MemberExpression": 0 }]*/

in .eslintrc "rules": {"indent": ["error", 2, { "MemberExpression": 0 }]} 在.eslintrc中的"rules": {"indent": ["error", 2, { "MemberExpression": 0 }]}

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM