代码风格
Nuxt 开箱即用地支持 ESLint。
ESLint
Nuxt 的推荐方法是使用 @nuxt/eslint
模块启用 ESLint 支持,该模块将为你设置项目感知的 ESLint 配置。
¥The recommended approach for Nuxt is to enable ESLint support using the @nuxt/eslint
module, that will setup project-aware ESLint configuration for you.
该模块是为 新的 ESLint 扁平配置格式 设计的,但同时也适用于 自 ESLint v9 起的默认格式。如果你使用的是旧版
.eslintrc
配置,则需要 使用 @nuxt/eslint-config
手动配置。我们强烈建议你迁移到扁平化配置,以确保面向未来。¥The module is designed for the new ESLint flat config format with is the default format since ESLint v9. If you are using the legacy .eslintrc
config, you will need to configure manually with @nuxt/eslint-config
. We highly recommend you to migrate over the flat config to be future-proof.快速设置
¥Quick Setup
npx nuxi module add eslint
启动你的 Nuxt 应用,eslint.config.mjs
文件将在你的项目根目录下生成。你可以根据需要进行自定义。
¥Start your Nuxt app, a eslint.config.mjs
file will be generated under your project root. You can customize it as needed.
你可以在 Nuxt ESLint 文档 中了解有关模块和自定义功能的更多信息。
¥You can learn more about the module and customizations in Nuxt ESLint's documentation.