使Vue开发如鱼得水的 VS Code 扩展

开发 前端
作为一个 Vue 搬砖工,我一直在为 Vue 开发寻找合适的 VS Code 扩展。以下是一些好用的扩展,可以让我们在搬砖时更加轻松。

[[407611]]

本文转载自微信公众号「前端有道」,作者星野丶。转载本文请联系前端有道公众号。

作为一个 Vue 搬砖工,我一直在为 Vue 开发寻找合适的 VS Code 扩展。以下是一些好用的扩展,可以让我们在搬砖时更加轻松。

目录

  • Vetur 开发Vue的童鞋必装插件之一
  • Volar 开发Vue3.0的童鞋必装插件之一
  • Simplified Language 简体语言包
  • 翻译(英汉词典)
  • Material Icon Theme 图标主题
  • VSCode Icons 图标主题
  • Bracket Pair Colorizer 彩色的括号
  • GitLens 增强Git工具
  • Git History
  • Path Intellisense 路径智能提示
  • Auto Rename Tag 自动关闭标签
  • Auto Close Tag 自动修改标签名
  • Code Runner 运行代码
  • Live Server 搭建本地服务器的静态页面
  • Prettier - Code formatter 代码格式化
  • ESlint 代码检测

Vetur

这款插件相信不用我多说,想必大家都知道或者用过,它提供了 Vue 特定的语法语义突出显示、代码片段和API语法以错误检查调试等。图片

官方地址:https://marketplace.visualstudio.com/items?itemName=octref.vetur

Volar(Vue3.0开发)

如果你的项目Vue3.0推荐用这款插件,体验上会更好。

Volar 是一个专为 Vue 3 构建的语言支持插件,它基于@vue/reactivity按需计算 TypeScript 来优化类似于原生 TypeScript 语言服务的性能。

官方地址:https://marketplace.visualstudio.com/items?itemName=johnsoncodehk.volar

Chinese (Simplified) Language Pack for Visual Studio Code

这款插件把VSCode的英文转换成中文。对我我这种英语渣渣特别刚需。而且这个是官方汉化包,理解没毛病。

每当VS code软件更新后,有变会英文,只需要关闭软件重启就行,或者重新安装一下这款插件。

官方地址:Chinese (Simplified) Language Pack for Visual Studio Code

翻译(英汉词典) 代码翻译

在线翻译,翻译出来的结果真慢,吐槽。这款本地77万词条英汉词典,不依赖任何在线翻译API,无查询次数限制,秒输出结果。

这款插件支持驼峰、小驼峰、下划线等等写法来写变量名、属性名、类名和方法名的。

-w1205

官方地址:https://marketplace.visualstudio.com/items?itemName=CodeInChinese.EnglishChineseDictionary

Material Icon Theme

非常齐全的图标,可以说你想要包含在这里面,只截了其中一小部分图。

-w895

官方地址:https://marketplace.visualstudio.com/items?itemName=PKief.material-icon-theme

vscode-icons

这一款是VSCode官方的图标主题包,看个人喜好选择图标库。效果如下

-w330

官方地址:https://marketplace.visualstudio.com/items?itemName=vscode-icons-team.vscode-icons

Bracket Pair Colorizer

这个插件使用颜色来标识匹配的括号。代码非常多的情况,括号也就变的非常多,如果删除某个属性名对象,没有颜色区分可以就会误删。

不过正常来说不推荐括号写的很多,推荐用扁平化写法,虽然颜色区分代码过长,看的也是脑壳疼。

官方地址:https://marketplace.visualstudio.com/items?itemName=CoenraadS.bracket-pair-colorizer

GitLens

增强Git功能构建到Visual Studio代码可视化代码作者一眼就通过Git指责注释和代码镜头,无缝导航和探索Git存储库。

官方地址:https://marketplace.visualstudio.com/items?itemName=eamodio.gitlens

Git History

查看git日志、文件历史、比较分支或提交。

当我们需要查看文件的历史,可能会借助另外一个Git UI工具查看,耶,只要点击文件的右上角图标就能看到历史代码还有代码差异性。

官方地址:https://marketplace.visualstudio.com/items?itemName=donjayamanne.githistory

Path Intellisense 路径智能提示

当我们需要引入某个文件或者图片,文件夹层级可能很多,我们可以通过这款插件来提示我们当前下的文件有哪些。

官方地址:https://marketplace.visualstudio.com/items?itemName=christian-kohler.path-intellisense

Auto Rename Tag

自动重命名成对的HTML/XML标签。

当我们修改的标签时就会生成

官方地址:https://marketplace.visualstudio.com/items?itemName=formulahendry.auto-rename-tag

Auto Close Tag

自动添加HTML/XML关闭标签。

当我们写下时就会生成

官方地址:https://marketplace.visualstudio.com/items?itemName=formulahendry.auto-close-tag

Code Runner

运行代码片段或多种语言的代码文件,支持C、Java、JavaScript、PHP、Python等

只需要点击鼠标右键,选择 Run Code 就能得到结果

官方地址:https://marketplace.visualstudio.com/items?itemName=formulahendry.code-runner

Live Server

在本地服务器搭建自动重新加载静态特性HTML页面。

html页面中鼠标右键选择 open with Live Server

官方地址:https://marketplace.visualstudio.com/items?itemName=ritwickdey.LiveServer

Prettier - Code formatter

Prettier是一个代码格式化程序。它通过解析代码并使用它自己的规则重新打印代码来强制实现一致的样式,这些规则考虑到最大行长度,在必要时格式化代码。

  1. // vscode setting.json 
  2.   "editor.formatOnSave"false, // 在保存时格式化文件 
  3.   "editor.defaultFormatter""esbenp.prettier-vscode"
  4.   "[javascript]": { 
  5.     "editor.defaultFormatter""esbenp.prettier-vscode" 
  6.   }, 
  7.   "[vue]": { 
  8.     "editor.defaultFormatter""esbenp.prettier-vscode" 
  9.   } 

官方地址:https://marketplace.visualstudio.com/items?itemName=esbenp.prettier-vscode

ESlint

在一个多人协同开发的团队中,统一的代码编写规范非常重要。一套规范可以让我们编写的代码达到一致的风格,提高代码的可读性和统一性。自然维护性也会有所提高。

以下eslint规范代码依托于 vue 官方的 eslint 规则 eslint-config-vue 做了少许的修改。大家可以按照自己的需求进行定制化配置。

  1. // .eslintrc.js 
  2. module.exports = { 
  3.   root: true
  4.   parserOptions: { 
  5.     parser: 'babel-eslint'
  6.     sourceType: 'module' 
  7.   }, 
  8.   env: { 
  9.     browser: true
  10.     node: true
  11.     es6: true
  12.   }, 
  13.   extends: ['plugin:vue/recommended''eslint:recommended'], 
  14.  
  15.   // add your custom rules here 
  16.   //it is base on https://github.com/vuejs/eslint-config-vue 
  17.   rules: { 
  18.     "vue/max-attributes-per-line": [2, { 
  19.       "singleline": 10, 
  20.       "multiline": { 
  21.         "max": 1, 
  22.         "allowFirstLine"false 
  23.       } 
  24.     }], 
  25.     "vue/singleline-html-element-content-newline""off"
  26.     "vue/multiline-html-element-content-newline":"off"
  27.     "vue/name-property-casing": ["error""PascalCase"], 
  28.     "vue/no-v-html""off"
  29.     'accessor-pairs': 2, 
  30.     'arrow-spacing': [2, { 
  31.       'before'true
  32.       'after'true 
  33.     }], 
  34.     'block-spacing': [2, 'always'], 
  35.     'brace-style': [2, '1tbs', { 
  36.       'allowSingleLine'true 
  37.     }], 
  38.     'camelcase': [0, { 
  39.       'properties''always' 
  40.     }], 
  41.     'comma-dangle': [2, 'never'], 
  42.     'comma-spacing': [2, { 
  43.       'before'false
  44.       'after'true 
  45.     }], 
  46.     'comma-style': [2, 'last'], 
  47.     'constructor-super': 2, 
  48.     'curly': [2, 'multi-line'], 
  49.     'dot-location': [2, 'property'], 
  50.     'eol-last': 2, 
  51.     'eqeqeq': ["error""always", {"null""ignore"}], 
  52.     'generator-star-spacing': [2, { 
  53.       'before'true
  54.       'after'true 
  55.     }], 
  56.     'handle-callback-err': [2, '^(err|error)$'], 
  57.     'indent': [2, 2, { 
  58.       'SwitchCase': 1 
  59.     }], 
  60.     'jsx-quotes': [2, 'prefer-single'], 
  61.     'key-spacing': [2, { 
  62.       'beforeColon'false
  63.       'afterColon'true 
  64.     }], 
  65.     'keyword-spacing': [2, { 
  66.       'before'true
  67.       'after'true 
  68.     }], 
  69.     'new-cap': [2, { 
  70.       'newIsCap'true
  71.       'capIsNew'false 
  72.     }], 
  73.     'new-parens': 2, 
  74.     'no-array-constructor': 2, 
  75.     'no-caller': 2, 
  76.     'no-console''off'
  77.     'no-class-assign': 2, 
  78.     'no-cond-assign': 2, 
  79.     'no-const-assign': 2, 
  80.     'no-control-regex': 0, 
  81.     'no-delete-var': 2, 
  82.     'no-dupe-args': 2, 
  83.     'no-dupe-class-members': 2, 
  84.     'no-dupe-keys': 2, 
  85.     'no-duplicate-case': 2, 
  86.     'no-empty-character-class': 2, 
  87.     'no-empty-pattern': 2, 
  88.     'no-eval': 2, 
  89.     'no-ex-assign': 2, 
  90.     'no-extend-native': 2, 
  91.     'no-extra-bind': 2, 
  92.     'no-extra-boolean-cast': 2, 
  93.     'no-extra-parens': [2, 'functions'], 
  94.     'no-fallthrough': 2, 
  95.     'no-floating-decimal': 2, 
  96.     'no-func-assign': 2, 
  97.     'no-implied-eval': 2, 
  98.     'no-inner-declarations': [2, 'functions'], 
  99.     'no-invalid-regexp': 2, 
  100.     'no-irregular-whitespace': 2, 
  101.     'no-iterator': 2, 
  102.     'no-label-var': 2, 
  103.     'no-labels': [2, { 
  104.       'allowLoop'false
  105.       'allowSwitch'false 
  106.     }], 
  107.     'no-lone-blocks': 2, 
  108.     'no-mixed-spaces-and-tabs': 2, 
  109.     'no-multi-spaces': 2, 
  110.     'no-multi-str': 2, 
  111.     'no-multiple-empty-lines': [2, { 
  112.       'max': 1 
  113.     }], 
  114.     'no-native-reassign': 2, 
  115.     'no-negated-in-lhs': 2, 
  116.     'no-new-object': 2, 
  117.     'no-new-require': 2, 
  118.     'no-new-symbol': 2, 
  119.     'no-new-wrappers': 2, 
  120.     'no-obj-calls': 2, 
  121.     'no-octal': 2, 
  122.     'no-octal-escape': 2, 
  123.     'no-path-concat': 2, 
  124.     'no-proto': 2, 
  125.     'no-redeclare': 2, 
  126.     'no-regex-spaces': 2, 
  127.     'no-return-assign': [2, 'except-parens'], 
  128.     'no-self-assign': 2, 
  129.     'no-self-compare': 2, 
  130.     'no-sequences': 2, 
  131.     'no-shadow-restricted-names': 2, 
  132.     'no-spaced-func': 2, 
  133.     'no-sparse-arrays': 2, 
  134.     'no-this-before-super': 2, 
  135.     'no-throw-literal': 2, 
  136.     'no-trailing-spaces': 2, 
  137.     'no-undef': 2, 
  138.     'no-undef-init': 2, 
  139.     'no-unexpected-multiline': 2, 
  140.     'no-unmodified-loop-condition': 2, 
  141.     'no-unneeded-ternary': [2, { 
  142.       'defaultAssignment'false 
  143.     }], 
  144.     'no-unreachable': 2, 
  145.     'no-unsafe-finally': 2, 
  146.     'no-unused-vars': [2, { 
  147.       'vars''all'
  148.       'args''none' 
  149.     }], 
  150.     'no-useless-call': 2, 
  151.     'no-useless-computed-key': 2, 
  152.     'no-useless-constructor': 2, 
  153.     'no-useless-escape': 0, 
  154.     'no-whitespace-before-property': 2, 
  155.     'no-with': 2, 
  156.     'one-var': [2, { 
  157.       'initialized''never' 
  158.     }], 
  159.     'operator-linebreak': [2, 'after', { 
  160.       'overrides': { 
  161.         '?''before'
  162.         ':''before' 
  163.       } 
  164.     }], 
  165.     'padded-blocks': [2, 'never'], 
  166.     'quotes': [2, 'single', { 
  167.       'avoidEscape'true
  168.       'allowTemplateLiterals'true 
  169.     }], 
  170.     'semi': [2, 'never'], 
  171.     'semi-spacing': [2, { 
  172.       'before'false
  173.       'after'true 
  174.     }], 
  175.     'space-before-blocks': [2, 'always'], 
  176.     'space-before-function-paren': [2, 'never'], 
  177.     'space-in-parens': [2, 'never'], 
  178.     'space-infix-ops': 2, 
  179.     'space-unary-ops': [2, { 
  180.       'words'true
  181.       'nonwords'false 
  182.     }], 
  183.     'spaced-comment': [2, 'always', { 
  184.       'markers': ['global''globals''eslint''eslint-disable''*package''!'','
  185.     }], 
  186.     'template-curly-spacing': [2, 'never'], 
  187.     'use-isnan': 2, 
  188.     'valid-typeof': 2, 
  189.     'wrap-iife': [2, 'any'], 
  190.     'yield-star-spacing': [2, 'both'], 
  191.     'yoda': [2, 'never'], 
  192.     'prefer-const': 2, 
  193.     'no-debugger': process.env.NODE_ENV === 'production' ? 2 : 0, 
  194.     'object-curly-spacing': [2, 'always', { 
  195.       objectsInObjects: false 
  196.     }], 
  197.     'array-bracket-spacing': [2, 'never'
  198.   } 

 

官方地址:https://marketplace.visualstudio.com/items?itemName=dbaeumer.vscode-eslint

 

责任编辑:武晓燕 来源: 前端有道
相关推荐

2021-12-28 09:40:48

VS Code工具代码

2023-09-08 10:23:13

JavaScriptNPM模块

2020-02-04 09:00:00

物联网开发VS CodeIOT

2019-04-23 12:10:00

前端开发编程

2023-06-05 11:26:23

2021-02-03 11:19:52

Go语言Go团队服务器

2021-12-27 10:57:04

SwiftXcodeSSWG

2022-04-20 09:02:57

架构

2022-01-10 10:48:34

SorbetVS CodeRuby

2021-01-26 02:29:04

VS CodePython开发

2021-04-21 07:51:06

Vue 开发VS CodeVetur

2022-04-06 10:16:08

微软Python 扩展Pylint 扩展

2022-05-07 09:43:15

Python微软扩展程序

2023-08-09 13:28:58

2021-01-25 15:18:37

Python 开发编程语言

2021-08-22 17:22:31

VS Code容器开发人员

2022-06-17 07:44:40

VSCode C#开源

2021-02-02 21:42:30

VS Code编辑器开发

2020-07-06 14:54:17

Python 开发编程语言

2020-11-16 19:18:15

Jupyter微软编程
点赞
收藏

51CTO技术栈公众号