{"record":{"id":"2b4b19629807e652","repo":"oxc-project/oxc","slug":"use-the-v-flag","errorCode":null,"errorMessage":"Use the 'v' flag.","messagePattern":"Use the 'v' flag\\.","errorType":"validation","errorClass":"OxcDiagnostic","httpStatus":null,"severity":"warning","filePath":"crates/oxc_linter/src/rules/eslint/require_unicode_regexp.rs","lineNumber":33,"sourceCode":"    AstNode,\n    ast_util::get_declaration_of_variable,\n    ast_util::variable_declaration_kind,\n    context::LintContext,\n    rule::{DefaultRuleConfig, Rule},\n    utils::is_regexp_callee,\n};\n\nfn require_unicode_regexp_diagnostic(\n    span: Span,\n    require_flag: Option<&RequireFlag>,\n) -> OxcDiagnostic {\n    let (msg, help_msg) = if matches!(require_flag, Some(RequireFlag::V)) {\n        (\"Use the 'v' flag.\", \"Add the 'v' flag.\")\n    } else {\n        (\"Use the 'u' flag.\", \"Add the 'u' flag.\")\n    };\n\n    OxcDiagnostic::warn(msg)\n        .with_note(\"The 'u' and 'v' flags enable Unicode-aware regular expression behavior and stricter pattern parsing.\")\n        .with_help(help_msg)\n        .with_label(span)\n}\n\n#[derive(Debug, Default, Clone, Serialize, Deserialize, JsonSchema)]\n#[serde(rename_all = \"camelCase\", default, deny_unknown_fields)]\nstruct RequireUnicodeRegexpConfig {\n    /// The `u` flag may be preferred in environments that do not support the `v` flag.\n    ///\n    /// Examples of **incorrect** code for this rule with the `{ \"requireFlag\": \"u\" }` option:\n    /// ```js\n    /// const fooEmpty = /foo/;\n    /// const fooEmptyRegexp = new RegExp('foo');\n    /// const foo = /foo/v;\n    /// const fooRegexp = new RegExp('foo', 'v');\n    /// ```\n    ///","sourceCodeStart":15,"sourceCodeEnd":51,"githubUrl":"https://github.com/oxc-project/oxc/blob/e1e7af627c8843ab64044ed466b128fcc21a035b/crates/oxc_linter/src/rules/eslint/require_unicode_regexp.rs#L15-L51","documentation":"oxlint `eslint/require-unicode-regexp` with `{ \"requireFlag\": \"v\" }`: a regex literal or `RegExp` construction lacks the `v` flag. In `require_unicode_regexp_diagnostic` (require_unicode_regexp.rs:33) the V branch selects message 'Use the \\'v\\' flag.' and help 'Add the \\'v\\' flag.'. The `v` flag enables Unicode Sets mode (`\\p{...}` classes, `--` subtraction) and stricter parsing; the config comment notes `u` may be preferred where `v` is unsupported.","triggerScenarios":"Rule configured with `requireFlag: \"v\"` and code containing `/foo/`, `/\\d+/u`, or `new RegExp(\"foo\")` — any regex without `v` in its flags.","commonSituations":"Shared config that mandates v-mode for consistent Unicode handling; upgrading a config from `u` to `v` and re-linting an older codebase; targeting Node/browsers that gained `v` support only recently.","solutions":["Add the flag to the literal: `/foo/` becomes `/foo/v` (note: `v` implies `u`, so `/foo/u` becomes `/foo/v`).","For constructed regexes pass the flag: `new RegExp(\"foo\", \"v\")`.","If you must support runtimes without `v`, set `\"requireFlag\": \"u\"` in the rule config instead."],"exampleFix":"// before\nconst re = /^\\p{Letter}+$/u;\n\n// after\nconst re = /^\\p{Letter}+$/v;","handlingStrategy":"validation","validationCode":"# regex literals missing the v flag\nrg -n --pcre2 '/[^\\n]*/[dgimsuy]*' src/ | rg -v '/[^\\n]*/[a-z]*v[a-z]*'","typeGuard":null,"tryCatchPattern":null,"preventionTips":["End every regex literal with `/v` when the config mandates it; `v` supersedes `u`.","Check runtime support (Node 20+, modern browsers) before standardizing on `v`.","If a target env lacks `v`, configure `\"requireFlag\": \"u\"` instead of scattering disables."],"tags":["eslint","oxlint","regex","unicode","lint"],"backgroundTag":"require-unicode-regexp","analyzedSha":"e1e7af627c8843ab64044ed466b128fcc21a035b","analyzedAt":"2026-08-20T07:01:07.079Z","contentChangedAt":"2026-08-20T07:01:07.079Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}