prettier⾃动格式化去换⾏的实现代码插件
新建 .prettierrc ⽂件在根⽬录,⾥⾯写上这个
第⼀个是超出800字符换⾏,第⼆个是单引号,第三个是结尾不要分号
vscode⾥⾯的设置⽂件ttings。json代码
{
// vscode默认启⽤了根据⽂件类型⾃动设置tabsize的选项
"editor.detectIndentation": fal,
// 重新设定tabsize
"editor.tabSize": 2,
// #每次保存的时候⾃动格式化
晚安 日语"editor.formatOnSave": true,
// // 添加 vue ⽀持
"eslint.validate": [
"javascript",
"javascriptreact",
{
"language": "vue",
"autoFix": true
}
],
"eslint.autoFixOnSave": true,
"plate": fal,
// #让prettier使⽤eslint的代码格式进⾏校验
"prettier.eslintIntegration": true,
副词有哪些/
/ #去掉代码结尾的分号
"prettier.mi": fal,
dde
// #使⽤带引号替代双引号
"prettier.singleQuote": true,
// #让函数(名)和后⾯的括号之间加个空格
"javascript.format.inrtSpaceBeforeFunctionParenthesis": true,
outdated// #这个按⽤户⾃⾝习惯选择
"vetur.format.defaultFormatter.html": "js-beautify-html",
// #让vue中的js按编辑器⾃带的ts格式进⾏格式化
"vetur.format.defaultFormatter.js": "vscode-typescript",
"vetur.format.defaultFormatterOptions": {
"js-beautify-html": {
// 换⾏
// "wrap_attributes": "force-aligned"
// 不换⾏
"wrap_attributes": "aligned-multiple"
}
},
// 格式化stylus, 需安装Manta's Stylus Supremacy插件 "stylusSupremacy.inrtColons": fal, // 是否插⼊冒号 "stylusSupremacy.inrtSemicolons": fal, // 是否插⼊分好 "stylusSupremacy.inrtBraces": fal, // 是否插⼊⼤括号 "stylusSupremacy.inrtNewLineAroundImports": fal, // import之后是否换⾏ "stylusSupremacy.inrtNewLineAroundBlocks": fal, // 两个选择器中是否换⾏ "auto-rename-tag.activationOnLanguage": [
"*"
],
"Level": 0,
// esli弹框报错
"devDependencies": {
"babel-eslint": "^10.0.3",
"eslint": "^4.15.0",
"eslint-config-airbnb": "^16.1.0",
"eslint-plugin-jsx-a11y": "^6.0.3",
"eslint-plugin-react": "^7.12.1",
"eslint-config-google": "^0.9.1",
jinxed
"eslint-config-standard": "^10.2.1",
"eslint-plugin-html": "^4.0.1",
"eslint-plugin-import": "^2.8.0",
"eslint-plugin-node": "^5.2.1",
"eslint-plugin-promi": "^3.6.0",
"eslint-plugin-standard": "^3.0.1"
},
"http.proxyAuthorization": null,
"eslint.migration.2_x": "off",
"workbench.editorAssociations": [],
"deAction.disableRuleComment": {},
"deAction.showDocumentation": {},
"editor.suggest.snippetsPreventQuickSuggestions": fal,
"files.associations": {
"*.cjson": "jsonc",
"*.wxss": "css",
广州在职研究生"*.wxs": "javascript"
},
"emmet.includeLanguages": {following
"wxml": "html"
},
"minapp-vscode.disableAutoConfig": true,
"deActionsOnSave": null,
"[vue]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},会计就业前景
"[jsonc]": {
"editor.defaultFormatter": "vscode.json-language-features" },
"[javascript]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
}
}
保存,打开⼀个后缀名为.vue⽂件,右键⽂档格式⽅式
点默认格式化程序,再点Vetur
⼤功告成,,ctrl+s⾃动格式化,这是不换⾏的⽅式
英联邦
后缀名为 .js,⽤上⾯同样步骤,但是默认值⽤prettier
喜欢标签换⾏⽤这个
打开vscode设置⽂件ttings。json,找到,想⽤哪个打开就好,不⽤就注释
wimax
总结
到此这篇关于prettier⾃动格式化去换⾏的实现代码的⽂章就介绍到这了,更多相关prettier格式化换⾏内容请搜索以前的⽂章或继续浏览下⾯的相关⽂章希望⼤家以后多多⽀持!