Code examples in documentation must be technically correct, complete, and non-misleading. Before merging a doc change:
myFindBestMatch instead of didYouMean) or add a comment explaining it must be implemented, so a first-time user copying the snippet doesn’t get a confusing “not defined” error.Example of a misleading snippet to avoid:
// BAD: didYouMean looks like a real API but isn't provided by the library
program.on('command:*', function (operands) {
console.error(`Did you mean '${didYouMean(operands[0])}'?`);
});
// GOOD: name clearly signals it's something the user must implement
const suggestion = myFindBestMatch(operands[0], availableCommands);
console.error(`Did you mean '${suggestion}'?`);