Search code examples
javascriptreactjsgoogle-closureeslintgoogle-closure-linter

Enable JSX in Closure Linter


Is there any option to use JSX syntax with Closure Linter? Or is it possible to use eslint with Google closure?

I'm trying figure out how to setup linter for my new project where I use Google closure library and Facebook React, but I can't get working closure linter with jsx syntax and I don't know how to configure .eslintrc to work with closure stuff like goog.require without getting warning "goog" is not defined


Solution

  • I don't believe closure linter understands JSX. As for configuring eslint, to let it know 'goog' is global and not show warning, put this in your .eslintrc file:

    YAML

    globals:
      $: true
      goog: true
    

    JSON

    {
        "globals": {
            "$": true,
            "goog": true
        }
    }
    

    Here is the eslint documentation.