Advertisement
Guest User

Untitled

a guest
Apr 5th, 2017
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VIM 0.55 KB | None | 0 0
  1.  
  2. fu! EslintWrapperFix()
  3.   let eslintFilesExist = filereadable('.eslintrc.json') || filereadable('.eslintrc.js') || filereadable('.eslintrc.yml')
  4.  
  5.   if eslintFilesExist == 0
  6.     echo 'No .eslintrc files found'
  7.     return
  8.   end
  9.  
  10.   let output = system("eslint --fix " . expand('%'))
  11.   let lines = split(output, '\n')
  12.  
  13.   " Nothing to fix, let's move along
  14.   if len(lines) == 0
  15.     return
  16.   endif
  17.  
  18.   if lines[1] =~# "File ignored by default"
  19.     return
  20.   endif
  21.  
  22.   checktime
  23.   Neomake
  24. endfu
  25. autocmd BufWritePost *.js call EslintWrapperFix()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement