Skip to content

Latest commit

 

History

History
42 lines (30 loc) · 1.02 KB

require-array-join-separator.md

File metadata and controls

42 lines (30 loc) · 1.02 KB

Enforce using the separator argument with Array#join()

This rule is part of the recommended config.

🔧 This rule is auto-fixable.

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

Fail

const string = array.join();
const string = Array.prototype.join.call(arrayLike);
const string = [].join.call(arrayLike);

Pass

const string = array.join(',');
const string = array.join('|');
const string = Array.prototype.join.call(arrayLike, '');
const string = [].join.call(arrayLike, '\n');