mirror of
https://github.com/CommunitySolidServer/CommunitySolidServer.git
synced 2024-10-03 14:55:10 +00:00
refactor: Update eslint related dependencies
This commit is contained in:
@@ -104,7 +104,7 @@ const transformQuotedStrings = (input: string): { result: string; replacements:
|
||||
const replacements: { [id: string]: string } = {};
|
||||
const result = input.replace(/"(?:[^"\\]|\\.)*"/gu, (match): string => {
|
||||
// Not all characters allowed in quoted strings, see BNF above
|
||||
if (!/^"(?:[\t !\u0023-\u005b\u005d-\u007e\u0080-\u00ff]|(?:\\[\t\u0020-\u007e\u0080-\u00ff]))*"$/u.test(match)) {
|
||||
if (!/^"(?:[\t !\u0023-\u005B\u005D-\u007E\u0080-\u00FF]|(?:\\[\t\u0020-\u007E\u0080-\u00FF]))*"$/u.test(match)) {
|
||||
throw new UnsupportedHttpError(
|
||||
`Invalid quoted string in Accept header: ${match}. Check which characters are allowed`,
|
||||
);
|
||||
@@ -179,7 +179,7 @@ const parseAcceptPart = (part: string, replacements: { [id: string]: string }):
|
||||
// Extension parameters appear after the q value
|
||||
map = extensionParams;
|
||||
testQValue(param);
|
||||
weight = parseFloat(value);
|
||||
weight = Number.parseFloat(value);
|
||||
} else {
|
||||
// Test replaced string for easier check
|
||||
// parameter = token "=" ( token / quoted-string )
|
||||
@@ -229,7 +229,7 @@ const parseNoParameters = (input: string): { range: string; weight: number }[] =
|
||||
const result = { range, weight: 1 };
|
||||
if (qvalue) {
|
||||
testQValue(qvalue);
|
||||
result.weight = parseFloat(qvalue.split('=')[1]);
|
||||
result.weight = Number.parseFloat(qvalue.split('=')[1]);
|
||||
}
|
||||
return result;
|
||||
}).sort((left, right): number => right.weight - left.weight);
|
||||
|
||||
@@ -9,7 +9,7 @@ export abstract class AsyncHandler<TInput, TOutput = void> {
|
||||
*
|
||||
* @returns A promise resolving if this input can be handled, rejecting with an Error if not.
|
||||
*/
|
||||
public abstract canHandle (input: TInput): Promise<void>;
|
||||
public abstract canHandle(input: TInput): Promise<void>;
|
||||
|
||||
/**
|
||||
* Handles the given input. This should only be done if the {@link canHandle} function returned `true`.
|
||||
@@ -17,7 +17,7 @@ export abstract class AsyncHandler<TInput, TOutput = void> {
|
||||
*
|
||||
* @returns A promise resolving when the handling is finished. Return value depends on the given type.
|
||||
*/
|
||||
public abstract handle (input: TInput): Promise<TOutput>;
|
||||
public abstract handle(input: TInput): Promise<TOutput>;
|
||||
|
||||
/**
|
||||
* Helper function that first runs the canHandle function followed by the handle function.
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { AsyncHandler } from './AsyncHandler';
|
||||
import type { AsyncHandler } from './AsyncHandler';
|
||||
import { UnsupportedHttpError } from './errors/UnsupportedHttpError';
|
||||
|
||||
/**
|
||||
@@ -40,7 +40,7 @@ export class CompositeAsyncHandler<TIn, TOut> implements AsyncHandler<TIn, TOut>
|
||||
|
||||
try {
|
||||
handler = await this.findHandler(input);
|
||||
} catch (error) {
|
||||
} catch {
|
||||
throw new Error('All handlers failed. This might be the consequence of calling handle before canHandle.');
|
||||
}
|
||||
|
||||
@@ -77,8 +77,12 @@ export class CompositeAsyncHandler<TIn, TOut> implements AsyncHandler<TIn, TOut>
|
||||
await handler.canHandle(input);
|
||||
|
||||
return handler;
|
||||
} catch (error) {
|
||||
errors.push(error);
|
||||
} catch (error: unknown) {
|
||||
if (error instanceof Error) {
|
||||
errors.push(error);
|
||||
} else {
|
||||
errors.push(new Error('Unknown error.'));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { Stats } from 'fs';
|
||||
import { Readable } from 'stream';
|
||||
import type { Stats } from 'fs';
|
||||
import type { Readable } from 'stream';
|
||||
import arrayifyStream from 'arrayify-stream';
|
||||
import { DataFactory, StreamParser, StreamWriter } from 'n3';
|
||||
import type { Quad } from 'rdf-js';
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
const createSuffixFn = (prefix: string): any => (suffix: string): string => `${prefix}${suffix}`;
|
||||
const createSuffixFn = (prefix: string): ((suf: string) => string) => (suffix: string): string => `${prefix}${suffix}`;
|
||||
|
||||
const ACL_PREFIX = createSuffixFn('http://www.w3.org/ns/auth/acl#');
|
||||
export const ACL = {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { Readable, Writable } from 'stream';
|
||||
import type { Readable, Writable } from 'stream';
|
||||
import arrayifyStream from 'arrayify-stream';
|
||||
import { UnsupportedHttpError } from './errors/UnsupportedHttpError';
|
||||
|
||||
|
||||
Reference in New Issue
Block a user