Reputation: 7608
I'm trying to set preferredTypes
to prevent *
or any
as param/property types. I don't want to use most of the recommended rules as it flags up too many issues. I'm trying to ease my team onto using this lint rule set, and gradually fix issues and switch rules on later.
I thought preventing @param {*}
would be easily done as per the docs:
settings.jsdoc.preferredTypes
An option map to indicate preferred or forbidden types (if default types are indicated here, these will have precedence over the default recommendations for check-types).
So my .eslintrc.js
settings object looks like:
...
settings: {
...
jsdoc: { preferredTypes: { '*': false } }
}
And I have the rules 'jsdoc/valid-types', 'jsdoc/no-undefined-types', and 'jsdoc/check-tag-names' (picked as a balance of flagging bigger errors but not too many right now).
But I'm not seeing any reporting of errors on @param {*}
.
Can this be done without adding extra jsdoc lint rules, or if it does need them can I customise it to it only hits {*}
or {any}
?
Upvotes: 1
Views: 2164
Reputation: 7608
jsdoc/check-types
This rule is referenced in the documentation for check-types
and this rule is required, even though it's not explicit under the documentation for preferredTypes
.
Here is the excerpt burried part way down the check-types
examples:
/**
* @param {*} baz
*/
function qux(baz) {
}
// Settings: {"jsdoc":{"preferredTypes":{"*":false,"abc":"Abc","string":"Str"}}}
// Message: Invalid JSDoc @param "baz" type "*".
Without check-types
the preferred types setting does nothing, which, if you think about it makes sense.
Upvotes: 2