A catch that does not use the error still had to name a variable, which every linter then flagged as unused.
// before
try {
return JSON.parse(raw);
} catch (e) { // eslint: 'e' is defined but never used
return null;
}
// ES2019
try {
return JSON.parse(raw);
} catch {
return null;
}
Small and genuinely useful for feature detection and for parsing where failure means a default. It is also worth being suspicious of: a catch that ignores the error is right for JSON.parse and wrong for almost anything involving the network, where the distinction between a timeout and a 404 matters. Making the omission syntactically explicit at least means the decision is visible in review rather than hidden behind an unused variable.