Choose identifier names that are unambiguous, self-explanatory, and consistent with existing conventions already used elsewhere in the codebase or in the relevant external spec/ecosystem. Before introducing a new name, check how similar concepts are named in sibling modules (e.g. other middlewares, adapters, generics) and reuse that convention rather than inventing a new one.
Specifically:
strict was rejected because it was unclear whether true meant “always redirect” or “only on 404”; it was replaced with the explicit alwaysRedirect). Likewise avoid overloading well-known terms incorrectly (e.g. don’t call something a “Factory” if it’s a single function, not something that creates multiple instances — use ExceptionFunction/HTTPExceptionFunction instead).headerName to configure a header, a new middleware with the same concept should also use headerName rather than header or authorization.export const languageDetector = ... return async function languageDetector(...)), and always use a named function (not an anonymous one) so it’s identifiable in stack traces/debugging tools.HonoJsonWebKey extends the standard JsonWebKey) and export it consistently from the shared types module.srcdoc, datetime, disablePictureInPicture).E for Env, not TEnv) and keep naming consistent across platform-specific builds (e.g. keep toSSG consistent between deno/bun adapters instead of renaming per-platform).Uint → Unit) since these become part of the public API and are hard to fix later.Example:
// Bad: ambiguous option name, anonymous function, inconsistent with sibling middleware
export const myMiddleware = (options: { authorization?: string; strict?: boolean }) => {
return async (c, next) => { ... }
}
// Good: name matches existing convention, named function, avoids ambiguity
export const myMiddleware = (options: { headerName?: string; alwaysRedirect?: boolean }) => {
return async function myMiddleware(c, next) { ... }
}
Applying this standard reduces confusion during code review, prevents churn from repeated renames, and keeps the public API coherent across the whole library.