【问题标题】:"No ESLint configuration found" error“未找到 ESLint 配置”错误
【发布时间】:2016-11-05 12:19:30
【问题描述】:

最近,我们已升级到ESLint 3.0.0,并开始收到以下运行grunt eslint 任务的消息:

> $ grunt eslint
Running "eslint:files" (eslint) task
Warning: No ESLint configuration found. Use --force to continue.

这是grunt-eslint的配置:

var lintTargets = [
    "<%= app.src %>/**/*/!(*test|swfobject)+(.js)",
    "test/e2e/**/*/*.js",
    "!test/e2e/db/models/*.js"
];
module.exports.tasks = {
    eslint: {
        files: {
            options: {
                config: 'eslint.json',
                fix: true,
                rulesdir: ['eslint_rules']
            },
            src: lintTargets
        }
    }
};

我们应该怎么做才能修复错误?

【问题讨论】:

    标签: javascript gruntjs eslint grunt-eslint


    【解决方案1】:

    对于那些有同样问题的人,我们就是这样解决的。

    按照Requiring Configuration to Run 迁移过程,我们必须eslint.json 重命名为.eslintrc.json,这是现在默认的 ESLint 配置文件名之一。

    我们还删除了config grunt-eslint 选项。

    【讨论】:

      【解决方案2】:

      尝试将configconfigFile 交换。然后:

      1. 创建eslint.json文件和
      2. 指向它的正确位置(相对于 Gruntfile.js 文件)
      3. 在该文件中放置一些配置 (eslint.json),即:

      .

      {
          "rules": {
              "eqeqeq": "off",
              "curly": "warn",
              "quotes": ["warn", "double"]
          }
      }
      

      更多示例,请转至here

      【讨论】:

      • 是的,configFile 也很有效。看起来我们使用的是config,它没有任何效果,但是因为 eslint 2 默认搜索它,所以它起作用了。现在我们已经迁移到 eslint 3 并且更改了默认配置文件名,eslint 不会自动找到配置,这表明我们应该从一开始就使用 configFile。这就是我现在的理论。谢谢!
      • 不客气。我最近刚刚处理了配置,所以避免了遗留问题。
      【解决方案3】:

      我在 Gulp 上遇到了同样的问题,并且正在运行 "gulp-eslint": "^3.0.1" 版本。 我不得不将 config: 重命名为 Gulp 任务中的 configFile

      .pipe(lint({configFile: 'eslint.json'}))
      

      【讨论】:

        【解决方案4】:
        gulp.task('eslint',function(){
        return gulp.src(['src/*.js'])
            .pipe(eslint())
            .pipe(eslint.format())
        });
        
        
        `touch .eslintrc`  instead of .eslint
        

        这两个步骤可能会对您有所帮助!

        【讨论】:

          【解决方案5】:

          按照步骤操作
          1.创建 eslint 配置文件名 eslintrc.json
          2.放置代码如下

          gulp.src(jsFiles)
                  // eslint() attaches the lint output to the "eslint" property
                  // of the file object so it can be used by other modules.
                  .pipe(eslint({configFile: 'eslintrc.json'}))
                  // eslint.format() outputs the lint results to the console.
                  // Alternatively use eslint.formatEach() (see Docs).
                  .pipe(eslint.format())
                  // To have the process exit with an error code (1) on
                  // lint error, return the stream and pipe to failAfterError last.
                  .pipe(eslint.failAfterError());
          

          【讨论】:

            【解决方案6】:

            您面临的错误是因为您的配置不存在。 配置eslint类型

            eslint --init

            然后根据您的要求进行配置。

            然后再次执行项目。

            【讨论】:

            • 非常感谢 ;-)
            【解决方案7】:

            网页包

            我的根项目目录中有 eslint.rc 文件,但是事件 我遇到了错误。
            解决方案是在“eslint-loader”规则配置中添加排除属性:

            module.exports = {
              // ...
              module: {
                rules: [
                  {
                    test: /\.js$/,
                    exclude: /node_modules/,
                    loader: "eslint-loader",
                    options: {
                      // eslint options (if necessary)
                    }
                  },
                ],
              },
              // ...
            }
            

            【讨论】:

              【解决方案8】:

              在根目录下新建一个名为 .eslintrc.json 的文件:

               {
                  "parserOptions": {
                       "ecmaVersion": 6,
                       "sourceType": "module",
                       "ecmaFeatures": {
                           "jsx": true
                       }
                  },
                  "rules": {
                      "semi": "error"
                  }
              }
              

              【讨论】:

                【解决方案9】:

                运行命令ember init。 当它要求覆盖现有文件时。键入 n 跳过覆盖文件。 现在它将自动创建所需的文件,如 .eslintrc 等。

                对我来说,当我将除 dist、dist_production 和 node_modules 文件夹之外的文件夹复制到另一个系统并尝试运行 ember build 时,发生了同样的问题。

                【讨论】:

                  【解决方案10】:

                  我遇到了同样的错误。好像需要配置一下。

                  转到您的项目根目录并在终端中运行

                  ./node_modules/.bin/eslint --init
                  

                  【讨论】:

                    【解决方案11】:

                    我们今天遇到了这个问题,并意识到问题不是在我们正在处理的项目内部引起的,而是在我们有一个使用命令链接的包内部引起的:

                    yarn link
                    

                    在测试新功能或尝试调试在另一个项目中表现出来的包中的问题时,该功能通常很有用。 我们通过删除链接或在 ember.js 禁用我们插件包的开发者模式的情况下解决了这个问题。

                    index.js

                    module.exports = {
                        isDevelopingAddon: function() {
                          return false;
                        },
                        ...
                    }
                    

                    【讨论】:

                      猜你喜欢
                      • 2017-07-13
                      • 2020-06-07
                      • 2020-03-07
                      • 2016-12-09
                      • 1970-01-01
                      • 2021-06-12
                      • 2021-12-09
                      • 1970-01-01
                      • 1970-01-01
                      相关资源
                      最近更新 更多