require-array-join-separator

March 27, 2026 ยท View on GitHub

๐Ÿ“ Enforce using the separator argument with Array#join().

๐Ÿ’ผ This rule is enabled in the following configs: โœ… recommended, โ˜‘๏ธ unopinionated.

๐Ÿ”ง This rule is automatically fixable by the --fix CLI option.

It's better to make it clear what the separator is when calling Array#join(), instead of relying on the default comma (',') separator.

Examples

// โŒ
const string = array.join();

// โœ…
const string = array.join(',');
// โœ…
const string = array.join('|');
// โŒ
const string = Array.prototype.join.call(arrayLike);

// โœ…
const string = Array.prototype.join.call(arrayLike, '');
// โŒ
const string = [].join.call(arrayLike);

// โœ…
const string = [].join.call(arrayLike, '\n');