Skip to content

Commit d68d742

Browse files
committedNov 2, 2022
fix(no-restricted-syntax): update jsdoccomment to be able to use new descriptionStartLine, descriptionEndLine, and hasPreterminalDescription properties; fixes #830
1 parent e5da5bb commit d68d742

File tree

3 files changed

+97
-1
lines changed

3 files changed

+97
-1
lines changed
 

‎README.md

+17
Original file line numberDiff line numberDiff line change
@@ -9641,6 +9641,16 @@ const MyComponent = ({ children }) => {
96419641
}
96429642
// "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."}]}]
96439643
// Message: The `FunctionComponent` type is not allowed. Please use `FC` instead.
9644+
9645+
/** Some text and more */
9646+
// "jsdoc/no-restricted-syntax": ["error"|"warn", {"contexts":[{"comment":"JsdocBlock[descriptionStartLine=0][descriptionEndLine=0]","context":"any","message":"Requiring descriptive text on 0th line only"}]}]
9647+
// Message: Requiring descriptive text on 0th line only
9648+
9649+
/** Some text and
9650+
* more
9651+
*/
9652+
// "jsdoc/no-restricted-syntax": ["error"|"warn", {"contexts":[{"comment":"JsdocBlock[descriptionStartLine=0][hasPreterminalDescription=0]","context":"any","message":"Requiring descriptive text on 0th line and no preterminal description"}]}]
9653+
// Message: Requiring descriptive text on 0th line and no preterminal description
96449654
````
96459655

96469656
The following patterns are not considered problems:
@@ -9699,6 +9709,13 @@ const MY_ENUM = Object.freeze({
96999709
/** Does something very important. */
97009710
function foo(): string;
97019711
// "jsdoc/no-restricted-syntax": ["error"|"warn", {"contexts":[{"comment":"JsdocBlock[endLine=0][description!=/^\\S[\\s\\S]*\\S\\s$/]"}]}]
9712+
9713+
/** Some text and more */
9714+
// "jsdoc/no-restricted-syntax": ["error"|"warn", {"contexts":[{"comment":"JsdocBlock[descriptionStartLine=0][descriptionEndLine=1]","context":"any","message":"Requiring descriptive text on 0th line and no final newline"}]}]
9715+
9716+
/** Some text and
9717+
* more */
9718+
// "jsdoc/no-restricted-syntax": ["error"|"warn", {"contexts":[{"comment":"JsdocBlock[descriptionStartLine=0][hasPreterminalDescription=0]","context":"any","message":"Requiring descriptive text on 0th line and no preterminal description"}]}]
97029719
````
97039720

97049721

‎package.json

+1-1
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.33.4",
8+
"@es-joy/jsdoccomment": "~0.35.0",
99
"comment-parser": "1.3.1",
1010
"debug": "^4.3.4",
1111
"escape-string-regexp": "^4.0.0",

‎test/rules/assertions/noRestrictedSyntax.js

+79
Original file line numberDiff line numberDiff line change
@@ -372,6 +372,52 @@ export default {
372372
],
373373
parser: require.resolve('@es-joy/jsdoc-eslint-parser/typescript.js'),
374374
},
375+
{
376+
code: `
377+
/** Some text and more */
378+
`,
379+
errors: [
380+
{
381+
line: 2,
382+
message: 'Requiring descriptive text on 0th line only',
383+
},
384+
],
385+
options: [
386+
{
387+
contexts: [
388+
{
389+
comment: 'JsdocBlock[descriptionStartLine=0][descriptionEndLine=0]',
390+
context: 'any',
391+
message: 'Requiring descriptive text on 0th line only',
392+
},
393+
],
394+
},
395+
],
396+
},
397+
{
398+
code: `
399+
/** Some text and
400+
* more
401+
*/
402+
`,
403+
errors: [
404+
{
405+
line: 2,
406+
message: 'Requiring descriptive text on 0th line and no preterminal description',
407+
},
408+
],
409+
options: [
410+
{
411+
contexts: [
412+
{
413+
comment: 'JsdocBlock[descriptionStartLine=0][hasPreterminalDescription=0]',
414+
context: 'any',
415+
message: 'Requiring descriptive text on 0th line and no preterminal description',
416+
},
417+
],
418+
},
419+
],
420+
},
375421
],
376422
valid: [
377423
{
@@ -531,5 +577,38 @@ export default {
531577
],
532578
parser: require.resolve('@typescript-eslint/parser'),
533579
},
580+
{
581+
code: `
582+
/** Some text and more */
583+
`,
584+
options: [
585+
{
586+
contexts: [
587+
{
588+
comment: 'JsdocBlock[descriptionStartLine=0][descriptionEndLine=1]',
589+
context: 'any',
590+
message: 'Requiring descriptive text on 0th line and no final newline',
591+
},
592+
],
593+
},
594+
],
595+
},
596+
{
597+
code: `
598+
/** Some text and
599+
* more */
600+
`,
601+
options: [
602+
{
603+
contexts: [
604+
{
605+
comment: 'JsdocBlock[descriptionStartLine=0][hasPreterminalDescription=0]',
606+
context: 'any',
607+
message: 'Requiring descriptive text on 0th line and no preterminal description',
608+
},
609+
],
610+
},
611+
],
612+
},
534613
],
535614
};

0 commit comments

Comments
 (0)
Please sign in to comment.