Enforces a minimum of chained method calls to allow multiline chains, except when the chain is too long to fit on a single line.
{
"@croct/min-chained-call-depth": [
"error",
{
"maxLineLength": 100
}
]
}
These are examples of how the rule might apply.
expect(screen.getElementById("very-long-identifier"))
.toBe(true)
expect(screen.getElementById("very-long-identifier"))
.toBe({
foo: true
});
expect(screen.getElementById("very-long-identifier")).toBe(true);
expect(screen.getElementById("very-long-identifier"))
// ...
.toBe(true);
expect(screen.getElementById("very-long-identifier")).toBe({
foo: true
});
These are the available options:
Specifies the maximum line length so that the rule allows breaking into multiple lines cases that otherwise would not be permitted to avoid exceeding the line length limit.
expect(screen.getElementById("identifier"))
.toBe(true);
/*eslint min-chained-call-depth: ["error", {"maxLineLength": 63}]*/
expect(screen.getElementById("very-long-identifier"))
.toBe(true);
Chains that are deeper than the specified number are allowed to break line, default is 2.
Array(10)
.fill(0)
.map(foo => foo);
/* eslint min-chained-call-depth: ["error", {"ignoreChainDeeperThan": 1}] */
Array(10)
.fill(0)
.map(foo => foo);
- ✅ Recommended
- 🔧 Fixable
- 💭 Requires type information