Kelsner
Kelsner

Reputation: 69

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 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?

Upvotes: 0

Views: 1219

Answers (2)

Edward Koetsjarjan
Edward Koetsjarjan

Reputation: 333

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

Upvotes: 0

agsigma
agsigma

Reputation: 331

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

Upvotes: 2

Related Questions