Skip to content
← Back to rules

nextjs/no-typos Correctness

An auto-fix is available for this rule.

它的作用

检测 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() {}

如何使用

To enable this rule using the config file or in the CLI, you can use:

json
{
  "plugins": ["nextjs"],
  "rules": {
    "nextjs/no-typos": "error"
  }
}
ts
import { defineConfig } from "oxlint";

export default defineConfig({
  plugins: ["nextjs"],
  rules: {
    "nextjs/no-typos": "error",
  },
});
bash
oxlint --deny nextjs/no-typos --nextjs-plugin

版本

此规则于 v0.2.1 中添加。

参考资料