Skip to content

Commit

Permalink
refactor(ignore): enhance regex for command parsing
Browse files Browse the repository at this point in the history
  • Loading branch information
johnsoncodehk committed Jan 5, 2025
1 parent d9d5dfc commit 4d210d2
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions packages/config/lib/plugins/ignore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,10 @@ export function create(
const [cmd, endCmd] = Array.isArray(cmdOption) ? cmdOption : [cmdOption, undefined];
const cmdText = cmd.replace(/\?/g, '');
const withRuleId = '[ \\t]*(?<ruleId>\\w\\S*)?';
const header = '^\\s*';
const ending = '([ \\t]+[^\\r\\n]*)?$';
const reg = new RegExp(`\\s*${cmd}${withRuleId}${ending}`);
const endReg = endCmd ? new RegExp(`\\s*${endCmd}${withRuleId}${ending}`) : undefined;
const reg = new RegExp(`${header}${cmd}${withRuleId}${ending}`);
const endReg = endCmd ? new RegExp(`${header}${endCmd}${withRuleId}${ending}`) : undefined;
const completeReg1 = /^\s*\/\/(\s*)([\S]*)?$/;
const completeReg2 = new RegExp(`//\\s*${cmd}(\\S*)?$`);

Expand Down

0 comments on commit 4d210d2

Please sign in to comment.