{"id":14749744,"url":"https://github.com/antfu/eslint-typegen","last_synced_at":"2025-05-15T06:02:42.972Z","repository":{"id":229926676,"uuid":"778046128","full_name":"antfu/eslint-typegen","owner":"antfu","description":"Generate types from ESLint rule schemas, with auto-completion and type-checking for rule options.","archived":false,"fork":false,"pushed_at":"2025-05-13T00:14:29.000Z","size":797,"stargazers_count":224,"open_issues_count":2,"forks_count":4,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-05-15T06:02:16.087Z","etag":null,"topics":["eslint","eslint-flat-config"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/antfu.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null},"funding":{"github":["antfu"],"open_collective":"antfu"}},"created_at":"2024-03-27T01:12:22.000Z","updated_at":"2025-05-13T02:30:51.000Z","dependencies_parsed_at":"2024-03-27T01:31:57.517Z","dependency_job_id":"e7287a0e-8319-4071-9947-db66c3f13539","html_url":"https://github.com/antfu/eslint-typegen","commit_stats":{"total_commits":54,"total_committers":6,"mean_commits":9.0,"dds":0.2407407407407407,"last_synced_commit":"f09c31a222d0141c07f1448da48821b5f0d44a7b"},"previous_names":["antfu/eslint-typegen"],"tags_count":21,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/antfu%2Feslint-typegen","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/antfu%2Feslint-typegen/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/antfu%2Feslint-typegen/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/antfu%2Feslint-typegen/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/antfu","download_url":"https://codeload.github.com/antfu/eslint-typegen/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254283336,"owners_count":22045140,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["eslint","eslint-flat-config"],"created_at":"2024-09-14T23:01:42.491Z","updated_at":"2025-05-15T06:02:42.920Z","avatar_url":"https://github.com/antfu.png","language":"TypeScript","funding_links":["https://github.com/sponsors/antfu","https://opencollective.com/antfu"],"categories":["TypeScript"],"sub_categories":[],"readme":"# eslint-typegen\n\n[![npm version][npm-version-src]][npm-version-href]\n[![npm downloads][npm-downloads-src]][npm-downloads-href]\n[![bundle][bundle-src]][bundle-href]\n[![JSDocs][jsdocs-src]][jsdocs-href]\n[![License][license-src]][license-href]\n\nGenerate types from ESLint rule schemas automatically, with auto-completion and type-checking for rule options.\n\n![](https://github.com/antfu/eslint-typegen/assets/11247099/642ffdc0-c662-4f3b-9237-16d776be1c3e)\n\n\u003e Btw, if you are using [`@antfu/eslint-config`](https://github.com/antfu/eslint-config), you may NOT need to setup this, as the types for rules [are already shipped with the package](https://github.com/antfu/eslint-config/blob/95963ac345d27cd06a4eeb5ebc16e1848cb2fd81/scripts/typegen.ts#L29-L33).\n\n## Usage\n\n```bash\nnpm i eslint-typegen\n```\n\nIn your `eslint.config.mjs`, wrap the export with `typegen` function:\n\n```ts\n// @ts-check\n/// \u003creference path=\"./eslint-typegen.d.ts\" /\u003e\nimport typegen from 'eslint-typegen'\n\nexport default typegen(\n  [\n    // ...your normal eslint flat config\n  ]\n)\n```\n\nRun ESLint once, an `eslint-typegen.d.ts` file will be generated to augment ESLint's `Linter.RulesRecord` types, to provide you with auto-completion and type-checking for your ESLint rules configuration based on the ESLint plugins you are using.\n\n\u003e It will caluclate the hash of the plugins meta from your flat config, and only regenerate the types when they changes. If you want to force regenerate the types, you can delete the `eslint-typegen.d.ts` file and run ESLint again.\n\n## Low-level API\n\nYou can find low-level APIs in the `eslint-typegen/core` modules.\n\n```ts\nimport fs from 'node:fs/promises'\nimport pluginTs from '@typescript-eslint/eslint-plugin'\nimport pluginN from 'eslint-plugin-n'\nimport { pluginsToRulesDTS } from 'eslint-typegen/core'\n\nconst dts = await pluginsToRulesDTS({\n  '@typescript-eslint': pluginTs,\n  'n': pluginN,\n})\n\nawait fs.writeFile('eslint-typegen.d.ts', dts)\n```\n\nThis can be useful if you want to have more control over the generation process, or even bundle the types with your config package. For example, [here](https://github.com/antfu/eslint-config/blob/95963ac345d27cd06a4eeb5ebc16e1848cb2fd81/scripts/typegen.ts#L29-L33) is how [`@antfu/eslint-config`](https://github.com/antfu/eslint-config) does.\n\n## How it works\n\nThanks to that [ESLint requires rules to provide the JSONSchema for options](https://eslint.org/docs/latest/extend/custom-rules#options-schemas), we could leverage that to generate types with [`json-schema-to-typescript`](https://github.com/bcherny/json-schema-to-typescript). With the new flat config allowing you to execute the code with fully resolved configs, we managed to sneak in the type generation process on the fly.\n\n## Credits\n\nThe initial idea comes from [@Shinigami92](https://github.com/Shinigami92) via his work on [`eslint-define-config`](https://github.com/eslint-types/eslint-define-config), thanks to him!\n\n## Sponsors\n\n\u003cp align=\"center\"\u003e\n  \u003ca href=\"https://cdn.jsdelivr.net/gh/antfu/static/sponsors.svg\"\u003e\n    \u003cimg src='https://cdn.jsdelivr.net/gh/antfu/static/sponsors.svg'/\u003e\n  \u003c/a\u003e\n\u003c/p\u003e\n\n## License\n\n[MIT](./LICENSE) License © 2023-PRESENT [Anthony Fu](https://github.com/antfu)\n\n\u003c!-- Badges --\u003e\n\n[npm-version-src]: https://img.shields.io/npm/v/eslint-typegen?style=flat\u0026colorA=080f12\u0026colorB=1fa669\n[npm-version-href]: https://npmjs.com/package/eslint-typegen\n[npm-downloads-src]: https://img.shields.io/npm/dm/eslint-typegen?style=flat\u0026colorA=080f12\u0026colorB=1fa669\n[npm-downloads-href]: https://npmjs.com/package/eslint-typegen\n[bundle-src]: https://img.shields.io/bundlephobia/minzip/eslint-typegen?style=flat\u0026colorA=080f12\u0026colorB=1fa669\u0026label=minzip\n[bundle-href]: https://bundlephobia.com/result?p=eslint-typegen\n[license-src]: https://img.shields.io/github/license/antfu/eslint-typegen.svg?style=flat\u0026colorA=080f12\u0026colorB=1fa669\n[license-href]: https://github.com/antfu/eslint-typegen/blob/main/LICENSE\n[jsdocs-src]: https://img.shields.io/badge/jsdocs-reference-080f12?style=flat\u0026colorA=080f12\u0026colorB=1fa669\n[jsdocs-href]: https://www.jsdocs.io/package/eslint-typegen\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fantfu%2Feslint-typegen","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fantfu%2Feslint-typegen","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fantfu%2Feslint-typegen/lists"}