Conversation
Currently, all arrow functions and function expressions are required to
be documented with JSDoc, and object types in return types are required
to documented as well.
This means:
``` typescript
// The arrow function here is now required to be documented
foo(() => {
// ...
})
foo({
// The arrow function here is now required to be documented
bar: () => {
// ...
}
})
function foo(): {
// This is now required to be documented
bar: string;
} {
// ...
}
```
This commit loosens the rules so that:
- Instead of restricting all arrow functions and function expressions,
restrict only those that are not contained within plain objects or are
not arguments to functions or methods
- Instead of restricting all interfaces or type aliases, restrict only
those that do not appear in `declare` blocks (ambient declarations)
- Instead of restricting object types in return types, restrict object
types in "root" types
|
This PR was derived directly from MetaMask/create-release-branch#168. The last changes I made to this PR tweaked the rules further. I was hoping to get another review on those changes, but assuming they are good, I planned on integrating them back into this PR. I don't have time to do this right now, but I talked with Mark and he said that he might have time. @Gudahtt If you do have time, feel free to take over this PR and get it merged. |
| - New things that now require documentation are: | ||
| - Arrow functions | ||
| - Class declarations | ||
| - TypeScript enum declarations |
There was a problem hiding this comment.
While it's true that the base config did apparently require JSDoc for TypeScript symbols, that wasn't true in practice because the JSDoc plugin within the base config doesn't know about TypeScript.
| - **BREAKING:** Update type import specifier rules ([#381](https://github.com/MetaMask/eslint-config/pull/381)) | ||
| - `@typescript-eslint/consistent-type-imports` has been replaced with `import-x/consistent-type-specifier-style` | ||
| - The rule now prefers "top-level" type imports over inline. e.g. `import type { a } from 'x'` over `import { type a } from 'x'` | ||
| - **BREAKING:** Update `jsdoc/require-jsdoc` to require documentation for more things ([#394](https://github.com/MetaMask/eslint-config/pull/394)) |
There was a problem hiding this comment.
This changelog entry was missing when 15.0.0 was released. This should list TypeScript symbols for which documentation is required (not the changelog for the base config).
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.

Currently, all arrow functions and function expressions are required to be documented with JSDoc, and object types in return types are required to documented as well.
This means:
This commit loosens the rules so that:
declareblocks (ambient declarations)Note
Medium Risk
Changes lint enforcement for
jsdoc/require-jsdoc, which can significantly alter consumer CI outcomes (fewer required docblocks) and relies on AST selectorcontextsbehaving as intended across JS/TS code.Overview
Loosens
jsdoc/require-jsdocin the base config by replacing the blanket requirement for all arrow functions and function expressions with AST-selectorcontextsthat only require JSDoc when those functions are not object properties and are not passed as call/new arguments.In the TypeScript config, replaces the previous simple
jsdoc/require-jsdoc: 'error'with an explicit rule config that extends the base rule options (via a new helper to collect upstream array-valued rule options) and adds TS-specific contexts to require docs for non-ambient (declare-block excluded) interfaces/type aliases plus enums. Changelogs and rule snapshots are updated to match.Written by Cursor Bugbot for commit 140fdf5. This will update automatically on new commits. Configure here.