Skip to content

Commit

Permalink
fix: ensure TSDeclareFunction is checked by default where function …
Browse files Browse the repository at this point in the history
…contexts are expected; closes #897
  • Loading branch information
brettz9 committed Aug 8, 2022
1 parent 4f8d242 commit 25d2a7f
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 0 deletions.
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3280,6 +3280,12 @@ function quux (foo) {
}
// "jsdoc/check-param-names": ["error"|"warn", {"enableFixer":true}]
// Message: Duplicate @param "foo"

/**
* @param barr This is the description of bar. Oops, we misspelled "bar" as "barr".
*/
declare function foo(bar: number) {}
// Message: Expected @param names to be "bar". Got "barr".
````

The following patterns are not considered problems:
Expand Down
1 change: 1 addition & 0 deletions src/iterateJsdoc.js
Original file line number Diff line number Diff line change
Expand Up @@ -1353,6 +1353,7 @@ export default function iterateJsdoc (iterator, ruleConfig) {
'ArrowFunctionExpression',
'FunctionDeclaration',
'FunctionExpression',
'TSDeclareFunction',
]) {
contextObject[prop] = checkJsdoc.bind(null, {
selector: prop,
Expand Down
1 change: 1 addition & 0 deletions src/jsdocUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -973,6 +973,7 @@ const enforcedContexts = (context, defaultContexts) => {
'ArrowFunctionExpression',
'FunctionDeclaration',
'FunctionExpression',
'TSDeclareFunction',
] : defaultContexts,
} = context.options[0] || {};

Expand Down
15 changes: 15 additions & 0 deletions test/rules/assertions/checkParamNames.js
Original file line number Diff line number Diff line change
Expand Up @@ -1162,6 +1162,21 @@ export default {
}
`,
},
{
code: `
/**
* @param barr This is the description of bar. Oops, we misspelled "bar" as "barr".
*/
declare function foo(bar: number) {}
`,
errors: [
{
line: 3,
message: 'Expected @param names to be "bar". Got "barr".',
},
],
parser: require.resolve('@typescript-eslint/parser'),
},
],
valid: [
{
Expand Down

0 comments on commit 25d2a7f

Please sign in to comment.