当前位置:网站首页>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
边栏推荐
- Usage of sprintf() function in C language
- IDEA2021.1 安装教程
- Tech talk activity preview | building intelligent visual products based on Amazon kVs
- 【Leetcode】13. Roman numeral to integer
- Nexus简介及小白使用IDEA打包上传到Nexus3私服详细教程
- 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
- Learning Weekly - total issue 60 - 25th week of 2022
- 体验居家办公完成项目有感 | 社区征文
- 详细介绍scrollIntoView()方法属性
- 畅玩集团冲刺港股:年营收2.89亿 刘辉有53.46%投票权
猜你喜欢

【Leetcode】13. 罗马数字转整数

Goodbye, shucang. Alibaba's data Lake construction strategy is really awesome!

剑指 Offer 24. 反转链表

Connect Porsche and 3PL EDI cases

Use of openpose

例题 非线性整数规划

福元医药上交所上市:市值105亿 胡柏藩身价超40亿

Configure ARP table entry restrictions and port security based on the interface (restrict users' private access to fool switches or illegal host access)

Jiuxian's IPO was terminated: Sequoia and Dongfang Fuhai were shareholders who had planned to raise 1billion yuan

PhD battle-11 preview | review and prospect backdoor attack and defense of neural network
随机推荐
剑指 Offer 25. 合并两个排序的链表
书包网小说多线程爬虫[通俗易懂]
深度之眼(三)——矩阵的行列式
[leetcode] 14. Préfixe public le plus long
Understand one article: four types of data index system
Youzan won the "top 50 Chinese enterprise cloud technology service providers" together with Tencent cloud and Alibaba cloud [easy to understand]
2020 "Lenovo Cup" National College programming online Invitational Competition and the third Shanghai University of technology programming competition (a sign in, B sign in, C sign in, D thinking +mst
Smart trash can (V) - light up OLED
深度之眼(二)——矩阵及其基本运算
Vscode setting delete line shortcut [easy to understand]
Seven charts, learn to do valuable business analysis
求简单微分方程
2022 interview questions
ETH数据集下载及相关问题
剑指 Offer 21. 调整数组顺序使奇数位于偶数前面
例题 非线性整数规划
QStyle实现自绘界面项目实战(二)
IPtables中SNAT、DNAT和MASQUERADE的含义
Blog theme "text" summer fresh Special Edition
[fluent] dart data type map type (create map set | initialize map set | traverse map set)