Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

eslint watch task running repeatedly

I am trying to lint my files with eslint on file change using npm scripts:

"scripts": {                                                                   
  "lint": "eslint ./* lib",                                                    
  "lint:watch":"watch 'npm run lint' .",                                       
  "test": "echo \"Error: no test specified\" && exit 1"                        
}

I use the watch package to accomplish this.

I find that the watch task runs infinitely in a loop. Does eslint write to a file in the app's root directory. If so, how can I teach watch to ignore the changes made by eslint.

My .eslintrc, if nessecary:

{                                                                                
   "parser":"babel-eslint",                                                        
   "extends":"eslint:recommended",                                                 
   "rules":{                                                                       
      "strict":2,                                                                  
      "no-var":2,                                                                  
      "prefer-template":2,                                                         
      "prefer-arrow-callback":1,                                                   
      "prefer-rest-params":2,                                                      
      "prefer-spread":2,                                                           
      "object-shorthand":1,                                                        
      "no-duplicate-imports":2,                                                    
      "no-confusing-arrow":2,                                                      
      "comma-dangle":0                                                             
    }                                                                              
 }        
like image 477
vamsiampolu Avatar asked Oct 18 '22 12:10

vamsiampolu


1 Answers

You can tell ESLint to ignore specific files and directories by creating an .eslintignore file in your project’s root directory. This is what one looks like:

It is plain text, simply add a .eslintignore file to your project and write the files you don't want 'watched'

The following will ignore all JS files:

**/*.js

You can get specific or use a glob pattern like the above to ignore all files of a certain type.

Relevant Docs

like image 176
omarjmh Avatar answered Oct 30 '22 22:10

omarjmh