sbdchd / eslint-plugin-cake

:cake: Sweet rules for ESLint
MIT License
1 stars 0 forks source link

new rule: `no-unused-return-value` #22

Open sbdchd opened 3 years ago

sbdchd commented 3 years ago
// err
const foo = {}
bar.map(x => {
   foo[x.id] = x
})

// ok
const foo = {}
bar.forEach(x => {
   foo[x.id] = x
})

// ok
const bar = { map: (cb: () => void) => {} }
bar.map(x => {
   foo[x.id] = x
})

Use type information to ensure we don't mess up.

A more extensive lint would replicate something like Rust's #[must_use]

rel: https://github.com/eslint/eslint/issues/12980

rel: https://github.com/sindresorhus/eslint-plugin-unicorn/issues/741