Skip to content

Commit 73f5594

Browse files
committed
refactor: simplify repetition
1 parent f6756db commit 73f5594

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/rules/checkIndentation.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,15 @@ const maskExcludedContent = (str, excludeTags) => {
44
const regContent = new RegExp(`([ \\t]+\\*)[ \\t]@(?:${excludeTags.join('|')})(?=[ \\n])([\\w|\\W]*?\\n)(?=[ \\t]*\\*(?:[ \\t]*@|\\/))`, 'gu');
55

66
return str.replace(regContent, (_match, margin, code) => {
7-
return Array.from({length: code.match(/\n/gu).length + 1}).join(margin + '\n');
7+
return (margin + '\n').repeat(code.match(/\n/gu).length);
88
});
99
};
1010

1111
const maskCodeBlocks = (str) => {
1212
const regContent = /([ \t]+\*)[ \t]```[^\n]*?([\w|\W]*?\n)(?=[ \t]*\*(?:[ \t]*(?:```|@\w+\s)|\/))/gu;
1313

1414
return str.replace(regContent, (_match, margin, code) => {
15-
return Array.from({length: code.match(/\n/gu).length + 1}).join(margin + '\n');
15+
return (margin + '\n').repeat(code.match(/\n/gu).length);
1616
});
1717
};
1818

0 commit comments

Comments
 (0)