unicorn/require-array-join-separator
Require the separator argument of Array#join()
fixable
Without an argument, join() puts a comma between the items. A reader might expect no separator at all, or a comma and a space. Writing the separator out removes the guesswork.
The rule only looks at the method name, so it reports .join() without arguments on any object. It also reports Array.prototype.join.call(items) and [].join.call(items).
--fix adds ",", which keeps the result the same.
Configure#
Off by default. To turn it on:
bunfig.toml
[lint.rules]
"unicorn/require-array-join-separator" = "error" # or "warn"Examples#
example.js2 problems
const header = columns.join()Enforce using the separator argument with Array#join();
const names = Array.prototype.join.call(arguments)Enforce using the separator argument with Array#join();example.jsNo problems
const header = columns.join(",");
const names = Array.prototype.join.call(arguments, ", ");
const word = letters.join("");