Autofill multiple js files in Cloud9

I'm trying to move my workspace to c9 because the Ace editor autocomplete really liked me when I was working on NodeJS projects.

But now I would like to work with client-side JS files. From that moment on, autocompletion goes wrong. In fact, there is nothing like the โ€œrequireโ€ command on the JS client side inside the JS files themselves (other than using some plugins) to report other source files used in.

Therefore, when I use a function defined in another file (even libraries, frameworks: jquery, etc.) in one of my JS files, Ace notifies me that the function is not defined (because it has no way to know that function is defined in another file, I think).

Here we say: is there some kind of comment line that I could add to my code or some c9 configuration that I could install to fix this behavior?

+4
source share
2 answers

To remove errors and warnings, you can simply add the following line at the top of your javascript file:

/* globals jquery lodash someOtherLibrary */

However, Cloud9 does not autocomplete for client-side libraries.

+2
source

C9 abuse requires support

When you use var yourLibrary = require("./somefile.js");, autocomplete works fine.

But, as you said, it require()does not exist, and you do not want to yourLibrarybe set to undefined. (Or just throw an error)

As it turned out, C9 is not so smart:

//Your library was defined in some other file

var yourLibrary; //"This does nothing other than making C9 happy
function require() {return 1;} //Define the require function
if(false) {
   yourLibrary = require("yourLibraryFile.js");
}

( )!

. .

+1

Source: https://habr.com/ru/post/1588926/


All Articles