最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - eslint watch task running repeatedly - Stack Overflow

programmeradmin0浏览0评论

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 acplish 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:remended",                                                 
   "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,                                                      
      "ma-dangle":0                                                             
    }                                                                              
 }        

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 acplish 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:remended",                                                 
   "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,                                                      
      "ma-dangle":0                                                             
    }                                                                              
 }        
Share Improve this question asked Apr 4, 2016 at 21:04 vamsiampoluvamsiampolu 6,64220 gold badges89 silver badges193 bronze badges 2
  • to quickly disable a file just put this line at the top: /* eslint-disable */ – omarjmh Commented Apr 4, 2016 at 21:22
  • 1 @Omarjmh I think there was a mismunication, I run a package called watch on eslint, this package is watching for files in the project's root directory, when eslint runs it seems to write to a folder on the root directory causing watch to detect changes which runs eslint again. If I know which file, I can ask watch to ignore it. – vamsiampolu Commented Apr 5, 2016 at 18:59
Add a ment  | 

1 Answer 1

Reset to default 5

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

发布评论

评论列表(0)

  1. 暂无评论