Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Eslint indent with chained methods

How do I configure eslint to:

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

instead of:

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

We are using the following eslint packages:

"eslint": "4.12.0",
"eslint-plugin-promise": "3.6.0",
"eslint-plugin-react": "7.5.1",
"eslint-plugin-react-native": "3.2.0",
like image 484
Waltari Avatar asked Nov 30 '17 05:11

Waltari


1 Answers

You can set MemberExpression to 0 as per documentation

"Indent of 2 spaces with MemberExpression set to 0 will indent the multi-line property chains with 0 spaces." - indent - Rules

as inline comment /*eslint indent: ["error", 2, { "MemberExpression": 0 }]*/

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

like image 141
mjabadilla Avatar answered Oct 25 '22 20:10

mjabadilla