Description
I'd like to see rules with contexts
be allowed to specify a special type of context which allows checking particular contexts, including the global context (i.e., a jsdoc block not associated with code) while insisting that a particular tag be present, e.g., @external
, @module
, @typedef
, @function
(including as a virtual function with @interface
) and @callback
.
The specific use case of global contexts wouldn't be useful for some rules with contexts
options, e.g., require-jsdoc
or probably require-example
(which assume a code context), but it would be helpful for some rules like require-description
and match-description
which allow contexts
, but do not allow checking that descriptions accompany those global tags specifically (see #407 for one such case).
If we allow generic contexts like "function" (as I think we should) as in #384, we could also consider including these tag-associated contexts (e.g., a "function" could include interface based ones).
And this could be useful for non-global contexts, e.g., ensuring an @author
is present on classes, or whatever conditions a project might want. Note: I've filed eslint/eslint#12975 which would enhance the usability of this proposed rule (i.e., to allow selective enabling/disabling within a file so it might only be required for a particular object or block).
(This issue to whitelist rules from certain contexts only when specific tags are present is a converse of #466 which seeks to blacklist rules from certain contexts only when certain tags are present.)
Particularly this case of checking for tags, but even for rules just using regular contexts
, it would also be helpful to allow defining a custom message, e.g., "Please add a @cli-arg
tag here so we know which arguments are passed into this file" (e.g., when overrides
is targeting all files within /bin
).
Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.