{"record":{"id":"c5da62a7fdc1039f","repo":"emotion-js/emotion","slug":"the-autolabel-option-must-be-undefined-or-one-o","errorCode":null,"errorMessage":"The 'autoLabel' option must be undefined, or one of the following: ${AUTO_LABEL_VALUES.map(\n        s => `\"${s}\"`\n      ).join(', ')}","messagePattern":"The 'autoLabel' option must be undefined, or one of the following: (.+?)\"`\n      \\)\\.join\\(', '\\)\\}","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/babel-plugin/src/index.js","lineNumber":83,"sourceCode":"  primitivesStyled: primitivesStyledMacro,\n  webStyled: webStyledMacro,\n  vanillaEmotion: vanillaEmotionMacro\n}\n\n/*\nexport type BabelPath = any\n\nexport type EmotionBabelPluginPass = any\n*/\n\nconst AUTO_LABEL_VALUES = ['dev-only', 'never', 'always']\n\nexport default function (babel, options) {\n  if (\n    options.autoLabel !== undefined &&\n    !AUTO_LABEL_VALUES.includes(options.autoLabel)\n  ) {\n    throw new Error(\n      `The 'autoLabel' option must be undefined, or one of the following: ${AUTO_LABEL_VALUES.map(\n        s => `\"${s}\"`\n      ).join(', ')}`\n    )\n  }\n\n  let t = babel.types\n  return {\n    name: '@emotion',\n    // https://github.com/babel/babel/blob/0c97749e0fe8ad845b902e0b23a24b308b0bf05d/packages/babel-plugin-syntax-jsx/src/index.ts#L9-L18\n    manipulateOptions(opts, parserOpts) {\n      const { plugins } = parserOpts\n\n      if (\n        plugins.some(p => {\n          const plugin = Array.isArray(p) ? p[0] : p\n          return plugin === 'typescript' || plugin === 'jsx'\n        })","sourceCodeStart":65,"sourceCodeEnd":101,"githubUrl":"https://github.com/emotion-js/emotion/blob/b882bcba85132554992e4bd49e94c95939bbf810/packages/babel-plugin/src/index.js#L65-L101","documentation":"The `autoLabel` option of @emotion/babel-plugin only accepts specific string values (dev, production, always). The plugin validates the option at setup and throws if it's set to anything else, preventing silently wrong label behavior.","triggerScenarios":"Setting `autoLabel` to an unsupported value like true, false, 'true', or a misspelling such as 'produciton' in the babel plugin options.","commonSituations":"Treating autoLabel as a boolean toggle instead of an enum, typos after hand-editing babel config, or copying configs from outdated blog posts.","solutions":["Change `autoLabel` to one of the allowed values: \"dev\", \"production\", or \"always\"","Remove the `autoLabel` option entirely to use the default (dev)","Check spelling/quotes: the value must be a string, not a boolean"],"exampleFix":"// before\n['@emotion/babel-plugin', { autoLabel: true }]\n// after\n['@emotion/babel-plugin', { autoLabel: 'dev' }]","handlingStrategy":"validation","validationCode":"const AUTO_LABEL_VALUES = ['dev', 'production', 'always'];\nif (opts.autoLabel !== undefined && !AUTO_LABEL_VALUES.includes(opts.autoLabel)) {\n  throw new Error(`autoLabel must be one of: ${AUTO_LABEL_VALUES.map(v => `\"${v}\"`).join(', ')}`);\n}","typeGuard":"const isAutoLabel = (v) => v === undefined || ['dev', 'production', 'always'].includes(v);","tryCatchPattern":null,"preventionTips":["Never pass booleans to autoLabel — it's a string enum","Type the babel options with a union type: type AutoLabel = 'dev' | 'production' | 'always'","Omit the option to accept the default"],"tags":["babel","emotion","configuration","option-validation"],"backgroundTag":"invalid-enum-value","analyzedSha":"b882bcba85132554992e4bd49e94c95939bbf810","analyzedAt":"2026-09-02T22:27:13.739Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-10T02:17:09.455Z"}