javascriptjshintbabeljsuse-strict

How to remove global "use strict" added by babel


I'm using function form of "use strict" and don't want global form which Babel adds after transpilation. The problem is I'm using some libraries that aren't using "use strict" mode and it might throw error after scripts are concatenated


Solution

  • Babel 5

    You'd blacklist "useStrict". For instance here's an example in a Gruntfile:

    babel: {
        options: {
            blacklist: ["useStrict"],
            // ...
        },
        // ...
    }
    

    Babel 6

    Since Babel 6 is fully opt-in for plugins now, instead of blacklisting useStrict, you just don't include the strict-mode plugin. If you're using a preset that includes it, I think you'll have to create your own that includes all the others, but not that one.