💼 This rule is enabled in the ✅ recommended
config.
🔧💡 This rule is automatically fixable by the --fix
CLI option and manually fixable by editor suggestions.
Array#push()
accepts multiple arguments. Multiple calls should be combined into one.
foo.push(1);
foo.push(2, 3);
foo.push(1, 2, 3);
const length = foo.push(1);
foo.push(2);
foo.push(1);
bar();
foo.push(2);
Type: object
Type: string[]
Ignore objects, stream
, this
, this.stream
are ignored by default.
Example:
{
'unicorn/no-array-push-push': [
'error',
{
ignore: [
'readable',
'foo.stream'
]
}
]
}
// eslint unicorn/no-array-push-push: ["error", {"ignore": ["readable"]}]
import {Readable} from 'node:stream';
const readable = new Readable();
readable.push('one');
readable.push('another');
readable.push(null);