Skip to content

Conversation

RatoX
Copy link

@RatoX RatoX commented Jul 12, 2023

Fixes #7


This Pull Request is improving the lint rule to check more edge cases, like:

new RegExp("(?<=)" + "");
new RegExp(`(?<=)`);

However, it still doesn't cover this kind of scenario:

const foo = "(?<=)";
new RegExp(`some content ${foo}`);

That would require a little bit of more code.

@@ -85,8 +85,25 @@ const noLookaheadLookbehindRegexp: Rule.RuleModule = {
if (!unsupportedTargets.length && hasConfig) return {};

return {
TemplateLiteral(node: ESTree.TemplateLiteral & Rule.NodeParentExtension): void {
for (let quasi of node.quasis) {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this would end up reporting the problem on any string template literal (regardless if it is used inside a regexp or not). We should first check if the template literal is inside a regexp constructor before we iterate over all the nodes

@JonasBa
Copy link
Owner

JonasBa commented Jul 31, 2023

@RatoX I'm sorry for the delayed review, I missed this in the flood of GH notifications.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

The rule doesn't find Regex from concatenated strings
2 participants