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,34 +1,48 @@
// TODO : test title and date are valid matches to columns in the database
const validSortParams = ['title', 'date']
const validSortDirs = ['asc', 'desc']
const validFilterParams = ['movie', 'show', 'seeding', 'downloading', 'paused', 'finished', 'downloaded']
const validSortParams = ["title", "date"];
const validSortDirs = ["asc", "desc"];
const validFilterParams = [
"movie",
"show",
"seeding",
"downloading",
"paused",
"finished",
"downloaded"
];
function validSort(by, direction) {
return new Promise((resolve, reject) => {
if (by === undefined) {
resolve()
resolve();
}
if (validSortParams.includes(by) && validSortDirs.includes(direction)) {
resolve()
resolve();
} else {
reject(new Error(`invalid sort parameter, must be of: ${validSortParams} with optional sort directions: ${validSortDirs} appended with ':'`))
reject(
new Error(
`invalid sort parameter, must be of: ${validSortParams} with optional sort directions: ${validSortDirs} appended with ':'`
)
);
}
});
}
function validFilter(filter_param) {
function validFilter(filterParam) {
return new Promise((resolve, reject) => {
if (filter_param === undefined) {
resolve()
if (filterParam === undefined) {
resolve();
}
if (filter_param && validFilterParams.includes(filter_param)) {
resolve()
if (filterParam && validFilterParams.includes(filterParam)) {
resolve();
} else {
reject(new Error(`filter parameteres must be of type: ${validFilterParams}`))
reject(
new Error(`filter parameteres must be of type: ${validFilterParams}`)
);
}
});
}
module.exports = { validSort, validFilter }
module.exports = { validSort, validFilter };