ruanyl / vim-fixmyjs

vim fixmyjs - auto fix your javascript using fixmyjs/eslint/tslint/jscs
MIT License
69 stars 11 forks source link

Error detected while processing function Fixmyjs #22

Closed herman-rogers closed 5 years ago

herman-rogers commented 6 years ago

Not sure what's happening - whenever I try to run Fixmyjs it throws the above error and fails to auto format my js.

ruanyl commented 6 years ago

Did you see any other useful error messages? Or do you have linting engine configured properly?

herman-rogers commented 6 years ago

I believe the linting is setup properly - I'll give it another look today. Sorry for the lack of information - but that's all that was output by fixmyjs. Fairly annoying :/

Edit: btw I'm using plain old eslint

herman-rogers commented 6 years ago

Here's a bit more information I was able to get out:

Error detected while processing function Fixmyjs:  
line   20: E37: No write since last change (add ! to override)
herman-rogers commented 6 years ago

Yea not sure what's going on here, I suspect the recent changes may have broken something. How I got around this was forking the project and resetting HEAD back to before the changes made 3 months ago. Everything is working now.

For some more information, I have eslint installed globally npm install -g eslint and I have it set to a custom eslint file let g:fixmyjs_rc_filename = ['.eslintrc', '.eslintrc.json'] and I have my preferences stored in a .eslint.json file.

zhongfox commented 6 years ago

same problem now: Error detected while processing function Fixmyjs: line 20: E37: No write since last change (add ! to override)

ruanyl commented 6 years ago

@herman-rogers @zhongfox Thank you very much for the comments. In the latest commit, let g:fixmyjs_rc_filename = ['.eslintrc', '.eslintrc.json'] is no longer needed. It will automatically resolve the .rc file just like how you use eslint in command line.

But there is a breaking change: eslint will fix the file in-place(previously, it copy the current buffer to a new tmp file and fix the tmp file and copy the fixed file back to current buffer). This change requires you to save your current file first and then run :Fixmyjs, I guess this might be the reason why you see this error.

aapelismith commented 5 years ago

This is how I configure my VIM to format the code when I save it. He made the same mistake.

au BufWritePre *.js :Fixmyjs   
au BufWritePre *.jsx :Fixmyjs  
au BufWritePre *.vue :Fixmyjs  
au BufWritePre *.html :Fixmyjs 
aapelismith commented 5 years ago

I changed the following way to solve the problem. au BufWritePost .js :Fixmyjs
au BufWritePost
.jsx :Fixmyjs
au BufWritePost .vue :Fixmyjs
au BufWritePost
.html :Fixmyjs

ruanyl commented 5 years ago

thanks! @aapelismith