Rules
Every rule from ESLint, Oxlint and Biome. Pick a rule to see its example. Reach is the weekly npm downloads of the presets that enable a rule; trend is its change over the last quarter.
Every rule from ESLint, Oxlint and Biome. Pick a rule to see its example. Reach is the weekly npm downloads of the presets that enable a rule; trend is its change over the last quarter.
// each object in scores gets shallow-copied. Since `scores` is never
// reused, spreading is inefficient.
function getDisplayData() {
const scores: Array<{ username: string, score: number }> = getScores();
const displayData = scores.map(score => ({ ...score, rank: getRank(score) }));
return displayData
}const arr = [{ a: 1 }, { a: 2 }, { a: 3 }];
arr.map(obj => Object.assign(obj, { b: obj.a * 2 }));
// instance properties are ignored
class UsersDb {
#users = [];
public get users() {
// clone users, providing caller with their own deep(ish) copy.
return this.#users.map(user => ({ ...user }));
}
}Popular · 1 of 1
Disallow the use of object or array spreads in Array.prototype.map and Array.prototype.flatMap to add properties/elements to array items.
// each object in scores gets shallow-copied. Since `scores` is never
// reused, spreading is inefficient.
function getDisplayData() {
const scores: Array<{ username: string, score: number }> = getScores();
const displayData = scores.map(score => ({ ...score, rank: getRank(score) }));
return displayData
}const arr = [{ a: 1 }, { a: 2 }, { a: 3 }];
arr.map(obj => Object.assign(obj, { b: obj.a * 2 }));
// instance properties are ignored
class UsersDb {
#users = [];
public get users() {
// clone users, providing caller with their own deep(ish) copy.
return this.#users.map(user => ({ ...user }));
}
}