Skip to content

Commit

Permalink
refactor: simplify repetition
Browse files Browse the repository at this point in the history
  • Loading branch information
brettz9 committed Dec 1, 2021
1 parent f6756db commit 73f5594
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/rules/checkIndentation.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@ const maskExcludedContent = (str, excludeTags) => {
const regContent = new RegExp(`([ \\t]+\\*)[ \\t]@(?:${excludeTags.join('|')})(?=[ \\n])([\\w|\\W]*?\\n)(?=[ \\t]*\\*(?:[ \\t]*@|\\/))`, 'gu');

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

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

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

Expand Down

0 comments on commit 73f5594

Please sign in to comment.