iitc-project / ingress-intel-total-conversion

ingress.com/intel total conversion user script with some new features. Should allow easier extension of the intel map.
http://iitc.jonatkins.com/
ISC License
989 stars 552 forks source link

Is there way to insert "use strict" with @@PLUGINSTART@@? #1186

Open hayeswise opened 7 years ago

hayeswise commented 7 years ago

I'm developing code using the IITC development framework and I've come to realize that using "use srict"; is problematic in this setting:

@@PLUGINSTART@@
 "use strict";

"use strict";must occur before any other statements and @@PLUGINSTART@@ is replace with a few lines of code after the function wrapper(plugin_info) {.

I've noticed that you can put "use strict"; before @@PLUGINSTART@@ and any other code in the file; but, TamperMonkey's jslint will flag this as warning: Use the function form of "use strict".

So one alternative is to put the following before any other code:

/*jslint node: true */
 "use strict";

But, if you have "use srict"; elsewhere, then jslint flags a bunch of errors. Furthermore, if you're mixing in non-strict code then more errors could be flagged (I'm using @@INCLUDERAW:...@@).

Thus, it seems like it would be better to do something like

@@PLUGINSTART:"use strict";@@

or

@@PLUGINSTART-USE-STRICT@@
nhamer commented 7 years ago

@@PLUGINSTART-USE-STRICT@@ makes sense, why not create a pull request for it?

hayeswise commented 7 years ago

Thanks for the encouragement. See pull request 1187.

johnd0e commented 5 years ago

Instead of separate macro @@PLUGINSTART-USE-STRICT@@ it's more proper (and simple) just modify wrapper for all plugins.

Is there any reason not to use strict; nowadays?