Skip to content

Commit

Permalink
fix(require-description-complete-sentence): avoid triggering punctu…
Browse files Browse the repository at this point in the history
…ation warning after Markdown headings; fixes #1220
  • Loading branch information
brettz9 committed Jun 5, 2024
1 parent fb3e0e6 commit e9e4440
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 1 deletion.
7 changes: 7 additions & 0 deletions docs/rules/match-name.md
Original file line number Diff line number Diff line change
Expand Up @@ -245,5 +245,12 @@ class A {
* @param {Foo|Bar} opt_b
*/
// "jsdoc/match-name": ["error"|"warn", {"match":[{"comment":"JsdocBlock:has(JsdocTag[tag=\"param\"]:has(JsdocTypeUnion:has(JsdocTypeName[value=\"Bar\"]:nth-child(1))))","disallowName":"/^opt_/i"}]}]

/**
* @template {string} [T=typeof FOO]
* @typedef {object} Test
* @property {T} test
*/
// "jsdoc/match-name": ["error"|"warn", {"match":[{"allowName":"/^[A-Z]{1}$/","message":"The name should be a single capital letter.","tags":["template"]}]}]
````

12 changes: 12 additions & 0 deletions docs/rules/require-description-complete-sentence.md
Original file line number Diff line number Diff line change
Expand Up @@ -829,5 +829,17 @@ function quux () {
* @param parameter
*/
const code = (parameter) => 123;

/**
* ### Overview
* My class is doing.
*
* ### Example
* ```javascript
* const toto = 'toto';
* ```
*/
export class ClassExemple {
}
````

6 changes: 6 additions & 0 deletions docs/rules/require-yields.md
Original file line number Diff line number Diff line change
Expand Up @@ -796,5 +796,11 @@ function * quux (foo) {
yield foo;
}
}

/**
*
*/
export { foo } from "bar"
// "jsdoc/require-yields": ["error"|"warn", {"contexts":["ExportNamedDeclaration"]}]
````

5 changes: 4 additions & 1 deletion src/rules/requireDescriptionCompleteSentence.js
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,10 @@ const validateDescription = (

const paragraphNoAbbreviations = paragraph.replace(abbreviationsRegex, '');

if (!/(?:[.?!|]|```)\s*$/u.test(paragraphNoAbbreviations)) {
if (
!/(?:[.?!|]|```)\s*$/u.test(paragraphNoAbbreviations) &&
!paragraphNoAbbreviations.startsWith('#')
) {
report('Sentences must end with a period.', fix, tag);
return true;
}
Expand Down
16 changes: 16 additions & 0 deletions test/rules/assertions/requireDescriptionCompleteSentence.js
Original file line number Diff line number Diff line change
Expand Up @@ -1591,5 +1591,21 @@ export default {
const code = (parameter) => 123;
`,
},
{
code: `
/**
* ### Overview
* My class is doing.
*
* ### Example
* \`\`\`javascript
* const toto = 'toto';
* \`\`\`
*/
export class ClassExemple {
}
`,
},
],
};

0 comments on commit e9e4440

Please sign in to comment.