代码格式化为eslint风格(参考自这里)
需要插件:eslint
在设置-setting.json中添加:
{
"atomKeymap.promptV3Features": true,
"editor.multiCursorModifier": "ctrlCmd",
"editor.formatOnPaste": true,
"workbench.colorCustomizations": {
"activityBarBadge.background": "#C6FF00",
"list.activeSelectionForeground": "#C6FF00",
"list.inactiveSelectionForeground": "#C6FF00",
"list.highlightForeground": "#C6FF00",
"scrollbarSlider.activeBackground": "#C6FF0050",
"editorSuggestWidget.highlightForeground": "#C6FF00",
"textLink.foreground": "#C6FF00",
"progressBar.background": "#C6FF00",
"pickerGroup.foreground": "#C6FF00",
"tab.activeBorder": "#C6FF00",
"notificationLink.foreground": "#C6FF00"
},
"window.zoomLevel": 1,
"files.autoSave": "off",
"workbench.iconTheme": "material-icon-theme",
// Format a file on save.
// A formatter must be available,
// the file must not be auto-saved,
// and editor must not be shutting down.
"editor.formatOnSave": true,
// Enable/disable default JavaScript formatter (For Prettier)
"javascript.format.enable": false,
// Use 'prettier-eslint' instead of 'prettier'.
// Other settings will only be fallbacks
// in case they could not be inferred from eslint rules.
"prettier.eslintIntegration": true,
"[javascriptreact]": {},
"javascript.updateImportsOnFileMove.enabled": "always",
"workbench.startupEditor": "newUntitledFile",
"workbench.activityBar.visible": true,
"editor.renderControlCharacters": false,
"workbench.colorTheme": "One Dark Pro",
"java.errors.incompleteClasspath.severity": "ignore",
"git.enableSmartCommit": true,
"files.autoGuessEncoding": true,
"workbench.editor.enablePreview": false,
"workbench.editor.enablePreviewFromQuickOpen": false,
"javascript.implicitProjectConfig.experimentalDecorators": true,
"search.location": "panel",
"sync.gist": "429952266e5778e1df75617be228faa6",
"eslint.autoFixOnSave": true,
"eslint.validate": [
"javascript",
"javascriptreact",
{
"language": "html",
"autoFix": true
},
{
"language": "vue",
"autoFix": true
}
],
"editor.suggestSelection": "first",
"vsintellicode.modify.editor.suggestSelection": "automaticallyOverrodeDefaultValue",
"workbench.sideBar.location": "left",
}
eslint.autoFixOnSave 用来进行保存时自动格式化,但是默认只支持 javascript .js 文件。
eslint.validate 用来配置作用的文件类型。
然后在保存代码的时候,就会自动格式化为eslint风格(需要保存多次)。
网友评论