unicorn/prefer-iterator-zip
eslint-plugin-unicorn
Suggestion
eslint.config.js
import unicorn from "eslint-plugin-unicorn";
export default [
{
plugins: { unicorn },
rules: {
"unicorn/prefer-iterator-zip": "error",
},
},
];for (let index = 0; index < Math.min(names.length, scores.length); index++) {
save(names[index], scores[index]);
}for (const [name, score] of Iterator.zip([names, scores])) {
save(name, score);
}Examples from the ESLint documentation.
unicorn/prefer-iterator-zip
eslint-plugin-unicorn
import unicorn from "eslint-plugin-unicorn";
export default [
{
plugins: { unicorn },
rules: {
"unicorn/prefer-iterator-zip": "error",
},
},
];Oxlint does not have this rule.
nursery/useIteratorZip
nursery · since 2.6.3
{
"linter": {
"rules": {
"nursery": {
"useIteratorZip": "error"
}
}
}
}Prefer early continues over conditionals wrapping the remainder of the loop body.
Enforce consistent class references in static methods.
Disallow simple recursive function calls that can be replaced with a loop.
Enforce consistent class member order.
Disallow checking a Map key before accessing a different key.
Enforce consistent conditional object spread style.