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:
$(M_B)eslint "./{src, tests}/**" --fix
lint-build:
$(M_B)eslint "./src/**" --fix
test:
$(M_B)jest
build: lint test
build: lint-build test
$(M_B)tsc

View File

@ -1,55 +1,55 @@
{
"name": "deemix-gui",
"version": "0.0.0",
"private": true,
"scripts": {
"start-old": "node bin/www",
"start": "nodemon src/app.ts",
"start-build": "node dist/app.js",
"lint": "eslint . --fix",
"prebuild": "yarn lint",
"build": "tsc",
"test": "jest",
"test-watch": "jest --watch"
},
"dependencies": {
"cookie-parser": "1.4.5",
"debug": "2.6.9",
"deemix": "^0.1.3",
"deezer-js": "^1.0.0",
"dotenv": "8.2.0",
"express": "4.17.1",
"express-session": "^1.17.1",
"morgan": "1.10.0",
"ramda": "0.27.1",
"uuid": "8.3.2",
"ws": "7.4.5"
},
"devDependencies": {
"@nuxtjs/eslint-config": "6.0.0",
"@types/cookie-parser": "1.4.2",
"@types/debug": "4.1.5",
"@types/express": "4.17.11",
"@types/express-session": "^1.17.3",
"@types/jest": "26.0.22",
"@types/morgan": "1.9.2",
"@types/node": "14.14.37",
"@types/ramda": "0.27.40",
"@types/supertest": "2.0.11",
"@types/uuid": "8.3.0",
"@types/ws": "7.4.1",
"@typescript-eslint/eslint-plugin": "4.21.0",
"@typescript-eslint/parser": "4.21.0",
"eslint": "7.23.0",
"eslint-config-prettier": "8.1.0",
"eslint-plugin-prettier": "3.3.1",
"jest": "26.6.3",
"nodemon": "2.0.7",
"prettier": "2.2.1",
"supertest": "6.1.3",
"ts-jest": "26.5.4",
"ts-node": "9.1.1",
"ts-node-dev": "1.1.6",
"typescript": "4.2.4"
}
"name": "deemix-gui",
"version": "0.0.0",
"private": true,
"scripts": {
"start": "nodemon src/app.ts",
"start-build": "node dist/app.js",
"lint": "eslint \"./{src, tests}/**\" --fix",
"lint-build": "eslint \"./src/**\" --fix",
"prebuild": "yarn lint-build",
"build": "tsc",
"test": "jest",
"test-watch": "jest --watch"
},
"dependencies": {
"cookie-parser": "1.4.5",
"debug": "2.6.9",
"deemix": "^0.1.3",
"deezer-js": "^1.0.0",
"dotenv": "8.2.0",
"express": "4.17.1",
"express-session": "^1.17.1",
"morgan": "1.10.0",
"ramda": "0.27.1",
"uuid": "8.3.2",
"ws": "7.4.5"
},
"devDependencies": {
"@nuxtjs/eslint-config": "6.0.0",
"@types/cookie-parser": "1.4.2",
"@types/debug": "4.1.5",
"@types/express": "4.17.11",
"@types/express-session": "^1.17.3",
"@types/jest": "26.0.22",
"@types/morgan": "1.9.2",
"@types/node": "14.14.37",
"@types/ramda": "0.27.40",
"@types/supertest": "2.0.11",
"@types/uuid": "8.3.0",
"@types/ws": "7.4.1",
"@typescript-eslint/eslint-plugin": "4.21.0",
"@typescript-eslint/parser": "4.21.0",
"eslint": "7.23.0",
"eslint-config-prettier": "8.1.0",
"eslint-plugin-prettier": "3.3.1",
"jest": "26.6.3",
"nodemon": "2.0.7",
"prettier": "2.2.1",
"supertest": "6.1.3",
"ts-jest": "26.5.4",
"ts-node": "9.1.1",
"ts-node-dev": "1.1.6",
"typescript": "4.2.4"
}
}

View File

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