Skip to content

Commit

Permalink
Revert "fix(require-description-complete-sentence): report bare pun…
Browse files Browse the repository at this point in the history
…ctuation; fixes #573"

This reverts commit b418dbd.
  • Loading branch information
brettz9 committed Jan 29, 2023
1 parent b418dbd commit 139d9b7
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 55 deletions.
17 changes: 1 addition & 16 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11296,14 +11296,6 @@ function quux (foo) {
}
// "jsdoc/require-description-complete-sentence": ["error"|"warn", {"tags":["template"]}]
// Message: Sentence should start with an uppercase character.

/**
* Just a component.
* @param {Object} props Свойства.
* @return {ReactElement}.
*/
function quux () {}
// Message: Sentence must be more than punctuation.
````

The following patterns are not considered problems:
Expand Down Expand Up @@ -11363,7 +11355,7 @@ function quux () {
}

/**
* Foo {@see Math.sin}.
* Foo. {@see Math.sin}.
*/
function quux () {

Expand Down Expand Up @@ -11635,13 +11627,6 @@ export default (foo) => {

/** @file To learn more,
* see: https://github.com/d3/d3-ease. */

/**
* This is a complete sentence...
*/
function quux () {

}
````


Expand Down
15 changes: 3 additions & 12 deletions src/rules/requireDescriptionCompleteSentence.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,18 +24,15 @@ const extractSentences = (text, abbreviationsRegex) => {

const sentenceEndGrouping = /([.?!])(?:\s+|$)/ug;

const puncts = [
...txt.matchAll(sentenceEndGrouping),
].map((sentEnd) => {
return sentEnd[0];
});
const puncts = txt.matchAll(sentenceEndGrouping);

return txt

.split(/[.?!](?:\s+|$)/u)

// Re-add the dot.
.map((sentence, idx) => {
return !puncts[idx] && /^\s*$/u.test(sentence) ? sentence : `${sentence}${puncts[idx] || ''}`;
return /^\s*$/u.test(sentence) ? sentence : `${sentence}${puncts[idx] || ''}`;
});
};

Expand Down Expand Up @@ -121,12 +118,6 @@ const validateDescription = (
reportOrig(msg, fixer, tagObj);
};

if (sentences.some((sentence) => {
return (/^[.?!]$/u).test(sentence);
})) {
report('Sentence must be more than punctuation.', null, tag);
}

if (sentences.some((sentence) => {
return !(/^\s*$/u).test(sentence) && !isCapitalized(sentence) && !isTable(sentence);
})) {
Expand Down
28 changes: 1 addition & 27 deletions test/rules/assertions/requireDescriptionCompleteSentence.js
Original file line number Diff line number Diff line change
Expand Up @@ -951,22 +951,6 @@ export default {
}
`,
},
{
code: `
/**
* Just a component.
* @param {Object} props Свойства.
* @return {ReactElement}.
*/
function quux () {}
`,
errors: [
{
line: 5,
message: 'Sentence must be more than punctuation.',
},
],
},
],
valid: [
{
Expand Down Expand Up @@ -1047,7 +1031,7 @@ export default {
{
code: `
/**
* Foo {@see Math.sin}.
* Foo. {@see Math.sin}.
*/
function quux () {
Expand Down Expand Up @@ -1504,15 +1488,5 @@ export default {
`,
ignoreReadme: true,
},
{
code: `
/**
* This is a complete sentence...
*/
function quux () {
}
`,
},
],
};

0 comments on commit 139d9b7

Please sign in to comment.