Skip to content

Commit

Permalink
refactor(ignore): improve 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 1d51e51 commit db89f2c
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions packages/config/lib/plugins/ignore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,10 @@ export function create(
const mode = typeof cmdOption === 'string' ? 'singleLine' : 'multiLine';
const [cmd, endCmd] = Array.isArray(cmdOption) ? cmdOption : [cmdOption, undefined];
const cmdText = cmd.replace(/\?/g, '');
const withRuleId = '(\\b[ \\t]*|[ \\t]+)(?<ruleId>\\S*\\b)?';
const reg = new RegExp(`\\s*${cmd}${withRuleId}`);
const endReg = endCmd ? new RegExp(`\\s*${endCmd}${withRuleId}`) : undefined;
const withRuleId = '[ \\t]*(?<ruleId>\\w\\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 completeReg1 = /^\s*\/\/(\s*)([\S]*)?$/;
const completeReg2 = new RegExp(`//\\s*${cmd}(\\S*)?$`);

Expand Down

0 comments on commit db89f2c

Please sign in to comment.