Insert Components imports automatically in ESLint.
You can use the nuxt-eslint-auto-components-import module directly, which integrates this plugin.
Suggested to use with nuxt-eslint-auto-explicit-import
Important
Only supports unplugin-vue-components
v28.5.0 or above
In your vite.config.ts
:
import Components from 'unplugin-vue-components/vite'
import { defineConfig } from 'vite'
export default defineConfig({
plugins: [
Components({
// other options...
dumpComponentsInfo: true // <---
})
]
})
And in your eslint.config.js
:
import fs from 'node:fs'
import { createAutoComponentsInsert } from 'eslint-plugin-unimport-components'
export default [
// your other configs...
createAutoComponentsInsert({
imports: JSON.parse(fs.readFileSync('.components-info.json', 'utf-8'))
}),
]
Refer to this file, where you can setup file paths and use it to insert imports.
- This project is heavily inspired by eslint-plugin-unimport