一、安装eslint
二、vscode全局配置
2.1 打开设置
2.2 打开 settings.json
2.3 在settings.json中添加eslint配置
{ "code-runner.runInTerminal": true, "eslint.format.enable": true, // 以下是eslint 配置 // vscode默认启用了根据文件类型自动设置tabsize的选项 "editor.detectIndentation": false, // 重新设定tabsize "editor.tabSize": 2, // "editor.tabSize": 4, // #每次保存的时候自动格式化 "editor.formatOnSave": true, // #每次保存的时候将代码按eslint格式进行修复 "eslint.validate": [ "javascript", "javascriptreact", "html", "vue" ], // "eslint.autoFixOnSave": true, // 改成下面的"editor.codeActionsOnSave" // #每次保存的时候将代码按eslint格式进行修复 "editor.codeActionsOnSave": { "source.fixAll.eslint": true }, // #让prettier(插件)使用eslint的代码格式进行校验 "prettier.eslintIntegration": true, // #去掉代码结尾的分号 "prettier.semi": false, // #使用单引号替代双引号 "prettier.singleQuote": true, // #让函数(名)和后面的括号之间加个空格 "javascript.format.insertSpaceBeforeFunctionParenthesis": true, // #这个按用户自身习惯选择 "vetur.format.defaultFormatter.html": "js-beautify-html", // #让vue中的js按编辑器自带的ts格式进行格式化 "vetur.format.defaultFormatter.js": "vscode-typescript", "vetur.format.defaultFormatterOptions": { // "wrap_attributes": "force-aligned", "js-beautify-html": { // - auto: 仅在超出行长度时才对属性进行换行。 // - force: 对除第一个属性外的其他每个属性进行换行。 // - force-aligned: 对除第一个属性外的其他每个属性进行换行,并保持对齐。 // - force-expand-multiline: 对每个属性进行换行。 // - aligned-multiple: 当超出折行长度时,将属性进行垂直对齐。 "wrap_attributes": "force-aligned" // #vue组件中html代码格式化样式 } }, // "window.zoomLevel": 1, "window.zoomLevel": 0, "explorer.confirmDelete": false, "explorer.confirmDragAndDrop": false, "editor.renderControlCharacters": true, "editor.renderWhitespace": "all", "workbench.sideBar.location": "left", "files.autoGuessEncoding": true, "editor.formatOnType": true, "editor.defaultFormatter": "dbaeumer.vscode-eslint", // 格式化stylus, 需安装Manta's Stylus Supremacy插件 "stylusSupremacy.insertColons": false, // 是否插入冒号 "stylusSupremacy.insertSemicolons": false, // 是否插入分好 "stylusSupremacy.insertBraces": false, // 是否插入大括号 "stylusSupremacy.insertNewLineAroundImports": false, // import之后是否换行 "stylusSupremacy.insertNewLineAroundBlocks": false // 两个选择器中是否换行 //"editor.defaultFormatter": "rvest.vs-code-prettier-eslint" // "editor.defaultFormatter": "esbenp.prettier-vscode", // "[javascript]": { // "editor.defaultFormatter": "esbenp.prettier-vscode" // }, // "vs-code-prettier-eslint.enabled":true, // "vs-code-prettier-eslint.eslintFileName":".eslintrc", // "vs-code-prettier-eslint.eslintFileType":"json", // "vs-code-prettier-eslint.prettierFileName":".prettierrc", // "vs-code-prettier-eslint.prettierFileType": "json", // "prettier.printWidth": null }
分类:
工具
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】凌霞软件回馈社区,博客园 & 1Panel & Halo 联合会员上线
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】博客园社区专享云产品让利特惠,阿里云新客6.5折上折
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 【.NET】调用本地 Deepseek 模型
· CSnakes vs Python.NET:高效嵌入与灵活互通的跨语言方案对比
· DeepSeek “源神”启动!「GitHub 热点速览」
· 我与微信审核的“相爱相杀”看个人小程序副业
· Plotly.NET 一个为 .NET 打造的强大开源交互式图表库