Skip to content

Commit

Permalink
docs(match-description): more endLine tests
Browse files Browse the repository at this point in the history
  • Loading branch information
brettz9 committed Mar 16, 2022
1 parent 9a3f70e commit 3bade86
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 0 deletions.
13 changes: 13 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7178,6 +7178,11 @@ function quux () {
*/
// "jsdoc/match-description": ["error"|"warn", {"contexts":["any"],"matchDescription":"^\\S[\\s\\S]*\\S$"}]
// Message: JSDoc description does not satisfy the regex pattern.

/** Does something very important. */
function foo(): string;
// "jsdoc/match-description": ["error"|"warn", {"contexts":[{"comment":"JsdocBlock[endLine=0]"}],"matchDescription":"^\\S[\\s\\S]*\\S$"}]
// Message: JSDoc description does not satisfy the regex pattern.
````

The following patterns are not considered problems:
Expand Down Expand Up @@ -7537,6 +7542,14 @@ function quux () {
/** Does something very important. */
function foo(): string;
// "jsdoc/match-description": ["error"|"warn", {"contexts":[{"comment":"JsdocBlock[endLine!=0]"}],"matchDescription":"^\\S[\\s\\S]*\\S$"}]

/**
* This is my favorite function, foo.
*
* @returns Nothing.
*/
function foo(): void;
// "jsdoc/match-description": ["error"|"warn", {"contexts":[{"comment":"JsdocBlock[endLine!=0]:not(:has(JsdocTag))"}],"matchDescription":"^\\S[\\s\\S]*\\S$"}]
````


Expand Down
44 changes: 44 additions & 0 deletions test/rules/assertions/matchDescription.js
Original file line number Diff line number Diff line change
Expand Up @@ -978,6 +978,29 @@ export default {
},
],
},
{
code: `
/** Does something very important. */
function foo(): string;
`,
errors: [
{
line: 3,
message: 'JSDoc description does not satisfy the regex pattern.',
},
],
options: [
{
contexts: [
{
comment: 'JsdocBlock[endLine=0]',
},
],
matchDescription: '^\\S[\\s\\S]*\\S$',
},
],
parser: require.resolve('@typescript-eslint/parser'),
},
],
valid: [
{
Expand Down Expand Up @@ -1653,5 +1676,26 @@ export default {
],
parser: require.resolve('@typescript-eslint/parser'),
},
{
code: `
/**
* This is my favorite function, foo.
*
* @returns Nothing.
*/
function foo(): void;
`,
options: [
{
contexts: [
{
comment: 'JsdocBlock[endLine!=0]:not(:has(JsdocTag))',
},
],
matchDescription: '^\\S[\\s\\S]*\\S$',
},
],
parser: require.resolve('@typescript-eslint/parser'),
},
],
};

0 comments on commit 3bade86

Please sign in to comment.