diff --git a/js/privatebin.js b/js/privatebin.js index ab6c600b..e8dbc7fa 100644 --- a/js/privatebin.js +++ b/js/privatebin.js @@ -90,8 +90,10 @@ jQuery.PrivateBin = (function($) { */ function CryptoData(data) { // store all keys in the default locations for drop-in replacement - for (let key in data) { - this[key] = data[key]; + for (const key in data) { + if (Object.prototype.hasOwnProperty.call(data, key)) { + this[key] = data[key]; + } } /** @@ -3607,7 +3609,7 @@ jQuery.PrivateBin = (function($) { // set date const created = comment.getCreated(); - const commentDate = created == 0 ? '' : ' (' + (new Date(created * 1000).toLocaleString()) + ')'; + const commentDate = created === 0 ? '' : ' (' + (new Date(created * 1000).toLocaleString()) + ')'; $commentEntry.find('span.commentdate') .text(commentDate) .attr('title', 'CommentID: ' + comment.id); @@ -5570,7 +5572,7 @@ jQuery.PrivateBin = (function($) { if (window.getSelection) { text = window.getSelection().toString(); - } else if (document.selection && document.selection.type != 'Control') { + } else if (document.selection && document.selection.type !== 'Control') { text = document.selection.createRange().text; } @@ -5727,7 +5729,7 @@ jQuery.PrivateBin = (function($) { Alert.hideLoading(); // only push new state if we are coming from a different one - if (Helper.baseUri() != window.location) { + if (Helper.baseUri() !== window.location) { history.pushState({type: 'create'}, document.title, Helper.baseUri()); } diff --git a/js/test/Helper.js b/js/test/Helper.js index eef2ac5e..709d5121 100644 --- a/js/test/Helper.js +++ b/js/test/Helper.js @@ -82,7 +82,7 @@ describe('Helper', function () { 'ignores non-URL content', 'string', function (content) { - content = content.replace(/\r|\f/g, '\n').replace(/\u0000/g, '').replace(/\u000b/g, ''); + content = content.replace(/\r|\f/g, '\n').replace('\u0000', '').replace('\u000b', ''); let clean = jsdom(); $('body').html('
'); let e = $('#foo'); @@ -100,8 +100,8 @@ describe('Helper', function () { jsc.array(common.jscHashString()), 'string', function (prefix, url, fragment, postfix) { - prefix = prefix.replace(/\r|\f/g, '\n').replace(/\u0000/g, '').replace(/\u000b/g, ''); - postfix = ' ' + postfix.replace(/\r/g, '\n').replace(/\u0000/g, ''); + prefix = prefix.replace(/\r|\f/g, '\n').replace('\u0000', '').replace('\u000b', '');; + postfix = ' ' + postfix.replace('\r', '\n').replace('\u0000', ''); url.fragment = fragment.join(''); let urlString = common.urlToString(url), clean = jsdom(); @@ -132,9 +132,9 @@ describe('Helper', function () { jsc.array(common.jscQueryString()), 'string', function (prefix, query, postfix) { - prefix = prefix.replace(/\r|\f/g, '\n').replace(/\u0000/g, '').replace(/\u000b/g, ''); - postfix = ' ' + postfix.replace(/\r/g, '\n').replace(/\u0000/g, ''); - let url = 'magnet:?' + query.join('').replace(/^&+|&+$/gm,''), + prefix = prefix.replace(/\r|\f/g, '\n').replace('\u0000', '').replace('\u000b', ''); + postfix = ' ' + postfix.replace('\r', '\n').replace('\u0000', ''); + let url = 'magnet:?' + query.join('').replace(/^&+|&+$/gm, ''), clean = jsdom(); $('body').html(''); let e = $('#foo'); @@ -346,4 +346,3 @@ describe('Helper', function () { }); }); }); - diff --git a/js/test/I18n.js b/js/test/I18n.js index 32723ecd..eeea648c 100644 --- a/js/test/I18n.js +++ b/js/test/I18n.js @@ -192,7 +192,9 @@ describe('I18n', function () { // mock clean = jsdom('', {cookie: ['lang=' + language]}); + // eslint-disable-line global-require $.PrivateBin.I18n.reset(language, require('../../i18n/' + language + '.json')); + // eslint-enable-line global-require var loadedLang = $.PrivateBin.I18n.getLanguage(), result = $.PrivateBin.I18n.translate('Never'), alias = $.PrivateBin.I18n._('Never'); diff --git a/js/test/PasteStatus.js b/js/test/PasteStatus.js index 3df9511b..f749f659 100644 --- a/js/test/PasteStatus.js +++ b/js/test/PasteStatus.js @@ -50,7 +50,7 @@ describe('PasteStatus', function () { 'nestring', common.jscUrl(), function (schema, domain, url) { - domain = domain.replace(/\P{Letter}|[\u00AA-\u00BA]/gu, '').toLowerCase(); + domain = domain.replace(/\P{Letter}|[\u{00AA}-\u{00BA}]/gu, '').toLowerCase(); if (domain.length === 0) { domain = 'a'; } diff --git a/js/test/PasteViewer.js b/js/test/PasteViewer.js index f612032a..eb9eab29 100644 --- a/js/test/PasteViewer.js +++ b/js/test/PasteViewer.js @@ -76,7 +76,8 @@ describe('PasteViewer', function () { '\'">>">' + '|\\>