consistent-chaining

September 3, 2024 ยท View on GitHub

Enforce consistent line breaks for chaining member access.

Rule Details

// ๐Ÿ‘Ž bad
const foo1 = [].map(x => x + 'bar')
  .filter(Boolean)

const foo2 = []
  .map(x => x + 'bar').filter(Boolean)
// ๐Ÿ‘ good
const foo1 = [].map(x => x + 'bar').filter(Boolean)

const foo2 = []
  .map(x => x + 'bar')
  .filter(Boolean)

It will check the newline style of the first property access and apply the same style to the rest of the chaining access.