{"record":{"id":"e38f64b619cacc97","repo":"ReactiveX/rxjs","slug":"unknown-option-argument","errorCode":null,"errorMessage":"Unknown option: ${argument}","messagePattern":"Unknown option: (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/migrate/src/cli.ts","lineNumber":158,"sourceCode":"        if (mode !== 'cold' && mode !== 'platform') throw new Error(`Unknown mode: ${mode}`);\n        options.mode = mode;\n        break;\n      }\n      case '--framework': {\n        const framework = requiredValue(argv, ++index, argument);\n        if (framework !== 'preserve' && framework !== 'mocha-chai-vitest') throw new Error(`Unknown framework: ${framework}`);\n        options.framework = framework;\n        break;\n      }\n      case '--write':\n        options.write = true;\n        break;\n      case '--help':\n      case '-h':\n        options.help = true;\n        break;\n      default:\n        if (argument.startsWith('-')) throw new Error(`Unknown option: ${argument}`);\n        options.files.push(argument);\n    }\n  }\n  return options;\n}\n\nfunction validateArguments(options: CliOptions): asserts options is RunnableCliOptions {\n  const missing = [\n    options.files.length === 0 ? 'at least one source file' : undefined,\n    options.sourceRoot ? undefined : '--source-root',\n    options.repository ? undefined : '--source-repo',\n    options.sha ? undefined : '--source-sha',\n  ].filter((value): value is string => value !== undefined);\n  if (missing.length > 0) throw new Error(`Missing required argument${missing.length === 1 ? '' : 's'}: ${missing.join(', ')}`);\n  if (options.write && !options.outputRoot) throw new Error('--out-dir is required with --write');\n}\n\nfunction requiredValue(argv: readonly string[], index: number, option: string): string {","sourceCodeStart":140,"sourceCodeEnd":176,"githubUrl":"https://github.com/ReactiveX/rxjs/blob/54796b38a57e6309f9861e174737479bb3f63f61/packages/migrate/src/cli.ts#L140-L176","documentation":"Thrown by parseArguments when the command line contains a token starting with '-' that does not match any known flag. The CLI rejects unknown options outright rather than silently ignoring them, so misspelled flags fail fast.","triggerScenarios":"Passing an unsupported flag such as --dry-run, --verbose, or -v, or a typo like --source-rrot. Any token beginning with '-' that is not in the switch statement hits the default case and throws.","commonSituations":"Assuming flags from other codemods (jest-codemods, ts-migrate), using short forms that do not exist, or leftover flags in a reused npm script.","solutions":["Remove the unsupported flag","Check spelling against the --help output","Replace with the supported equivalent (e.g. --write instead of --dry-run semantics)"],"exampleFix":"# before\nnpx @rxjs/migrate --dry-run file.ts\n# after\nnpx @rxjs/migrate file.ts   # plan is printed by default; add --write to apply","handlingStrategy":"validation","validationCode":"const KNOWN_FLAGS = new Set(['--source-root','--source-repo','--source-sha','--mode','--framework','--write','--out-dir','--help','-h']);\nfor (const a of argv) if (a.startsWith('-') && !KNOWN_FLAGS.has(a)) throw new Error(`Unsupported flag in wrapper: ${a}`);","typeGuard":"const isKnownFlag = (a: string) => a.startsWith('-') && KNOWN_FLAGS.has(a);","tryCatchPattern":"try { runCli(argv); } catch (e) { console.error((e as Error).message); /* prints the exact unknown option */ }","preventionTips":["Generate CLI invocations from a typed options object instead of string concatenation","Smoke-test scripts after upgrading @rxjs/migrate since flags may change"],"tags":["cli","argument-validation","unknown-flag"],"backgroundTag":"unknown-cli-option","analyzedSha":"54796b38a57e6309f9861e174737479bb3f63f61","analyzedAt":"2026-08-28T10:21:27.410Z","schemaVersion":2},"datasetVersion":"2026-08-28T11:17:15.048Z"}