Search code examples
javascriptcloud9-ide

How do I get Cloud9 to accept a "global" variable?


From using Cloud9 I have noticed that the editor accepts $ as a global variable, but not other variables like _:

Cloud9 screenshot

Is there any way I can instruct the editor that it should accept the global underscore variable?


When I say "global" in this context, I mean "defined on the window object"


Solution

  • This hasn't been answered yet so I figured I'd update everyone who's landing here from Google.

    It's now possible to do this without explicitly defining globals at the top of every javascript file by using an .eslintrc file at the root of your project in C9. You can see the documentation for this here on the eslint site.

    For your use case, your .eslintrc file would look something like this:

    {
        "globals": {
            "_": false
        }
    }
    

    Assigning it to false means that the linter will warn you when you try to overwrite the global. Setting it to true would allow reassignment of the global. Javascript would allow you to do it in either case, this setting only affects the linter behaviour.