JSHint file #9

Closed
wants to merge 4 commits into
from

2 participants

@nschonni
  • Normalize mixed spaces and tabs to all tabs
  • Adds Use Strict directive
  • Strict equality comparisons
  • Bump version to 0.0.7
  • Re-minify using http://refresh-sf.com/yui/
@mathiasbynens mathiasbynens commented on the diff Nov 6, 2012
jquery.details.js
// Wrap child text nodes in a `span` element
$detailsNotSummaryContents.filter(function() {
// Only keep the node in the collection if it’s a text node containing more than only whitespace
// http://www.whatwg.org/specs/web-apps/current-work/multipage/common-microsyntaxes.html#space-character
- return this.nodeType == 3 && /[^ \t\n\f\r]/.test(this.data);
+ return this.nodeType === 3 && /[^ \t\n\f\r]/.test(this.data);
@mathiasbynens
Owner
mathiasbynens added a line comment Nov 6, 2012

Why? A strict equality check is not needed (overkill) here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@mathiasbynens mathiasbynens commented on the diff Nov 6, 2012
jquery.details.js
@@ -110,12 +110,12 @@
}
// Look for direct child text nodes
- if ($detailsNotSummary.length != $detailsNotSummaryContents.length) {
+ if ($detailsNotSummary.length !== $detailsNotSummaryContents.length) {
@mathiasbynens
Owner
mathiasbynens added a line comment Nov 6, 2012

Why? A strict equality check is not needed (overkill) here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@mathiasbynens mathiasbynens commented on the diff Nov 6, 2012
jquery.details.js
@@ -131,7 +131,7 @@
// Toggle the `open` and `aria-expanded` attributes and the `open` property of the `details` element and display the additional info
toggleOpen($details, $detailsSummary, $detailsNotSummary, true);
}).keyup(function(event) {
- if (32 == event.keyCode || (13 == event.keyCode && !isOpera)) {
+ if (event.keyCode === 32 || (event.keyCode === 13 && !isOpera)) {
@mathiasbynens
Owner
mathiasbynens added a line comment Nov 6, 2012

Why? A strict equality check is not needed (overkill) here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@mathiasbynens mathiasbynens commented on the diff Nov 6, 2012
jquery.details.js
;(function(document, $) {
-
+ "use strict";
@mathiasbynens
Owner
mathiasbynens added a line comment Nov 6, 2012

Why? I don’t think strict mode matters for this code, or does it?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@mathiasbynens

I don’t “mix tabs and spaces” — I use tabs for indentation and spaces for presentational indentation. That way, the source code looks like I intended it to, regardless of editor settings.

@nschonni

Since the var goes from line 5 to 47, I think it is seeing that as one "line" so even turning on SmartTabs still causes it to give the warning.
Strict was mostly about style, but those comparisons don't need type coercion.
JSHint is more about style than function, but most of the rules can be all opted out selectively using a /* jshint */ directive at the top.

@nschonni

Closing since it has been 3 months and no response

@nschonni nschonni closed this Feb 14, 2013
@nschonni nschonni deleted the nschonni:jshint branch Feb 14, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment