Hashar has submitted this change and it was merged.

Change subject: Lint: Go-go-gadget jshint! Passing entire JS code base (again).
......................................................................


Lint: Go-go-gadget jshint! Passing entire JS code base (again).

There were still some files not passing jshint, and for files
that did, we managed to screw 'em up again.

Added more explicit settings in .jshintrc to avoid relying on a
kind of default somewhere. There are too many default-factors:
closest(.jshintrc), ~/.jshintrc, IDE/editor, node-jshint..

Added node_modules/ and extensions/ to .jshintignore.
Previously "$ jshint ." would recurse over all kinds of
unrelated code. Extensions should have their own jshint
dotfiles. When linting from Jenkins this won't be a problem as
those will be ran per repo (so when linting core it will skip extensions and 
when in an extension dir, the core dotfiles
don't apply as they'll be out of scope).

Some of our modules are really messy and should be refactored
to be less spaghetti-ish and have more descriptive variable
names and more manageable function-level complexity.
But for this commit, I'm keeping it as much as-is as possible,
because its hard/large enough to review as it is.

A few errors are cited below to give an impression of the kind
of warnings I addressed (for cases where the diff isn't
so obvious):

* jquery.hidpi.js: line 110, col 15, Empty block.
* mediawiki.jqueryMsg.js: line 34, col 17, Too many var statements.
* mediawiki.jqueryMsg.js: line 145, col 33, Strings must use singlequote.
* mediawiki.action.edit.js: line 74, col 73, 'selectText' is defined but never 
used.
* startup.js: line 19, col 22, 'isCompatible' is defined but never used.
* jquery.byteLength.test.js: line 26, col 9, Identifier 'U_00A2' is not in 
camel case.
* jquery.localize.test.js: line 63, col 29, 'attrs' is defined but never used.
* mediawiki.cldr.test.js: line 72, col 27, 'mw' is not defined.
* mediawiki.jscompat.test.js: line 6, col 17, Strings must use singlequote.
* mediawiki.api.parse.test.js: line 9, col 17, Strings must use singlequote.
* mediawiki.api.parse.test.js: line 7, col 15, 'mw' is not defined.
* mediawiki.api.parse.test.js: line 14, col 24, '$' is not defined.
* mediawiki.api.test.js: line 43, col 28, 'data' is defined but never used.

Other fixes:
* Add closures fix implied global errors ($, mw and more),
  and prevents local variables from becoming globals.
* Avoid jQ magic map arg etc. (per code conventions).
* Fix incorrect usage of jQuery methods (prop instead of attr,
  prop false instead of removeProp, ..).
* Unquote keys in object literals for consistency, and
  enforce single quotes (no magic quotes in javascript, as much
  as we might think "\n" and '/n' are really exactly the same).
  Chose single quotes over double quotes since that's what most
  code already had and what conventions seemed to prefer
  (both the old generic ones and the new per-lang ones since
  2011/2012).
* Enforce camelCase variable names with jshint per code
  conventions.
* $foo.on('x', fn).trigger('x') -> $foo.on('x', fn); fn()
  (No event simulation overhead, unless intended of course)
* Incorrect indentation (ignore whitespace in the diff!).
* Avoid proprietary selectors like ':first' when .eq(0)
  afterwards is just as possible (significantly faster in
  jQuery due to mostly avoiding the Sizzle engine and going
  native in modern browsers).
* When at it, convert deprecated jQuery methods to new ones.
  Mostly just .delegate(sel, type, fn) -> .on(type, sel, fn).
* Addressed whitespace here and there.

Interesting:
* mediawiki.js: local function "compare" wasn't used anymore
  (hasn't been in a while!) removed per jshint warning.

* mediawiki.special.recentchanges.js: Was a mess, only a few
  lines of code, rewritten.

Pfew, let's hope it's the last one before we lint from Jenkins!

Change-Id: I23ad60a1d804c542d9b91454aaa20ce7be4ff289
---
M .gitignore
M .jshintignore
M .jshintrc
M resources/jquery/jquery.checkboxShiftClick.js
M resources/jquery/jquery.client.js
M resources/jquery/jquery.collapsibleTabs.js
M resources/jquery/jquery.colorUtil.js
M resources/jquery/jquery.expandableField.js
M resources/jquery/jquery.hidpi.js
M resources/jquery/jquery.highlightText.js
M resources/jquery/jquery.mw-jump.js
M resources/jquery/jquery.mwExtension.js
M resources/jquery/jquery.qunit.completenessTest.js
M resources/jquery/jquery.suggestions.js
M resources/jquery/jquery.textSelection.js
M resources/mediawiki.action/mediawiki.action.edit.js
M resources/mediawiki.language/mediawiki.cldr.js
M resources/mediawiki.language/mediawiki.language.init.js
M resources/mediawiki.language/mediawiki.language.js
M resources/mediawiki.page/mediawiki.page.ready.js
M resources/mediawiki.page/mediawiki.page.watch.ajax.js
M resources/mediawiki.special/mediawiki.special.block.js
M resources/mediawiki.special/mediawiki.special.javaScriptTest.js
M resources/mediawiki.special/mediawiki.special.js
M resources/mediawiki.special/mediawiki.special.movePage.js
M resources/mediawiki.special/mediawiki.special.preferences.js
M resources/mediawiki.special/mediawiki.special.recentchanges.js
M resources/mediawiki.special/mediawiki.special.search.js
M resources/mediawiki.special/mediawiki.special.undelete.js
M resources/mediawiki.special/mediawiki.special.upload.js
M resources/mediawiki/mediawiki.Title.js
M resources/mediawiki/mediawiki.feedback.js
M resources/mediawiki/mediawiki.hidpi.js
M resources/mediawiki/mediawiki.htmlform.js
M resources/mediawiki/mediawiki.jqueryMsg.js
M resources/mediawiki/mediawiki.js
M resources/mediawiki/mediawiki.notification.js
M resources/mediawiki/mediawiki.util.js
M resources/startup.js
M tests/qunit/data/callMwLoaderTestCallback.js
M tests/qunit/data/generateJqueryMsgData.php
M tests/qunit/data/mediawiki.jqueryMsg.data.js
M tests/qunit/data/testrunner.js
M tests/qunit/suites/resources/jquery/jquery.autoEllipsis.test.js
M tests/qunit/suites/resources/jquery/jquery.byteLength.test.js
M tests/qunit/suites/resources/jquery/jquery.byteLimit.test.js
M tests/qunit/suites/resources/jquery/jquery.client.test.js
M tests/qunit/suites/resources/jquery/jquery.colorUtil.test.js
M tests/qunit/suites/resources/jquery/jquery.delayedBind.test.js
M tests/qunit/suites/resources/jquery/jquery.getAttrs.test.js
M tests/qunit/suites/resources/jquery/jquery.hidpi.test.js
M tests/qunit/suites/resources/jquery/jquery.highlightText.test.js
M tests/qunit/suites/resources/jquery/jquery.localize.test.js
M tests/qunit/suites/resources/jquery/jquery.mwExtension.test.js
M tests/qunit/suites/resources/jquery/jquery.tabIndex.test.js
M tests/qunit/suites/resources/jquery/jquery.tablesorter.test.js
M tests/qunit/suites/resources/jquery/jquery.textSelection.test.js
M tests/qunit/suites/resources/mediawiki.api/mediawiki.api.parse.test.js
M tests/qunit/suites/resources/mediawiki.api/mediawiki.api.test.js
M 
tests/qunit/suites/resources/mediawiki.special/mediawiki.special.recentchanges.test.js
M tests/qunit/suites/resources/mediawiki/mediawiki.Title.test.js
M tests/qunit/suites/resources/mediawiki/mediawiki.Uri.test.js
M tests/qunit/suites/resources/mediawiki/mediawiki.cldr.test.js
M tests/qunit/suites/resources/mediawiki/mediawiki.jscompat.test.js
M tests/qunit/suites/resources/mediawiki/mediawiki.language.test.js
M tests/qunit/suites/resources/mediawiki/mediawiki.test.js
M tests/qunit/suites/resources/mediawiki/mediawiki.user.test.js
M tests/qunit/suites/resources/mediawiki/mediawiki.util.test.js
68 files changed, 4,442 insertions(+), 4,237 deletions(-)

Approvals:
  Hashar: Looks good to me, approved
  jenkins-bot: Verified


--
To view, visit https://gerrit.wikimedia.org/r/32183
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I23ad60a1d804c542d9b91454aaa20ce7be4ff289
Gerrit-PatchSet: 3
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Krinkle <ttij...@wikimedia.org>
Gerrit-Reviewer: Catrope <roan.katt...@gmail.com>
Gerrit-Reviewer: Hashar <has...@free.fr>
Gerrit-Reviewer: Krinkle <ttij...@wikimedia.org>
Gerrit-Reviewer: Nikerabbit <niklas.laxst...@gmail.com>
Gerrit-Reviewer: Siebrand <siebr...@wikimedia.org>
Gerrit-Reviewer: jenkins-bot

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to