require-unicode-regexp
eslint
Suggestion
eslint.config.js
export default [
{
rules: {
"require-unicode-regexp": "error",
},
},
];const a = /aaa/
const b = /bbb/gi
const c = new RegExp("ccc")
const d = new RegExp("ddd", "gi")const a = /aaa/u
const b = /bbb/giu
const c = new RegExp("ccc", "u")
const d = new RegExp("ddd", "giu")
const e = /aaa/v
const f = /bbb/giv
const g = new RegExp("ccc", "v")
const h = new RegExp("ddd", "giv")
// This rule ignores RegExp calls if the flags could not be evaluated to a static value.
function i(flags) {
return new RegExp("eee", flags)
}Examples from the ESLint documentation.
require-unicode-regexp
eslint
export default [
{
rules: {
"require-unicode-regexp": "error",
},
},
];require-unicode-regexp
eslint plugin · pedantic
{
"rules": {
"require-unicode-regexp": "error"
}
}style/useUnicodeRegex
style · since 2.4.5
{
"linter": {
"rules": {
"style": {
"useUnicodeRegex": "error"
}
}
}
}Enforce a maximum cyclomatic complexity allowed in a program
Enforce a maximum depth that callbacks can be nested
Disallow use of Object.prototype.hasOwnProperty.call() and prefer use of Object.hasOwn()
Disallow calls to the Object constructor without an argument
Disallow equal signs explicitly at the beginning of regular expressions
Disallow declarations in the global scope