Skip to content

Commit c6cb740

Browse files
anton-rudeshkogajus
authored andcommitted
fix: correct check for non-ASCII descriptions (#39)
* chore: include rule tests in regular tests run * fix: correct check for non-ASCII descriptions
1 parent d99da90 commit c6cb740

File tree

3 files changed

+31
-2
lines changed

3 files changed

+31
-2
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@
4747
"build": "NODE_ENV=production babel ./src --out-dir ./dist --copy-files --source-maps",
4848
"generate-readme": "gitdown ./.README/README.md --output-file ./README.md && npm run add-assertions",
4949
"lint": "eslint ./src ./test",
50-
"test": "mocha --compilers js:babel-register"
50+
"test": "mocha --recursive --compilers js:babel-register"
5151
},
5252
"version": "2.4.0"
5353
}

src/rules/requireDescriptionCompleteSentence.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,10 @@ const isNewLinePrecededByAPeriod = (text) => {
2121
});
2222
};
2323

24+
const isCapitalized = (str) => {
25+
return str[0] === str[0].toUpperCase();
26+
};
27+
2428
const validateDescription = (description, report) => {
2529
if (!description) {
2630
return false;
@@ -29,7 +33,7 @@ const validateDescription = (description, report) => {
2933
const paragraphs = extractParagraphs(description);
3034

3135
return _.some(paragraphs, (paragraph, index) => {
32-
if (!/^[A-Z]/.test(paragraph)) {
36+
if (!isCapitalized(paragraph)) {
3337
if (index === 0) {
3438
report('Description must start with an uppercase character.');
3539
} else {

test/rules/assertions/requireDescriptionCompleteSentence.js

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,21 @@ export default {
3434
}
3535
]
3636
},
37+
{
38+
code: `
39+
/**
40+
* тест.
41+
*/
42+
function quux () {
43+
44+
}
45+
`,
46+
errors: [
47+
{
48+
message: 'Description must start with an uppercase character.'
49+
}
50+
]
51+
},
3752
{
3853
code: `
3954
/**
@@ -144,6 +159,16 @@ export default {
144159
}
145160
`
146161
},
162+
{
163+
code: `
164+
/**
165+
* Тест.
166+
*/
167+
function quux () {
168+
169+
}
170+
`
171+
},
147172
{
148173
code: `
149174
/**

0 commit comments

Comments
 (0)