简体   繁体   中英

Grunt - grunt-eslint does not start task

I've set up the grunt-eslint in my gruntfile.js, but when I run the "grunt eslint", nothing happends. The task looks like it would start but just stands still even after 15min.

All my other tasks works just fine, all except eslint wich shows no errors or anything.

gruntfile.js

module.exports = function(grunt) {
  grunt.initConfig({
   eslint: {
    options: {
      configFile: '.eslintrc.json'
    },
    target: ['src/js/*.js']
   },
  })

  grunt.loadNpmTasks('grunt-eslint');

  grunt.registerTask('eslint', [
    'eslint',
  ]);
}

.eslintrc.json

{
  "env": {
    "browser": true
  },
  "extends": "eslint:recommended",
  "rules": {
    "indent": [
        "error",
        "tab"
    ],
    "linebreak-style": [
        "error",
        "windows"
    ],
    "quotes": [
        "error",
        "double"
    ],
    "semi": [
        "error",
        "always"
    ]
  }
}

Both the gruntfile and .eslintrc.json is in root

Does anyone know what it is that can cause this? Is my setup wrong?

I had the same problem.

If you add --verbose option when running:

grunt eslint --verbose

You'll see that your task is running repeatedly - because you named your task eslint(which is the same name as already registered eslint task) grunt falls into infinite loop.

Change

 grunt.registerTask('eslint', [
    'eslint',
  ]);

to:

 grunt.registerTask('myeslinttask', [
    'eslint',
  ]);

and run:

grunt myeslinttask

the problem of:

grunt.registerTask('eslint', [ 'eslint', ]);

is that it will call it self forever, just delete this registerTask command and run grunt eslint , that will be enough to

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM