備一份vscode的setting.json檔案(儲存格式化,遵循ESlint規範)

iusugar發表於2020-12-03
{
	"files.autoSaveDelay": 1000,
	"files.autoSave": "afterDelay",
	"editor.tabSize": 2,
	// "terminal.integrated.shell.windows": "powershell.exe",
	"terminal.integrated.shell.windows": "cmd.exe",
	// "terminal.integrated.shell.windows": "D:/Software/Git/bin/bash.exe",
	"files.associations": {},
	"code-runner.ignoreSelection": true,
	"C_Cpp.default.compilerPath": "",
	"window.restoreWindows": "none",
	"code-runner.runInTerminal": true,
	"terminal.integrated.automationShell.windows": "",
	"terminal.integrated.automationShell.linux": "",
	"editor.quickSuggestions": {
		"strings": true
	},
	"terminal.integrated.shellArgs.windows": null,
	"oneDarkPro.editorTheme": "Onedark Pro",
	"typescript.npm": "",
	"code-runner.languageIdToFileExtensionMap": {
		"bat": ".bat",
		"powershell": ".ps1",
		"typescript": ".ts"
	},
	"code-runner.executorMapByGlob": {
		"pom.xml": "cd $dir && mvn clean package"
	},
	"explorer.compactFolders": false,

	"eslint.options": {
		"plugins": ["html"]
	},
	"vetur.experimental.templateInterpolationService": true,

	//格式化外掛配置

	// vscode預設啟用了根據檔案型別自動設定tabsize的選項
	"editor.detectIndentation": false,
	// #值設定為true時,每次儲存的時候自動格式化;值設定為false時,程式碼格式化請按shift+alt+F
	"editor.formatOnSave": true,
	// #每次儲存的時候將程式碼按eslint格式進行修復
	"eslint.autoFixOnSave": true,
	// 新增 vue 支援
	"eslint.validate": [
		"javascript",
		"javascriptreact",
		"html",
		{
			"language": "vue",
			"autoFix": true
		}
	],
	//  #讓prettier使用eslint的程式碼格式進行校驗
	"prettier.eslintIntegration": true,
	//  #去掉程式碼結尾的分號
	"prettier.semi": false,
	//  #使用單引號替代雙引號
	"prettier.singleQuote": true,
	"prettier.tabWidth": 4,
	//  #讓函式(名)和後面的括號之間加個空格
	"javascript.format.insertSpaceBeforeFunctionParenthesis": false,
	// #這個按使用者自身習慣選擇
	"vetur.format.defaultFormatter.html": "js-beautify-html",
	// #讓vue中的js按"prettier"格式進行格式化
	"vetur.format.defaultFormatter.js": "vscode-typescript",
	"vetur.format.defaultFormatterOptions": {
		"js-beautify-html": {
			// #vue元件中html程式碼格式化樣式
			"wrap_attributes": "force-aligned", //也可以設定為“auto”,效果會不一樣
			"wrap_line_length": 200,
			"end_with_newline": false,
			"semi": false,
			"singleQuote": true
		},
		"prettier": {
			"semi": false,
			"singleQuote": true
		}
	},
	"[jsonc]": {
		"editor.defaultFormatter": "esbenp.prettier-vscode"
	},
	// 格式化stylus, 需安裝Manta's Stylus Supremacy外掛
	"stylusSupremacy.insertColons": false, // 是否插入冒號
	"stylusSupremacy.insertSemicolons": false, // 是否插入分號
	"stylusSupremacy.insertBraces": false, // 是否插入大括號
	"stylusSupremacy.insertNewLineAroundImports": false, // import之後是否換行
	"stylusSupremacy.insertNewLineAroundBlocks": false,
	"prettier.useTabs": true,
	"explorer.confirmDelete": false,
	"[javascript]": {
		"editor.defaultFormatter": "esbenp.prettier-vscode"
	},
	"[json]": {
		"editor.defaultFormatter": "esbenp.prettier-vscode"
	},
	"diffEditor.ignoreTrimWhitespace": false,
	"[vue]": {
		"editor.defaultFormatter": "octref.vetur"
	},
	"editor.codeActionsOnSave": {
		"source.fixAll.eslint": true
  } 
}

相關文章