Skip to content

Commit 951d354

Browse files
committed
fix(check-param-names): only fire on TSPropertySignature if with TSFunctionNode; fixes #1663
1 parent b36a67a commit 951d354

File tree

3 files changed

+29
-1
lines changed

3 files changed

+29
-1
lines changed

docs/rules/check-param-names.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1180,5 +1180,13 @@ const inner = (c: number, d: string): void => {
11801180
console.log(d);
11811181
};
11821182
// Settings: {"jsdoc":{"contexts":["VariableDeclaration"]}}
1183+
1184+
const emit = defineEmits<{
1185+
/**
1186+
* Fired when an editable field is submitted.
1187+
* @param index the index of the editable field
1188+
*/
1189+
submitField: [index: number];
1190+
}>();
11831191
````
11841192

src/rules/checkParamNames.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -386,12 +386,18 @@ export default iterateJsdoc(({
386386
useDefaultObjectProperties = false,
387387
} = context.options[0] || {};
388388

389+
const nde = /** @type {import('@typescript-eslint/types').TSESTree.Node} */ (node);
390+
389391
// Although we might just remove global settings contexts from applying to
390392
// this rule (as they can cause problems with `getFunctionParameterNames`
391393
// checks if they are not functions but say variables), the user may
392394
// instead wish to narrow contexts in those settings, so this check
393395
// is still useful
394-
if (!allowedNodes.includes(/** @type {import('estree').Node} */ (node).type)) {
396+
if (!allowedNodes.includes(nde.type) ||
397+
nde.type === 'TSPropertySignature' &&
398+
(/** @type {import('@typescript-eslint/types').TSESTree.TSPropertySignature} */ (
399+
nde
400+
)?.typeAnnotation?.typeAnnotation?.type !== 'TSFunctionType')) {
395401
return;
396402
}
397403

test/rules/assertions/checkParamNames.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2064,5 +2064,19 @@ export default /** @type {import('../index.js').TestCases} */ ({
20642064
},
20652065
},
20662066
},
2067+
{
2068+
code: `
2069+
const emit = defineEmits<{
2070+
/**
2071+
* Fired when an editable field is submitted.
2072+
* @param index the index of the editable field
2073+
*/
2074+
submitField: [index: number];
2075+
}>();
2076+
`,
2077+
languageOptions: {
2078+
parser: typescriptEslintParser,
2079+
},
2080+
},
20672081
],
20682082
});

0 commit comments

Comments
 (0)