Skip to content

Commit

Permalink
feat: update @es-joy/jsdoccomment
Browse files Browse the repository at this point in the history
Also:
- test: demo use of `inlineTags`
  • Loading branch information
brettz9 committed May 5, 2023
1 parent aeaae4f commit 40d5ee0
Show file tree
Hide file tree
Showing 5 changed files with 85 additions and 3 deletions.
18 changes: 18 additions & 0 deletions docs/rules/no-restricted-syntax.md
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,24 @@ class Test {
}
// "jsdoc/no-restricted-syntax": ["error"|"warn", {"contexts":[{"comment":"JsdocBlock:not(*:has(JsdocTag[tag=/returns/]))","context":"TSEmptyBodyFunctionExpression[returnType.typeAnnotation.type!=/TSVoidKeyword|TSUndefinedKeyword/]","message":"methods with non-void return types must have a @returns tag"}]}]
// Message: methods with non-void return types must have a @returns tag

/**
* This has an inline {@link http://example.com}
*/
function quux () {

}
// "jsdoc/no-restricted-syntax": ["error"|"warn", {"contexts":[{"comment":"JsdocBlock:has(JsdocInlineTag)","context":"FunctionDeclaration"}]}]
// Message: Syntax is restricted: FunctionDeclaration with JsdocBlock:has(JsdocInlineTag)

/**
* @see This has an inline {@link http://example.com}
*/
function quux () {

}
// "jsdoc/no-restricted-syntax": ["error"|"warn", {"contexts":[{"comment":"JsdocBlock:has(JsdocTag:has(JsdocInlineTag[format=\"plain\"]))","context":"FunctionDeclaration"}]}]
// Message: Syntax is restricted: FunctionDeclaration with JsdocBlock:has(JsdocTag:has(JsdocInlineTag[format="plain"]))
````


Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"url": "http://gajus.com"
},
"dependencies": {
"@es-joy/jsdoccomment": "~0.37.1",
"@es-joy/jsdoccomment": "~0.38.0",
"are-docs-informative": "^0.0.2",
"comment-parser": "1.3.1",
"debug": "^4.3.4",
Expand Down
14 changes: 12 additions & 2 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions test/iterateJsdoc.js
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ describe('iterateJsdoc', () => {
`,
}, '')).to.deep.equal({
description: 'SomeDescription',
inlineTags: [],
problems: [],
source: [
{
Expand All @@ -147,6 +148,7 @@ describe('iterateJsdoc', () => {
tags: [
{
description: ' desc',
inlineTags: [],
name: 'name',
optional: false,
problems: [],
Expand Down
52 changes: 52 additions & 0 deletions test/rules/assertions/noRestrictedSyntax.js
Original file line number Diff line number Diff line change
Expand Up @@ -652,6 +652,58 @@ export default {
],
parser: require.resolve('@typescript-eslint/parser'),
},
{
code: `
/**
* This has an inline {@link http://example.com}
*/
function quux () {
}
`,
errors: [
{
line: 2,
message: 'Syntax is restricted: FunctionDeclaration with JsdocBlock:has(JsdocInlineTag)',
},
],
options: [
{
contexts: [
{
comment: 'JsdocBlock:has(JsdocInlineTag)',
context: 'FunctionDeclaration',
},
],
},
],
},
{
code: `
/**
* @see This has an inline {@link http://example.com}
*/
function quux () {
}
`,
errors: [
{
line: 2,
message: 'Syntax is restricted: FunctionDeclaration with JsdocBlock:has(JsdocTag:has(JsdocInlineTag[format="plain"]))',
},
],
options: [
{
contexts: [
{
comment: 'JsdocBlock:has(JsdocTag:has(JsdocInlineTag[format="plain"]))',
context: 'FunctionDeclaration',
},
],
},
],
},
],
valid: [
{
Expand Down

0 comments on commit 40d5ee0

Please sign in to comment.