Roadmap for ECMAScript 6 on the Frontend (Obsolete Syntax Checker)

Martin76
Kilo Expert

Many times the question has been asked why ServiceNow does not support ECMAScript 6 (ES6) in server-scripts. This is not my question.

My question is why on Earth scripts supposed to run in client's browser are being checked for syntax errors using an outdated server-side syntax checker that does not recognise ES6?

find_real_file.png

Think of it as two different languages: ECMAScript 5, supported by the server, and ECMAScript 6, supported by any modern browser. There is no sense in using an ES5 checker to check ES6 code. It's like using Shakespeare's English to spellcheck this post.

I'm getting complaints from other developers that they cannot edit ES6 code right in the editor when they need to touch it.

Please ServiceNow remove the counterproductive ES5 checks for client-side script fields and make a statement on this.

Please anyone else interested in lifting the restriction upvote the request.
Thank you

 
5 REPLIES 5

Tommy Jensen
Giga Guru

What happens if you use the vs code (the official) extension to edit the code. Will that still be refused when saving? I have not tried myself but that might be a work around.

That's a good point. This problem solely occurs when editing through the web interface. Hence the fix from ServiceNow should be quite simple.
And even though I do use an external editor to push code to the instance, there are colleagues who don't. From their point of view, I can be seen as a troublemaker who uses some kind of "black magic syntax" that makes the script unsaveable.

 

DrewW
Mega Sage
Mega Sage

I'm sure that the reason the script formatter is only ES5 is because the backend is ES5 and they do not want people to get confused on which version of javascript to write the code in when you can use a UI Action that has both a client and server portion in the same script.  The backend is going to stay ES5 until Rhino JavaScript engine is updated to ES6 which has not happened last I checked.

There is a button on the script editor to allow a user to turn it off, its the second icon from the left.  Not the best option but it is an option.

Personally I would tell people to stick with ES5 since that is what the backend uses. So they have to add a few more parentheses here and there, not that difficult.  Also as stated above there are also UI Actions that you can use that can also have a backend component so I would just stick with ES5, but thats just me.

 

Thank you for your point of view, Drew.

I agree up to a point.

Yes, there is the possibility of having mixed UI and server code for UI Actions which would make it difficult to decide which part of the code should be checked. However, I don't personally see it as an impediment. If that must be checked, the message could be just a warning instead of an error which prevents the record from saving.

As for the button you mentioned, it only turns formatting and highlighting on/off, not the syntax checker, so this is unfortunately not an option.

find_real_file.png

And of course, you can always add a few braces here and there together with extra keywords, function calls and newlines to make it more readable. The question is why wouldn't you simplify your life 🙂