vscode-eslint-petter
效果点击保存自动格式化代码
需要安装Eslint 和 petter
涉及的文件有:
package.json(标红是需要添加的文件)
{ "name": "paces-ccps-unify-admin-f2e", "version": "0.1.0", "private": true, "scripts": { "serve": "vue-cli-service serve", "release": "node .release", "fix": "eslint --fix --ext .js --ext .vue src/", // 需要添加的文件 "lint": "vue-cli-service lint" }, "dependencies": { "axios": "^0.19.1", "consola": "^2.15.3", "core-js": "^3.4.4", "element-ui": "^2.13.0", "file-saver": "^2.0.2", "js-cookie": "^2.2.1", "normalize.css": "^8.0.1", "vue": "^2.6.10", "vue-router": "^3.1.3", "vuex": "^3.1.2", "xlsx": "^0.16.3" }, "devDependencies": { "babel-eslint": "^10.0.3", // 需要添加的文件 "@vue/cli-plugin-eslint": "^4.1.0", // 需要添加的文件 "@vue/eslint-config-standard": "^4.0.0", "eslint-config-prettier": "^8.3.0", "eslint-config-standard": "^16.0.3", "eslint-plugin-import": "^2.20.1", "eslint-plugin-node": "^11.0.0", "eslint-plugin-prettier": "^3.4.1", "eslint-plugin-promise": "^4.2.1", "eslint-plugin-standard": "^4.0.0", "eslint-plugin-vue": "^5.0.0", "@vue/cli-plugin-babel": "^4.1.0", "eslint": "^6.7.2", "prettier": "1.19.1", // 需要添加的文件 "@vue/cli-plugin-router": "^4.1.0", "@vue/cli-plugin-vuex": "^4.1.0", "@vue/cli-service": "^4.1.0", "consola": "^2.15.3", "node-sass": "^4.12.0", "sass-loader": "^8.0.0", "svg-sprite-loader": "^4.1.6", "vue-template-compiler": "^2.6.10" } }
.eslintignore
public/*
.eslintrc.js
module.exports = { root: true, env: { node: true }, extends: ['plugin:vue/essential', 'plugin:prettier/recommended'], rules: { 'no-console': process.env.NODE_ENV === 'production' ? 'warn' : 'off', 'no-debugger': process.env.NODE_ENV === 'production' ? 'warn' : 'off' }, parserOptions: { parser: 'babel-eslint' } }
.prettierignore
static/**/*/.js node_modules/
.prettierrc
{ "semi": false, "singleQuote": true, "trailingComma": "none" }
setting.json 配置
{ "editor.tabSize": 2, "editor.codeActionsOnSave": { "source.fixAll.eslint": true }, "eslint.codeAction.disableRuleComment": { "enable": true, "location": "separateLine" }, "eslint.format.enable": true, "eslint.lintTask.enable": true, "eslint.alwaysShowStatus": true, "explorer.confirmDragAndDrop": false, "git.autofetch": true, "editor.renderWhitespace": "none", "workbench.iconTheme": "vscode-icons", "git.confirmSync": false, // 解决vscode cpu占用率过高 "search.followSymlinks": false, "editor.wordSeparators": "`~!@#$%^&*()=+[{]}\\|;:'\",.<>/?", "workbench.editor.enablePreview": true, "workbench.editor.enablePreviewFromQuickOpen": false, "workbench.editor.closeEmptyGroups": false, "workbench.editor.centeredLayoutAutoResize": false, "workbench.editor.focusRecentEditorAfterClose": false, "prettier.useTabs": true, "editor.renderIndentGuides": false, "editor.highlightActiveIndentGuide": false, "window.clickThroughInactive": false, "launch": { "configurations": [], "compounds": [] }, "files.associations": { "*.vue": "vue" }, "vsicons.dontShowNewVersionMessage": true, "diffEditor.ignoreTrimWhitespace": false, "editor.defaultFormatter": "esbenp.prettier-vscode", "[javascript]": { "editor.defaultFormatter": "esbenp.prettier-vscode" }, "[typescript]": { "editor.defaultFormatter": "esbenp.prettier-vscode" }, "[jsonc]": { "editor.defaultFormatter": "esbenp.prettier-vscode" }, "[html]": { "editor.defaultFormatter": "esbenp.prettier-vscode" }, "[vue]": { "editor.defaultFormatter": "esbenp.prettier-vscode" }, "[json]": { "editor.defaultFormatter": "esbenp.prettier-vscode" }, "[typescriptreact]": { "editor.defaultFormatter": "esbenp.prettier-vscode" }, "[javascriptreact]": { "editor.defaultFormatter": "esbenp.prettier-vscode" }, "javascript.updateImportsOnFileMove.enabled": "always", "editor.rulers": [], "security.workspace.trust.untrustedFiles": "open", "explorer.confirmDelete": false, "editor.minimap.enabled": false, "editor.renderControlCharacters": true }
将来的自己,会感谢现在不放弃的自己!