eslint-plugin-istanbul

raw JSON →
0.1.2 verified Sat Apr 25 auth: no javascript maintenance

ESLint plugin providing rules to enforce best practices for istanbul code coverage comments. Current stable version 0.1.2, low release cadence (last release 2020). Key differentiators: specifically targets istanbul ignore comments (no-ignore-file, prefer-ignore-reason) to maintain code quality in coverage exclusions. Requires ESLint 6.x or 7.x (not compatible with ESLint 8+/9+). Lightweight, no runtime dependencies beyond ESLint peer dependency.

error Error: Failed to load plugin 'istanbul': Cannot find module 'eslint-plugin-istanbul'
cause Plugin not installed or ESLint cannot resolve it.
fix
Run npm install --save-dev eslint-plugin-istanbul and ensure node_modules is in the right location.
error Error: Configuration for rule 'istanbul/no-ignore-file' is invalid: Value "error" must be an object or a string/array
cause ESLint expects rule severity to be a number (0,1,2) or string ('off','warn','error').
fix
Use "error" (string) is correct; ensure your config file is valid JSON.
error ReferenceError: eslint is not defined (when using flat config)
cause Trying to use old-style .eslintrc in ESLint 9+ without proper FlatConfig setup.
fix
Migrate to flat config: export default [{ plugins: { istanbul: require('eslint-plugin-istanbul') }, rules: { 'istanbul/no-ignore-file': 'error' } }]
breaking Requires ESLint 6.x or 7.x; incompatible with ESLint 8+ and 9+ flat config without migration
fix Use eslint-plugin-istanbul only with ESLint 6 or 7, or migrate to ESLint 8+ using flat config and check plugin compatibility (may need alternative plugins).
deprecated The 'prefer-ignore-reason' rule may become stricter in future versions
fix Always provide a reason in ignore comments: /* istanbul ignore next -- reason */
gotcha Plugin rules only catch certain ignore comment formats; malformed comments may pass
fix Ensure ignore comments follow exactly: /* istanbul ignore <type> -- optional reason */ or // istanbul ignore <type>
npm install eslint-plugin-istanbul
yarn add eslint-plugin-istanbul
pnpm add eslint-plugin-istanbul

Shows ESLint configuration with both plugin rules and usage of istanbul ignore comments.

// Install: npm install --save-dev eslint eslint-plugin-istanbul
// .eslintrc.json
{
  "plugins": ["istanbul"],
  "rules": {
    "istanbul/no-ignore-file": "error",
    "istanbul/prefer-ignore-reason": "error"
  }
}

// In your code:
/* istanbul ignore next -- needs refactor */
function deprecatedFunction() { return 42; }

/* istanbul ignore file */ // This will cause an error with no-ignore-file rule