https://bugzilla.wikimedia.org/show_bug.cgi?id=68280

Krinkle <[email protected]> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Priority|Unprioritized               |Lowest
                 CC|                            |[email protected]
          Component|JavaScript                  |ResourceLoader
            Summary|Make skip files valid       |ResourceLoader: Skip files
                   |javascript files            |should be valid javascript
                   |                            |files
           Severity|normal                      |enhancement

--- Comment #2 from Krinkle <[email protected]> ---
Also note that this is the result of various different attempts and
compromises.

The dozens of other approaches all involved bloating the startup module output,
repeating the same boilerplate in lots of files, or ending up with error pronse
constructions, or files that aren't valid on their own.

These files are valid javascript code (as verified by jshint). Returning from
outside a function is indeed a syntax error if it were executed like that, but
it's executed as a function, not as a standalone program.

Some of the alternatives I considered:

--- func
function skip() {
  return true;
}

* Downside: Trips jshint's quality rule against having unused functions. We'd
have to put /*jshint unused:false */ atop each file.

-- block
skip: {
  return true;
}

* This makes use of javascript supporting (goto/continue-like) label statements
and unattached block statements to wrap code.
* If executed standalone would be an illegal return statement.

-- expression
true;

* This makes use of javascript supporting bare expression statements.
* Downside: Trips jshint's quality rule against having code that does not
assign or invoke anything. We'd have to put /*jshint expr:true */ atop each
file.

-- return
return true;

* If executed standalone would be an illegal return statement.


--
For 'func' and 'block':
* Extra boilerplate to repeat in each file.
* Either bloats the startup module and requires the client to perform extra
actions to invoke it (due to name collision otherwise), or, it could be
stripped by the server and reduced to 'return true;' but in that case it needs
to be very exact. And anything outside of it would be ignored or result in an
error. I think if all files contain the same character-by-character
prefix/suffix only to be stripped, and result in exceptions when not exactly
the same, might as well not have it.


The cleanest of these are 'block' and 'return'. They require no jshint
overrides, is valid javascript passing jshint. Of those 'return' seemed the
best.

-- 
You are receiving this mail because:
You are the assignee for the bug.
You are on the CC list for the bug.
_______________________________________________
Wikibugs-l mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/wikibugs-l

Reply via email to