Skip to content

Latest commit

 

History

History
27 lines (18 loc) · 595 Bytes

no-regexp-v-flag.md

File metadata and controls

27 lines (18 loc) · 595 Bytes

no-regexp-v-flag

This prevents the use of the v flag in RegExps

/[\p{Letter}]/v

new RegExp('[\\p{Letter}]', 'v')

These will not be allowed because they are not supported in the following browsers:

  • Edge > 0
  • Safari < 17
  • Firefox < 116
  • Chrome < 112

What is the Fix?

You can avoid using the v flag by expanding the sets to their unicode ranges:

let vFlag = /[\p{ASCII}]/v;
let noVFlag = /[\0-\x7F]/;

This can be safely disabled if you intend to compile code with the @babel/plugin-transform-unicode-sets-regex Babel plugin, or @babel/preset-env.