Skip to content

Commit

Permalink
fix(check-indentation): update function and variable names
Browse files Browse the repository at this point in the history
  • Loading branch information
ahwayakchih authored and golopot committed Oct 2, 2019
1 parent 41af93c commit 756520a
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/rules/checkIndentation.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import iterateJsdoc from '../iterateJsdoc';

const maskExamples = (str, excludeTags) => {
const regExamples = new RegExp(`([ \\t]+\\*)[ \\t]@(?:${excludeTags.join('|')})(?=[ \\n])([\\w|\\W]*?\\n)(?=[ \\t]*\\*(?:[ \\t]*@|\\/))`, 'g');
const maskExcludedContent = (str, excludeTags) => {
const regContent = new RegExp(`([ \\t]+\\*)[ \\t]@(?:${excludeTags.join('|')})(?=[ \\n])([\\w|\\W]*?\\n)(?=[ \\t]*\\*(?:[ \\t]*@|\\/))`, 'g');

return str.replace(regExamples, (match, margin, code) => {
return str.replace(regContent, (match, margin, code) => {
return (new Array(code.match(/\n/g).length + 1)).join(margin + '\n');
});
};
Expand All @@ -20,7 +20,7 @@ export default iterateJsdoc(({
} = options;

const reg = new RegExp(/^(?:\/?\**|[ \t]*)\*[ \t]{2}/gm);
const text = excludeTags.length ? maskExamples(sourceCode.getText(jsdocNode), excludeTags) : sourceCode.getText(jsdocNode);
const text = excludeTags.length ? maskExcludedContent(sourceCode.getText(jsdocNode), excludeTags) : sourceCode.getText(jsdocNode);

if (reg.test(text)) {
const lineBreaks = text.slice(0, reg.lastIndex).match(/\n/g) || [];
Expand Down

0 comments on commit 756520a

Please sign in to comment.