【问题标题】:Eslint indent with chained methods带有链式方法的 Eslint 缩进
【发布时间】:2018-05-13 23:22:11
【问题描述】:

我如何将 eslint 配置为:

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

代替:

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

我们正在使用以下 eslint 包:

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

【问题讨论】:

    标签: javascript reactjs react-native eslint chained


    【解决方案1】:

    您可以根据文档将 MemberExpression 设置为 0

    “MemberExpression 设置为 0 的缩进 2 个空格将缩进 0 个空格的多行属性链。” - indent - Rules

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

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-11-12
      • 2022-08-18
      • 2012-01-30
      • 2017-02-08
      • 1970-01-01
      • 1970-01-01
      • 2019-04-06
      • 2016-07-28
      相关资源
      最近更新 更多