From 522f546d9607022a312cc30f8699c5282469f9a1 Mon Sep 17 00:00:00 2001 From: Oleg Gaidarenko Date: Sat, 9 Jul 2016 00:46:58 +0300 Subject: [PATCH] Build: More ESLint related changes --- .eslintrc | 4 ++++ dist/.eslintrc | 1 + package.json | 2 +- src/attributes/prop.js | 8 ++++++++ src/css/showHide.js | 2 +- test/unit/core.js | 1 - test/unit/manipulation.js | 2 +- 7 files changed, 16 insertions(+), 4 deletions(-) diff --git a/.eslintrc b/.eslintrc index 6dcb6353a..bbf96f809 100644 --- a/.eslintrc +++ b/.eslintrc @@ -3,5 +3,9 @@ "root": true, "env": { "node": true + }, + rules: { + // Until https://github.com/jquery/eslint-config-jquery/issues/7 is resolved + "no-unused-expressions": "error" } } diff --git a/dist/.eslintrc b/dist/.eslintrc index c86665b21..22a970f8a 100644 --- a/dist/.eslintrc +++ b/dist/.eslintrc @@ -5,6 +5,7 @@ "no-multiple-empty-lines": "off", // Because sizze is not compatible to jquery code style + "no-unused-expressions": "off", "lines-around-comment": "off", "space-in-parens": "off", "camelcase": "off", diff --git a/package.json b/package.json index 3d38d9b74..6ef29dc0e 100644 --- a/package.json +++ b/package.json @@ -36,7 +36,7 @@ "grunt-compare-size": "0.4.2", "grunt-contrib-uglify": "1.0.1", "grunt-contrib-watch": "1.0.0", - "grunt-eslint": "18.1.0", + "grunt-eslint": "19.0.0", "grunt-git-authors": "3.2.0", "grunt-jsonlint": "1.0.7", "grunt-newer": "1.2.0", diff --git a/src/attributes/prop.js b/src/attributes/prop.js index 2f73a8508..b69177adf 100644 --- a/src/attributes/prop.js +++ b/src/attributes/prop.js @@ -88,9 +88,14 @@ jQuery.extend( { // on the option // The getter ensures a default option is selected // when in an optgroup +// eslint rule "no-unused-expressions" is disabled for this code +// since it considers such accessions noop if ( !support.optSelected ) { jQuery.propHooks.selected = { get: function( elem ) { + + /* eslint no-unused-expressions: "off" */ + var parent = elem.parentNode; if ( parent && parent.parentNode ) { parent.parentNode.selectedIndex; @@ -98,6 +103,9 @@ if ( !support.optSelected ) { return null; }, set: function( elem ) { + + /* eslint no-unused-expressions: "off" */ + var parent = elem.parentNode; if ( parent ) { parent.selectedIndex; diff --git a/src/css/showHide.js b/src/css/showHide.js index 11b1479d9..3eeafef11 100644 --- a/src/css/showHide.js +++ b/src/css/showHide.js @@ -18,7 +18,7 @@ function getDefaultDisplay( elem ) { return display; } - temp = doc.body.appendChild( doc.createElement( nodeName ) ), + temp = doc.body.appendChild( doc.createElement( nodeName ) ); display = jQuery.css( temp, "display" ); temp.parentNode.removeChild( temp ); diff --git a/test/unit/core.js b/test/unit/core.js index 8c0f8640e..b00db8c33 100644 --- a/test/unit/core.js +++ b/test/unit/core.js @@ -1196,7 +1196,6 @@ QUnit.test( "jQuery.extend(Object, Object)", function( assert ) { ret = jQuery.extend( true, { "foo": 4 }, { "foo": new MyNumber( 5 ) } ); assert.ok( parseInt( ret.foo, 10 ) === 5, "Wrapped numbers copy correctly" ); - nullUndef; nullUndef = jQuery.extend( {}, options, { "xnumber2": null } ); assert.ok( nullUndef[ "xnumber2" ] === null, "Check to make sure null values are copied" ); diff --git a/test/unit/manipulation.js b/test/unit/manipulation.js index b8fdb8e79..911852451 100644 --- a/test/unit/manipulation.js +++ b/test/unit/manipulation.js @@ -1359,7 +1359,7 @@ QUnit.test( "Empty replaceWith (trac-13401; trac-13596; gh-2204)", function( ass assert.strictEqual( $el.html(), "", "replaceWith(" + label + ")" ); $el.html( "" ).children().replaceWith( function() { return input; } ); assert.strictEqual( $el.html(), "", "replaceWith(function returning " + label + ")" ); - $el.html( "" ).children().replaceWith( function( i ) { i; return input; } ); + $el.html( "" ).children().replaceWith( function( i ) { return input; } ); assert.strictEqual( $el.html(), "", "replaceWith(other function returning " + label + ")" ); $el.html( "

" ).children().replaceWith( function( i ) { return i ? -- 2.39.5