【问题标题】:ESLint not sending warning for console.logESLint 没有为 console.log 发送警告
【发布时间】:2019-03-05 15:41:59
【问题描述】:

我有以下 .eslintrc...

{
  plugins: [
    'markdown',
    'json'
  ],
  parserOptions: {
    'ecmaVersion': 2017,
    'sourceType': 'module',
  },
  extends: [
    'eslint:recommended',
    'plugin:vue/essential'
  ]
}

为了测试它,我将控制台语句添加到 test.js 并运行 ./node_modules/.bin/eslint <folder>/test.js。我希望看到类似...

警告意外的控制台语句
无控制台

但是我没有看到任何输出。我错过了什么?

【问题讨论】:

    标签: eslint


    【解决方案1】:

    我认为它对你有用。注意扩展插件。我在我的项目中使用了这个结构,一切都很好。并且您在 .js 文件中添加了console.logeslint:recommended 将起作用。

    module.exports = {
      root: true,
      parserOptions: {
        parser: "babel-eslint",
        sourceType: "module"
      },
      env: {
        browser: true
      },
      extends: [
        "eslint:recommended",
        "plugin:vue/recommended"
      ],
      plugins: [
        "vue" // required to lint *.vue files
      ],
      // add your custom rules here
      rules: {
        "arrow-parens": 0,
        "generator-star-spacing": 0,
        "no-debugger": process.env.NODE_ENV === "production" ? 2 : 0
      }
    }
    

    【讨论】:

      【解决方案2】:

      在我的情况下,我有另一个 eslintrc 更进一步...

      extends: [
        'plugin:vue/strongly-recommended',
        'plugin:vue/recommended'
      ]
      

      我认为这出于某种原因合并了列表,但它实际上覆盖了列表。

      【讨论】:

        猜你喜欢
        • 2021-05-12
        • 2018-10-06
        • 2016-01-09
        • 1970-01-01
        • 2020-01-06
        • 2019-10-15
        • 2019-07-14
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多