Skip to content

v1.17.6 - Fix @invar/require-jsdoc-example rule

Choose a tag to compare

@Tefx Tefx released this 06 Jan 03:23
· 1389 commits to Main since this release

Fix

  • @invar/require-jsdoc-example: Now correctly detects JSDoc `@example` for exported async functions
    • Add new selector: `ExportNamedDeclaration > FunctionDeclaration`
    • JSDoc comments attach to `ExportNamedDeclaration` parent node, not `FunctionDeclaration` child
    • Add test coverage for async functions (3 new test cases)
    • All 88 tests passing

Technical Details

The issue was that for `export async function foo()`, the AST structure is:

```
ExportNamedDeclaration ← JSDoc attaches here
└── FunctionDeclaration ← Rule was checking here (wrong!)
```

The rule's `FunctionDeclaration` selector was querying comments from the child node instead of the parent `ExportNamedDeclaration`, resulting in false positives.

Related

  • TypeScript eslint-plugin version: 0.1.1 (bumped)