【问题标题】:Why is my ESlinter not formatting on save?为什么我的 ESLinter 在保存时没有格式化?
【发布时间】:2021-02-02 04:23:02
【问题描述】:

我在 Ubuntu 20.04 上使用 VSCode 在 JS(Node.js) 中编写代码。 我配置了我的 ESlint settings.json

{
    "todo-tree.tree.showScanModeButton": false,
    "editor.suggestSelection": "first",
    "vsintellicode.modify.editor.suggestSelection": "automaticallyOverrodeDefaultValue",
    "editor.codeActionsOnSave": {
        "source.fixAll.eslint": true
      },
      "eslint.validate": ["javascript"]
}

还有.eslinterc.js

module.exports = {
    "env": {
        "browser": true,
        "es2021": true
    },
    "extends": [
        "eslint:recommended",
        "plugin:react/recommended"
    ],
    "parserOptions": {
        "ecmaFeatures": {
            "jsx": true
        },
        "ecmaVersion": 12,
        "sourceType": "module"
    },
    "plugins": [
        "react"
    ],
    "rules" : {
        "no-console": "off",
         "quotes": [
            "error",
            "double"
          ]
      }
};

我的第一部分代码是在保存时格式化的

passport.use("register", new LocalStrategy(
    {
        usernameField: "username",
        passwordField: "password",
        passReqToCallback: true,
        session: false,
    },

午休后,我加了新台词

passport.use(
  'login',
  new LocalStrategy(
    {
      usernameField: 'username',
      passwordField: 'password',
      session: false,
    },

但什么也没发生。

问题

表示服务器正在运行

[Info  - 1:24:15 PM] ESLint server is starting
[Info  - 1:24:15 PM] ESLint server running in node v12.14.1
[Info  - 1:24:15 PM] ESLint server is running.
[Info  - 1:24:16 PM] ESLint library loaded from: /home/milenko/myblog/backend/node_modules/eslint/lib/api.js

如何控制我的 ESLinter?

【问题讨论】:

    标签: javascript visual-studio-code eslint eslintrc


    【解决方案1】:

    问题截图中列出的所有问题似乎都不是可以自动修复的。因此,保存时的自动 lint 似乎无法正常工作,但在午餐前工作时可能没问题。

    尝试使用您确定会自动修复的错误对简单文件进行 linting。例如使用错误类型的引号。

    【讨论】:

    • 我确实是在平台上贡献的新手,但我认为“为什么我的 ESLinter 没有在保存时格式化?”这个问题的答案。回答说:“它是......你只是没有看到它”。这是我上面回答的核心。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2016-10-31
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-11-14
    • 2023-03-16
    • 2018-12-17
    相关资源
    最近更新 更多