eslint-config-preact

raw JSON →
2.0.0 verified Sat Apr 25 auth: no javascript

Unopinionated baseline ESLint configuration for Preact and Preact CLI codebases. Current stable version is 2.0.0, released with ESLint v9 support and dropped support for legacy configs. It provides sensible defaults for modern JS, JSX, Preact, Jest, and Mocha, avoiding stylistic or subjective rules. This config helps catch bugs and suggests optimal patterns. It has a low release cadence (major versions every ~1-2 years). Differentiator: focused solely on Preact, unlike generic React configs.

error Cannot find module 'eslint-config-preact'
cause Package not installed or missing peer dependency eslint.
fix
Run npm i -D eslint eslint-config-preact.
error Failed to load config "preact" to extend from.
cause Using legacy .eslintrc with v2 which requires flat config.
fix
Use eslint.config.js (flat config) or downgrade to v1.x.
error Invalid config: "preact" is not a valid configuration object.
cause Array config imported without spread.
fix
Use ...preact inside the config array.
error Module "eslint-config-preact" does not export a default export
cause Using CommonJS require without destructuring default.
fix
Use const {default: preact} = require('eslint-config-preact').
breaking Version 2.0.0 drops support for legacy .eslintrc configs. Only flat config (eslint.config.js) is supported.
fix Migrate to eslint.config.js using the flat config format. See the quickstart for an example.
breaking Version 2.0.0 requires ESLint v8.57.1 or v9.0.0+. ESLint v7 is no longer supported.
fix Upgrade ESLint to version ^8.57.1 || ^9.0.0.
deprecated Version 1.x used legacy config format; migration to flat config is needed for v2.
fix Update to v2 and use flat config, or pin to v1.x if you cannot migrate.
gotcha The config is exported as an array; it must be spread into your config array. Using it directly as a single element will not apply rules correctly.
fix Use `...preact` inside the exported array.
gotcha CommonJS users must destructure the `default` export: `const {default: preact} = require('eslint-config-preact')`.
fix See installation instructions.
npm install eslint-config-preact
yarn add eslint-config-preact
pnpm add eslint-config-preact

Shows how to import and extend eslint-config-preact in an ESLint flat config file.

// eslint.config.js
import preact from 'eslint-config-preact';

export default [
  ...preact,
  // your custom rules
  {
    rules: {
      'no-console': 'warn'
    }
  }
];