Page MenuHomePhabricator

JS code editor in 2010 wikitext editor: Warning: Too many errors. (n% scanned).
Closed, DuplicatePublicFeature

Description

Feature summary:
Not sure if this should be filed as a feature request or a bug.

The code editor info/warnings/errors (which seem to be based on JSHint?) is very useful. But unfortunately whenever you edit a script that isn't very small, it throws this "too many errors" warning, even if there aren't any errors.

diff-context.js is an example of a script that triggers this, and that's just a 10K script. It shows three warnings: limitLineNum is already defined (nothing to worry about), some confusing plusses (same) and "too many errors". The same script in JSHint shows only two warnings: limitLineNum and the plusses.

Use case(s):
Get useful warnings/errors.

Benefits:
Less need for external JSHint checking.

I'm hoping this is just a limit that was configured way too conservatively and can easily be raised.

Event Timeline

Restricted Application added a subscriber: Aklapper. · View Herald Transcript

Pretty sure this is provided by Extension:CodeEditor, so have tagged CodeEditor instead :)

I couldn't immediately see a config variable for this, but I feel like its something to do with the $wgScribuntoEngineConf here?

<sarcasm>
Side note, seeing as we have

we definitely need to create MirrorMirror, and EditorMirror
</sarcasm>

Pretty sure this is provided by Extension:CodeEditor, so have tagged CodeEditor instead :)

I couldn't immediately see a config variable for this, but I feel like its something to do with the $wgScribuntoEngineConf here?

I don't think so. I found this issue on Github which links maxerr in ace/lib/ace/mode/javascript_worker.js. For us this is found in https://en.wikipedia.org/w/extensions/CodeEditor/modules/ace/worker-javascript.js. There's a window.ace object but I can't find changeOptions in it.

<sarcasm>
Side note, seeing as we have

we definitely need to create MirrorMirror, and EditorMirror
</sarcasm>

Here's an EditorEditor. :-)

Pretty sure this is provided by Extension:CodeEditor, so have tagged CodeEditor instead :)

I couldn't immediately see a config variable for this, but I feel like its something to do with the $wgScribuntoEngineConf here?

It's definitely maxerr. Here's how to reliably reproduce this: https://commons.wikimedia.beta.wmflabs.org/wiki/User:AJ/toomanyerrors.js

It's counting strict errors, but it's not running in strict mode. Aborting after 100 errors have been shown is sensible, but when not running in strict mode those "errors" aren't shown at all.

I propose we just multiply maxerr with a factor 1000 or so. Doesn't solve the underlying issue, but good enough for us.

Pretty sure this is provided by Extension:CodeEditor, so have tagged CodeEditor instead :)

I couldn't immediately see a config variable for this, but I feel like its something to do with the $wgScribuntoEngineConf here?

I don't think so. I found this issue on Github which links maxerr in ace/lib/ace/mode/javascript_worker.js. For us this is found in https://en.wikipedia.org/w/extensions/CodeEditor/modules/ace/worker-javascript.js. There's a window.ace object but I can't find changeOptions in it.

Oooh, you're quite right..

Pretty sure this is provided by Extension:CodeEditor, so have tagged CodeEditor instead :)

I couldn't immediately see a config variable for this, but I feel like its something to do with the $wgScribuntoEngineConf here?

It's definitely maxerr. Here's how to reliably reproduce this: https://commons.wikimedia.beta.wmflabs.org/wiki/User:AJ/toomanyerrors.js

It's counting strict errors, but it's not running in strict mode. Aborting after 100 errors have been shown is sensible, but when not running in strict mode those "errors" aren't shown at all.

I propose we just multiply maxerr with a factor 1000 or so. Doesn't solve the underlying issue, but good enough for us.

I'm going to set maxerr: 1000 (tested User:AJ/toomanyerrors.js and User:NguoiDungKhongDinhDanh/diff-context.js locally, it "resolves" the error) — we should see how that goes & try to resolve the root cause

Change 799384 had a related patch set uploaded (by Samtar; author: Samtar):

[mediawiki/extensions/CodeEditor@master] Ace editor config: Increase maxerr

https://gerrit.wikimedia.org/r/799384

Test wiki created on Patch demo by TheresNoTime using patch(es) linked to this task:
https://patchdemo.wmflabs.org/wikis/c2b4c82f0c/w/

Thanks, I was able to change the contents after messing around a bit.

1000 isn't enough for Bawl for which JSHint normally reports no errors: https://en.wikipedia.org/wiki/User:Alexis_Jazz/Bawl-test.js. On your demo page "too many errors" is triggered at line 1760 (out of 6645). Maybe 10000 would cover most scripts?

For Bawl, there are two types of error that cause the ceiling to be reached:

  • Ironic Missing "use strict" statement. errors for every single function.
  • $ is not declared errors. Just repeating $('body'); 101 times also triggers "too many errors". In JSHint there's this "assume jQuery" option, can that be enabled somehow here as well? (putting /*globals $:false */ in the script also works, but isn't that pretty) Maybe 1000 would be enough if $ was ignored, Bawl has "only" 300 functions.

It seems Bawl is already strict-compliant, just not declared as such, so for Bawl I'll switch to strict mode soon.

Test wiki on Patch demo by TheresNoTime using patch(es) linked to this task was deleted:

https://patchdemo.wmflabs.org/wikis/c2b4c82f0c/w/