Skip to content

Commit 7c17f05

Browse files
committed
fix: fix sentence splitting
1 parent cca2a15 commit 7c17f05

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

src/textlint-rule-max-comma.js

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,16 @@ export default function (context, options = defaultOptions) {
1717
const { Syntax, RuleError, report, getSource } = context;
1818
return {
1919
[Syntax.Paragraph](node) {
20-
const nodeWithoutCode = filter(node, (node) => {
20+
const paragraphSentence = splitAST(node)
21+
const paragraphSencenceWithoutNode = filter(paragraphSentence, (node) => {
2122
return node.type !== Syntax.Code;
2223
});
23-
if (!nodeWithoutCode) {
24-
return;
25-
}
26-
const sentences = splitAST(nodeWithoutCode).children.filter(node => node.type === SentenceSyntax.Sentence);
27-
sentences.forEach(sentence => {
24+
// This `sum(0,1,2,3,4,5,6,7,8,9,10)` is ok
25+
// → This is ok
26+
const sentencesWithoutCode = paragraphSencenceWithoutNode
27+
.children
28+
.filter(node => node.type === SentenceSyntax.Sentence);
29+
sentencesWithoutCode.forEach(sentence => {
2830
const source = new StringSource(sentence);
2931
const sentenceValue = source.toString();
3032
const count = countOfComma(sentenceValue);

0 commit comments

Comments
 (0)