Skip to content
← Back to rules

nextjs/no-typos 正确性

🚧 An auto-fix is planned for this rule, but not implemented at this time.

它的作用

检测 Next.js 数据获取函数名称中的常见拼写错误。

为什么这是个问题?

Next.js 不会调用命名错误的数据获取函数,导致页面在缺少预期数据的情况下渲染。

示例

此规则的不正确代码示例:

javascript
export default function Page() {
  return <div></div>;
}
export async function getServurSideProps() {}

此规则的正确代码示例:

javascript
export default function Page() {
  return <div></div>;
}
export async function getServerSideProps() {}

如何使用

要通过配置文件或命令行启用此规则,可以使用:

json
{
  "plugins": ["nextjs"],
  "rules": {
    "nextjs/no-typos": "error"
  }
}
bash
oxlint --deny nextjs/no-typos --nextjs-plugin

参考资料