I have recently been working on
One thing I didn’t like about the Closure Linter is that error messages are not configurable. There are some cases where I think 80 characters per line are just wrong, for example a for() statement that has 81 characters. Would you really want to break lines for just one character? What about URLs in comments that are just longer than 80 characters? Also, I’m not a fan of single quotes.
On the internet I found the Closure Linter’s feature request issue and a few discussion topics. While the feature request links a patch, I wanted a solution that does not modify the Closure Linter so new contributors don’t have to go around patching things just to check and fix the style. To do so I created a wrapper script around
fixjsstyle, as well as a common file for defining the errors to ignore.
First of all, the common file. Name it something like
from closure_linter import errors from closure_linter import errorrules OriginalShouldReportError = None def InjectErrorReporter(): global OriginalShouldReportError OriginalShouldReportError = errorrules.ShouldReportError errorrules.ShouldReportError = MyShouldReportError def MyShouldReportError(error): global OriginalShouldReportError return error not in ( errors.UNNECESSARY_DOUBLE_QUOTED_STRING, errors.LINE_TOO_LONG, ) and OriginalShouldReportError(error)
Then you need a small wrapper around
from closure_linter import gjslint import myerrorrules if __name__ == '__main__': myerrorrules.InjectErrorReporter() gjslint.main()
And quite the same for
from closure_linter import fixjsstyle import myerrorrules if __name__ == '__main__': myerrorrules.InjectErrorReporter() fixjsstyle.main()
That is all! Now you just have to start
fixjsstyle through these wrappers and you will have all the errors ignored that you like.