fix(server): lint errors on main.ts; fix(server): lint script not linting

This commit is contained in:
Roberto Tonino 2021-06-01 22:56:01 +02:00
parent 8d9f79e662
commit a9fe54eb72
3 changed files with 63 additions and 58 deletions

View File

@ -20,8 +20,11 @@ M_B ?= $(call FixPath, ./node_modules/.bin/)
lint: lint:
$(M_B)eslint "./{src, tests}/**" --fix $(M_B)eslint "./{src, tests}/**" --fix
lint-build:
$(M_B)eslint "./src/**" --fix
test: test:
$(M_B)jest $(M_B)jest
build: lint test build: lint-build test
$(M_B)tsc $(M_B)tsc

View File

@ -3,11 +3,11 @@
"version": "0.0.0", "version": "0.0.0",
"private": true, "private": true,
"scripts": { "scripts": {
"start-old": "node bin/www",
"start": "nodemon src/app.ts", "start": "nodemon src/app.ts",
"start-build": "node dist/app.js", "start-build": "node dist/app.js",
"lint": "eslint . --fix", "lint": "eslint \"./{src, tests}/**\" --fix",
"prebuild": "yarn lint", "lint-build": "eslint \"./src/**\" --fix",
"prebuild": "yarn lint-build",
"build": "tsc", "build": "tsc",
"test": "jest", "test": "jest",
"test-watch": "jest --watch" "test-watch": "jest --watch"

View File

@ -6,7 +6,7 @@ import deemix from 'deemix'
import WebSocket from 'ws' import WebSocket from 'ws'
import { wss } from './app' import { wss } from './app'
import { Settings } from './types' import { Settings } from './types'
import { AlreadyInQueue, NotLoggedIn } from './helpers/errors' import { NotLoggedIn } from './helpers/errors'
const Downloader = deemix.downloader.Downloader const Downloader = deemix.downloader.Downloader
const { Single, Collection, Convertable } = deemix.types.downloadObjects const { Single, Collection, Convertable } = deemix.types.downloadObjects
@ -19,6 +19,7 @@ export const getAccessToken = deemix.utils.deezer.getAccessToken
export const getArlFromAccessToken = deemix.utils.deezer.getArlFromAccessToken export const getArlFromAccessToken = deemix.utils.deezer.getArlFromAccessToken
export const plugins: any = { export const plugins: any = {
// eslint-disable-next-line new-cap
spotify: new deemix.plugins.spotify() spotify: new deemix.plugins.spotify()
} }
plugins.spotify.setup() plugins.spotify.setup()
@ -102,7 +103,7 @@ export async function addToQueue(dz: any, url: string[], bitrate: number) {
slimmedObjects.push(downloadObj.getSlimmedDict()) slimmedObjects.push(downloadObj.getSlimmedDict())
}) })
const isSingleObject = downloadObjs.length == 1 const isSingleObject = downloadObjs.length === 1
if (isSingleObject) listener.send('addedToQueue', downloadObjs[0].getSlimmedDict()) if (isSingleObject) listener.send('addedToQueue', downloadObjs[0].getSlimmedDict())
else listener.send('addedToQueue', slimmedObjects) else listener.send('addedToQueue', slimmedObjects)
@ -178,6 +179,7 @@ export function cancelDownload(uuid: string) {
queueOrder.splice(queueOrder.indexOf(uuid), 1) queueOrder.splice(queueOrder.indexOf(uuid), 1)
fs.writeFileSync(configFolder + `queue${sep}order.json`, JSON.stringify(queueOrder)) fs.writeFileSync(configFolder + `queue${sep}order.json`, JSON.stringify(queueOrder))
// break // break
// eslint-disable-next-line no-fallthrough
default: default:
// This gets called even in the 'inQueue' case. Is this the expected behaviour? If no, de-comment the break // This gets called even in the 'inQueue' case. Is this the expected behaviour? If no, de-comment the break
listener.send('removedFromQueue', uuid) listener.send('removedFromQueue', uuid)
@ -192,7 +194,7 @@ export function cancelAllDownloads() {
queueOrder = [] queueOrder = []
let currentItem: string | null = null let currentItem: string | null = null
Object.values(queue).forEach((downloadObject: any) => { Object.values(queue).forEach((downloadObject: any) => {
if (downloadObject.status == 'downloading') { if (downloadObject.status === 'downloading') {
currentJob.downloadObject.isCanceled = true currentJob.downloadObject.isCanceled = true
listener.send('cancellingCurrentItem', downloadObject.uuid) listener.send('cancellingCurrentItem', downloadObject.uuid)
currentItem = downloadObject.uuid currentItem = downloadObject.uuid
@ -218,7 +220,7 @@ export function restoreQueueFromDisk() {
if (!fs.existsSync(configFolder + 'queue')) fs.mkdirSync(configFolder + 'queue') if (!fs.existsSync(configFolder + 'queue')) fs.mkdirSync(configFolder + 'queue')
const allItems: string[] = fs.readdirSync(configFolder + 'queue') const allItems: string[] = fs.readdirSync(configFolder + 'queue')
allItems.forEach((filename: string) => { allItems.forEach((filename: string) => {
if (filename == 'order.json') { if (filename === 'order.json') {
queueOrder = JSON.parse(fs.readFileSync(configFolder + `queue${sep}order.json`).toString()) queueOrder = JSON.parse(fs.readFileSync(configFolder + `queue${sep}order.json`).toString())
} else { } else {
const currentItem: any = JSON.parse(fs.readFileSync(configFolder + `queue${sep}${filename}`).toString()) const currentItem: any = JSON.parse(fs.readFileSync(configFolder + `queue${sep}${filename}`).toString())