enforce double quotes via JSHint. Closes gh-975

This commit is contained in:
Mike Sherov 2012-10-16 10:17:14 -04:00 committed by Rick Waldron
parent 605a38073e
commit ed9e34482a
16 changed files with 116 additions and 107 deletions

View File

@ -5,6 +5,7 @@
"expr": true,
"latedef": true,
"noarg": true,
"quotmark": "double",
"smarttabs": true,
"trailing": true,
"undef": true

View File

@ -153,7 +153,7 @@ module.exports = function( grunt ) {
}, {
authUsername: config.authUsername,
authToken: config.authToken,
jobName: 'jQuery commit #<a href="https://github.com/jquery/jquery/commit/' + commit + '">' + commit.substr( 0, 10 ) + '</a>',
jobName: "jQuery commit #<a href='https://github.com/jquery/jquery/commit/" + commit + "'>" + commit.substr( 0, 10 ) + "</a>",
runMax: config.runMax,
"runNames[]": tests,
"runUrls[]": testUrls,

View File

@ -26,7 +26,7 @@
"grunt-compare-size": ">=0.1.0",
"grunt-git-authors": ">=1.0.0",
"grunt-update-submodules": ">=0.1.0",
"grunt": "~0.3.9",
"grunt": "~0.3.17",
"testswarm": "0.2.2"
},
"keywords": []

View File

@ -10,7 +10,8 @@
"undef": true,
"smarttabs": true,
"sub": true,
"maxerr": 100
"maxerr": 100,
"quotmark": "double"
},
"globals": {
"define": true,

View File

@ -10,7 +10,8 @@
"undef": true,
"smarttabs": true,
"maxerr": 100,
"sub": true
"sub": true,
"quotmark": "double"
},
"globals": {
"define": true,

View File

@ -2674,7 +2674,7 @@ if ( jQuery.ajax && ( !isLocal || hasPHP ) ) {
ok( false, "error callback called" );
}
}).fail(function( _, reason ) {
strictEqual( reason, 'canceled', "Request aborted by the prefilter must fail with 'canceled' status text" );
strictEqual( reason, "canceled", "Request aborted by the prefilter must fail with 'canceled' status text" );
});
});

View File

@ -516,11 +516,11 @@ test("removeAttr(String)", function() {
try {
$first = jQuery("#first").attr("contenteditable", "true").removeAttr("contenteditable");
equal( $first.attr('contenteditable'), undefined, "Remove the contenteditable attribute" );
equal( $first.attr("contenteditable"), undefined, "Remove the contenteditable attribute" );
} catch(e) {
ok( false, "Removing contenteditable threw an error (#10429)" );
}
$first = jQuery("<div Case='mixed'></div>");
equal( $first.attr("Case"), "mixed", "case of attribute doesn't matter" );
$first.removeAttr("Case");

View File

@ -32,14 +32,14 @@ var output,
};
}
};
function showFlags( flags ) {
if ( typeof flags === "string" ) {
return '"' + flags + '"';
return "'" + flags + "'";
}
var output = [], key;
for ( key in flags ) {
output.push( '"' + key + '": ' + flags[ key ] );
output.push( "'" + key + "': " + flags[ key ] );
}
return "{ " + output.join( ", " ) + " }";
}

View File

@ -567,7 +567,7 @@ test("XSS via location.hash", function() {
};
try {
// This throws an error because it's processed like an id
jQuery( '#<img id="check9521" src="no-such-.gif" onerror="jQuery._check9521(false)">' ).appendTo("#qunit-fixture");
jQuery( "#<img id='check9521' src='no-such-.gif' onerror='jQuery._check9521(false)'>" ).appendTo("#qunit-fixture");
} catch (err) {
jQuery["_check9521"](true);
}

View File

@ -570,7 +570,10 @@ test("jQuery.data supports interoperable hyphenated/camelCase get/set of propert
"an-object": {},
"bool-true": true,
"bool-false": false,
"some-json": '{ "foo": "bar" }',
// JSHint enforces double quotes,
// but JSON strings need double quotes to parse
// so we need escaped double quotes here
"some-json": "{ \"foo\": \"bar\" }",
"num-1-middle": true,
"num-end-2": true,
"2-num-start": true
@ -597,7 +600,10 @@ test("jQuery.data supports interoperable removal of hyphenated/camelCase propert
"an-object": {},
"bool-true": true,
"bool-false": false,
"some-json": '{ "foo": "bar" }'
// JSHint enforces double quotes,
// but JSON strings need double quotes to parse
// so we need escaped double quotes here
"some-json": "{ \"foo\": \"bar\" }"
};
expect( 27 );
@ -650,7 +656,7 @@ test( "Only check element attributes once when calling .data() - #8909", functio
test( "JSON data- attributes can have newlines", function() {
expect(1);
var x = jQuery("<div data-some='{\n\"foo\":\n\t\"bar\"\n}'></div>");
equal( x.data("some").foo, "bar", "got a JSON data- attribute with spaces" );
x.remove();

18
test/unit/effects.js vendored
View File

@ -429,7 +429,7 @@ asyncTest( "animate option { queue: 'name' }", function() {
order = [];
foo.animate( { width: origWidth + 100 }, {
queue: 'name',
queue: "name",
duration: 1,
complete: function() {
@ -1369,10 +1369,10 @@ test("animate will scale margin properties individually", function() {
// clean up for next test
foo.css({
"marginLeft": '',
"marginRight": '',
"marginTop": '',
"marginBottom": ''
"marginLeft": "",
"marginRight": "",
"marginTop": "",
"marginBottom": ""
});
start();
});
@ -1486,9 +1486,9 @@ test( "animate should set display for disconnected nodes", function() {
// parentNode = null
jQuery("<div/>"),
jQuery('<div style="display:inline"/>'),
jQuery("<div style='display:inline'/>"),
jQuery('<div style="display:none"/>')
jQuery("<div style='display:none'/>")
];
strictEqual( elems[ 0 ].show()[ 0 ].style.display, "block", "set display with show() for element with parentNode = document fragment" );
@ -1532,7 +1532,7 @@ asyncTest("Animation callback should not show animated element as animated (#715
foo.animate({
opacity: 0
}, 100, function() {
ok( !foo.is(':animated'), "The element is not animated" );
ok( !foo.is(":animated"), "The element is not animated" );
start();
});
});
@ -1563,7 +1563,7 @@ asyncTest( "hide, fadeOut and slideUp called on element width height and width =
elems = jQuery();
for ( ; i < 5; i++ ) {
elems = elems.add('<div style="width:0;height:0;"></div>');
elems = elems.add("<div style='width:0;height:0;'></div>");
}
foo.append( elems );

View File

@ -861,7 +861,7 @@ test("withinElement implemented with jQuery.contains()", function() {
expect(1);
jQuery("#qunit-fixture").append('<div id="jc-outer"><div id="jc-inner"></div></div>');
jQuery("#qunit-fixture").append("<div id='jc-outer'><div id='jc-inner'></div></div>");
jQuery("#jc-outer").bind("mouseenter mouseleave", function( event ) {
@ -934,8 +934,8 @@ test("trigger() shortcuts", function() {
elem.remove();
// test that special handlers do not blow up with VML elements (#7071)
jQuery('<xml:namespace ns="urn:schemas-microsoft-com:vml" prefix="v" />').appendTo('head');
jQuery('<v:oval id="oval" style="width:100pt;height:75pt;" fillcolor="red"> </v:oval>').appendTo('#form');
jQuery("<xml:namespace ns='urn:schemas-microsoft-com:vml' prefix='v' />").appendTo("head");
jQuery("<v:oval id='oval' style='width:100pt;height:75pt;' fillcolor='red'> </v:oval>").appendTo("#form");
jQuery("#oval").click().keydown();
});
@ -1003,21 +1003,21 @@ test("trigger(type, [data], [fn])", function() {
};
$elem.live('mouseenter', function(){
ok( true, 'Trigger mouseenter bound by live' );
$elem.live("mouseenter", function(){
ok( true, "Trigger mouseenter bound by live" );
});
$elem.live('mouseleave', function(){
ok( true, 'Trigger mouseleave bound by live' );
$elem.live("mouseleave", function(){
ok( true, "Trigger mouseleave bound by live" );
});
$elem.trigger('mouseenter');
$elem.trigger("mouseenter");
$elem.trigger('mouseleave');
$elem.trigger("mouseleave");
$elem.die('mouseenter');
$elem.die("mouseenter");
$elem.die('mouseleave');
$elem.die("mouseleave");
// Triggers handlrs and native
// Trigger 5
@ -1264,7 +1264,7 @@ test(".trigger() doesn't bubble load event (#10717)", function() {
});
// It's not an image, but as long as it fires load...
jQuery( '<img src="index.html" />' )
jQuery("<img src='index.html' />")
.appendTo( "body" )
.on( "load", function() {
ok( true, "load fired on img" );
@ -1279,10 +1279,10 @@ test("Delegated events in SVG (#10791)", function() {
expect(2);
var svg = jQuery(
'<svg height="1" version="1.1" width="1" xmlns="http://www.w3.org/2000/svg">'+
'<rect class="svg-by-class" x="10" y="20" width="100" height="60" r="10" rx="10" ry="10"></rect>'+
'<rect id="svg-by-id" x="10" y="20" width="100" height="60" r="10" rx="10" ry="10"></rect>'+
'</svg>'
"<svg height='1' version='1.1' width='1' xmlns='http://www.w3.org/2000/svg'>" +
"<rect class='svg-by-class' x='10' y='20' width='100' height='60' r='10' rx='10' ry='10'></rect>" +
"<rect id='svg-by-id' x='10' y='20' width='100' height='60' r='10' rx='10' ry='10'></rect>" +
"</svg>"
).appendTo( "body" );
jQuery( "body" )
@ -1305,9 +1305,9 @@ test("Delegated events in forms (#10844; #11145; #8165; #11382, #11764)", functi
// Alias names like "id" cause havoc
var form = jQuery(
'<form id="myform">'+
'<input type="text" name="id" value="secret agent man" />'+
'</form>'
"<form id='myform'>" +
"<input type='text' name='id' value='secret agent man' />" +
"</form>"
)
.on( "submit", function( event ) {
event.preventDefault();
@ -1323,7 +1323,7 @@ test("Delegated events in forms (#10844; #11145; #8165; #11382, #11764)", functi
.end()
.off("submit");
form.append('<input type="text" name="disabled" value="differently abled" />');
form.append("<input type='text' name='disabled' value='differently abled' />");
jQuery("body")
.on( "submit", "#myform", function() {
ok( true, "delegated id selector with aliased disabled" );
@ -1334,7 +1334,7 @@ test("Delegated events in forms (#10844; #11145; #8165; #11382, #11764)", functi
.off("submit");
form
.append( '<button id="nestyDisabledBtn"><span>Zing</span></button>' )
.append( "<button id='nestyDisabledBtn'><span>Zing</span></button>" )
.on( "click", "#nestyDisabledBtn", function() {
ok( true, "click on enabled/disabled button with nesty elements" );
})
@ -1360,10 +1360,10 @@ test("Submit event can be stopped (#11049)", function() {
// Since we manually bubble in IE, make sure inner handlers get a chance to cancel
var form = jQuery(
'<form id="myform">'+
'<input type="text" name="sue" value="bawls" />'+
'<input type="submit" />'+
'</form>'
"<form id='myform'>" +
"<input type='text' name='sue' value='bawls' />" +
"<input type='submit' />" +
"</form>"
)
.appendTo("body");
@ -2255,14 +2255,14 @@ test(".delegate()/.undelegate()", function() {
test("jQuery.off using dispatched jQuery.Event", function() {
expect(1);
var markup = jQuery( '<p><a href="#">target</a></p>' ),
var markup = jQuery("<p><a href='#'>target</a></p>"),
count = 0;
markup
.on( "click.name", "a", function( event ) {
equal( ++count, 1, "event called once before removal" );
jQuery().off( event );
})
.find( "a" ).click().click().end()
.find("a").click().click().end()
.remove();
});
@ -2708,7 +2708,7 @@ test("special bind/delegate name mapping", function() {
};
// Ensure a special event isn't removed by its mapped type
jQuery( '<p>Gut Feeling</p>' )
jQuery( "<p>Gut Feeling</p>" )
.on( "click", jQuery.noop )
.on( "gutfeeling", jQuery.noop )
.off( "click" )
@ -2716,14 +2716,14 @@ test("special bind/delegate name mapping", function() {
.remove();
// Ensure special events are removed when only a namespace is provided
jQuery( '<p>Gut Feeling</p>' )
jQuery( "<p>Gut Feeling</p>" )
.on( "gutfeeling.Devo", jQuery.noop )
.off( ".Devo" )
.trigger( "gutfeeling" )
.remove();
// Ensure .one() events are removed after their maiden voyage
jQuery( '<p>Gut Feeling</p>' )
jQuery( "<p>Gut Feeling</p>" )
.one( "gutfeeling", jQuery.noop )
.trigger( "gutfeeling" ) // This one should
.trigger( "gutfeeling" ) // This one should not
@ -2805,7 +2805,7 @@ test("fixHooks extensions", function() {
$fixture.bind( "click", function( event ) {
ok( !("blurrinessLevel" in event), "event.blurrinessLevel does not exist" );
});
fireNative( $fixture[0], 'click' );
fireNative( $fixture[0], "click" );
$fixture.unbind( "click" );
jQuery.event.fixHooks.click = {
@ -2819,7 +2819,7 @@ test("fixHooks extensions", function() {
$fixture.bind( "click", function( event ) {
equal( event.blurrinessLevel, 42, "event.blurrinessLevel was set" );
});
fireNative( $fixture[0], 'click' );
fireNative( $fixture[0], "click" );
delete jQuery.event.fixHooks.click;
$fixture.unbind( "click" ).remove();

View File

@ -190,7 +190,7 @@ test("wrap(String) consecutive elements (#10177)", function() {
targets.each(function() {
var $this = jQuery(this);
ok( $this.parent().is('.wrapper'), "Check each elements parent is correct (.wrapper)" );
ok( $this.parent().is(".wrapper"), "Check each elements parent is correct (.wrapper)" );
equal( $this.siblings().length, 0, "Each element should be wrapped individually" );
});
});
@ -447,7 +447,7 @@ var testAppend = function(valueObj) {
ok( jQuery("#nonnodes").contents().length >= 2, "Check node,textnode,comment append cleanup worked" );
QUnit.reset();
var $input = jQuery("<input />").attr({ "type": "checkbox", "checked": true }).appendTo('#testForm');
var $input = jQuery("<input />").attr({ "type": "checkbox", "checked": true }).appendTo("#testForm");
equal( $input[0].checked, true, "A checked checkbox that is appended stays checked" );
QUnit.reset();
@ -746,8 +746,8 @@ test("appendTo(String|Element|Array&lt;Element&gt;|jQuery)", function() {
if ( jQuery.getScript ) {
stop();
jQuery.getScript('data/test.js', function() {
jQuery('script[src*="data\\/test\\.js"]').remove();
jQuery.getScript("data/test.js", function() {
jQuery("script[src*='data\\/test\\.js']").remove();
start();
});
}
@ -919,7 +919,7 @@ test("before and after w/ empty object (#10812)", function() {
test("before and after on disconnected node (#10517)", function() {
expect(2);
equal( jQuery("<input type='checkbox'/>").before("<div/>").length, 2, "before() returned all elements" );
equal( jQuery("<input type='checkbox'/>").after("<div/>").length, 2, "after() returned all elements" );
});
@ -1242,7 +1242,7 @@ test("clone()", function() {
divEvt.remove();
// Test both html() and clone() for <embed and <object types
div = jQuery("<div/>").html('<embed height="355" width="425" src="http://www.youtube.com/v/3KANI2dpXLw&amp;hl=en"></embed>');
div = jQuery("<div/>").html("<embed height='355' width='425' src='http://www.youtube.com/v/3KANI2dpXLw&amp;hl=en'></embed>");
clone = div.clone(true);
equal( clone.length, 1, "One element cloned" );
@ -1713,25 +1713,25 @@ test("jQuery.buildFragment - no plain-text caching (Bug #6779)", function() {
test( "jQuery.html - execute scripts escaped with html comment or CDATA (#9221)", function() {
expect( 3 );
jQuery( [
'<script type="text/javascript">',
'<!--',
'ok( true, "<!-- handled" );',
'//-->',
'</script>'
"<script type='text/javascript'>",
"<!--",
"ok( true, '<!-- handled' );",
"//-->",
"</script>"
].join ( "\n" ) ).appendTo( "#qunit-fixture" );
jQuery( [
'<script type="text/javascript">',
'<![CDATA[',
'ok( true, "<![CDATA[ handled" );',
'//]]>',
'</script>'
"<script type='text/javascript'>",
"<![CDATA[",
"ok( true, '<![CDATA[ handled' );",
"//]]>",
"</script>"
].join ( "\n" ) ).appendTo( "#qunit-fixture" );
jQuery( [
'<script type="text/javascript">',
'<!--//--><![CDATA[//><!--',
'ok( true, "<!--//--><![CDATA[//><!-- (Drupal case) handled" );',
'//--><!]]>',
'</script>'
"<script type='text/javascript'>",
"<!--//--><![CDATA[//><!--",
"ok( true, '<!--//--><![CDATA[//><!-- (Drupal case) handled' );",
"//--><!]]>",
"</script>"
].join ( "\n" ) ).appendTo( "#qunit-fixture" );
});
@ -1739,7 +1739,7 @@ test("jQuery.buildFragment - plain objects are not a document #8950", function()
expect(1);
try {
jQuery('<input type="hidden">', {});
jQuery("<input type='hidden'>", {});
ok( true, "Does not allow attribute object to be treated like a doc object");
} catch (e) {}
@ -1930,7 +1930,7 @@ test("checked state is cloned with clone()", function(){
var elem = jQuery.parseHTML("<input type='checkbox' checked='checked'/>")[0];
elem.checked = false;
equal( jQuery(elem).clone().attr("id","clone")[0].checked, false, "Checked false state correctly cloned" );
elem = jQuery.parseHTML("<input type='checkbox'/>")[0];
elem.checked = true;
equal( jQuery(elem).clone().attr("id","clone")[0].checked, true, "Checked true state correctly cloned" );

View File

@ -476,15 +476,15 @@ test("offsetParent", function(){
test("fractions (see #7730 and #7885)", function() {
expect(2);
jQuery('body').append('<div id="fractions"/>');
jQuery("body").append("<div id='fractions'/>");
var expected = { "top": 1000, "left": 1000 };
var div = jQuery('#fractions');
var div = jQuery("#fractions");
div.css({
"position": 'absolute',
"left": '1000.7432222px',
"top": '1000.532325px',
"position": "absolute",
"left": "1000.7432222px",
"top": "1000.532325px",
"width": 100,
"height": 100
});

View File

@ -48,30 +48,30 @@ if ( jQuery.css ) {
t( "Is Not Hidden", "#qunit-fixture:hidden", [] );
t( "Is Hidden", "#form input:hidden", ["hidden1","hidden2"] );
var $div = jQuery('<div/>').appendTo("body");
var $div = jQuery("<div/>").appendTo("body");
$div.css({ fontSize: 0, lineHeight: 0 });// IE also needs to set font-size and line-height to 0
$div.css( "width", 1 ).css( "height", 0 );
t( "Is Visible", '#nothiddendivchild:visible', ['nothiddendivchild'] );
t( "Is Not Visible", '#nothiddendivchild:hidden', [] );
t( "Is Visible", "#nothiddendivchild:visible", ["nothiddendivchild"] );
t( "Is Not Visible", "#nothiddendivchild:hidden", [] );
$div.css( "width", 0 ).css( "height", 1 );
t( "Is Visible", '#nothiddendivchild:visible', ['nothiddendivchild'] );
t( "Is Not Visible", '#nothiddendivchild:hidden', [] );
t( "Is Visible", "#nothiddendivchild:visible", ["nothiddendivchild"] );
t( "Is Not Visible", "#nothiddendivchild:hidden", [] );
$div.css( "width", 1 ).css( "height", 1 );
t( "Is Visible", '#nothiddendivchild:visible', ['nothiddendivchild'] );
t( "Is Not Visible", '#nothiddendivchild:hidden', [] );
t( "Is Visible", "#nothiddendivchild:visible", ["nothiddendivchild"] );
t( "Is Not Visible", "#nothiddendivchild:hidden", [] );
$div.remove();
});
}
test("disconnected nodes", function() {
expect( 4 );
var $opt = jQuery('<option></option>').attr("value", "whipit").appendTo("#qunit-fixture").detach();
var $opt = jQuery("<option></option>").attr("value", "whipit").appendTo("#qunit-fixture").detach();
equal( $opt.val(), "whipit", "option value" );
equal( $opt.is(":selected"), false, "unselected option" );
$opt.attr("selected", true);
equal( $opt.is(":selected"), true, "selected option" );
var $div = jQuery( '<div/>' );
var $div = jQuery("<div/>");
equal( $div.is("div"), true, "Make sure .is('nodeName') works on disconnect nodes." );
});
@ -105,7 +105,7 @@ testIframe("selector/html5_selector", "attributes - jQuery.attr", function( jQue
i = 0;
for ( ; i < f.length; i++ ) {
s += (s && ",") + '"' + f[i].id + '"';
s += (s && ",") + "'" + f[i].id + "'";
}
deepEqual(f, q.apply( q, c ), a + " (" + b + ")");
@ -167,7 +167,7 @@ testIframe("selector/sizzle_cache", "Sizzle cache collides with multiple Sizzles
var $cached = window["$cached"];
expect(3);
deepEqual( $cached('.test a').get(), [ document.getElementById('collision') ], "Select collision anchor with first sizzle" );
equal( jQuery('.evil a').length, 0, "Select nothing with second sizzle" );
equal( jQuery('.evil a').length, 0, "Select nothing again with second sizzle" );
deepEqual( $cached(".test a").get(), [ document.getElementById("collision") ], "Select collision anchor with first sizzle" );
equal( jQuery(".evil a").length, 0, "Select nothing with second sizzle" );
equal( jQuery(".evil a").length, 0, "Select nothing again with second sizzle" );
});

View File

@ -107,7 +107,7 @@ test("is() with positional selectors", function() {
expect(23);
var html = jQuery(
'<p id="posp"><a class="firsta" href="#"><em>first</em></a><a class="seconda" href="#"><b>test</b></a><em></em></p>'
"<p id='posp'><a class='firsta' href='#'><em>first</em></a><a class='seconda' href='#'><b>test</b></a><em></em></p>"
).appendTo( "body" ),
isit = function(sel, match, expect) {
equal( jQuery( sel ).is( match ), expect, "jQuery( " + sel + " ).is( " + match + " )" );
@ -234,16 +234,16 @@ test("filter(jQuery)", function() {
test("filter() with positional selectors", function() {
expect(19);
var html = jQuery('' +
'<p id="posp">' +
'<a class="firsta" href="#">' +
'<em>first</em>' +
'</a>' +
'<a class="seconda" href="#">' +
'<b>test</b>' +
'</a>' +
'<em></em>' +
'</p>').appendTo( "body" ),
var html = jQuery( "" +
"<p id='posp'>" +
"<a class='firsta' href='#'>" +
"<em>first</em>" +
"</a>" +
"<a class='seconda' href='#'>" +
"<b>test</b>" +
"</a>" +
"<em></em>" +
"</p>" ).appendTo( "body" ),
filterit = function(sel, filter, length) {
equal( jQuery( sel ).filter( filter ).length, length, "jQuery( " + sel + " ).filter( " + filter + " )" );
};