Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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"

like image 907
Hubro Avatar asked Jan 02 '15 07:01

Hubro


People also ask

How to use global variables in AutoSys?

Looking for a way to use global variables in AutoSys to perform the following functions. 1) SQL query job obtains a value from the database and stores that value in an existing AutoSys global variable "BillID". Later in the day, different jobs use the value of the variable a parameter.

How to create a variable automatically in an app?

Go to Solution. 04-06-2021 06:37 PM 2\ If you want to create variables automatically, please try the following ways. (1) Use app's OnStart property. Automatically create a variable when the app is opened (2) Use screen's OnVisible property.Automatically create variables when a specific screen is visible.

Is there a way to add a global varname in JavaScript?

The obvious solution would be to just add the comment /*global VarName*/ and be done with it, but I don't believe this is a good practice. After researching, I came across the JavaScript import functionality.


1 Answers

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.

like image 107
Nimphious Avatar answered Oct 04 '22 11:10

Nimphious