Fix some issues from ESLint

This commit is contained in:
rugk 2018-02-21 22:51:31 +01:00
parent 99972b5f7b
commit 0687448d0a
No known key found for this signature in database
GPG key ID: 05D40A636AFAB34D
5 changed files with 37 additions and 30 deletions

View file

@ -19,6 +19,7 @@ globals:
it: false
jsc: false
jsdom: true
kjua: true
# http://eslint.org/docs/rules/
rules:

View file

@ -16,26 +16,31 @@
"nonew": true,
"quotmark": "single",
"singleGroups": true,
"strict": "global",
"strict": true,
"undef": true,
"unused": true,
"jquery": true,
"browser": true,
"predef": {
"after": true,
"before": true,
"cleanup": true,
"console": true,
"describe": false,
"document": true,
"fs": false,
"global": true,
"exports": true,
"it": false,
"jsc": false,
"jsdom": true,
"require": false,
"setTimeout": false,
"window": true
"after": true,
"before": true,
"cleanup": true,
"console": true,
"describe": false,
"document": true,
"fs": false,
"global": true,
"exports": true,
"it": false,
"jsc": false,
"jsdom": true,
"require": false,
"setTimeout": false,
"window": true
},
"globals": {
"sjcl": true,
"DOMPurify": true,
"kjua": true
}
}

View file

@ -28,6 +28,7 @@ sjcl.random.startCollectors();
// main application start, called when DOM is fully loaded
jQuery(document).ready(function() {
'use strict';
// run main controller
$.PrivateBin.Controller.init();
});
@ -331,7 +332,7 @@ jQuery.PrivateBin = (function($, sjcl, Base64, RawDeflate) {
var usesPlurals = $.isArray(args[0]);
if (usesPlurals) {
// use the first plural form as messageId, otherwise the singular
messageId = (args[0].length > 1 ? args[0][1] : args[0][0]);
messageId = args[0].length > 1 ? args[0][1] : args[0][0];
} else {
messageId = args[0];
}
@ -415,16 +416,16 @@ jQuery.PrivateBin = (function($, sjcl, Base64, RawDeflate) {
case 'fr':
case 'oc':
case 'zh':
return (n > 1 ? 1 : 0);
return n > 1 ? 1 : 0;
case 'pl':
return (n === 1 ? 0 : (n % 10 >= 2 && n %10 <=4 && (n % 100 < 10 || n % 100 >= 20) ? 1 : 2));
return n === 1 ? 0 : (n % 10 >= 2 && n %10 <=4 && (n % 100 < 10 || n % 100 >= 20) ? 1 : 2);
case 'ru':
return (n % 10 === 1 && n % 100 !== 11 ? 0 : (n % 10 >= 2 && n % 10 <= 4 && (n % 100 < 10 || n % 100 >= 20) ? 1 : 2));
return n % 10 === 1 && n % 100 !== 11 ? 0 : (n % 10 >= 2 && n % 10 <= 4 && (n % 100 < 10 || n % 100 >= 20) ? 1 : 2);
case 'sl':
return (n % 100 === 1 ? 1 : (n % 100 === 2 ? 2 : (n % 100 === 3 || n % 100 === 4 ? 3 : 0)));
return n % 100 === 1 ? 1 : (n % 100 === 2 ? 2 : (n % 100 === 3 || n % 100 === 4 ? 3 : 0));
// de, en, es, it, no, pt
default:
return (n !== 1 ? 1 : 0);
return n !== 1 ? 1 : 0;
}
};
@ -660,7 +661,7 @@ jQuery.PrivateBin = (function($, sjcl, Base64, RawDeflate) {
*/
me.hasCipherData = function()
{
return (me.getCipherData().length > 0);
return me.getCipherData().length > 0;
};
/**
@ -831,7 +832,7 @@ jQuery.PrivateBin = (function($, sjcl, Base64, RawDeflate) {
var viewportTop = $(window).scrollTop();
var viewportBottom = viewportTop + $(window).height();
return (elementTop > viewportTop && elementTop < viewportBottom);
return elementTop > viewportTop && elementTop < viewportBottom;
};
/**
@ -1194,8 +1195,8 @@ jQuery.PrivateBin = (function($, sjcl, Base64, RawDeflate) {
*/
function sendToShortener()
{
window.location.href = $shortenButton.data('shortener')
+ encodeURIComponent($pasteUrl.attr('href'));
window.location.href = $shortenButton.data('shortener') +
encodeURIComponent($pasteUrl.attr('href'));
}
/**
@ -2008,7 +2009,7 @@ jQuery.PrivateBin = (function($, sjcl, Base64, RawDeflate) {
me.hasAttachment = function()
{
var link = $attachmentLink.prop('href');
return (typeof link !== 'undefined' && link !== '');
return typeof link !== 'undefined' && link !== '';
};
/**

View file

@ -75,7 +75,7 @@ if ($MARKDOWN):
<?php
endif;
?>
<script type="text/javascript" src="js/privatebin.js?<?php echo rawurlencode($VERSION); ?>" integrity="sha512-kln7CKhJse+R3qsKw01qJ5nLISVhC/S4T/RRetZbNW3uhheH49NBd8NamOaYcXGQ+CRU8OoN1iD7JLX88Jt0Sg==" crossorigin="anonymous"></script>
<script type="text/javascript" src="js/privatebin.js?<?php echo rawurlencode($VERSION); ?>" integrity="sha512-9HcFkJcGWfvpGHD7tTGYzBtx4TbVfR9z7oujlX2WZ2dYWVv/2QIW5eMSjpvfxUVTJVF+DHD7Ps/80qR8GcQsIg==" crossorigin="anonymous"></script>
<!--[if lt IE 10]>
<style type="text/css">body {padding-left:60px;padding-right:60px;} #ienotice {display:block;} #oldienotice {display:block;}</style>
<![endif]-->

View file

@ -54,7 +54,7 @@ if ($QRCODE):
<?php
endif;
?>
<script type="text/javascript" src="js/privatebin.js?<?php echo rawurlencode($VERSION); ?>" integrity="sha512-kln7CKhJse+R3qsKw01qJ5nLISVhC/S4T/RRetZbNW3uhheH49NBd8NamOaYcXGQ+CRU8OoN1iD7JLX88Jt0Sg==" crossorigin="anonymous"></script>
<script type="text/javascript" src="js/privatebin.js?<?php echo rawurlencode($VERSION); ?>" integrity="sha512-9HcFkJcGWfvpGHD7tTGYzBtx4TbVfR9z7oujlX2WZ2dYWVv/2QIW5eMSjpvfxUVTJVF+DHD7Ps/80qR8GcQsIg==" crossorigin="anonymous"></script>
<!--[if lt IE 10]>
<style type="text/css">body {padding-left:60px;padding-right:60px;} #ienotice {display:block;} #oldienotice {display:block;}</style>
<![endif]-->