Skip to content

Commit

Permalink
feat: update jsdoccomment; fixes #831
Browse files Browse the repository at this point in the history
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`
  • Loading branch information
brettz9 committed Jan 26, 2022
1 parent e71de13 commit 5530e07
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 1 deletion.
7 changes: 7 additions & 0 deletions README.md
Expand Up @@ -9126,6 +9126,13 @@ const MY_ENUM = Object.freeze({
} as const);
// "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"}]}]
// Message: @enum not allowed on declarations
/** @type {React.FunctionComponent<{ children: React.ReactNode }>}*/
const MyComponent = ({ children }) => {
return children;
}
// "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."}]}]
// Message: The `FunctionComponent` type is not allowed. Please use `FC` instead.
````
The following patterns are not considered problems:
Expand Down
2 changes: 1 addition & 1 deletion package.json
Expand Up @@ -5,7 +5,7 @@
"url": "http://gajus.com"
},
"dependencies": {
"@es-joy/jsdoccomment": "~0.17.0",
"@es-joy/jsdoccomment": "~0.18.0",
"comment-parser": "1.3.0",
"debug": "^4.3.3",
"escape-string-regexp": "^4.0.0",
Expand Down
25 changes: 25 additions & 0 deletions test/rules/assertions/noRestrictedSyntax.js
Expand Up @@ -322,6 +322,31 @@ export default {
],
parser: require.resolve('@typescript-eslint/parser'),
},
{
code: `
/** @type {React.FunctionComponent<{ children: React.ReactNode }>}*/
const MyComponent = ({ children }) => {
return children;
}
`,
errors: [
{
line: 2,
message: 'The `FunctionComponent` type is not allowed. Please use `FC` instead.',
},
],
options: [
{
contexts: [
{
comment: 'JsdocBlock:has(JsdocTag[tag="type"]:has([value=/FunctionComponent/]))',
context: 'any',
message: 'The `FunctionComponent` type is not allowed. Please use `FC` instead.',
},
],
},
],
},
],
valid: [
{
Expand Down

0 comments on commit 5530e07

Please sign in to comment.