Skip to content

Commit

Permalink
Support the s (dotAll) flag
Browse files Browse the repository at this point in the history
  • Loading branch information
tjenkinson committed Oct 29, 2023
1 parent c319095 commit ecad135
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 9 deletions.
14 changes: 7 additions & 7 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
"lint-staged": "15.0.2",
"micromatch": "4.0.5",
"prettier": "3.0.3",
"redos-detector": "4.2.0",
"redos-detector": "4.3.0",
"rollup": "4.1.4",
"ts-jest": "29.1.1",
"tslib": "2.6.2",
Expand Down
6 changes: 5 additions & 1 deletion src/eslint-plugin-redos-detector.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { rules } from './eslint-plugin-redos-detector';
import { RuleTester } from 'eslint';

const ruleTester = new RuleTester({ parserOptions: { ecmaVersion: 6 } });
const ruleTester = new RuleTester({ parserOptions: { ecmaVersion: 'latest' } });

describe('Eslint Plugin Redos Detector', () => {
describe(`'no-unsafe-regex' rule`, () => {
Expand All @@ -20,6 +20,10 @@ describe('Eslint Plugin Redos Detector', () => {
code: '/a/u',
options: [{ ignoreError }],
},
{
code: '/a/s',
options: [{ ignoreError }],
},
...(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 @@ -59,12 +59,15 @@ export const rules: Record<string, Rule.RuleModule> = {

let caseInsensitive = false;
let unicode = false;
let dotAll = false;

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

0 comments on commit ecad135

Please sign in to comment.