{"id":"011254b5dc845c5f","repo":"babel/babel","slug":"useunicodeflag-must-be-a-boolean-or-undefined","errorCode":null,"errorMessage":".useUnicodeFlag must be a boolean, or undefined","messagePattern":"\\.useUnicodeFlag must be a boolean, or undefined","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/babel-plugin-transform-unicode-property-regex/src/index.ts","lineNumber":14,"sourceCode":"/* eslint-disable @babel/development/plugin-name */\nimport { createRegExpFeaturePlugin } from \"@babel/helper-create-regexp-features-plugin\";\nimport { declare } from \"@babel/helper-plugin-utils\";\n\nexport interface Options {\n  useUnicodeFlag?: boolean;\n}\n\nexport default declare((api, options: Options) => {\n  api.assertVersion(REQUIRED_VERSION(\"^7.0.0-0 || ^8.0.0\"));\n\n  const { useUnicodeFlag = true } = options;\n  if (typeof useUnicodeFlag !== \"boolean\") {\n    throw new Error(\".useUnicodeFlag must be a boolean, or undefined\");\n  }\n\n  return createRegExpFeaturePlugin({\n    name: \"transform-unicode-property-regex\",\n    feature: \"unicodePropertyEscape\",\n    options: { useUnicodeFlag },\n  });\n});\n","sourceCodeStart":1,"sourceCodeEnd":23,"githubUrl":"https://github.com/babel/babel/blob/06b6eae39da4ce0689fad64e2c48a6375a464208/packages/babel-plugin-transform-unicode-property-regex/src/index.ts#L1-L23","documentation":"@babel/plugin-transform-unicode-property-regex validates (index.ts:13) that `useUnicodeFlag` (default `true`) is a boolean. The value controls whether the generated regex gets the `u` flag; non-boolean values are rejected to prevent silent misuse such as the string `'false'` being truthy.","triggerScenarios":"Passing `useUnicodeFlag: \"true\"`, `useUnicodeFlag: 1`, `useUnicodeFlag: null`, or any other non-boolean value to the plugin.","commonSituations":"JSON/JSON5 config files where booleans get quoted; programmatic configs passing a number or an environment-variable string.","solutions":["Pass a literal boolean (`true`/`false`) for `useUnicodeFlag`.","Or omit the option entirely to accept the default `true`."],"exampleFix":"// before\n[\"@babel/plugin-transform-unicode-property-regex\", { useUnicodeFlag: \"true\" }]\n// after\n[\"@babel/plugin-transform-unicode-property-regex\", { useUnicodeFlag: true }]","handlingStrategy":"type-guard","validationCode":"if (opts.useUnicodeFlag != null && typeof opts.useUnicodeFlag !== \"boolean\") {\n  throw new TypeError(\"useUnicodeFlag must be a boolean\");\n}","typeGuard":"const isBoolOrUndef = v => v === undefined || typeof v === \"boolean\";","tryCatchPattern":null,"preventionTips":["Never quote boolean values in JSON config.","Use the shipped `Options` TypeScript interface to catch type errors at compile time."],"tags":["config","validation","unicode-regex","type-error"],"analyzedSha":"06b6eae39da4ce0689fad64e2c48a6375a464208","analyzedAt":"2026-08-03T20:13:43.465Z","schemaVersion":2}