Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix more complex requireDescriptionCompleteSentence cases #201

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,9 @@ function requireDescriptionCompleteSentence(node, err) {
}

var sanitized = doc.description
.replace(/(`)([^`]+)\1/, quotedSanitizer)
.replace(/(')([^']+)\1/, quotedSanitizer)
.replace(/(")([^"]+)\1/, quotedSanitizer)
.replace(/(`)([^`]+)\1/g, quotedSanitizer)
.replace(/(')([^']+)\1/g, quotedSanitizer)
.replace(/(")([^"]+)\1/g, quotedSanitizer)
// sanitize HTML tags which close
.replace(/<([^ >]+)[^>]*>[\s\S]*?.*?<\/\1>|<[^\/]+\/>/g, htmlSanitizer)
// sanitize self-closing HTML tags eg <br>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,33 @@ describe('lib/rules/validate-jsdoc/require-description-complete-sentence', funct
function fun(p) {}
},
errors: 1
}, {
it: 'should not report because of strings between backtick',
code: function () {
/**
* Some `fo.o` and some `b.ar`. Also some `ba.r` and some `.foo`.
*/
function fun(p) {}
},
errors: 0
}, {
it: 'should not report because of strings between single quotes',
code: function () {
/**
* Some 'fo.o' and some 'b.ar'. Also some 'ba.r' and some '.foo'.
*/
function fun(p) {}
},
errors: 0
}, {
it: 'should not report because of strings between double quotes',
code: function () {
/**
* Some "fo.o" and some "b.ar". Also some "ba.r" and some ".foo".
*/
function fun(p) {}
},
errors: 0
}, {
it: 'should report missing period at end of first line',
code: function () {
Expand Down Expand Up @@ -232,6 +259,20 @@ describe('lib/rules/validate-jsdoc/require-description-complete-sentence', funct
*/
function quux() {}
}
}, {
it: 'should not report correct sentences formatted as (complex) lists',
code: function () {
/**
* To become a `Foo.Bar`, `element` has to:
*
* - be an `HTMLElement`
* - have an `options` property
* - have `foo` and `bar` properties in its `options` object
* - not have a foo (`.bar`) as source, or if it does:
* - have `options.foo` set to `true`
*/
function quux() {}
}
}, {
it: 'should not report sentences with html tags inside',
code: function () {
Expand Down