figwheel-main icon indicating copy to clipboard operation
figwheel-main copied to clipboard

How to treat warnings as errors?

Open metametadata opened this issue 5 years ago • 2 comments

I'm trying to use figwheel-main to produce the final minified js file and can't find the way to fail the build in case JS warnings are detected:

2019-02-19 00:40:33.016:INFO::main: Logging initialized @4830ms
[Figwheel] Validating figwheel-main.edn
[Figwheel] figwheel-main.edn is valid \(ツ)/
[Figwheel] Compiling build min to "resources/public/js/spa.js"
[Figwheel:WARNING] Compile Warning   /Users/yuri/xxxx   line:44  column:22

  Use of undeclared Var app.app/app123
...
[Figwheel] Successfully compiled build min to "resources/public/js/spa.js" in 61.212 seconds.

With cljsbuild it was possible to achieve via :warning-handlers (http://jakemccrary.com/blog/2015/12/19/clojurescript-treat-warnings-as-errors/).

This is crucial for automated CI builds. We don't want to deploy the buggy bundle.

metametadata avatar Feb 18 '19 22:02 metametadata

So this is certainly possible and it sounds like a good feature to explore. The idea of failing on warnings when you are doing a build-once context. I like the idea of having this as a flag.

bhauman avatar Apr 10 '19 14:04 bhauman

For reference, I've found some :warning-handlers in figwheel.main, for example here but it doesn't seem used.

Would you accept @bhauman to give some breadcrumbs about how to implement that, and would you consider a PR if you think it's a good first issue?

piotr-yuxuan avatar Feb 08 '22 22:02 piotr-yuxuan