vue基础-某个项目ESLint不生效问题


文章目录

  • 前言
  • 一、解决方法
  • 二、在配置文件中添加一下配置
  • 三、本人电脑的ESLint配置
  • 总结


前言

vue基础,最近接手同事的项目,发现ESLint不生效了,找了很久也没有发现问题,因为其他的项目是可以用的。


一、解决方法

1、在vscode中打开设置
vue基础-某个项目ESLint不生效问题_第1张图片
2、搜索到ESLint
vue基础-某个项目ESLint不生效问题_第2张图片
3、在settings.json中编辑,如图所示:
vue基础-某个项目ESLint不生效问题_第3张图片

二、在配置文件中添加一下配置

1、添加配置

   "editor.codeActionsOnSave": {
      "source.fixAll.eslint":true
    },
   "eslint.validate":["javascript","javascriptreact",{"language":"vue","autoFix":true},"vue"],

2、重新启动vscode,验证是否生效

npm install -g @vue/cli

三、本人电脑的ESLint配置

1、eslint配置


{
    "workbench.iconTheme": "material-icon-theme",
    "workbench.startupEditor": "newUntitledFile",
    "workbench.colorTheme": "Slack Theme Dark Mode",
    "files.associations": {
      "*.wxml": "html",
      "*.wxss": "css",
      "*.wpy": "vue",
      "*.json": "json"
    },
    "[css]": {
      "editor.tabSize": 2,
      "editor.defaultFormatter": "esbenp.prettier-vscode"
    },
    "[dart]": {
      //当保存文件的时候进行格式化
      "editor.formatOnSave": true,
      //当一行输入完成后进行格式化
      "editor.formatOnType": true,
      "editor.rulers": [80],
      "editor.selectionHighlight": false,
      "editor.suggest.snippetsPreventQuickSuggestions": false,
      "editor.suggestSelection": "first",
      "editor.tabCompletion": "onlySnippets",
      "editor.wordBasedSuggestions": false,
      "editor.defaultFormatter": "Dart-Code.dart-code"
    },
    "gitlens.advanced.messages": {
      "suppressCommitHasNoPreviousCommitWarning": false,
      "suppressCommitNotFoundWarning": false,
      "suppressFileNotUnderSourceControlWarning": false,
      "suppressGitVersionWarning": false,
      "suppressLineUncommittedWarning": false,
      "suppressNoRepositoryWarning": false,
      "suppressResultsExplorerNotice": false,
      "suppressShowKeyBindingsNotice": true
    },
    "gitlens.historyExplorer.enabled": true,
    "javascript.updateImportsOnFileMove.enabled": "never",
    "editor.renderWhitespace": "none",
    "javascript.preferences.quoteStyle": "single",
    "editor.wordWrap": "on",
    "cSpell.enabledLanguageIds": [
      "asciidoc",
      "c",
      "cpp",
      "csharp",
      "css",
      "go",
      "handlebars",
      "html",
      "jade",
      "javascript",
      "javascriptreact",
      "json",
      "latex",
      "less",
      "markdown",
      "php",
      "plaintext",
      "python",
      "pub",
      "restructuredtext",
      "rust",
      "scss",
      "text",
      "typescript",
      "typescriptreact",
      "yml",
      "vue"
    ],
    "[javascript]": {
      "editor.tabSize": 2,
      "editor.defaultFormatter": "vscode.typescript-language-features"
    },
    "gitlens.views.fileHistory.enabled": true,
    "gitlens.views.lineHistory.enabled": true,
    "eslint.options": {
      "extensions": [".js", ".vue"]
    },
  "eslint.validate":["javascript","javascriptreact",{"language":"vue","autoFix":true},"vue"],
    "editor.suggestSelection": "first",
    "vsintellicode.modify.editor.suggestSelection": "automaticallyOverrodeDefaultValue",
    "explorer.confirmDragAndDrop": false,
    "[html]": {
      "editor.defaultFormatter": "vscode.html-language-features"
    },
    "[json]": {
      "editor.defaultFormatter": "SimonSiefke.prettier-vscode"
    },
    "C_Cpp.updateChannel": "Insiders",
    "http.proxySupport": "off",
    "diffEditor.renderSideBySide": true,
    "vim.highlightedyank.enable": true,
    "vim.hlsearch": true,
    "workbench.colorCustomizations": {
      "statusBar.background": "#005f5f",
      "statusBar.noFolderBackground": "#005f5f",
      "statusBar.debuggingBackground": "#005f5f"
    },
    "vim.debug.silent": true,
    "[less]": {
      "editor.defaultFormatter": "esbenp.prettier-vscode"
    },
    "[vue]": {
      "editor.defaultFormatter": "rvest.vs-code-prettier-eslint"
    },
    "[scss]": {
      "editor.defaultFormatter": "esbenp.prettier-vscode"
    },
    "html.mirrorCursorOnMatchingTag": false,
    "editor.minimap.maxColumn": 80,
    "editor.tabSize": 2,
    "editor.detectIndentation": false,
    "files.autoSave": "afterDelay",
    "eslint.alwaysShowStatus": true,
    "editor.codeActionsOnSave": {
      "source.fixAll.eslint":true
    },
    "editor.defaultFormatter": "dbaeumer.vscode-eslint",
    "editor.formatOnSave": true,
    "vetur.format.defaultFormatterOptions": {
      "js-beautify-html": {
        "wrap_attributes": "auto"
      },
      "prettier": {
        "semi": true,
        "eslintIntegration": true,
        "singleQuote": true
      }
    },
    "prettier.eslintIntegration": true,
    "workbench.statusBar.visible": true,
    "security.workspace.trust.untrustedFiles": "open",
    "workbench.editorAssociations": {
      "*.dll": "default"
    },
    "bracketPairColorizer.depreciation-notice": false,
    "workbench.editor.untitled.hint": "hidden",
    "dart.flutterHotReloadOnSave": "always",
    "dart.previewFlutterUiGuides": true,
    "editor.bracketPairColorization.enabled": true,
    "vsicons.dontShowNewVersionMessage": true,
    "cmake.configureOnOpen": true,
    "explorer.confirmDelete": false,
    "svelte.plugin.svelte.note-new-transformation": false,
    "merge-conflict.autoNavigateNextConflict.enabled": true,
    "volar.autoCompleteRefs": true,
    "editor.formatOnType": true,
    "[postcss]": {
      "editor.defaultFormatter": "SimonSiefke.prettier-vscode"
    },
  "npm.keybindingsChangedWarningShown": true,
  "git.mergeEditor": false,
  "editor.fontSize": 13,
  "eslint.codeActionsOnSave.rules": null
  }

总结

这就是解决某个项目ESLint不生效问题,希望帮助到你。

你可能感兴趣的:(vue,vue.js,前端,javascript)