Description
Describe the bug
summary
when we generate eslint-plugin-jsx-a11y
rules with using pluginsToRulesDTS
, the type of these rules cannot resolve.
details
As an example of jsx-a11y/accessible-emoji
,
in eslint-typegen.d.ts
generated by reproduction, the output is as follows:
RuleOptions
/**
* Enforce emojis are wrapped in `<span>` and provide screenreader access.
* @see https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/tree/HEAD/docs/rules/accessible-emoji.md
* @deprecated
*/
'jsx-a11y/accessible-emoji'?: Linter.RuleEntry<JsxA11yAccessibleEmoji>
Type Declarations:
// ----- jsx-a11y/accessible-emoji -----
type _JsxA11YAccessibleEmoji_JsxA11YAccessibleEmoji = []|[{
[k: string]: unknown | undefined
}]
In RuleOptions, it's output as JsxA11yAccessibleEmoji
, but in Declarations it is output as _JsxA11yAccessibleEmoji_JsxA11yAccessibleEmoji
and the type. The type is not correctly linked.
Debugging tips
I’ve found out the code to see where the problem was and found that the issue was around compile from JSON schema.
Lines 214 to 223 in 55af100
In the eslint-plugin-jsx-a11y
case, schema.$id
and name
do not match, so _${name}_${resolved}
is resolved.
In jsx-a11y/accessible-emoji
case, these values are the following values:
name
:'JsxA11yAccessibleEmoji'
schema.$id
:'JsxA11YAccessibleEmoji'
Why it's normalized though, I have debugged deeply, and that’s normalized at toSafeString
in json-schema-to-typescript-lite
.
I hope my debugging info will help you debug. :)
Reproduction
https://github.com/kazupon/eslint-typegen-repro1
System Info
System:
OS: macOS 13.6.7
CPU: (10) arm64 Apple M1 Max
Memory: 251.56 MB / 64.00 GB
Shell: 5.9 - /bin/zsh
Binaries:
Node: 18.19.1 - ~/.nvm/versions/node/v18.19.1/bin/node
Browsers:
Chrome: 127.0.6533.119
Edge: 127.0.2651.98
Firefox: 118.0.1
Safari: 16.6
Used Package Manager
pnpm
Validations
- Follow our Code of Conduct
- Read the Contributing Guide.
- Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.
- Check that this is a concrete bug. For Q&A, please open a GitHub Discussion instead.
- 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!)