{"record":{"id":"a4815117a649f2d6","repo":"oxc-project/oxc","slug":"typo-may-be-a-typo-did-you-mean-suggestion","errorCode":null,"errorMessage":"`{typo}` may be a typo. Did you mean `{suggestion}`?","messagePattern":"`(.+?)` may be a typo\\. Did you mean `(.+?)`\\?","errorType":"validation","errorClass":"OxcDiagnostic","httpStatus":null,"severity":"warning","filePath":"crates/oxc_linter/src/rules/nextjs/no_typos.rs","lineNumber":16,"sourceCode":"use oxc_ast::{\n    AstKind,\n    ast::{BindingPattern, Declaration},\n};\nuse oxc_diagnostics::OxcDiagnostic;\nuse oxc_macros::declare_oxc_lint;\nuse oxc_span::{Span, best_match};\n\nuse crate::{\n    AstNode,\n    context::{ContextHost, LintContext},\n    rule::Rule,\n};\n\nfn no_typos_diagnostic(typo: &str, suggestion: &str, span: Span) -> OxcDiagnostic {\n    OxcDiagnostic::warn(format!(\"`{typo}` may be a typo. Did you mean `{suggestion}`?\"))\n        .with_help(format!(\"Change `{typo}` to `{suggestion}`\"))\n        .with_label(span)\n}\n\n#[derive(Debug, Default, Clone)]\npub struct NoTypos;\n\ndeclare_oxc_lint!(\n    /// ### What it does\n    ///\n    /// Detects common typos in Next.js data fetching function names.\n    ///\n    /// ### Why is this bad?\n    ///\n    /// Next.js will not call incorrectly named data fetching functions, causing pages to render without expected data.\n    ///\n    /// ### Examples\n    ///","sourceCodeStart":1,"sourceCodeEnd":34,"githubUrl":"https://github.com/oxc-project/oxc/blob/a3d33dda7cb69da23db4fcaa2c0c05de61e760a1/crates/oxc_linter/src/rules/nextjs/no_typos.rs#L1-L34","documentation":"Warning from oxlint rule `nextjs/no-typos`. Next.js opts pages into data fetching by exact export name (`getInitialProps`, `getStaticProps`, `getStaticPaths`, `getServerSideProps`, ...). A near-miss spelling silently opts the page out: it renders with no data and no build error. The rule uses edit-distance matching (`oxc_span::best_match`) to flag misspelled exports and suggest the intended name.","triggerScenarios":"An exported function whose name is within edit distance of a known Next.js data-fetching hook but not exactly equal — e.g. `getStaicProps`, `getServerSideProp`, or wrong casing such as `getinitialprops`.","commonSituations":"Typos neither TypeScript nor webpack catch (the export is simply unused); renames during refactors; mixing up singular/plural (`getStaticPath`).","solutions":["Rename the export to the exact suggested name with exact casing: `getStaticProps`, `getStaticPaths`, `getServerSideProps`, `getInitialProps`.","Add a type or unit check asserting page-level data-fetching exports are actually consumed, so unused exports surface early."],"exampleFix":"// before\nexport async function getStaicProps() { /* never called by Next.js */ }\n\n// after\nexport async function getStaticProps() { return { props: {} }; }","handlingStrategy":"type-guard","validationCode":"const NEXT_FETCHERS = new Set([\n  'getInitialProps', 'getStaticProps', 'getStaticPaths', 'getServerSideProps',\n]);\n// fail when a page exports something within typo distance but not exact:\nfor (const name of Object.keys(pageExports)) {\n  if (!NEXT_FETCHERS.has(name) && /get/i.test(name)) console.warn('suspicious export:', name);\n}","typeGuard":"function isNextDataFetcher(name: string): boolean {\n  return new Set(['getInitialProps', 'getStaticProps', 'getStaticPaths', 'getServerSideProps']).has(name);\n}","tryCatchPattern":null,"preventionTips":["Copy data-fetching names from the docs, casing included: getStaticProps, getStaticPaths, getServerSideProps.","Add a page test asserting the fetcher actually runs (props arrive), which a typo would fail.","Enable nextjs/no-typos in CI; it catches the near-miss before the page ships data-less."],"tags":["nextjs","typo","data-fetching","lint"],"backgroundTag":"misspelled-data-fetching-export","analyzedSha":"a3d33dda7cb69da23db4fcaa2c0c05de61e760a1","analyzedAt":"2026-08-20T07:01:07.079Z","contentChangedAt":"2026-08-20T07:01:07.079Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}