Fix: Linter warnings (#137)

* Automaticly fixable eslint issues, mostly 3 -> 2 space indentation

* fix: updated plex_userid to camelcase

* Linted and some consistency refactor on middleware

* eslint uses ecmaversion 2020 & allow empty catch rule

* Started linting source files

* Fixed eslint errors & improved a lot of error handling

* Set 2 eslint rules as warning temporarly
This commit is contained in:
2022-08-20 17:21:25 +02:00
committed by GitHub
parent cfbd4965db
commit 1815a429b0
83 changed files with 1625 additions and 1294 deletions

View File

@@ -1,4 +1,3 @@
const assert = require("assert");
const http = require("http");
const { URL } = require("url");
const PythonShell = require("python-shell");
@@ -8,12 +7,12 @@ const establishedDatabase = require("../database/database");
const cache = require("../cache/redis");
function getMagnetFromURL(url) {
return new Promise((resolve, reject) => {
return new Promise(resolve => {
const options = new URL(url);
if (options.protocol.includes("magnet")) resolve(url);
http.get(options, res => {
if (res.statusCode == 301 || res.statusCode == 302) {
if (res.statusCode === 301 || res.statusCode === 302) {
resolve(res.headers.location);
}
});
@@ -43,13 +42,14 @@ async function callPythonAddMagnet(url, callback) {
PythonShell.run("deluge_cli.py", options, callback);
})
.catch(err => {
console.log(err);
throw new Error(err);
});
}
async function SearchPiratebay(query) {
if (query && query.includes("+")) {
async function SearchPiratebay(_query) {
let query = String(_query);
if (query?.includes("+")) {
query = query.replace("+", "%20");
}
@@ -62,7 +62,7 @@ async function SearchPiratebay(query) {
.catch(() =>
find(query, (err, results) => {
if (err) {
console.log("THERE WAS A FUCKING ERROR!\n", err);
console.log("THERE WAS A FUCKING ERROR!\n", err); // eslint-disable-line no-console
reject(Error("There was a error when searching for torrents"));
}
@@ -76,8 +76,8 @@ async function SearchPiratebay(query) {
);
}
async function AddMagnet(magnet, name, tmdb_id) {
return await new Promise((resolve, reject) =>
function AddMagnet(magnet, name, tmdbId) {
return new Promise((resolve, reject) =>
callPythonAddMagnet(magnet, (err, results) => {
if (err) {
/* eslint-disable no-console */
@@ -87,13 +87,12 @@ async function AddMagnet(magnet, name, tmdb_id) {
/* eslint-disable no-console */
console.log("result/error:", err, results);
database = establishedDatabase;
insert_query =
"INSERT INTO requested_torrent(magnet,torrent_name,tmdb_id) \
VALUES (?,?,?)";
const database = establishedDatabase;
const insertQuery =
"INSERT INTO requested_torrent(magnet,torrent_name,tmdb_id) VALUES (?,?,?)";
let response = database.run(insert_query, [magnet, name, tmdb_id]);
console.log("Response from requsted_torrent insert: " + response);
const response = database.run(insertQuery, [magnet, name, tmdbId]);
console.log(`Response from requsted_torrent insert: ${response}`);
resolve({ success: true });
})