GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — fix(`ts-method-signature-style`): do not turn optional or readonly fu… · gajus/eslint-plugin-jsdoc@94952b2

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • docs/rules
    • ts-method-signature-style.md
  • src/rules
    • tsMethodSignatureStyle.js
  • test/rules/assertions
    • tsMethodSignatureStyle.js
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎docs/rules/ts-method-signature-style.md‎

Copy file name to clipboardExpand all lines: docs/rules/ts-method-signature-style.md
+9Lines changed: 9 additions & 0 deletions
  • Display the source diff
  • Display the rich diff
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,15 @@ The following patterns are not considered problems:
141141
*/
142142
// "jsdoc/ts-method-signature-style": ["error"|"warn", "property"]
143143

144+
/**
145+
* @param {{
146+
* optionalFunc?: (arg: string) => number,
147+
* readonly readonlyFunc: (arg: string) => number,
148+
* optionalOverloads?: ((arg: string) => number) & ((arg: number) => string)
149+
* }} someName
150+
*/
151+
// "jsdoc/ts-method-signature-style": ["error"|"warn", "method"]
152+
144153
/**
145154
* @param {{
146155
* func: ((arg: number) => void) &
Collapse file

‎src/rules/tsMethodSignatureStyle.js‎

Copy file name to clipboardExpand all lines: src/rules/tsMethodSignatureStyle.js
+9-2Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,11 @@ export default iterateJsdoc(({
5151
break;
5252
}
5353

54+
// Optional and readonly function properties have no method
55+
// signature equivalent that keeps their meaning here
5456
if (parentNode?.type === 'JsdocTypeObjectField' &&
55-
typeof parentNode.key === 'string'
57+
typeof parentNode.key === 'string' &&
58+
!parentNode.optional && !parentNode.readonly
5659
) {
5760
utils.reportJSDoc(
5861
'Found function property; prefer method signature.',
@@ -100,7 +103,11 @@ export default iterateJsdoc(({
100103
// @ts-expect-error Our own added API
101104
parentNode.parentNode.parentNode.type === 'JsdocTypeObjectField' &&
102105
// @ts-expect-error Our own added API
103-
typeof parentNode.parentNode.parentNode.key === 'string'
106+
typeof parentNode.parentNode.parentNode.key === 'string' &&
107+
// @ts-expect-error Our own added API
108+
!parentNode.parentNode.parentNode.optional &&
109+
// @ts-expect-error Our own added API
110+
!parentNode.parentNode.parentNode.readonly
104111
) {
105112
// @ts-expect-error Our own added API
106113
const intersection = parentNode.parentNode;
Collapse file

‎test/rules/assertions/tsMethodSignatureStyle.js‎

Copy file name to clipboardExpand all lines: test/rules/assertions/tsMethodSignatureStyle.js
+14Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -273,6 +273,20 @@ export default {
273273
'property',
274274
],
275275
},
276+
{
277+
code: `
278+
/**
279+
* @param {{
280+
* optionalFunc?: (arg: string) => number,
281+
* readonly readonlyFunc: (arg: string) => number,
282+
* optionalOverloads?: ((arg: string) => number) & ((arg: number) => string)
283+
* }} someName
284+
*/
285+
`,
286+
options: [
287+
'method',
288+
],
289+
},
276290
{
277291
code: `
278292
/**

0 commit comments

Comments
0 (0)
You are visitor 01402605 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.