{"id":20010,"library":"eslint-typegen","title":"eslint-typegen","description":"Generates TypeScript types from ESLint rule JSON schemas automatically, providing auto-completion and type-checking for rule options. Current stable version is 2.3.1, with an active release cadence. Key differentiators: leverages ESLint's flat config to generate types on the fly, uses json-schema-to-typescript-lite under the hood, and is ESM-only from v2.0.0. Eliminates manual type definitions for ESLint plugin options.","status":"active","version":"2.3.1","language":"javascript","source_language":"en","source_url":"https://github.com/antfu/eslint-typegen","tags":["javascript","eslint","typescript"],"install":[{"cmd":"npm install eslint-typegen","lang":"bash","label":"npm"},{"cmd":"yarn add eslint-typegen","lang":"bash","label":"yarn"},{"cmd":"pnpm add eslint-typegen","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"peer dependency — required for rule schema introspection and flat config support","package":"eslint","optional":false}],"imports":[{"note":"Default export in ESM-only package (since v2.0.0). Named export does not exist.","wrong":"import { typegen } from 'eslint-typegen'","symbol":"typegen","correct":"import typegen from 'eslint-typegen'"},{"note":"Low-level API available from the 'eslint-typegen/core' subpath export. Not exported from the main entry.","wrong":"import pluginsToRulesDTS from 'eslint-typegen'","symbol":"pluginsToRulesDTS","correct":"import { pluginsToRulesDTS } from 'eslint-typegen/core'"},{"note":"CommonJS require() fails because the package is ESM-only. Use dynamic import in CJS contexts.","wrong":"const pluginsToRulesDTS = require('eslint-typegen/core')","symbol":"pluginsToRulesDTS","correct":"const { pluginsToRulesDTS } = await import('eslint-typegen/core')"}],"quickstart":{"code":"// @ts-check\n/// <reference path=\"./eslint-typegen.d.ts\" />\nimport typegen from 'eslint-typegen'\n\nexport default typegen(\n  [\n    {\n      rules: {\n        'semi': ['error', 'always'],\n      },\n    },\n  ]\n)\n\n// Run ESLint once to generate eslint-typegen.d.ts\n// npx eslint .","lang":"typescript","description":"Wraps ESLint flat config with typegen() to auto-generate TypeScript declarations for rule options."},"warnings":[{"fix":"Convert to ESM (use 'import' syntax or dynamic import) or pin to v1.x if CJS is required.","message":"ESM-only since v2.0.0. CommonJS require() will throw an error.","severity":"breaking","affected_versions":">=2.0.0"},{"fix":"Upgrade to v0.3.2+ to avoid needing @types/eslint separately.","message":"The @types/eslint dependency was removed in v0.3.2; types are self-contained.","severity":"deprecated","affected_versions":"<=0.3.1"},{"fix":"Run ESLint at least once after configuration changes to regenerate eslint-typegen.d.ts.","message":"Type generation only triggers on ESLint run; it does not happen at import time.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Skip installing eslint-typegen if using @antfu/eslint-config; its types are pre-generated.","message":"If using @antfu/eslint-config, typegen types are already bundled; do not add separate eslint-typegen setup.","severity":"gotcha","affected_versions":"*"},{"fix":"Ensure project uses ESLint 9+ with flat config (eslint.config.js/mjs). Not compatible with legacy .eslintrc.","message":"Peer dependency eslint ^9.0.0 || ^10.0.0; flat config required.","severity":"gotcha","affected_versions":"*"}],"env_vars":null,"last_verified":"2026-04-25T00:00:00.000Z","next_check":"2026-07-24T00:00:00.000Z","problems":[{"fix":"Ensure typegen() receives an array of valid flat config objects: typegen([...configs]).","cause":"Typegen is called with a config array that is empty or missing rules.","error":"TypeError: Cannot read properties of undefined (reading 'rules')"},{"fix":"Convert your script to ESM (use 'import') or use dynamic import: const typegen = (await import('eslint-typegen')).default.","cause":"Package is ESM-only since v2.0.0; CJS require() is not supported.","error":"[ERR_REQUIRE_ESM] require() of ES Module from CommonJS"},{"fix":"Upgrade to v2.0.0+ or use import { pluginsToRulesDTS } from 'eslint-typegen' in older versions (check docs accordingly).","cause":"Using a version before v2.0.0 where 'eslint-typegen/core' subpath did not exist.","error":"Cannot find module 'eslint-typegen/core'"},{"fix":"Use typegen as an exported function, not as a plugin. Remove from plugins array and wrap config: export default typegen([...]).","cause":"Mistakenly trying to use eslint-typegen as an ESLint plugin instead of a config generator function.","error":"ESLint error: Failed to load config 'eslint-typegen' in plugin"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}