当前位置:网站首页>Vscode + eslint configuration
Vscode + eslint configuration
2022-07-02 17:22:00 【zhangchuan7758】
1. install Node.js
Download link :https://npm.taobao.org/mirrors/node/v8.9.3/node-v8.9.3-x64.msi
2. install VSCode
Download link :https://vscode.cdn.azure.cn/stable/79b44aa704ce542d8ca4a3cc44cfca566e7720f1/VSCodeSetup-x64-1.21.1.exe
Be careful : It is best to check
- take “ adopt Code open ” Add operations to Windows Explorer file context menu
- take “ adopt Code open ” Add operations to Windows Explorer directory context menu
- take Code An editor registered as a supported file type
3. To configure NPM
3.1 NPM Introduce
(1) install Node.js It will be bundled and installed npm.
(2)npm It's a package management tool , Common scenarios :
Allow users from NPM The server downloads third-party packages written by others to use locally ;
Allow users from NPM The server downloads and installs command-line programs written by others to use locally ;
Allow users to send their own packages or command-line programs to NPM Servers for other people to use
3.2 Introduction to global installation and local installation
- If the project needs to rely on specific modules ( for example Node.js China needs require Additional modules introduced ), Modules should be installed in the project directory ( That is, local installation ), This is also npm The default installation mode .
- If you want to use a software package as a command line tool ( For example, we will introduce ESLint Tools ), You need to install it in the global scope ( This can be used in different projects , Prevent reinstallation in each project ).
- npm install <package_name>: Install specific packages locally , It will create a node_modules Catalog , And put the software package and the software package that the software package depends on into the directory .
- npm install <package_name> -g: Install specific packages globally , It will download the software package you installed in the default path of your global installation , This directory will also be added to the environment variable , So you can use the globally installed package from the command line .
3.3 test run npm
npm –v: Check to see if the installation was successful npm, And look at npm Version of
3.4 To configure npm Proxy server for
npm config set proxy <proxy>: Set up npm The proxy server used when downloading resources ,<proxy> For proxy server URL, The format is (<protocol>//<username>:<password>@<hostname>:<port>)
3.5 To configure npm Download the image of the server
npm config set registry <url>: because npm The server of package management is abroad , So the speed of domestic visits will be very slow , You can use the domestic image server to speed up the download ( For example, you can use Taobao's image server npm config set registry http://registry.npm.taobao.org/)
3.6 Check whether the proxy server and mirror server are configured successfully
- npm config get proxy: Check whether the proxy server is configured
- npm config get registry: Check whether the mirror server is configured
4. To configure ESLint
4.1 Globally install the specified version of ESLint
npm install –g [email protected]
4.2 install VSCode ESLint plug-in unit
- Click on VSCode Left activity bar expansion icon ( You can also use shortcut keys Ctrl+Shift+X)
- Search for “ESLint” keyword , And install the plug-in
4.3 binding ESLint Auto format code shortcuts
- file -> Preferences –> Keyboard shortcuts ( You can also use shortcut keys Ctrl+K, Ctrl+S)
- Click... Below the search box keybindings.json
- Expanded on the right keybindings.json In file , Add an object to the end of the array
- { “key”: “shift+alt+f”, “command”: “eslint.executeAutofix” }
- This object indicates that the “shift+alt+f” The shortcut key is bound to “eslint.executeAutofix” On the order , This command uses ESLint AutoFormat code
5. To configure VSCode
5.1 Configure theme
- file -> Preferences -> Color theme ( You can also use shortcut keys Ctrl+K, Ctrl+T)
- Recommended MonoKai Color theme
5.2 Profile icon theme
1. file -> Preferences -> File icon theme ;
2. Recommended download vscode-icons plug-in unit , And use it as the file icon theme
5.3 Configuration editor
- file -> Preferences -> Set up
- The user setting area on the right can be customized VSCode All configurations of , for example
- “editor.tabSize”: 2, // Set the code indentation size of the editor ( Mandatory requirements )
- “editor.fontFamily”: “Consolas, ‘ Microsoft YaHei ’”, // Set the font type of the editor ( It's not mandatory )
6. Use ESLint Check / formatting code
6.1 Use VSCode open , There are many ways
- If in VSCode During installation, check “… Add context menu …”, You can right-click in the project directory , choice Open Width Code
- You can run VSCode( Double-click to open , Or from the command line code), Drag the project directory to VScode IDE in
- Can be opened in VSCode after , choice file -> Open folder , Then select the project directory you want to open
6.2 add to ESLint The configuration file
- Add .eslintrc.js file , This directory can not be the root directory of the project
6.3 Generate code check results
eslint –f html –o eslint-log.html <name>
among ,<name> For the directory or file you want to check
边栏推荐
- Experience home office, feel the completion of the project | community essay solicitation
- 相信自己,这次一把搞定JVM面试
- 移动应用性能工具探索之路
- Notice on holding a salon for young editors of scientific and Technological Journals -- the abilities and promotion strategies that young editors should have in the new era
- 二、mock平台的扩展
- What if the default browser cannot be set?
- Baobab's gem IPO was terminated: Tang Guangyu once planned to raise 1.8 billion to control 47% of the equity
- Sword finger offer 22 The penultimate node in the linked list
- Smart trash can (V) - light up OLED
- 深度之眼(二)——矩阵及其基本运算
猜你喜欢

体验居家办公完成项目有感 | 社区征文

Eye of depth (II) -- matrix and its basic operations

TCP拥塞控制详解 | 2. 背景

畅玩集团冲刺港股:年营收2.89亿 刘辉有53.46%投票权

Sword finger offer 22 The penultimate node in the linked list

LeetCode:1380. Lucky number in matrix -- simple

Qwebengineview crash and alternatives

Smart trash can (V) - light up OLED

智能垃圾桶(五)——点亮OLED

福元医药上交所上市:市值105亿 胡柏藩身价超40亿
随机推荐
Learning Weekly - total issue 60 - 25th week of 2022
二、mock平台的扩展
Introduction to Hisilicon hi3798mv100 set top box chip [easy to understand]
Easy language ABCD sort
相信自己,这次一把搞定JVM面试
What if the default browser cannot be set?
简单介绍BASE64Encoder的使用
Tech Talk 活动预告 | 基于Amazon KVS打造智能视觉产品
綠竹生物沖刺港股:年期內虧損超5億 泰格醫藥與北京亦莊是股東
executescalar mysql_ExecuteScalar()
2322. Remove the minimum fraction of edges from the tree (XOR and & Simulation)
Connect Porsche and 3PL EDI cases
[leetcode] 14. Préfixe public le plus long
七张图,学会做有价值的经营分析
Understand one article: four types of data index system
PCL知识点——体素化网格方法对点云进行下采样
P6774 [noi2020] tears in the era (block)
人生的开始
Error when uploading code to remote warehouse: remote origin already exists
Use of openpose