0

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?

Jason Aller
  • 3,541
  • 28
  • 38
  • 38
Kelsner
  • 59
  • 2
  • 9
  • Is your config file name correct? I mean in your configuration it looks like "eslintrc.json" but maybe actually it's ".eslintrc.json"? – omer.ersoy Jan 12 '18 at 10:35
  • Thanks for the correction, been trying different filenames. Even with ".eslintrc.json" it is the same thing, nothing happends – Kelsner Jan 12 '18 at 10:43

2 Answers2

2

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
agsigma
  • 321
  • 1
  • 8
0

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