Skip to content

Commit 5530e07

Browse files
committed
feat: update jsdoccomment; fixes #831
Includes: - feat: add non-visitable `endLine` property (so can detect line number when no description present) - fix: ensure `postName` gets a space for `@template` with a description - fix: converting JSDoc comment with tag on same line as end (e.g., single line) to AST - chore: update `jsdoc-type-pratt-parser`
1 parent e71de13 commit 5530e07

File tree

3 files changed

+33
-1
lines changed

3 files changed

+33
-1
lines changed

README.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9126,6 +9126,13 @@ const MY_ENUM = Object.freeze({
91269126
} as const);
91279127
// "jsdoc/no-restricted-syntax": ["error"|"warn", {"contexts":[{"comment":"JsdocBlock[postDelimiter=\"\"]:has(JsdocTag ~ JsdocTag[tag=/private|protected/])","context":"any","message":"Access modifier tags must come first"},{"comment":"JsdocBlock[postDelimiter=\"\"]:has(JsdocTag[tag=\"enum\"])","context":":declaration","message":"@enum not allowed on declarations"}]}]
91289128
// Message: @enum not allowed on declarations
9129+
9130+
/** @type {React.FunctionComponent<{ children: React.ReactNode }>}*/
9131+
const MyComponent = ({ children }) => {
9132+
return children;
9133+
}
9134+
// "jsdoc/no-restricted-syntax": ["error"|"warn", {"contexts":[{"comment":"JsdocBlock:has(JsdocTag[tag=\"type\"]:has([value=/FunctionComponent/]))","context":"any","message":"The `FunctionComponent` type is not allowed. Please use `FC` instead."}]}]
9135+
// Message: The `FunctionComponent` type is not allowed. Please use `FC` instead.
91299136
````
91309137
91319138
The following patterns are not considered problems:

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"url": "http://gajus.com"
66
},
77
"dependencies": {
8-
"@es-joy/jsdoccomment": "~0.17.0",
8+
"@es-joy/jsdoccomment": "~0.18.0",
99
"comment-parser": "1.3.0",
1010
"debug": "^4.3.3",
1111
"escape-string-regexp": "^4.0.0",

test/rules/assertions/noRestrictedSyntax.js

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -322,6 +322,31 @@ export default {
322322
],
323323
parser: require.resolve('@typescript-eslint/parser'),
324324
},
325+
{
326+
code: `
327+
/** @type {React.FunctionComponent<{ children: React.ReactNode }>}*/
328+
const MyComponent = ({ children }) => {
329+
return children;
330+
}
331+
`,
332+
errors: [
333+
{
334+
line: 2,
335+
message: 'The `FunctionComponent` type is not allowed. Please use `FC` instead.',
336+
},
337+
],
338+
options: [
339+
{
340+
contexts: [
341+
{
342+
comment: 'JsdocBlock:has(JsdocTag[tag="type"]:has([value=/FunctionComponent/]))',
343+
context: 'any',
344+
message: 'The `FunctionComponent` type is not allowed. Please use `FC` instead.',
345+
},
346+
],
347+
},
348+
],
349+
},
325350
],
326351
valid: [
327352
{

0 commit comments

Comments
 (0)