1 .与编辑器配置集成编辑器配置有助于确保在不同IDE编辑器中处理同一项目的多个开发人员的编码样式一致。
vs代码需要插件。EditorConfig for VS Code
必须在代码主目录下创建.editorconfig文件,以复制以下配置
# http://editor config.org root=true [ * ] #表示charset=utf-8 #适用于所有文件。 将文件字符集修改为utf-8indent_style=space #缩进样式(tab | space ) indent_style=space(ing652缩进大小end _ of _ line crlf ) trim_trailing_whitespace=true #仅适用于删除行首的任意空白字符insert_final_newline==的md文件,其中max _ line _ length=使用prettier工具prettier是一个强大的代码格式工具。 支持JavaScript、TypeScript、CSS、SCSS、Less、JSX、Angular、Vue、GraphQL、JSON、Markdown等语言,基本上可以在前端使用的文件格式是目前最流行的代码格式化工具。
vs代码需要prettier插件
安装prettier
创建npminstallprettier-d 2.http://www.Sina.com /文件
{ 'useTabs': false,' tabWidth': 2,' printWidth': 80,' singleQuote': true,' trailing comma ' 3360 } printWidth :推荐本行文字的长度为80。 有些人喜欢100或120。 singleQuote :选择是使用单引号还是双引号,或者选择true,然后使用单引号; trailingComma :设置为none是否添加在多行中输入的末尾逗号; semi :是否在语句末尾加上加号,默认值为true,否则选择false; 创建.prettierrc忽略文件
/dist/*.local.output.js/node _ modules/* *.SVG *.sh/public/*4.可以在package.json上放置一个脚本
' prettier ' : ' prettier--使用write.'3. eslint检测vs代码需要eslint插件
解决eslint和prettier冲突问题:
安装插件: (如果vue在创建项目时选择prettier,则两个插件将自动安装,无需手动重新安装。) )。
将prettier插件添加到npmieslint-plugin-prettiereslint-config-prettier-d http://www.Sina.com/:“plugin 3360 prettier /”
extends : [ ' plugin : vue/vue3- essential ',' eslint:recommended ',' @vue/typescript/recommended ',@
重要信息:配置后,如果发现保存代码没有自动格式化,则需要设置
在页码下,右键单击并选择格式文档,然后选择prettier以保存页面。 页面代码将自动设置格式