Skip to content

Commit

Permalink
Support m (multi-line) flag
Browse files Browse the repository at this point in the history
  • Loading branch information
tjenkinson committed Nov 12, 2023
1 parent 23d971e commit 1a2d500
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/eslint-plugin-redos-detector.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@ describe('Eslint Plugin Redos Detector', () => {
code: '/a/s',
options: [{ ignoreError }],
},
{
code: '/a/m',
options: [{ ignoreError }],
},
...(ignoreError
? [
{
Expand All @@ -49,6 +53,11 @@ describe('Eslint Plugin Redos Detector', () => {
options: [{ ignoreError }],
errors: 1,
},
{
code: '/a+a+/m',
options: [{ ignoreError }],
errors: 1,
},
...(!ignoreError
? [
{
Expand Down
4 changes: 4 additions & 0 deletions src/eslint-plugin-redos-detector.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ export const rules: Record<string, Rule.RuleModule> = {
let caseInsensitive = false;
let unicode = false;
let dotAll = false;
let multiLine = false;

for (const flag of flags.split('')) {
if (flag === 'i') {
Expand All @@ -68,6 +69,8 @@ export const rules: Record<string, Rule.RuleModule> = {
unicode = true;
} else if (flag === 's') {
dotAll = true;
} else if (flag === 'm') {
multiLine = true;
} else if (flag !== 'g') {
if (!ignoreError) {
context.report({
Expand Down Expand Up @@ -98,6 +101,7 @@ export const rules: Record<string, Rule.RuleModule> = {
caseInsensitive,
unicode,
dotAll,
multiLine,
});
} catch (e: any) {
if (!ignoreError) {
Expand Down

0 comments on commit 1a2d500

Please sign in to comment.