@next/next/no-typos
Disallow misspellings of getStaticProps, getStaticPaths and getServerSideProps
has suggestions
Also called nextjs/no-typos
Next.js finds a page's data fetching functions by their exact names. If you export getStaticProp or getserverSideProps, nothing complains. The function is never called and the page renders without its props.
The rule checks files under a pages directory, except pages/api. It reports an exported function or variable with a name that's one character away from getStaticProps, getStaticPaths or getServerSideProps.
--fix-suggestions corrects the name.
Configure#
Off by default. To turn it on:
bunfig.toml
[lint.rules]
"@next/next/no-typos" = "error" # or "warn"Examples#
pages/posts.jsx1 problem
export async function getStaticPropgetStaticProp may be a typo. Did you mean getStaticProps?() {
return { props: { posts: await loadPosts() } };
}
export default function Posts({ posts }) {
return <PostList posts={posts} />;
}pages/account.jsx1 problem
export const getserverSidePropsgetserverSideProps may be a typo. Did you mean getServerSideProps? = async ({ req }) => {
return { props: { user: await loadUser(req) } };
};pages/posts.jsxNo problems
export async function getStaticProps() {
return { props: { posts: await loadPosts() } };
}
export default function Posts({ posts }) {
return <PostList posts={posts} />;
}Outside pages, the names mean nothing to Next.js:
lib/posts.jsNo problems
export async function getStaticProp() {
return loadPosts();
}