eslint
@nuxt/eslint

Project-aware, easy-to-use, extensible and future-proof ESLint integration.

Introduction

All-in-one ESLint integration for Nuxt. It generates a project-aware ESLint flat config and provides the ability to optionally run ESLint check alongside the dev server.

This module is designed for the new ESLint flat config format which is the default format since ESLint v9. It supports ESLint v9 and v10. We recommend you to use the latest version of ESLint to get the best experience.
The legacy .eslintrc config is not supported by this module. We highly recommend you to migrate over the flat config to be future-proof.
The source code of the module is in packages/module on GitHub.

Features

Quick Setup

Run the following command to add the @nuxt/eslint module to your project:

Terminal
npx nuxt add eslint

Once you start your Nuxt app, a eslint.config.mjs file will be generated under your project root. You can customize it as needed.

If you are using TypeScript, you need to install the typescript in your project:

yarn add --dev typescript

Manual Setup

yarn add --dev @nuxt/eslint eslint typescript
nuxt.config.ts
export default defineNuxtConfig({
  modules: [
    '@nuxt/eslint'
  ],
  eslint: {
    // options here
  }
})

And create an eslint.config.mjs file under your project root, with the following content:

eslint.config.mjs
// @ts-check
import withNuxt from './.nuxt/eslint.config.mjs'

export default withNuxt(
  // your custom flat configs go here, for example:
  // {
  //   files: ['**/*.ts', '**/*.tsx'],
  //   rules: {
  //     'no-console': 'off' // allow console.log in TypeScript files
  //   }
  // },
  // {
  //   ...
  // }
)

withNuxt will take the rest arguments of flat configs and append them after Nuxt flat config items. You can either use the Nuxt DevTools panel to inspect the resolved ESLint flat config, or manually run npx @eslint/config-inspector.