简体   繁体   中英

How can I intregate EsLint with Vite+react project

When I created react application using create-react-app then there have By default Eslint. that's why we don't want to integrate manually. but when I create React application using Vite there doesn't exist any kind of Lint like Eslint, jslint

please tell me any suggestions. How can I implement eslint at the Vite+react project?

First of all is a good idea to have eslint installed globally in your machine, npm istall -g eslint so you can use the eslint cli to initialize the eslint config file in your projects.

For install it in a React project, if you have never done it before you can follow next steps: Do a npm istall eslint --save-dev or yarn add -D eslint and after it install the eslint plugin for React with npm install eslint-plugin-react --save-dev or yarn add -D eslint-plugin-react .

Once both dependencies are installed just open a terminal in the root of the project and run the command eslint --init that will create an .eslintrc.json file in your project with basic configs added already. You can check the doc for the eslint-plugin-react package to understand better how to add more rules to the file and the rules supported by that plugin. https://www.npmjs.com/package/eslint-plugin-react

And this article should also help you https://medium.com/@RossWhitehouse/setting-up-eslint-in-react-c20015ef35f7

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM