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
exemptDestructuredRootsFromChecks
setting for param type and description checks to be dropped (e.g., React props)
#752
Comments
Hi, I agree with that enhancement need. Could these kind of comments be valid without the root parameter being inserted during linting:
Should the following options not do that?
|
@ccambournac : Yes, your options will work. Another workaround which will work even with /**
* A module
*
* @param {{reader: Reader}} obj
* @return {JSX.Element}
* @constructor
*/ And if that is still too much extra text for you, you could use a reusable typedef: /**
* @typedef {object} ReaderObj
* @property reader
*/
/**
* A module
*
* @param {ReaderObj} obj
* @return {JSX.Element}
* @constructor
*/ But as far as the OP, having |
Hi @brettz9 and thanks for the reply. I indeed posted a bit too quick (playing around with this new-to-me eslint plugin) and, as you point out, there are other rules involved. Like However, does my point not still hold? I mean if I want that destructuring of input parameters be considered as a list of parameters, not taking into account the root object, which is quite a common functional pattern, should not the
Maybe a Or am I missing something? Maybe related to standard JSDoc preventing the plugin from doing that. Anyway, thank you for the workaround suggestions. I would however like to stick as much as possible to an existing codebase when adding theses rules for my coworkers. |
ESLint options are not shared between rules. We would have to change
That being said, I can see a use case for allowing and even requiring the root and yet disabling the need for a type or description. Perhaps this could be resolved by a separate global setting available to rules such as I think this makes more sense than specifically React-aware code. But it does come at the cost of adding complexity to the other rules which would now need to determine whether a param had destructured children or not. But probably worth it. We could create a reusable utility for this purpose. Note, however, that this is not on my priority list, though PRs would be welcome.
Nothing preventing our rules from doing such detection except for the concern of balancing complexity. Standard JSDoc doesn't really insist that params have a type or description or arguably even a name: https://jsdoc.app/tags-param.html On the topic of standard JSDoc though, I'd be curious to know how well other tools that people are using work without destructuring roots, e.g., IDE tooltips or documentation building. |
@ccambournac : It should be helpful though if you could file a new issue for the other rules like |
Hi @brettz9 and thank you for your enlightening comments!
That makes sense :)
I agree. Maybe add the
I understand.
Which, to my opinion, favors a fine-grained configuration of related rules. As you requested, I added below how JSDoc can be automatically injected by typing Finally, I will file a new issue as you suggest. |
I'd prefer we use a new setting
Yup.
I see, thanks. That example is really more of a real bug, imo, as it doesn't follow jsdoc even basically as far as objects. Hopefully other IDEs follow this more faithfully.
Please link to it here once you have done so. |
While the idea for an |
exemptDestructuredRootsFromChecks
setting for param type and description checks to be dropped (e.g., React props)
One workaround is to use the For example, the following will avoid reporting (e.g., for {
contexts: [
{
comment: 'JsdocBlock:has(JsdocTag:not([name=props]))',
context: 'FunctionDeclaration',
},
],
}, |
…estructuredRootsFromChecks` setting; fixes gajus#752 Also: - feat(`require-param-type`): add `setDefaultDestructuredRootType` and `defaultDestructuredRootType` options - feat(`require-param-description`): add `setDefaultDestructuredRootDescription` and `defaultDestructuredRootDescription` options
I've submitted #929 which should address the remaining items that I feel should be supported (including the issue I originally asked be submitted as a separate issue). With the PR, one will be able to avoid (or auto-add) a type and description for such root objects (and |
…estructuredRootsFromChecks` setting; fixes #752 Also: - feat(`require-param-type`): add `setDefaultDestructuredRootType` and `defaultDestructuredRootType` options - feat(`require-param-description`): add `setDefaultDestructuredRootDescription` and `defaultDestructuredRootDescription` options
🎉 This issue has been resolved in version 39.4.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |
This PR contains the following updates: | Package | Type | Update | Change | |---|---|---|---| | [eslint-plugin-jsdoc](https://github.com/gajus/eslint-plugin-jsdoc) | devDependencies | minor | [`39.3.25` -> `39.4.0`](https://renovatebot.com/diffs/npm/eslint-plugin-jsdoc/39.3.25/39.4.0) | --- ### Release Notes <details> <summary>gajus/eslint-plugin-jsdoc</summary> ### [`v39.4.0`](https://github.com/gajus/eslint-plugin-jsdoc/releases/tag/v39.4.0) [Compare Source](gajus/eslint-plugin-jsdoc@v39.3.25...v39.4.0) ##### Features - **`require-param-type`, `require-param-description`:** add `exemptDestructuredRootsFromChecks` setting; fixes [#​752](gajus/eslint-plugin-jsdoc#752) ([da1c85f](gajus/eslint-plugin-jsdoc@da1c85f)) </details> --- ### Configuration 📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined). 🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied. ♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this PR and you won't be reminded about this update again. --- - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box --- This PR has been generated by [Renovate Bot](https://github.com/renovatebot/renovate). <!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNC45LjEiLCJ1cGRhdGVkSW5WZXIiOiIzNC45LjEifQ==--> Co-authored-by: cabr2-bot <cabr2.help@gmail.com> Reviewed-on: https://codeberg.org/Calciumdibromid/CaBr2/pulls/1617 Reviewed-by: Epsilon_02 <epsilon_02@noreply.codeberg.org> Co-authored-by: Calciumdibromid Bot <cabr2_bot@noreply.codeberg.org> Co-committed-by: Calciumdibromid Bot <cabr2_bot@noreply.codeberg.org>
Motivation
When using react, documenting props is tedious because of that we should put the
@param props
every time or else not document the props in the JsDoc. This is worse if we have the rule, because then we are forced to describe what theprops
parameter is each time, given that the description is obvious.When using react, we need an easy way to document component props. This is easy thanks to the destructuring property in require-param-names. The problem is that if the
require-param-description
rule is active, we should put a description for theprops
param, even if it is obvious.Current behavior
This code:
with these settings:
Gives this warning:
Desired behavior
Having the
@props
parameter description to be optional if it is a jsx component.Otherwise, having the
@props
param to not be required if it is a jsx component.Alternatives considered
None.
Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.
The text was updated successfully, but these errors were encountered: