unicorn/no-return-array-push
eslint-plugin-unicorn
Suggestion
eslint.config.js
import unicorn from "eslint-plugin-unicorn";
export default [
{
plugins: { unicorn },
rules: {
"unicorn/no-return-array-push": "error",
},
},
];Disallow using the return value of Array#push() and Array#unshift().
function add(item) {
return items.push(item);
}const add = item => items.push(item);const length = items.unshift(item);function add(item) {
items.push(item);
return;
}const add = item => {
items.push(item);
};items.unshift(item);
const length = items.length;Examples from the ESLint documentation.
unicorn/no-return-array-push
eslint-plugin-unicorn
import unicorn from "eslint-plugin-unicorn";
export default [
{
plugins: { unicorn },
rules: {
"unicorn/no-return-array-push": "error",
},
},
];Oxlint does not have this rule.
nursery/noReturnArrayPush
nursery · since 2.6.4
{
"linter": {
"rules": {
"nursery": {
"noReturnArrayPush": "error"
}
}
}
}Disallow event-control method calls after the synchronous event dispatch has finished.
Disallow Array#splice() when simpler alternatives exist.
Disallow accessing event.currentTarget after the synchronous event dispatch has finished.
Disallow .map() and .filter() in for…of and for await…of loop headers.
Disallow confusing uses of Array#{splice,toSpliced}().
Prefer putting the condition in the while statement.