Generate types from ESLint rule schemas, with auto-completion and type-checking for rule options.
by antfuTypeScript
Last 12 weeks · 0 commits
5 of 6 standards met
Describe the bug When generating types for the rule, emits the same interface twice: TypeScript merges interfaces with the same name, but duplicate index signatures collide: The rule's JSON schema references a shape from two distinct subschemas ( and the inner replacements map). The emitter derives the same generated name () for both and writes a full declaration per occurrence instead of deduping by name. Interfaces with only non-index members would merge cleanly, but identical index signatures cannot. Reproduction System Info 2.3.1 64.0.0 TypeScript with Used Package Manager pnpm
Describe the bug When the option is set the generated code contains the following declaration: In ESLint 9.38.0 is now a type in place of an interface and thus can no longer be extended: https://github.com/eslint/eslint/blob/8fe511b4c0fb74df3290271b29c672c3fbf3be1f/lib/types/index.d.ts#L1328 If I'm getting it correctly the new proposed way to extend config type going forward is: As a side note has been changed too in ESLint 9.39.0. Although it still work as the type is essentially the same, it may be worth importing directly from the @eslint/core module. Reproduction Generate any .d.ts file with set System Info Used Package Manager pnpm Validations [x] Follow our Code of Conduct [x] Read the Contributing Guide. [x] Check that there isn't already an issue that reports the same bug to avoid creating a duplicate. [x] Check that this is a concrete bug. For Q&A, please open a GitHub Discussion instead. [x] The provided reproduction is a minimal reproducible of the bug. Contributions [x] I am willing to submit a PR to fix this issue [ ] I am willing to submit a PR with failing tests (actually just go ahead and do it, thanks!)
Describe the bug are currently generated as typed keys, and this can cause conflicts with other properties if they have different value types. For example, Vitest's has the following type generated for it's options: This type is problematic, and gives the following errors in Typescript: This is similar to the issue faced in json-schema-to-typescript#671. This can be seen by running the typegen on 's rules. The invalid type is also present in the distributed version of @antfu/eslint-config, in lines 15419-15426 of Reproduction https://www.npmjs.com/package/@antfu/eslint-config?activeTab=code System Info Used Package Manager n/a Validations [x] Follow our Code of Conduct [x] Read the Contributing Guide. [x] Check that there isn't already an issue that reports the same bug to avoid creating a duplicate. [x] Check that this is a concrete bug. For Q&A, please open a GitHub Discussion instead. [x] The provided reproduction is a minimal reproducible of the bug. Contributions [ ] I am willing to submit a PR to fix this issue [ ] I am willing to submit a PR with failing tests (actually just go ahead and do it, thanks!)
Clear and concise description of the problem After dependency installation, I get this peer dependency mismatch warning: WARN Issues with peer dependencies found However, the types are correctly generated. Suggested solution _package.json_ I'm not sure if this is all that should be changed. (ESLint v10 migration) Alternative _No response_ Additional context _No response_ Validations [x] Follow our Code of Conduct [x] Read the Contributing Guide. [x] Check that there isn't already an issue that request the same feature to avoid creating a duplicate.
I created this issue to let you know that prior to 14.0.0, the package is vulnerable to Server-Side Request Forgery (SSRF) due to the default schema resolver which can potentially fetch requests from tainted urls without further validation. An attacker could exploit this by submitting a malicious schema with $ref pointing to localhost, internal APIs, or cloud metadata services, potentially bypassing network controls and accessing sensitive data. I added this issue here because this package is a fork so i don't know if there is something you can do about it.
Repository: antfu/eslint-typegen. Description: Generate types from ESLint rule schemas, with auto-completion and type-checking for rule options. Stars: 277, Forks: 10. Primary language: TypeScript. Languages: TypeScript (98%), JavaScript (2%). License: MIT. Topics: eslint, eslint-flat-config. Latest release: v2.3.1 (4mo ago). Open PRs: 1, open issues: 4. Last activity: 4mo ago. Community health: 85%. Top contributors: antfu, hugop95, andreww2012, Copilot, LIUeng, Lpmvb, luxass, hyoban.