Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Issue while configuring eslint

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 :

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

This can happen due to following:

  1. First and foremost, you are using the eslint-plugin-import which has a rule import/no-extraneous-dependencies.
  2. Second, your ESLint is also checking and validating vite.config.js for the lint errors and your vite.config.js has import statement referring to vite 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...
})
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading