{"id":27723,"library":"eslint-config-sensible-prettier-typescript","title":"Sensible ESLint + Prettier Config for TypeScript","description":"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.","status":"active","version":"1.9.0","language":"javascript","source_language":"en","source_url":"https://github.com/james-hu/eslint-config-sensible-typescript","tags":["javascript","eslint","eslintplugin","eslintconfig","eslint-config","sensible","defaults","prettier","typescript"],"install":[{"cmd":"npm install eslint-config-sensible-prettier-typescript","lang":"bash","label":"npm"},{"cmd":"yarn add eslint-config-sensible-prettier-typescript","lang":"bash","label":"yarn"},{"cmd":"pnpm add eslint-config-sensible-prettier-typescript","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"peer dependency for ESLint 9 flat config","package":"eslint","optional":false},{"reason":"peer dependency for TypeScript type checking","package":"typescript","optional":false},{"reason":"peer dependency for Prettier formatting","package":"prettier","optional":false},{"reason":"peer dependency for TypeScript ESLint rules","package":"@typescript-eslint/eslint-plugin","optional":false},{"reason":"peer dependency for parsing TypeScript","package":"@typescript-eslint/parser","optional":false},{"reason":"peer dependency to disable conflicting ESLint rules","package":"eslint-config-prettier","optional":false},{"reason":"peer dependency for import ordering and validation","package":"eslint-plugin-import-x","optional":false},{"reason":"peer dependency for additional useful rules","package":"eslint-plugin-unicorn","optional":false}],"imports":[{"note":"ESM-only since v1.6.2 (ESLint 9 migration); CJS require will fail if package.json type is module.","wrong":"const { eslintConfig } = require('eslint-config-sensible-prettier-typescript')","symbol":"eslintConfig","correct":"import { eslintConfig } from 'eslint-config-sensible-prettier-typescript'"},{"note":"Same as eslintConfig; use ESM import.","wrong":"const prettierConfig = require('eslint-config-sensible-prettier-typescript').prettierConfig","symbol":"prettierConfig","correct":"import { prettierConfig } from 'eslint-config-sensible-prettier-typescript'"},{"note":"Helper function for modifying flat config array programmatically.","wrong":null,"symbol":"customiseESLintConfig","correct":"import { customiseESLintConfig } from 'eslint-config-sensible-prettier-typescript'"},{"note":"Builder for ESLint flat config, takes options like defaultSourceType.","wrong":null,"symbol":"buildESLintConfig","correct":"import { buildESLintConfig } from 'eslint-config-sensible-prettier-typescript'"}],"quickstart":{"code":"// Install peer dependencies (example command)\n// 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\n\n// eslint.config.js (ESM)\nimport { eslintConfig } from 'eslint-config-sensible-prettier-typescript';\nimport { defineConfig } from 'eslint/config';\n\nexport default defineConfig([\n  ...eslintConfig(),\n  {\n    rules: {\n      'no-console': 'warn',\n      '@typescript-eslint/no-unused-vars': ['error', { argsIgnorePattern: '^_' }],\n    },\n  },\n]);\n\n// prettier.config.js (ESM)\nimport { prettierConfig } from 'eslint-config-sensible-prettier-typescript';\n\nexport default {\n  ...prettierConfig(),\n  printWidth: 120,\n};","lang":"typescript","description":"Shows ESM usage to set up ESLint and Prettier configs with custom rules overrides."},"warnings":[{"fix":"Switch to eslint.config.js flat config and use eslintConfig() builder.","message":"Migration from v1.5.x to v1.6.0+ requires ESLint 9 flat config; old .eslintrc style is not supported.","severity":"breaking","affected_versions":">=1.6.0"},{"fix":"Use import syntax or ensure your project is set to CommonJS (type: 'commonjs' in package.json).","message":"CJS require() usage for eslintConfig or prettierConfig may fail in newer versions due to ESM-first design.","severity":"deprecated","affected_versions":">=1.6.2"},{"fix":"Use ...eslintConfig() instead of eslintConfig directly.","message":"The package exports builder functions, not a static config array. Calling eslintConfig() returns an array; spread it inside defineConfig.","severity":"gotcha","affected_versions":">=1.6.0"},{"fix":"Install all peer dependencies listed in package.json or use install-peerdeps.","message":"Many peer dependencies (e.g., eslint-plugin-unicorn, eslint-plugin-import-x) are required but not auto-installed. Missing them causes runtime errors.","severity":"gotcha","affected_versions":">=1.6.0"},{"fix":"Clone the config array and objects if you need to preserve original state.","message":"The `customiseESLintConfig` function mutates config objects in-place. Be careful when reusing the same config array.","severity":"gotcha","affected_versions":">=1.6.0"}],"env_vars":null,"last_verified":"2026-05-09T00:00:00.000Z","next_check":"2026-08-07T00:00:00.000Z","problems":[{"fix":"Use `import` syntax in your eslint.config.js or rename file to .mjs and set `\"type\": \"module\"` in package.json.","cause":"Using CJS require() on an ESM-only package.","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."},{"fix":"Install the missing peer dependency: `npm i -D eslint-plugin-unicorn`.","cause":"Missing required peer dependency.","error":"Error [ERR_MODULE_NOT_FOUND]: Cannot find module 'eslint-plugin-unicorn'"},{"fix":"Add `import { defineConfig } from 'eslint/config';` at top of eslint.config.js.","cause":"Forgetting to import `defineConfig` from `eslint/config` or `eslint` package.","error":"Error: `defineConfig` is not defined"},{"fix":"Use `import { eslintConfig } from 'eslint-config-sensible-prettier-typescript'` and call it as `eslintConfig()`.","cause":"Importing the package incorrectly or using an older version without the builder.","error":"TypeError: eslintConfig is not a function"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}