Skip to main content
interlace
Plugin: reliabilityRules

no-silent-errors

Report catch blocks that do nothing, so an error is never silently swallowed.

Report a catch block that does nothing. An empty handler swallows the error: nothing is logged, nothing is rethrown, and the failure vanishes.

This rule is part of eslint-plugin-reliability.

Quick Summary

AspectDetails
SeverityError (code quality)
Auto-Fix❌ No
CategoryError-handling
Suggestions✅ Log, handle or rethrow the error

Rule Details

The rule reports a catch clause whose body holds no statement: an empty block, or one holding only empty statements (;). Every spelling of the clause counts: with a binding (catch (err) {}), without one (catch {}), followed by finally, inside an async function.

A catch block that does anything handles the error and is not reported: it logs it, rethrows it, returns a fallback value, or records a flag for the caller.

Configuration

OptionTypeDefaultDescription
allowWithCommentbooleanfalseAccept an empty catch with an explanatory comment inside the block or within two lines above it
ignoreInTestsbooleantrueSkip *.test.* / *.spec.* files

With allowWithComment, a comment counts as an explanation when it uses one of these words: intentional, expected, ignore, silent, noop / no-op, by design, known issue, legacy, third-party, framework, library, not implemented, TODO, FIXME. A comment far above the try, about something else, explains nothing.

Examples

❌ Incorrect

try {
  data = readCache();
} catch (err) {}

try {
  await flush();
} catch {
  ;
}

✅ Correct

try {
  data = readCache();
} catch (err) {
  console.error('cache read failed', err);
}

try {
  data = readCache();
} catch {
  return null; // a cold cache is a valid state
}

// With { allowWithComment: true }
try {
  data = readCache();
} catch {
  // intentional: a missing cache file means a cold start
}

Configuration Examples

// eslint.config.mjs
export default [
  {
    rules: {
      'reliability/no-silent-errors': ['error', { allowWithComment: true }],
    },
  },
];

Known False Negatives

The following patterns are not detected:

Promise .catch with an empty handler

Why: the rule inspects catch clauses; .catch(() => {}) is a function argument, not a clause.

// ❌ NOT DETECTED
save().catch(() => {});

Mitigation: give the handler a body that logs or rethrows.

Use this rule

npm install -D oxlint-plugin-reliability
.oxlintrc.json
{  "jsPlugins": ["oxlint-plugin-reliability"],  "rules": {    "reliability/no-silent-errors": "error"  }}
vite.config.ts
import { defineConfig } from 'vite-plus';export default defineConfig({  lint: {    jsPlugins: ['oxlint-plugin-reliability'],    rules: {      'reliability/no-silent-errors': 'error',    },  },});

oxlint-plugin-reliability re-exports eslint-plugin-reliability/oxlint: the same rules under the same IDs, and no ESLint install. Why oxlint.

Did this rule catch something? Star the repo to get new CWE coverage as we ship it — or follow the AI-code-security benchmarks behind these rules.