no-invalid-regexp should catch non-cross-platform regex features #11931
What rule do you want to change?
Does this change cause the rule to produce more or fewer warnings?
How will the change be implemented? (New option, new default behavior, etc.)?
Please provide some example code that this change will affect:
const namedCaptureGroupsExample = /^(?<foo>.+)/; const lookBehindExample = /(?<=[a-z])(?=[A-Z])/g;
This uses regex feature (named capture groups and lookbehind) that are only supported in some browsers: https://www.smashingmagazine.com/2019/02/regexp-features-regular-expressions/. Firefox actually throws a syntax error for this.
What does the rule currently do for this code?
What will the rule do after it's changed?
Are you willing to submit a pull request to implement this change?
At least all the features that Firefox doesn't currently support. I know of the two examples in my post, but there could be others.
At FB, we've had breakages in some internal tools due to usage of regex features that Firefox doesn't support. Unfortunately, these are syntax errors in Firefox, meaning they break the entire script at parse time
Thank you @mysticatea - That is perfect!! Just enabled these rules in my ESLint config, as I verified that they're all syntax errors in the latest Firefox:
Since these rules exist, I guess this issue can be closed.