Skip to content

Latest commit

Β 

History

History
43 lines (30 loc) Β· 1.13 KB

File metadata and controls

43 lines (30 loc) Β· 1.13 KB

require-array-join-separator

πŸ“ 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');