Skip to content

Commit f3b17e7

Browse files
authored
upgrade to ESLint 4 (#2013)
* upgrade to ESLint 4, adjust eslintrc to match codebase * autofix new errors * manual fixes * Old Blue: factor out in-template ternaries
1 parent 19e15de commit f3b17e7

File tree

12 files changed

+710
-159
lines changed

12 files changed

+710
-159
lines changed

.eslintrc.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,20 +27,21 @@
2727
requireParamDescription: false
2828
requireReturnDescription: false
2929

30-
indent: [error, tab, {SwitchCase: 1}]
30+
indent: [error, tab, {SwitchCase: 1, MemberExpression: off, CallExpression: {arguments: off}}]
3131
semi: error
3232
brace-style: [error, 1tbs, allowSingleLine: true]
3333
linebreak-style: [error, unix]
3434
semi-spacing: error
3535
comma-spacing: error
3636
space-infix-ops: error
3737
template-curly-spacing: error
38-
space-before-function-paren: [error, never]
38+
space-before-function-paren: [error, {anonymous: never, named: never, asyncArrow: always}]
3939
space-before-blocks: error
4040
keyword-spacing:
4141
- error
4242
- before: true
4343
after: true
44+
no-useless-escape: off
4445
globals:
4546
BigInt: false
4647
_: true

Extensions/better_reblogs.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -314,7 +314,7 @@ XKit.extensions.better_reblogs = new Object({
314314
}
315315
$this.addClass("xkit-better-reblogs-done");
316316

317-
// trick tumblr into displaying the little blog info popovers for the reblog avatars
317+
// trick tumblr into displaying the little blog info popovers for the reblog avatars
318318
$this.find(".reblog-avatar").addClass("post_sub_avatar");
319319

320320
if (XKit.extensions.better_reblogs.preferences.reorder_reblog_title.value) {
@@ -432,8 +432,8 @@ XKit.extensions.better_reblogs = new Object({
432432
},
433433

434434
hex_to_rgb: function(hex) {
435-
// From: http://stackoverflow.com/questions/5623838/rgb-to-hex-and-hex-to-rgb
436-
/* eslint-disable id-length */
435+
// From: http://stackoverflow.com/questions/5623838/rgb-to-hex-and-hex-to-rgb
436+
/* eslint-disable id-length */
437437

438438
var result = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(hex);
439439
return result ? {

Extensions/classic_header.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,7 @@ XKit.extensions.classic_header = new Object({
239239
}
240240

241241
var raw_id = tab_blog.attr('id');
242-
// Id has the form tab_blog_{blog-name}
242+
// Id has the form tab_blog_{blog-name}
243243
var blog_id = raw_id.substring('tab_blog_'.length, raw_id.length);
244244
var blog_icon = tab_blog.find('.blog_icon').css('background-image');
245245
if (!blog_icon || blog_icon === "none") {

Extensions/hideavatars.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ XKit.extensions.hideavatars = new Object({
108108
return $(this).attr("title") === blogname.title;
109109
}).attr("style", "opacity: 0.5; background-image: url('" + hidden_avatar + "');");
110110

111-
//Avatars in activity lines
111+
//Avatars in activity lines
112112
$(".ui_avatar_link").filter(function() {
113113
return $(this).attr("title") === blogname.title;
114114
}).find(".avatar").attr("style", "opacity: 0.5; background-image: url('" + hidden_avatar + "');");

Extensions/old_blue.js

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,9 @@ XKit.extensions.old_blue = new Object({
2929
if (!XKit.page.react) {
3030
XKit.tools.init_css("old_blue");
3131
} else {
32+
const old_font_family_rule = this.preferences.old_font.value ? '--font-family: "Helvetica Neue", "HelveticaNeue", Helvetica, Arial, sans-serif' : '';
33+
const old_font_size_rule = this.preferences.old_font_size.value ? ':root { --base-font-size: 14px !important; }' : '';
34+
3235
XKit.tools.add_css(`
3336
.xkit--react {
3437
--rgb-white: 255, 255, 255;
@@ -64,17 +67,10 @@ XKit.extensions.old_blue = new Object({
6467
--gray-13: rgba(var(--rgb-black), 0.13);
6568
--gray-7: rgba(var(--rgb-black), 0.07);
6669
67-
${this.preferences.old_font.value ?
68-
'--font-family: "Helvetica Neue", "HelveticaNeue", Helvetica, Arial, sans-serif'
69-
: ''
70-
}
70+
${old_font_family_rule}
7171
}
7272
73-
${this.preferences.old_font_size.value ?
74-
`:root {
75-
--base-font-size: 14px !important;
76-
}` : ''
77-
}
73+
${old_font_size_rule}
7874
`, "old_blue");
7975
}
8076
}

Extensions/show_picture_size.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ XKit.extensions.show_picture_size = new Object({
3737
var post = XKit.interface.post($(this));
3838

3939
if (post.type === 'photo') {
40-
// Photo
40+
// Photo
4141
$(this).find('.post_media .post_media_photo').each(function() {
4242
var photo = $(this);
4343
var photoLink = $(this).parent('.post_media_photo_anchor');
@@ -54,7 +54,7 @@ XKit.extensions.show_picture_size = new Object({
5454
});
5555
});
5656
} else if (post.type === 'photoset') {
57-
// Photo set
57+
// Photo set
5858
$(this).find('.photoset_photo').each(function() {
5959
var photoLink = $(this);
6060

Extensions/timestamps.js

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -409,18 +409,18 @@ XKit.extensions.timestamps = new Object({
409409
const sameYear = date.getFullYear() === now.getFullYear();
410410

411411
if (sameDate) {
412-
return date.toLocaleTimeString(locale, {
413-
hour: 'numeric',
414-
minute: 'numeric',
415-
});
412+
return date.toLocaleTimeString(locale, {
413+
hour: 'numeric',
414+
minute: 'numeric',
415+
});
416416
} else {
417-
return date.toLocaleDateString(locale, {
418-
day: 'numeric',
419-
month: 'short',
420-
year: sameYear ? undefined : 'numeric',
421-
});
417+
return date.toLocaleDateString(locale, {
418+
day: 'numeric',
419+
month: 'short',
420+
year: sameYear ? undefined : 'numeric',
421+
});
422422
}
423-
},
423+
},
424424

425425
format_date: function(timestamp) {
426426
const absolute_type = this.preferences.format_type_absolute.value;

Extensions/xkit_patches.js

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ XKit.extensions.xkit_patches = new Object({
9090
let blogs = [];
9191
Promise.race([
9292
new Promise((resolve) => setTimeout(resolve, 30000)),
93-
(async() => {
93+
(async () => {
9494
const {response} = await tumblr.apiFetch("/v2/user/info", {
9595
queryParams: {'fields[blogs]': 'name'},
9696
});
@@ -426,9 +426,7 @@ XKit.extensions.xkit_patches = new Object({
426426

427427
const add_func = `(async ({callback_nonce, arguments}) => {
428428
try {
429-
const return_value = await (${
430-
XKit.tools.normalize_indentation("\t".repeat(7), func.toString())
431-
})(arguments);
429+
const return_value = await (${XKit.tools.normalize_indentation("\t".repeat(7), func.toString())})(arguments);
432430
433431
window.postMessage({
434432
xkit_callback_nonce: callback_nonce,
@@ -690,7 +688,7 @@ XKit.extensions.xkit_patches = new Object({
690688
return this.cssMap;
691689
}
692690

693-
this.cssMap = await XKit.tools.async_add_function(async() => {
691+
this.cssMap = await XKit.tools.async_add_function(async () => {
694692
if (!window.tumblr) {
695693
return null;
696694
}
@@ -1324,7 +1322,7 @@ XKit.extensions.xkit_patches = new Object({
13241322
if (typeof(revisionString[1]) === "undefined") {
13251323
version.patch = 0;
13261324
} else {
1327-
// No need for toLowerCase here since we already do that when we split versionSplit above
1325+
// No need for toLowerCase here since we already do that when we split versionSplit above
13281326
version.patch = revisionString[1].trim().charCodeAt(0) - "a".charCodeAt(0);
13291327
}
13301328
} else {
@@ -3110,7 +3108,7 @@ XKit.extensions.xkit_patches = new Object({
31103108

31113109
$("#xkit-notifications").append(m_html);
31123110

3113-
// console.log(" Notification > " + message);
3111+
// console.log(" Notification > " + message);
31143112

31153113
var m_notification_id = XKit.notifications.count;
31163114
setTimeout(function() {
@@ -3121,7 +3119,7 @@ XKit.extensions.xkit_patches = new Object({
31213119
try {
31223120
callback();
31233121
} catch (e) {
3124-
// Meh.
3122+
// Meh.
31253123
}
31263124
}
31273125
$("#xkit_notification_" + m_notification_id).slideUp('slow');

Extensions/xkit_preferences.js

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -313,7 +313,7 @@ XKit.extensions.xkit_preferences = new Object({
313313
if (new_version > my_version) {
314314
XKit.notifications.add("<b>Please update XKit!</b><br/>A new version of XKit is available for your browser. " +
315315
"Please click here for more information and how you can easily and quickly update now.", "warning", true, function() {
316-
XKit.window.show("Please update XKit",
316+
XKit.window.show("Please update XKit",
317317
"<b>A new version of XKit, version " + mb_object.version + " is available.</b><br/>" +
318318
"You are currently using XKit version " + XKit.version + ".<br/><br/>" +
319319
"Please update to the latest version as soon as possible. If you don't, XKit might not work properly, " +
@@ -322,7 +322,7 @@ XKit.extensions.xkit_preferences = new Object({
322322
"warning",
323323
'<a class="xkit-button default" href="https://new-xkit-extension.tumblr.com/downloads">Go to Download page</a>' +
324324
'<div class="xkit-button" id="xkit-close-message">Not now, remind me later.</div>');
325-
});
325+
});
326326
}
327327
});
328328
},
@@ -2215,9 +2215,7 @@ XKit.extensions.xkit_preferences = new Object({
22152215
$("#xkit-panel-extension-info").click(function() {
22162216

22172217
var text = "XKit version " + XKit.version + "\n" +
2218-
"extensions:\n" + XKit.installed.list().map(function(i) {
2219-
return " " + i + ": " + XKit.installed.version(i) + (XKit.installed.enabled(i) ? "" : " (disabled)");
2220-
}).join("\n");
2218+
"extensions:\n" + XKit.installed.list().map(i => " " + i + ": " + XKit.installed.version(i) + (XKit.installed.enabled(i) ? "" : " (disabled)")).join("\n");
22212219
var timestamp = new Date();
22222220

22232221
XKit.tools.make_file("XKit Basic Export " + timestamp.getTime() + ".txt", text);

0 commit comments

Comments
 (0)