[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
[orion-dev] Custom Types/Globals in CodeEditWidget
|
Hi,
to use the CodeEditWidget and its completion/validation features with my own custom types, I currently have to do the following steps (which currently work fine for me):
1. In ternWorkerCore.js search for the ternDefaults definition and add a link to my ASP.NET HTTP request handler (e.g. TypeHandler.ashx?return=types) to the dependencies list => this loads the code completion definitions for Tern
2. In ternWorkerCore.js search for eslint/conf/environments and add a link to my request handler (e.g. TypeHandler.ashx?return=globals) which extends the builtin globals by my types => ESLint knows my types WITHOUT having to specify a eslint-env directive
3. In javascriptPlugin.js search for ecma5 in the computeContentAssist function and add the name of my type definition file (e.g. mydefinition: true)
The mentioned request handler dynamically creates the Tern definitions / ESLint globals for the custom types (see below for example outputs), because they can possibly change due to a plugin concept. Therefore a static definition file is not sufficient.
But this procedure is tedious and error prone especially when I update the widget, since the mentioned files are minified by default(!). To figure out the steps above I actually created a custom build definition which omits the minification step.
With all the new possibilities due to .tern-project files, is there an easier way to accomplish this? Ideally I would like to write some kind of plugin file where I setup all I need and then just feed it to the CodeEditWidget by a function/during the create step. The important points for me are:
1. A dynamic HTTP request handler has to work, a static definition file is not sufficient
2. The types should behave like builtins without the need to specify a eslint-env directive in every script
TypeHandler.ashx?return=types returns a Tern definition file like this:
define([], function () {
return {
"!name": "mydefinition",
MyType1: {
...
}
};
});
TypeHandler.ashx?return=globals returns ESLint globals like this (extending the predefined builtins!):
define(["eslint/conf/globals"], function (globals) {
globals.builtin.MyType1 = false;
...
return { builtin: globals.builtin };
});
Thanks and regards,
Sebastian