Skip to content

Commit

Permalink
skip all u flag
Browse files Browse the repository at this point in the history
  • Loading branch information
fisker committed Nov 29, 2019
1 parent a79c04c commit 2f57da8
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions rules/regex-shorthand.js
Expand Up @@ -31,17 +31,14 @@ const create = context => {
return;
}

const optimized = optimize(value);

// The optimized regex might be broken and crash ESLint
try {
optimized.toRegExp();
} catch (_) {
// `u` flag regex is not well handled by `regexp-tree`
// https://github.com/DmitrySoshnikov/regexp-tree/issues/162
if (parsedSource.flags.includes('u')) {
return;
}

const originalRegex = generate(parsedSource).toString();
const optimizedRegex = optimized.toString();
const optimizedRegex = optimize(value).toString();

if (originalRegex === optimizedRegex) {
return;
Expand Down

0 comments on commit 2f57da8

Please sign in to comment.