-
Notifications
You must be signed in to change notification settings - Fork 9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Documentation not generated when package.json name prefix and Config name mismatch #610
Comments
Which documentation is missing? In eslint-plugin-vitest, I see that a generated rules list is present in the README, and the rule docs have generated headers. However, when I run eslint-doc-generator in that project, the output changes. Is that project missing an |
I would like to generate content like the following in the rule documentation:
This is because it generates a legacy config. As I will mention later, I plan to add a
Yes, it currently doesn't have one. I'm trying to fix that, but I'm encountering this issue in the process. In this branch, changing the name in package.json to "vitest/eslint-plugin" generates the expected documentation. However, since there are no plans to change the name, I am currently facing this issue. |
I did some investigation. eslint-plugin-vitest exports a {
"legacy-recommended": {
"plugins": [ "@vitest" ],
"rules": {
"@vitest/expect-expect": "error",
"@vitest/no-identical-title": "error",
"...": "..."
}
},
"legacy-all": {
"plugins": [ "@vitest" ],
"rules": {
"@vitest/prefer-lowercase-title": "warn",
"@vitest/max-nested-describe": "warn",
"...": "..."
}
},
"recommended": {
"plugins": { "vitest": [{ "...": "..." }] },
"rules": {
"vitest/expect-expect": "error",
"vitest/no-identical-title": "error",
"...": "..."
}
},
"all": {
"plugins": { "vitest": [{ "...": "..." }] },
"rules": {
"vitest/prefer-lowercase-title": "warn",
"vitest/max-nested-describe": "warn",
"...": "..."
}
}
} The plugin name used for the flat configs is different for the non-flat configs, and as such, the prefixes used for the rules in each config correspond to the plugin name in the config. eslint-doc-generator contains a false assumption that the plugin prefix from package.json ( Could you fix the config plugin name inconsistency in eslint-plugin-vitest like this?
This seems to help somewhat with the eslint-doc-generator problem since now the plugin name matches the plugin prefix However, there's a separate issue still which is that eslint-doc-generator thinks the actual rule names are all prefixed with the plugin prefix So to summarize, there's a number of issues with eslint-doc-generator erroneously assuming the plugin prefix from package.json is always the appropriate rule prefix. But eslint-plugin-vitest appears to be using |
Thank you for investigating and providing the background.😄 I understand the situation better now. |
We shouldn't need a new option to fix this bug in eslint-doc-generator. It should be possible to fix eslint-doc-generator so that it automatically works for any eslint plugin regardless of naming patterns. We'll have to determine the correct prefixes by reading from the right locations in the exported data from the eslint plugin, instead of simply using the prefix from the plugin's package.json everywhere. This may be somewhat tricky and require a lot of additional plumbing. |
I see, that makes perfect sense. |
In your plugin, shouldn't it always be: # Enforce having expectation in test body (vitest/expect-expect) I don't think the user can refer to the rule with |
I'm curious about what kind of rule documentation titles would be generated if
Does this refer to enabling the rule? import vitest from '@vitest/eslint-plugin';
// ex: eslint.config.js
export default [
...
{
plugins: {
['@vitest']: vitest,
},
rules: {
'@vitest/consistent-test-it': ['error', { fn: 'it' }],
},
}
] With this setup, I believe the rule can be enabled. |
Author of
I don't think |
Hello,
I noticed an issue where documentation fails to generate if the prefix derived from the name field in package.json does not match the name in the Config.
Example: eslint-plugin-vitest
package.json:
"name": "@vitest/eslint-plugin"
Config:
vitest/${ruleName}
Since there is a mismatch between
@vitest
andvitest
, the documentation for such as share configurations is not generated.(It has been confirmed that resolving the mismatch allows the documentation to be generated correctly.)
It would be great if documentation could still be generated in such cases.
Are there any solutions or plans to address this?
Thank you!
The text was updated successfully, but these errors were encountered: