Closed
Description
Notes
- I tried to find similar issues, but failed
- It works both when I run eslint from IDE and from CLI.
- Unrelated
Expected behavior
When using the require-param
rule with the contexts
option set to ['TSFunctionType']
, I expect it to report an error when a TypeScript function type lacks @param
tags for its parameters.
For example, in the following code, I expect an error because the parameter foo
is undocumented:
/**
* Some test function type.
*/
export type Test = (foo: number) => string;
Actual behavior
No error is reported, even though the function parameter foo
is undocumented.
ESLint Config
import { defineConfig } from "eslint/config";
import jsdoc from 'eslint-plugin-jsdoc';
import * as eslintTs from 'typescript-eslint';
export default defineConfig(
[
{
files: ['src/**.ts'],
languageOptions: {
parser: eslintTs.parser,
parserOptions: {
projectService: true,
},
},
plugins: {
'@typescript-eslint': eslintTs.plugin,
jsdoc,
},
rules: {
'jsdoc/require-param': [
'error',
{
checkDestructured: false,
unnamedRootBase: [ 'param' ],
contexts: ['TSFunctionType', 'FunctionDeclaration', 'TSDeclareFunction']
}
],
},
},
]
);
ESLint sample
/**
* No error, though it should be.
*/
export type Test = (foo: number) => string;
/**
* Error: 'Missing JSDoc @param "foo" declaration', so we can say the rule works
*/
export function test(foo: string): void {
console.log(foo);
}
REPRO
Environment
- Node version: v22.15.0
- ESLint version: 9.26.0
eslint-plugin-jsdoc
version: 50.6.14typescript-eslint
version: 8.32.1
I’ve tried various permutations of the contexts
value but haven’t been able to get the rule to apply to TS function types. It’s possible I’m misunderstanding the intended usage of contexts, or missing a necessary option elsewhere—please let me know if that’s the case.
Thanks in advance!