Skip to content

Commit 2932ca2

Browse files
committed
lint code
1 parent 2b5400d commit 2932ca2

File tree

10 files changed

+29
-49
lines changed

10 files changed

+29
-49
lines changed

index.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ const { app } = require('./lib/server.js')
22
const helmet = require('helmet')
33
const middleware = require('webpack-dev-middleware')
44
const config = require('./src/webpack.dev.js')
5-
const path = require('path')
65
const compression = require('compression')
76
const webpack = require('webpack')
87

lib/postinstall.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
const decompress = require('decompress')
2-
const decompressTarxz = require('decompress-tarxz')
32
const path = require('path')
43

54
decompress(

lib/proxy.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ function checkTo (allowed, requested) {
1818
for (let i = 0; i < allowed.length; i++) {
1919
const to = allowed[i]
2020

21-
if ((to.host == requested.host || !to.host) && (to.port == requested.port || !to.port)) {
21+
if ((to.host === requested.host || !to.host) && (to.port === requested.port || !to.port)) {
2222
if (to.blacklist) { // This item is blacklisted
2323
return false
2424
} else { // Otheriwse, it's whitelisted
@@ -67,7 +67,7 @@ module.exports = function (options, connectionListener) {
6767

6868
res.header('Access-Control-Allow-Origin', allowOrigin)
6969

70-
if (req.method.toUpperCase() == 'OPTIONS') { // Preflighted requests
70+
if (req.method.toUpperCase() === 'OPTIONS') { // Preflighted requests
7171
res.header('Access-Control-Allow-Methods', 'GET, POST, OPTIONS')
7272
res.header('Access-Control-Allow-Headers', 'Content-Type')
7373

@@ -99,7 +99,7 @@ module.exports = function (options, connectionListener) {
9999
}
100100
}
101101

102-
var socket = net.connect({
102+
const socket = net.connect({
103103
host: host,
104104
port: port
105105
}, function (err) {
@@ -146,7 +146,7 @@ module.exports = function (options, connectionListener) {
146146
}
147147
})
148148

149-
const wss = expressWs(app, server)
149+
expressWs(app, server)
150150

151151
app.ws(urlRoot + '/socket', function (ws, req) {
152152
const token = req.query.token
@@ -170,7 +170,7 @@ module.exports = function (options, connectionListener) {
170170
socket.on('data', function (chunk) {
171171
// myLog('Received: ', chunk.toString());
172172
// Providing a callback is important, otherwise errors can be thrown
173-
ws.send(chunk, { binary: true }, function (err) {})
173+
ws.send(chunk, { binary: true }, function (err) { if (err !== undefined) { console.log(err) } })
174174
})
175175
socket.on('end', function () {
176176
myLog('TCP connection closed by remote (' + token + ')')

src/scripts/EventHandler.js

Lines changed: 4 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -192,33 +192,17 @@ class EventHandler {
192192
})
193193
}
194194
const lockChangeAlert = () => {
195-
if (
196-
document.pointerLockElement === this.game.canvas ||
197-
document.mozPointerLockElement === this.game.canvas
198-
) {
195+
if (document.pointerLockElement === this.game.canvas || document.mozPointerLockElement === this.game.canvas) {
199196
if (this.gameState === 'game') {
200197
this.setState('gameLock')
201198
}
202-
} else if (
203-
this.gameState === 'gameLock' &&
204-
this.gameState !== 'inventory'
205-
) {
199+
} else if (this.gameState === 'gameLock' && this.gameState !== 'inventory') {
206200
this.setState('menu')
207201
}
208202
}
209203
document.addEventListener('pointerlockchange', lockChangeAlert, false)
210-
document.addEventListener(
211-
'mozpointerlockchange',
212-
lockChangeAlert,
213-
false
214-
)
215-
document.addEventListener(
216-
'mousemove',
217-
(e) => {
218-
return this.updatePosition(e)
219-
},
220-
false
221-
)
204+
document.addEventListener('mozpointerlockchange', lockChangeAlert, false)
205+
document.addEventListener('mousemove', (e) => { return this.updatePosition(e) }, false)
222206
}
223207

224208
updatePosition (e) {

src/scripts/Setup.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import Stats from 'three/examples/jsm/libs/stats.module.js'
22
import * as dat from 'three/examples/jsm/libs/dat.gui.module.js'
3-
import { WebGLRenderer, Scene, PerspectiveCamera, AmbientLight, Mesh, BoxGeometry, MeshBasicMaterial } from 'three'
3+
import { WebGLRenderer, Scene, PerspectiveCamera, AmbientLight } from 'three'
44
import { DistanceBasedFog } from './rendering/DistanceBasedFog.js'
55
import { UrlParams } from './UrlParams.js'
66
import { gpuInfo } from './additional/gpuInfo.js'

src/scripts/additional/tools.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ const antiXSS = (str) => {
66
[/"/g, '&quot;']
77
]
88
for (const replacement of replacements) {
9-
str = str.replace(replacement[0], replacement[1])
9+
str = str.replace(replacement[0], replacement[1])
1010
}
1111
return str
1212
}

src/scripts/proxy/Proxy.worker.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import Convert from 'ansi-to-html'
44
import { antiXSS } from './../additional/tools.js'
55
const convert = new Convert()
66
importScripts('./mineflayer.js')
7-
mineflayer = mineflayer.default
87

98
global.window = self
109
let bot = null
@@ -22,7 +21,7 @@ addEventListener('message', function (e) {
2221
case 'init':
2322
data = data[0]
2423
console.log(data)
25-
bot = mineflayer(null, data.hostname, data.port, {
24+
bot = self.mineflayer.default(null, data.hostname, data.port, {
2625
host: data.server,
2726
port: data.serverPort,
2827
username: data.nick

src/scripts/world/AnimatedTextureAtlas.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import {
22
MeshStandardMaterial,
3-
TextureLoader,
43
NearestFilter,
54
NearestMipmapLinearFilter,
65
CanvasTexture

src/scripts/world/chunk.worker.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,6 @@ class TerrainManager {
8686
let nearestDistance = -1
8787
let isNearest = false
8888
for (const chunkId in this.chunkNeedsUpdate) {
89-
const pos = this.chunkTerrain.strToVec(chunkId)
9089
const dist = this.distance(chunkId)
9190
if (
9291
(nearestDistance === -1 || nearestDistance > dist) &&

src/vendor/browser.js

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1+
/* global WebSocket,Blob,FileReader */
12
const stream = require('stream')
23
const util = require('util')
3-
const timers = require('timers')
44
const http = require('http')
55

66
const debug = util.debuglog('net')
77

88
const proxy = {
9-
protocol: (window.location.protocol == 'https:') ? 'wss' : 'ws',
9+
protocol: (window.location.protocol === 'https:') ? 'wss' : 'ws',
1010
hostname: window.location.hostname,
1111
port: window.location.port,
1212
path: '/api/vm/net'
@@ -55,14 +55,14 @@ exports.connect = exports.createConnection = function (/* options, connectListen
5555
function toNumber (x) { return (x = Number(x)) >= 0 ? x : false }
5656

5757
function isPipeName (s) {
58-
return util.isString(s) && toNumber(s) === false
58+
return typeof s === 'string' && toNumber(s) === false
5959
}
6060

6161
// Returns an array [options] or [options, cb]
6262
// It is the same as the argument of Socket.prototype.connect().
6363
function normalizeConnectArgs (args) {
6464
let options = {}
65-
if (util.isObject(args[0])) {
65+
if (typeof args[0] === 'object') {
6666
// connect(options, [cb])
6767
options = args[0]
6868
} else if (isPipeName(args[0])) {
@@ -71,12 +71,12 @@ function normalizeConnectArgs (args) {
7171
} else {
7272
// connect(port, [host], [cb])
7373
options.port = args[0]
74-
if (util.isString(args[1])) {
74+
if (typeof args[1] === 'string') {
7575
options.host = args[1]
7676
}
7777
}
7878
const cb = args[args.length - 1]
79-
return util.isFunction(cb) ? [options, cb] : [options]
79+
return typeof cb === 'function' ? [options, cb] : [options]
8080
}
8181
exports._normalizeConnectArgs = normalizeConnectArgs
8282

@@ -86,8 +86,9 @@ function Socket (options) {
8686
this._connecting = false
8787
this._host = null
8888

89-
if (util.isNumber(options)) { options = { fd: options } } // Legacy interface.
90-
else if (util.isUndefined(options)) { options = {} }
89+
if (typeof options === 'number') {
90+
options = { fd: options }
91+
} else if (typeof options === 'undefined') { options = {} }
9192

9293
stream.Duplex.call(this, options)
9394

@@ -98,7 +99,7 @@ function Socket (options) {
9899
this._writableState.decodeStrings = false
99100

100101
// default to *not* allowing half open sockets
101-
this.allowHalfOpen = options && options.allowHalfOpen || false
102+
this.allowHalfOpen = (options && options.allowHalfOpen) || false
102103
}
103104
util.inherits(Socket, stream.Duplex)
104105

@@ -235,9 +236,9 @@ Socket.prototype._write = function (data, encoding, cb) {
235236
this._pendingData = null
236237
this._pendingEncoding = ''
237238

238-
if (encoding == 'binary' && typeof data === 'string') { // TODO: maybe apply this for all string inputs?
239+
if (encoding === 'binary' && typeof data === 'string') { // TODO: maybe apply this for all string inputs?
239240
// Setting encoding is very important for binary data - otherwise the data gets modified
240-
data = new Buffer(data, encoding)
241+
data = Buffer.alloc(data, encoding)
241242
}
242243

243244
// Send the data
@@ -251,14 +252,14 @@ Socket.prototype._write = function (data, encoding, cb) {
251252
}
252253

253254
Socket.prototype.write = function (chunk, encoding, cb) {
254-
if (!util.isString(chunk) && !util.isBuffer(chunk)) { throw new TypeError('invalid data') }
255+
if (typeof chunk !== 'string' && !Buffer.isBuffer(chunk)) { throw new TypeError('invalid data') }
255256
return stream.Duplex.prototype.write.apply(this, arguments)
256257
}
257258

258259
Socket.prototype.connect = function (options, cb) {
259260
const self = this
260261

261-
if (!util.isObject(options)) {
262+
if (typeof options !== 'object') {
262263
// Old API:
263264
// connect(port, [host], [cb])
264265
// connect(path, [cb]);
@@ -374,22 +375,22 @@ Socket.prototype._handleWebsocket = function () {
374375
}
375376

376377
if (typeof contents === 'string') {
377-
const buffer = new Buffer(contents)
378+
const buffer = Buffer.alloc(contents)
378379
gotBuffer(buffer)
379380
} else if (window.Blob && contents instanceof Blob) {
380381
const fileReader = new FileReader()
381382
fileReader.addEventListener('load', function (e) {
382383
const buf = fileReader.result
383384
const arr = new Uint8Array(buf)
384-
gotBuffer(new Buffer(arr))
385+
gotBuffer(Buffer.from(arr))
385386
})
386387
fileReader.readAsArrayBuffer(contents)
387388
} else {
388389
console.warn('Cannot read TCP stream: unsupported message type', contents)
389390
}
390391
})
391392
this._ws.addEventListener('close', function () {
392-
if (self.readyState == 'open') {
393+
if (self.readyState === 'open') {
393394
// console.log('TCP closed');
394395
self.destroy()
395396
}

0 commit comments

Comments
 (0)