当前位置:网站首页>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
边栏推荐
- 一年顶十年
- 【Leetcode】14. 最長公共前綴
- 七张图,学会做有价值的经营分析
- Shutter: action feedback
- Chmod command principle and usage details [easy to understand]
- Configure MySQL under Linux to authorize a user to access remotely, which is not restricted by IP
- Schoolbag novel multithreaded crawler [easy to understand]
- AP and F107 data sources and processing
- Eth data set download and related problems
- dstat使用[通俗易懂]
猜你喜欢
随机推荐
剑指 Offer 25. 合并两个排序的链表
visibilitychange – 指定标签页可见时,刷新页面数据
2322. Remove the minimum fraction of edges from the tree (XOR and & Simulation)
[leetcode] 14. Préfixe public le plus long
dstat使用[通俗易懂]
如何与博格华纳BorgWarner通过EDI传输业务数据?
Geoserver: publishing PostGIS data sources
Configure ARP table entry restrictions and port security based on the interface (restrict users' private access to fool switches or illegal host access)
剑指 Offer 22. 链表中倒数第k个节点
Weili holdings listed on the Hong Kong Stock Exchange: with a market value of HK $500million, it contributed an IPO to Hubei
Nexus簡介及小白使用IDEA打包上傳到Nexus3私服詳細教程
Deep learning image data automatic annotation [easy to understand]
一年頂十年
社交元宇宙平台Soul冲刺港股:年营收12.8亿 腾讯是股东
剑指 Offer 21. 调整数组顺序使奇数位于偶数前面
871. Minimum refueling times
QWebEngineView崩溃及替代方案
Use of openpose
剑指 Offer 27. 二叉树的镜像
线性规划例题 投资的收益与风险