Registry / devops / eslint-typegen

eslint-typegen

JSON →
library2.3.1jsnpmunverified

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.

npm install eslint-typegen
INSTALL
IMPORT
SIG · ESLINT-TYPEGEN
E
eslint-typegen
devopsjavascriptv2.3.1
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

typegen
import typegen from 'eslint-typegen'
import { typegen } from 'eslint-typegen'
Default export in ESM-only package (since v2.0.0). Named export does not exist.
pluginsToRulesDTS
import { pluginsToRulesDTS } from 'eslint-typegen/core'
import pluginsToRulesDTS from 'eslint-typegen'
Low-level API available from the 'eslint-typegen/core' subpath export. Not exported from the main entry.
pluginsToRulesDTS
const { pluginsToRulesDTS } = await import('eslint-typegen/core')
const pluginsToRulesDTS = require('eslint-typegen/core')
CommonJS require() fails because the package is ESM-only. Use dynamic import in CJS contexts.

Wraps ESLint flat config with typegen() to auto-generate TypeScript declarations for rule options.

// @ts-check /// <reference path="./eslint-typegen.d.ts" /> import typegen from 'eslint-typegen' export default typegen( [ { rules: { 'semi': ['error', 'always'], }, }, ] ) // Run ESLint once to generate eslint-typegen.d.ts // npx eslint .
Debug
Known issues
breakingESM-only since v2.0.0. CommonJS require() will throw an error.
fix
Convert to ESM (use 'import' syntax or dynamic import) or pin to v1.x if CJS is required.
affects: >=2.0.0
deprecatedThe @types/eslint dependency was removed in v0.3.2; types are self-contained.
fix
Upgrade to v0.3.2+ to avoid needing @types/eslint separately.
affects: <=0.3.1
gotchaType generation only triggers on ESLint run; it does not happen at import time.
fix
Run ESLint at least once after configuration changes to regenerate eslint-typegen.d.ts.
affects: >=1.0.0
gotchaIf using @antfu/eslint-config, typegen types are already bundled; do not add separate eslint-typegen setup.
fix
Skip installing eslint-typegen if using @antfu/eslint-config; its types are pre-generated.
affects: *
gotchaPeer dependency eslint ^9.0.0 || ^10.0.0; flat config required.
fix
Ensure project uses ESLint 9+ with flat config (eslint.config.js/mjs). Not compatible with legacy .eslintrc.
affects: *
Errors
Common errors & fixes
TypeError: Cannot read properties of undefined (reading 'rules')
Typegen is called with a config array that is empty or missing rules.
fix
Ensure typegen() receives an array of valid flat config objects: typegen([...configs]).
[ERR_REQUIRE_ESM] require() of ES Module from CommonJS
Package is ESM-only since v2.0.0; CJS require() is not supported.
fix
Convert your script to ESM (use 'import') or use dynamic import: const typegen = (await import('eslint-typegen')).default.
Cannot find module 'eslint-typegen/core'
Using a version before v2.0.0 where 'eslint-typegen/core' subpath did not exist.
fix
Upgrade to v2.0.0+ or use import { pluginsToRulesDTS } from 'eslint-typegen' in older versions (check docs accordingly).
ESLint error: Failed to load config 'eslint-typegen' in plugin
Mistakenly trying to use eslint-typegen as an ESLint plugin instead of a config generator function.
fix
Use typegen as an exported function, not as a plugin. Remove from plugins array and wrap config: export default typegen([...]).
Upgrade
Version history
2.3.1latest on npm
Audit
Dependencies
eslintrequiredpeer dependency — required for rule schema introspection and flat config support
Agent activity
2 hits · last 30 days
node
2
Resources
eslint-typegen — npm install eslint-typegen · libregistry