Generate ESLint config from current Nuxt settings
—
Quality
Pending
Does it follow best practices?
Impact
Pending
No eval scenarios have been run
Real-time ESLint checking during development with Vite or Webpack integration. The module provides seamless integration with your development workflow, showing linting errors and warnings directly in your terminal and browser during development.
Configuration options for ESLint checker integration with the development server.
/**
* Configuration options for ESLint checker integration
*/
interface CheckerOptions {
/**
* Use ESLint cache to improve performance
* @default true
*/
cache?: boolean;
/**
* ESLint config type
* Default to `flat` unless env `ESLINT_USE_FLAT_CONFIG` is set to `false`
* @default 'flat'
*/
configType?: 'flat' | 'eslintrc';
/**
* Files to include for linting
* @default [`${nuxt.options.srcDir}/**/*.{js,jsx,ts,tsx,vue}`]
*/
include?: string[];
/**
* Files to exclude from linting
* @default ['**/node_modules/**', nuxt.options.buildDir]
*/
exclude?: string[];
/**
* ESLint formatter for the output
* @default 'stylish'
* @see https://eslint.org/docs/user-guide/formatters/
*/
formatter?: string;
/**
* Path to the ESLint module
* @default 'eslint' or 'eslint/use-at-your-own-risk' based on configType
*/
eslintPath?: string;
/**
* Lint on start
* @default true
*/
lintOnStart?: boolean;
/**
* The warnings found will printed
* @default true
*/
emitWarning?: boolean;
/**
* The errors found will printed
* @default true
*/
emitError?: boolean;
/**
* Run ESLint fix
* @default false
*/
fix?: boolean;
/**
* Vite specific options
*/
vite?: ViteCheckerOptions;
/**
* Webpack specific options
* @see https://www.npmjs.com/package/eslint-webpack-plugin
*/
webpack?: WebpackCheckerOptions;
}For projects using Nuxt with Vite, the module integrates with vite-plugin-eslint2.
/**
* Vite-specific ESLint integration options
* Extends vite-plugin-eslint2 options
*/
interface ViteCheckerOptions {
/** Run linting in a worker thread */
lintInWorker?: boolean;
/** Additional vite-plugin-eslint2 specific options */
[key: string]: any;
}Usage Examples:
// Basic Vite integration
export default defineNuxtConfig({
modules: ['@nuxt/eslint'],
eslint: {
checker: {
vite: {
lintInWorker: true
}
}
}
})For projects using Nuxt with Webpack, the module integrates with eslint-webpack-plugin.
/**
* Webpack-specific ESLint integration options
* Uses eslint-webpack-plugin under the hood
*/
interface WebpackCheckerOptions {
/** Context directory for linting */
context?: string;
/** Files pattern to lint */
files?: string[];
/** Only lint changed files */
lintDirtyModulesOnly?: boolean;
/** Additional eslint-webpack-plugin options */
[key: string]: any;
}Usage Examples:
// Basic Webpack integration
export default defineNuxtConfig({
modules: ['@nuxt/eslint'],
eslint: {
checker: {
webpack: {
lintDirtyModulesOnly: true
}
}
}
})The module automatically detects which ESLint config format to use.
/**
* ESLint configuration format detection
*/
type ConfigType = 'flat' | 'eslintrc';
/**
* Automatic config type detection based on environment
* Defaults to 'flat' unless ESLINT_USE_FLAT_CONFIG=false
*/
function detectConfigType(): ConfigType;The module automatically watches ESLint configuration files for changes.
/**
* ESLint config files that are watched for changes
*/
const watchedConfigFiles: string[] = [
'.eslintignore',
'.eslintrc',
'.eslintrc.js',
'.eslintrc.yaml',
'.eslintrc.yml',
'.eslintrc.json',
'eslint.config.js',
'eslint.config.mjs',
'eslint.config.cjs'
];Usage Examples:
// Enable checker with custom file patterns
export default defineNuxtConfig({
modules: ['@nuxt/eslint'],
eslint: {
checker: {
include: ['src/**/*.{ts,vue}'],
exclude: ['src/generated/**'],
formatter: 'unix',
fix: true
}
}
})
// Checker with different config type
export default defineNuxtConfig({
modules: ['@nuxt/eslint'],
eslint: {
checker: {
configType: 'eslintrc',
eslintPath: 'eslint'
}
}
})
// Disable warnings, only show errors
export default defineNuxtConfig({
modules: ['@nuxt/eslint'],
eslint: {
checker: {
emitWarning: false,
emitError: true,
lintOnStart: false
}
}
})The checker integration enhances the development workflow:
The module automatically detects the build system and integrates appropriately:
vite-plugin-eslint2 for integrationeslint-webpack-plugin for integration/**
* Builder detection based on Nuxt configuration
* Automatically determines which ESLint integration to use
*/
interface BuilderDetection {
/** Detected builder name */
builder: '@nuxt/vite-builder' | '@nuxt/webpack-builder' | 'unknown';
/** Whether ESLint integration is supported */
supported: boolean;
/** Integration plugin to use */
plugin?: 'vite-plugin-eslint2' | 'eslint-webpack-plugin';
}The development server integration includes comprehensive error handling:
Install with Tessl CLI
npx tessl i tessl/npm-nuxt--eslint