Skip to content

Commit 1f10854

Browse files
committed
Cleanup lint
1 parent 9561dac commit 1f10854

File tree

6 files changed

+44
-46
lines changed

6 files changed

+44
-46
lines changed

app.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
const koa = require('koa');
2-
const app = new koa();
1+
const Koa = require('koa');
2+
const app = new Koa();
33
const config = require('config');
44
const path = require('path');
55
const router = require('./router');

controllers/pastes.js

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,12 @@ module.exports = {
3232
} else {
3333
ctx.body = paste.paste;
3434
}
35-
} catch (ex) {
35+
} catch {
3636
ctx.throw(404, 'Paste Not Found');
3737
}
3838
},
3939

40+
/* eslint-disable-next-line complexity */
4041
async create(ctx) {
4142
ctx.set('Cache-Control', 'no-cache');
4243

@@ -60,20 +61,20 @@ module.exports = {
6061

6162
try {
6263
await fs.unlink(path);
63-
} catch (ex) {
64+
} catch {
6465
// Ignore
6566
}
66-
} catch (ex) {
67+
} catch {
6768
ctx.throw(400, 'Bad Paste Body');
6869
}
6970
}
7071

7172
// Expiry multiplier
7273
try {
7374
if (ctx.request.body.expire && ctx.request.body.multiplier) {
74-
ctx.request.body.expire = ctx.request.body.expire * ctx.request.body.multiplier;
75+
ctx.request.body.expire *= ctx.request.body.multiplier;
7576
}
76-
} catch (ex) {
77+
} catch {
7778
ctx.throw(400, 'Bad Paste Expiry');
7879
}
7980

@@ -100,7 +101,7 @@ module.exports = {
100101

101102
const paste = new Paste({
102103
paste: ctx.request.body.paste,
103-
expiresAt: new Date(Date.now() + ctx.request.body.expire * 1000)
104+
expiresAt: new Date(Date.now() + (ctx.request.body.expire * 1000))
104105
});
105106

106107
try {
@@ -116,7 +117,7 @@ module.exports = {
116117

117118
// /?xxx
118119
if (!ctx.request.body.highlight && !ctx.query.highlight && ctx.query) {
119-
ctx.request.body.highlight = Object.keys(ctx.query).filter(k => k != 'redirect' && k != 'expire')[0];
120+
ctx.request.body.highlight = Object.keys(ctx.query).filter((k) => k !== 'redirect' && k !== 'expire')[0];
120121
}
121122

122123
let highlight = '';

docker-compose.yml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,25 +3,25 @@ version: "3"
33
services:
44
app:
55
image: node:latest
6-
command: "npm start"
6+
command: npm start
77
restart: unless-stopped
88
working_dir: /app
99
depends_on:
10-
- db
10+
- db
1111
environment:
1212
- NODE_ENV=production
1313
- NODE_CONFIG_ENV=docker
1414
volumes:
15-
- .:/app:Z
15+
- .:/app:Z
1616
ports:
17-
- "80:80"
17+
- "80:80"
1818

1919
db:
2020
image: mongo:latest
2121
restart: unless-stopped
2222
volumes:
23-
- ./db:/data/db:Z
23+
- ./db:/data/db:Z
2424
expose:
25-
- 27017
25+
- 27017
2626
ports:
27-
- "27017:27017"
27+
- "27017:27017"

package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212
},
1313
"keywords": [
1414
"pastebin",
15+
"text upload",
16+
"text paste",
1517
"paste",
1618
"koa",
1719
"mongodb"
@@ -42,7 +44,7 @@
4244
"devDependencies": {
4345
"eclint": "^2.8.1",
4446
"nodemon": "^2.0.4",
45-
"pug-lint": "^2.6.0"
47+
"pug-lint": "^2.6.0",
4648
"xo": "^0.32.1"
4749
}
4850
}

prism-langs.js

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@
33
const https = require('https');
44

55
// Match version number to included copy
6-
https.get('https://raw.githubusercontent.com/PrismJS/prism/v1.20.0/components.json', res => {
6+
https.get('https://raw.githubusercontent.com/PrismJS/prism/v1.20.0/components.json', (res) => {
77
res.setEncoding('utf8');
88

99
let body = '';
10-
res.on('data', data => {
10+
res.on('data', (data) => {
1111
body += data;
1212
});
1313

@@ -17,15 +17,17 @@ https.get('https://raw.githubusercontent.com/PrismJS/prism/v1.20.0/components.js
1717
const highlights = {};
1818

1919
// Split markup
20-
for (let id in components.languages.markup.aliasTitles) {
20+
for (const id in components.languages.markup.aliasTitles) {
21+
if (!Object.prototype.hasOwnProperty.call(components.languages.markup.aliasTitles, id)) continue;
22+
2123
components.languages[id] = {
2224
title: components.languages.markup.aliasTitles[id]
2325
};
2426
}
2527

26-
for (let id in components.languages) {
27-
if (id == 'meta') continue;
28-
if (id == 'markup') continue;
28+
for (const id in components.languages) {
29+
if (id === 'meta') continue;
30+
if (id === 'markup') continue;
2931

3032
const lang = components.languages[id];
3133
const name = lang.title || lang;
@@ -41,10 +43,10 @@ https.get('https://raw.githubusercontent.com/PrismJS/prism/v1.20.0/components.js
4143
}
4244

4345
highlights[id] = {
44-
name: name
46+
name
4547
};
4648

47-
if (contents.length) {
49+
if (contents.length > 0) {
4850
highlights[id].alias = contents;
4951
}
5052
}
@@ -68,8 +70,6 @@ https.get('https://raw.githubusercontent.com/PrismJS/prism/v1.20.0/components.js
6870
highlights.json.alias = ['javascript object notation'];
6971
highlights.json5.alias = ['javascript object notation'];
7072
highlights.jsonp.alias = ['javascript object notation'];
71-
// highlights.jsstacktrace.name = 'JavaScript stack trace';
72-
// highlights.jsstacktrace.alias.push('javascript'];
7373
highlights.nasm.alias = ['assembly'];
7474
highlights.protobuf.alias = ['protobuf'];
7575
highlights.pug.alias = ['jade'];
@@ -83,7 +83,7 @@ https.get('https://raw.githubusercontent.com/PrismJS/prism/v1.20.0/components.js
8383

8484
// Sort
8585
const ordered = {};
86-
Object.keys(highlights).sort().forEach(function(key) {
86+
Object.keys(highlights).sort().forEach((key) => {
8787
ordered[key] = highlights[key];
8888
});
8989

public/main.js

Lines changed: 13 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
1-
/* eslint-env browser */
2-
/* global $ autosize */
3-
4-
$(function() {
5-
if (localStorage.getItem('expire-value') != null) $('input#expire').val(localStorage.getItem('expire-value'));
6-
if (localStorage.getItem('expire-multiplier') != null) $('#multiplier').val(localStorage.getItem('expire-multiplier'));
1+
$(() => {
2+
if (localStorage.getItem('expire-value') !== null) $('input#expire').val(localStorage.getItem('expire-value'));
3+
if (localStorage.getItem('expire-multiplier') !== null) $('#multiplier').val(localStorage.getItem('expire-multiplier'));
74

85
$.fn.selectpicker.Constructor.BootstrapVersion = '4';
96

@@ -22,25 +19,23 @@ $(function() {
2219
});
2320

2421
$('textarea').on('keydown', function(e) {
25-
if ((e.keyCode == 10 || e.keyCode == 13) && e.ctrlKey && $(this).val()) {
22+
if ((e.keyCode === 10 || e.keyCode === 13) && e.ctrlKey && $(this).val()) {
2623
$(this).closest('form').submit();
2724
}
2825
});
2926

30-
$('input#expire').on('change', function(e) {
27+
$('input#expire').on('change', (e) => {
3128
var value = $(e.target).val();
3229

33-
$('#multiplier option').text(function(_, t) {
34-
var plural = t.substring(t.length - 1) == 's';
30+
$('#multiplier option').text((_, t) => {
31+
var plural = t.slice(Math.max(0, t.length - 1)) === 's';
3532

3633
if (value > 1) {
3734
if (!plural) {
3835
return t + 's';
3936
}
40-
} else {
41-
if (plural) {
42-
return t.slice(0, -1);
43-
}
37+
} else if (plural) {
38+
return t.slice(0, -1);
4439
}
4540

4641
return t;
@@ -49,22 +44,22 @@ $(function() {
4944
localStorage.setItem('expire-value', value);
5045
});
5146

52-
$('#multiplier').on('change', function(e) {
47+
$('#multiplier').on('change', (e) => {
5348
localStorage.setItem('expire-multiplier', $(e.target).val());
5449
});
5550

5651
$('select#highlight').on('change', function() {
57-
if ($(this).val() == '') {
52+
if ($(this).val() === '') {
5853
history.pushState({}, '', '/');
5954
} else {
6055
location.hash = $(this).val();
6156
}
6257
});
6358

64-
$(window).on('hashchange', function() {
59+
$(window).on('hashchange', () => {
6560
var value = location.hash.slice(1);
6661

67-
if (value && $('select#highlight option[value=' + value + ']').length) {
62+
if (value && $('select#highlight option[value=' + value + ']').length > 0) {
6863
$('select#highlight').selectpicker('val', value);
6964
} else {
7065
$('select#highlight').selectpicker('val', '');

0 commit comments

Comments
 (0)