Advertisements
I am facing the following issues while adding new commit, I have project configured with eslint + husky + prettier + react + vite
1:1 error 'vite' should be listed in the project's dependencies, not devDependencies import/no-extraneous-dependencies
2:1 error '@vitejs/plugin-react-swc' should be listed in the project's dependencies, not devDependencies import/no-extraneous-dependencies
>Solution :
This can happen due to following:
- First and foremost, you are using the eslint-plugin-import which has a rule
import/no-extraneous-dependencies
. - Second, your ESLint is also checking and validating
vite.config.js
for the lint errors and yourvite.config.js
hasimport
statement referring tovite
and@vite/plugin-react-swc
packages.
Ideally, you should not lint vite.config.js
file. You should ignore it completely:
// ESLint - .eslintrc / .eslintrc.js / eslint.config.js
{
"ignorePatterns": ["vite.config.js", /* other files to ginore */],
"rules": {
// ... rules
}
}
Or, if you still wish to lint the file but resolve this particular error, then you should put the following comment in your vite.config.js
file:
// vite.config.js
/* eslint-disable import/no-extraneous-dependencies */
import { defineConfig } from 'vite';
export default defineConfig({
// Your Vite config...
})