implementing ESlint suggestions

This commit is contained in:
El RIDO 2018-01-06 07:17:33 +01:00
parent 5e070db6a1
commit 2db412873b
No known key found for this signature in database
GPG key ID: 0F5C940A6BD81F92
9 changed files with 24 additions and 23 deletions

View file

@ -1 +1,2 @@
**/*{.,-}min.js js/*.js
!js/privatebin.js

View file

@ -67,7 +67,6 @@ rules:
no-case-declarations: 2 no-case-declarations: 2
no-div-regex: 2 no-div-regex: 2
no-else-return: 0 no-else-return: 0
no-empty-label: 2
no-empty-pattern: 2 no-empty-pattern: 2
no-eq-null: 2 no-eq-null: 2
no-eval: 2 no-eval: 2

View file

@ -104,7 +104,7 @@ describe('Alert', function () {
icon = icon.join(''); icon = icon.join('');
message = message.join(''); message = message.join('');
var default_message = 'Loading…'; var default_message = 'Loading…';
if (message.length == 0) { if (message.length === 0) {
message = default_message; message = default_message;
} }
var expected = '<ul class="nav navbar-nav"><li ' + var expected = '<ul class="nav navbar-nav"><li ' +
@ -191,7 +191,7 @@ describe('Alert', function () {
$.PrivateBin.Alert.showRemaining, $.PrivateBin.Alert.showRemaining,
$.PrivateBin.Alert.showLoading $.PrivateBin.Alert.showLoading
]; ];
if (message.length == 0) { if (message.length === 0) {
message = default_message; message = default_message;
} }
$('body').html( $('body').html(

View file

@ -93,12 +93,12 @@ describe('DiscussionViewer', function () {
$.PrivateBin.DiscussionViewer.getReplyNickname() === $('#reply #nickname').val() && $.PrivateBin.DiscussionViewer.getReplyNickname() === $('#reply #nickname').val() &&
$.PrivateBin.DiscussionViewer.getReplyMessage() === $('#reply #replymessage').val() $.PrivateBin.DiscussionViewer.getReplyMessage() === $('#reply #replymessage').val()
); );
var notificationResult = $.PrivateBin.DiscussionViewer.handleNotification(alertType == 'other' ? alert : alertType); var notificationResult = $.PrivateBin.DiscussionViewer.handleNotification(alertType === 'other' ? alert : alertType);
if (alertType == 'loading') { if (alertType === 'loading') {
results.push(notificationResult === false); results.push(notificationResult === false);
} else { } else {
results.push( results.push(
alertType == 'danger' ? ( alertType === 'danger' ? (
notificationResult.hasClass('alert-danger') && notificationResult.hasClass('alert-danger') &&
!notificationResult.hasClass('alert-info') !notificationResult.hasClass('alert-info')
) : ( ) : (

View file

@ -44,11 +44,11 @@ describe('Editor', function () {
$.PrivateBin.Editor.show(); $.PrivateBin.Editor.show();
$.PrivateBin.Editor.focusInput(); $.PrivateBin.Editor.focusInput();
results.push( results.push(
$.PrivateBin.Editor.getText().length == 0 $.PrivateBin.Editor.getText().length === 0
); );
$.PrivateBin.Editor.setText(text); $.PrivateBin.Editor.setText(text);
results.push( results.push(
$.PrivateBin.Editor.getText() == $('#message').val() $.PrivateBin.Editor.getText() === $('#message').val()
); );
$.PrivateBin.Editor.setText(); $.PrivateBin.Editor.setText();
results.push( results.push(

View file

@ -32,7 +32,7 @@ describe('PasteStatus', function () {
var result1 = $('#pasteurl')[0].href, var result1 = $('#pasteurl')[0].href,
result2 = $('#deletelink a')[0].href; result2 = $('#deletelink a')[0].href;
clean(); clean();
return result1 == expected1 && result2 == expected2; return result1 === expected1 && result2 === expected2;
} }
); );
}); });
@ -58,7 +58,8 @@ describe('PasteStatus', function () {
var clean = jsdom('', { var clean = jsdom('', {
url: schema.join('') + '://' + address.join('') + url: schema.join('') + '://' + address.join('') +
'/?' + query.join('') + '#' + fragment '/?' + query.join('') + '#' + fragment
}); }),
result;
$('body').html('<div id="remainingtime" class="hidden"></div>'); $('body').html('<div id="remainingtime" class="hidden"></div>');
$.PrivateBin.PasteStatus.init(); $.PrivateBin.PasteStatus.init();
$.PrivateBin.PasteStatus.showRemainingTime({ $.PrivateBin.PasteStatus.showRemainingTime({
@ -67,14 +68,14 @@ describe('PasteStatus', function () {
'expire_date': remaining_time ? ((new Date()).getTime() / 1000) + remaining_time : 0 'expire_date': remaining_time ? ((new Date()).getTime() / 1000) + remaining_time : 0
}); });
if (burnafterreading) { if (burnafterreading) {
var result = $('#remainingtime').hasClass('foryoureyesonly') && result = $('#remainingtime').hasClass('foryoureyesonly') &&
!$('#remainingtime').hasClass('hidden'); !$('#remainingtime').hasClass('hidden');
} else if (remaining_time) { } else if (remaining_time) {
var result =!$('#remainingtime').hasClass('foryoureyesonly') && result =!$('#remainingtime').hasClass('foryoureyesonly') &&
!$('#remainingtime').hasClass('hidden'); !$('#remainingtime').hasClass('hidden');
} else { } else {
var result = $('#remainingtime').hasClass('hidden') && result = $('#remainingtime').hasClass('hidden') &&
!$('#remainingtime').hasClass('foryoureyesonly'); !$('#remainingtime').hasClass('foryoureyesonly');
} }
clean(); clean();
return result; return result;

View file

@ -28,8 +28,8 @@ describe('PasteViewer', function () {
$('#placeholder').hasClass('hidden') && $('#placeholder').hasClass('hidden') &&
$('#prettymessage').hasClass('hidden') && $('#prettymessage').hasClass('hidden') &&
$('#plaintext').hasClass('hidden') && $('#plaintext').hasClass('hidden') &&
$.PrivateBin.PasteViewer.getFormat() == format && $.PrivateBin.PasteViewer.getFormat() === format &&
$.PrivateBin.PasteViewer.getText() == '' $.PrivateBin.PasteViewer.getText() === ''
); );
$.PrivateBin.PasteViewer.run(); $.PrivateBin.PasteViewer.run();
results.push( results.push(
@ -48,9 +48,9 @@ describe('PasteViewer', function () {
results.push( results.push(
$('#placeholder').hasClass('hidden') && $('#placeholder').hasClass('hidden') &&
!$.PrivateBin.PasteViewer.isPrettyPrinted() && !$.PrivateBin.PasteViewer.isPrettyPrinted() &&
$.PrivateBin.PasteViewer.getText() == text $.PrivateBin.PasteViewer.getText() === text
); );
if (format == 'markdown') { if (format === 'markdown') {
results.push( results.push(
$('#prettymessage').hasClass('hidden') && $('#prettymessage').hasClass('hidden') &&
!$('#plaintext').hasClass('hidden') !$('#plaintext').hasClass('hidden')

View file

@ -32,7 +32,7 @@ describe('Prompt', function () {
$('#passwordform').submit(); $('#passwordform').submit();
var result = $.PrivateBin.Prompt.getPassword(); var result = $.PrivateBin.Prompt.getPassword();
clean(); clean();
return result == password; return result === password;
} }
); );
}); });

View file

@ -39,7 +39,7 @@ describe('UiHelper', function () {
jsc.array(common.jscQueryString()), jsc.array(common.jscQueryString()),
jsc.nearray(common.jscBase64String()), jsc.nearray(common.jscBase64String()),
function (schema, address, query, fragment) { function (schema, address, query, fragment) {
var expected = schema + '://' + address.join('') + '/' + '?' + var expected = schema + '://' + address.join('') + '/?' +
query.join('') + '#' + fragment.join(''), query.join('') + '#' + fragment.join(''),
clean = jsdom('', {url: expected}); clean = jsdom('', {url: expected});