Igor L.
Igor L.

Reputation: 3465

ES Lint rule for chained then promise calls

I am searching for an ES Lint rule that will force the following behavior:

aPromiseCall()
   .then(() => {
       // logic
   })
   .then(() => {
       // logic
   })
   .catch(() => {

   })

Notice that each .then should be indented by 4 spaces and on a . separate line

Upvotes: 2

Views: 999

Answers (1)

Igor L.
Igor L.

Reputation: 3465

Use the following rule:

"indent": ["error", 4, { "MemberExpression": 1 }]

"MemberExpression" (default: 1) enforces indentation level for multi-line property chains. This can also be set to "off" to disable checking for MemberExpression indentation.

https://eslint.org/docs/rules/indent#memberexpression

Upvotes: 2

Related Questions