网页
综合
更新时间 2026-11-16 04:29:57
@nuxt/eslint-config · @nuxt/eslint · Nuxt Modules
自动蜘蛛
nuxt.com
正文约 3394 字
Shared ESLint config for Nuxt projects. Unopinionated by default, but customizable.
Since v1.0, this package only provides the flat config format and requires ESLint v9 or v10. The entry @nuxt/eslint-config provides a factory function to create a project-aware ESLint config for Nuxt projects. It is unopinionated by default but customizable by passing options to the factory function. Used by @nuxt/eslint module to generate project-aware ESLint config.
You might also want to add a script entry to your package.json:
Note that createConfigForNuxt() returns a chainable FlatConfigComposer instance from eslint-flat-config-utils which allows you to manipulate the ESLint flat config with ease. If you want to combine with other configs, you can use the .append() method:
FlatConfigComposer is also a Promise object, that you can use await to get the final config object.
You can also pass your custom flat configs as extra arguments, they are appended after the Nuxt configs:
This config also provides rules for module/library authors. You can enable them by setting the features.tooling option to true:
This will enable rules with unicorn, regexp and jsdoc plugins, to ensure your module is following best practices.
You can also turn them off individually by providing an object with the rule names set to false:
Similar to the ESLint Module, you can opt in by setting stylistic to true in the features options.
Learn more about all the available options in the ESLint Stylistic documentation.
TypeScript support is enabled automatically when typescript is installed in your project. This config also provides type-aware rules for TypeScript and Vue. You can enable them by setting features.typescript to an object with tsconfigPath the path to your tsconfig.json file.
The TypeScript rules use the strict preset by default. Set features.typescript.strict to false to use the recommended preset only, or features.typescript to false to disable TypeScript support.
To also format CSS, HTML, GraphQL and other files with ESLint, set features.formatters to true or to an object picking the file types. It requires eslint-plugin-format to be installed. See the Formatters recipe for the details.
The import rules use eslint-plugin-import-x by default. You can switch to the lighter eslint-plugin-import-lite with features.import.package, or disable the import rules with features.import: false:
When features.stylistic is enabled, the keys of your nuxt.config are sorted in a recommended order by the nuxt/nuxt-config-keys-order rule. You can turn it on or off independently with features.nuxt.sortConfigKeys:
Like the ESLint Module, set features.standalone to false to only include the Nuxt-specific rules, without the JavaScript, TypeScript, Vue and import setup, when you combine it with another config preset.
Without the module, the config cannot read your Nuxt project structure. It assumes your source code is in the project root or in app/, following both the Nuxt 3 and Nuxt 4 conventions, and derives the directories of pages, layouts, components and others from it. Use dirs to match your project when it differs:
Editor setup, formatting, config customizations, the dev server checker and other recipes for the ESLint module.
ESLint plugin of additional rules for Nuxt.
Stay updated on new releases and features, guides, and community updates.
Copyright © 2016-2026 Nuxt - MIT License
本页为82搜索生成的网页快照,内容来自站内索引;演示数据的原文链接仅作示例。