diff --git a/.eslintrc.json b/.eslintrc.json index 4e02e7b..f008f76 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -1,3 +1,23 @@ { - "extends": "eslint-config-wordpress" + "env": { + "es6": false, + "browser": true + }, + "globals": { + "sclivetickerAjax": "readonly" + }, + "extends": [ + "plugin:@wordpress/eslint-plugin/recommended", + "plugin:@wordpress/eslint-plugin/es5" + ], + "overrides": [ + { + "files": [ + "*" + ], + "rules": { + "no-var": "off" + } + } + ] } diff --git a/package.json b/package.json index d6448fe..3aa6673 100644 --- a/package.json +++ b/package.json @@ -6,7 +6,7 @@ "license": "GPL-2.0+", "devDependencies": { "eslint": "^6", - "eslint-config-wordpress": "^2.0", + "@wordpress/eslint-plugin": "^2.4", "stylelint": "^10.1", "stylelint-config-wordpress": "^14.0" } diff --git a/scripts/liveticker.js b/scripts/liveticker.js index 32edbbf..c2ba8f0 100644 --- a/scripts/liveticker.js +++ b/scripts/liveticker.js @@ -12,7 +12,6 @@ function scLiveticker() { * @return {void} */ scLiveticker.init = function() { - // Opt out if AJAX pobject not present. if ( 'undefined' === typeof sclivetickerAjax ) { return; @@ -31,7 +30,7 @@ scLiveticker.init = function() { s: elem.getAttribute( 'data-sclt-ticker' ), l: elem.getAttribute( 'data-sclt-limit' ), t: elem.getAttribute( 'data-sclt-last' ), - e: elem + e: elem, }; } ); @@ -44,7 +43,7 @@ scLiveticker.init = function() { w: elem.getAttribute( 'data-sclt-ticker' ), l: elem.getAttribute( 'data-sclt-limit' ), t: elem.getAttribute( 'data-sclt-last' ), - e: elem + e: elem, }; } ); @@ -61,7 +60,6 @@ scLiveticker.init = function() { * @return {void} */ scLiveticker.update = function() { - // Extract ticker-slug, limit and timestamp of last poll. var updateReq = 'action=sclt_update-ticks&_ajax_nonce=' + scLiveticker.nonce; var i, j; @@ -112,6 +110,7 @@ scLiveticker.update = function() { } setTimeout( scLiveticker.update, scLiveticker.pollInterval ); // Re-trigger update. } catch ( e ) { + // eslint-disable-next-line no-console console.warn( 'Liveticker AJAX update failed, stopping automatic updates.' ); } } @@ -131,7 +130,6 @@ scLiveticker.update = function() { * @return {void} */ scLiveticker.updateHTML = function( t, u ) { - // Prepend HTML of new ticks. t.e.innerHTML = u.h + t.e.innerHTML; t.e.setAttribute( 'data-sclt-last', u.t );