Grunt - grunt-eslint does not start task

1.1k views Asked by At

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

All my other tasks works just fine, all except eslint which 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?

2

There are 2 answers

0
agsigma On

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
0
Edward Koetsjarjan On

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