Skip to content

Latest commit

 

History

History
106 lines (74 loc) · 1.14 KB

fluent-chaining.md

File metadata and controls

106 lines (74 loc) · 1.14 KB

Enforce formatting for chained calls (fluent-chaining)

This rule aims to keep a consistent format when working with chained functions such as those provided by lodash chained functions or Q based promises.

Examples

Member expressions should not span more than 2 lines

Invalid example:

a()

   .b();

Valid example:

a()
   .b();

Once a statement is broken into multiple lines, each member expression should be on its own line.

Invalid example:

a()
   .b().c;

Valid example:

a().b().c;

// OR

a()
   .b()
   .c;

Missing indentation when member expression is on multiple lines.

Invalid example:

a()
.b();

Valid example:

a()
   .b();

Chained function calls must have the same indentation as the previous call.

Invalid example:

object.handleArray([
   'abc',
   'def',
])
   .doSomething(function(abc, def) {
   });

Valid example:

object
   .handleArray([
      'abc',
      'def',
   ])
   .doSomething(function(abc, def) {
   });

// OR

var values;

values = [
   'abc',
   'def',
];

Q.handleArray(values)
   .doSomething(function(abc, def) {
   });