Sensible ESLint + Prettier Config for TypeScript

raw JSON →
1.9.0 verified Sat May 09 auth: no javascript

Provides sensible default ESLint rules and Prettier config for TypeScript projects, using ESLint 9 flat config. Version 1.9.0 supports ESLint 9.34+, Prettier 3.6+, TypeScript 5.9+, and includes peer dependencies for TypeScript-ESLint, import resolution, JSDoc, Unicorn, and more. Published by james-hu, it offers builder functions (`eslintConfig`, `prettierConfig`) and a `customiseESLintConfig` helper for programmatic customization of flat config arrays. Supports both ESM and CJS usage. Ships TypeScript type definitions.

error ERR_REQUIRE_ESM: require() of ES Module /path/to/node_modules/eslint-config-sensible-prettier-typescript/dist/index.js from /path/to/eslint.config.js not supported.
cause Using CJS require() on an ESM-only package.
fix
Use import syntax in your eslint.config.js or rename file to .mjs and set "type": "module" in package.json.
error Error [ERR_MODULE_NOT_FOUND]: Cannot find module 'eslint-plugin-unicorn'
cause Missing required peer dependency.
fix
Install the missing peer dependency: npm i -D eslint-plugin-unicorn.
error Error: `defineConfig` is not defined
cause Forgetting to import `defineConfig` from `eslint/config` or `eslint` package.
fix
Add import { defineConfig } from 'eslint/config'; at top of eslint.config.js.
error TypeError: eslintConfig is not a function
cause Importing the package incorrectly or using an older version without the builder.
fix
Use import { eslintConfig } from 'eslint-config-sensible-prettier-typescript' and call it as eslintConfig().
breaking Migration from v1.5.x to v1.6.0+ requires ESLint 9 flat config; old .eslintrc style is not supported.
fix Switch to eslint.config.js flat config and use eslintConfig() builder.
deprecated CJS require() usage for eslintConfig or prettierConfig may fail in newer versions due to ESM-first design.
fix Use import syntax or ensure your project is set to CommonJS (type: 'commonjs' in package.json).
gotcha The package exports builder functions, not a static config array. Calling eslintConfig() returns an array; spread it inside defineConfig.
fix Use ...eslintConfig() instead of eslintConfig directly.
gotcha Many peer dependencies (e.g., eslint-plugin-unicorn, eslint-plugin-import-x) are required but not auto-installed. Missing them causes runtime errors.
fix Install all peer dependencies listed in package.json or use install-peerdeps.
gotcha The `customiseESLintConfig` function mutates config objects in-place. Be careful when reusing the same config array.
fix Clone the config array and objects if you need to preserve original state.
npm install eslint-config-sensible-prettier-typescript
yarn add eslint-config-sensible-prettier-typescript
pnpm add eslint-config-sensible-prettier-typescript

Shows ESM usage to set up ESLint and Prettier configs with custom rules overrides.

// Install peer dependencies (example command)
// npm i -D eslint prettier typescript @typescript-eslint/eslint-plugin @typescript-eslint/parser eslint-config-prettier eslint-plugin-import-x eslint-plugin-unicorn eslint-config-sensible-prettier-typescript

// eslint.config.js (ESM)
import { eslintConfig } from 'eslint-config-sensible-prettier-typescript';
import { defineConfig } from 'eslint/config';

export default defineConfig([
  ...eslintConfig(),
  {
    rules: {
      'no-console': 'warn',
      '@typescript-eslint/no-unused-vars': ['error', { argsIgnorePattern: '^_' }],
    },
  },
]);

// prettier.config.js (ESM)
import { prettierConfig } from 'eslint-config-sensible-prettier-typescript';

export default {
  ...prettierConfig(),
  printWidth: 120,
};