At minimum you need 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.
» npm install eslint-plugin-jsdoc
Setting up eslint-plugin-jsdoc
How do I configure eslint-plugin-jsdoc to disallow '*' and 'any' while using minimal set of rules?
Newest 'eslint-plugin-jsdoc' Questions - Stack Overflow
typescript - ESLint error: Failed to load 'eslint-plugin-jsdoc' in IntelliJ on Ubuntu - troubleshooting tips? - Stack Overflow
I'm trying to set up eslint-plugin-jsdoc to enforce JSDoc in my TS project, but for some reason the linter is not complaining at all when I don't add JSDoc above a function. My config file is as follows:
{
"extends": ["eslint:recommended", "plugin:jsdoc/recommended"],
"env": {
"node": true,
"es6": true
},
"parserOptions": {
"ecmaVersion": 2021
},
"plugins": ["jsdoc"],
"rules": {
...
}
}To my (limited) knowledge, as long as I have the recommended rules, the linter should enforce JSDocs for every function. Could someone please help me understand why this isn't working? I do have both ESLint and eslint-plugin-jsdoc installed:
"devDependencies": {
"@eslint/js": "^9.12.0",
"@types/eslint__js": "^8.42.3",
"@types/node": "^22.7.4",
"eslint": "^9.12.0",
"eslint-plugin-jsdoc": "^50.3.2",
"globals": "^15.11.0",
"tsx": "^4.19.1",
"typescript": "^5.6.3",
"typescript-eslint": "^8.8.1"
}I created an ESLint plugin that enforces the use of `@throws` (or `@exception`) in JSDoc comments for functions that throw, or that call other functions documented to throw.
The idea is to bring some of the clarity of Java-style checked exceptions to JavaScript, making exception flow more explicit and less error-prone.
Features:
Flags undocumented `@throw` statements
Flags implicit propagation of exceptions
Adds `@throws` tags automatically with fixer support
Fully type-aware using `@typescript-eslint`
Supports Promise rejections too