we're using the ACE editor to write javascript code that's interpreted on the server side. So the server has a JavaScript interface and can execute submitted code to accomplish some task from the outside.
The server implements some new objects that are not known by ACE. So ACE shows a warning, if one of this unknown objects is used in code.
What is the correct way to tell ACE, that there are some new objects, variables und functions? I already took a look into worker-javascript.js, but I DON'T want to reimplement this whole stuff (updating ACE would get harder than). Is there any interface I can use?
Ace uses jshint, which has an option to set a list of global variables:
(function configureAceWorker() {
const worker = editor.session.$worker;
if (!worker) {
// Chris Janssen: You may need to set a timeout to delay the call
// until the editor is done being setup by ace
// or you will get an error due to the worker not existing yet.
setTimeout(configureAceWorker, 500);
} else {
worker.call("changeOptions", [{
// https://jshint.com/docs/options
globals: { foo: false, bar: false }, // false = read-only
undef: true, // enable warnings on undefined variables
}]);
}
})();