{"id":"65bfdc1e9ae92229","repo":"eslint/eslint","slug":"context-report-called-with-a-suggest-option-that","errorCode":null,"errorMessage":"context.report() called with a suggest option that defines both a 'messageId' and an 'desc'. Please only pass one.","messagePattern":"context\\.report\\(\\) called with a suggest option that defines both a 'messageId' and an 'desc'\\. Please only pass one\\.","errorType":"exception","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"lib/linter/file-report.js","lineNumber":414,"sourceCode":"\tif (suggest && Array.isArray(suggest)) {\n\t\tsuggest.forEach(suggestion => {\n\t\t\tif (suggestion.messageId) {\n\t\t\t\tconst { messageId } = suggestion;\n\n\t\t\t\tif (!messages) {\n\t\t\t\t\tthrow new TypeError(\n\t\t\t\t\t\t`context.report() called with a suggest option with a messageId '${messageId}', but no messages were present in the rule metadata.`,\n\t\t\t\t\t);\n\t\t\t\t}\n\n\t\t\t\tif (!messages[messageId]) {\n\t\t\t\t\tthrow new TypeError(\n\t\t\t\t\t\t`context.report() called with a suggest option with a messageId '${messageId}' which is not present in the 'messages' config: ${JSON.stringify(messages, null, 2)}`,\n\t\t\t\t\t);\n\t\t\t\t}\n\n\t\t\t\tif (suggestion.desc) {\n\t\t\t\t\tthrow new TypeError(\n\t\t\t\t\t\t\"context.report() called with a suggest option that defines both a 'messageId' and an 'desc'. Please only pass one.\",\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t} else if (!suggestion.desc) {\n\t\t\t\tthrow new TypeError(\n\t\t\t\t\t\"context.report() called with a suggest option that doesn't have either a `desc` or `messageId`\",\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tif (typeof suggestion.fix !== \"function\") {\n\t\t\t\tthrow new TypeError(\n\t\t\t\t\t`context.report() called with a suggest option without a fix function. See: ${JSON.stringify(suggestion, null, 2)}`,\n\t\t\t\t);\n\t\t\t}\n\t\t});\n\t}\n}\n","sourceCodeStart":396,"sourceCodeEnd":432,"githubUrl":"https://github.com/eslint/eslint/blob/f131c034ad91bbf06bcbb6b5e931447a8e419a46/lib/linter/file-report.js#L396-L432","documentation":"Thrown by validateSuggestions() when a single suggestion object provides BOTH a messageId and a desc property. ESLint allows either a messageId (resolved from meta.messages) or an inline desc string, but not both — providing both is ambiguous and almost always a copy-paste mistake. The error forces the author to pick one.","triggerScenarios":"context.report({ suggest: [{ messageId: 'useBar', desc: 'Replace with bar', fix }] }) — both messageId and desc present. The check at file-report.js:413 `if (suggestion.desc)` inside the messageId branch throws.","commonSituations":"Converting a suggestion from inline desc to messageId and forgetting to remove desc; copy-pasting a suggestion template; merging two suggestions incorrectly.","solutions":["Decide which representation you want and delete the other: keep messageId for centralized messages, or keep desc for one-off inline text.","If migrating to messageId, remove the desc property and ensure meta.messages has the key.","Add an ESLint-level or project-level lint check that suggestion objects use exactly one of messageId/desc."],"exampleFix":"// before\ncontext.report({\n  node,\n  suggest: [{ messageId: 'useBar', desc: 'Replace with bar', fix(fixer) { return fixer.replaceText(node, 'bar'); } }]\n});\n\n// after\ncontext.report({\n  node,\n  suggest: [{ messageId: 'useBar', fix(fixer) { return fixer.replaceText(node, 'bar'); } }]\n});","handlingStrategy":"validation","validationCode":"function assertSuggestionHasOneLabel(suggestion) {\n  const hasId = Boolean(suggestion.messageId);\n  const hasDesc = Boolean(suggestion.desc);\n  if (hasId && hasDesc) {\n    throw new Error('Suggestion must not define both messageId and desc');\n  }\n}","typeGuard":"function hasExactlyOneLabel(s) {\n  return Boolean(s.messageId) !== Boolean(s.desc); // XOR\n}","tryCatchPattern":null,"preventionTips":["Standardize your team's rule style on exactly one of messageId or desc.","Add a pre-commit/test step that scans suggestion objects for the both-present case.","When migrating from desc to messageId, delete desc in the same commit."],"tags":["eslint","custom-rule","suggestions","messageid","validation"],"analyzedSha":"f131c034ad91bbf06bcbb6b5e931447a8e419a46","analyzedAt":"2026-08-03T19:53:24.025Z","schemaVersion":2}