mirror of
https://github.com/CommunitySolidServer/CommunitySolidServer.git
synced 2024-10-03 14:55:10 +00:00
refactor: Remove eslint-disable when possible
This commit is contained in:
parent
65bf2bd34e
commit
fa060b86f3
@ -5,7 +5,6 @@ export const ACCOUNT_SETTINGS_REMEMBER_LOGIN = 'rememberLogin';
|
||||
|
||||
export type AccountSettings = { [ACCOUNT_SETTINGS_REMEMBER_LOGIN]?: boolean };
|
||||
|
||||
/* eslint-disable ts/method-signature-style */
|
||||
/**
|
||||
* Used to store account data.
|
||||
*/
|
||||
@ -24,7 +23,7 @@ export interface AccountStore {
|
||||
* @param id - The account identifier.
|
||||
* @param setting - The setting to find the value of.
|
||||
*/
|
||||
getSetting<T extends keyof AccountSettings>(id: string, setting: T): Promise<AccountSettings[T]>;
|
||||
getSetting: <T extends keyof AccountSettings>(id: string, setting: T) => Promise<AccountSettings[T]>;
|
||||
|
||||
/**
|
||||
* Updates the settings for the account with the given identifier to the new values.
|
||||
@ -33,5 +32,5 @@ export interface AccountStore {
|
||||
* @param setting - The setting to update.
|
||||
* @param value - The new value for the setting.
|
||||
*/
|
||||
updateSetting<T extends keyof AccountSettings>(id: string, setting: T, value: AccountSettings[T]): Promise<void>;
|
||||
updateSetting: <T extends keyof AccountSettings>(id: string, setting: T, value: AccountSettings[T]) => Promise<void>;
|
||||
}
|
||||
|
@ -61,7 +61,7 @@ export class BaseLoginAccountStorage<T extends IndexTypeCollection<T>> implement
|
||||
return this.storage.defineType(type, description);
|
||||
}
|
||||
|
||||
public async createIndex<TType extends StringKey<T>>(type: TType, key: StringKey<TType>): Promise<void> {
|
||||
public async createIndex<TType extends StringKey<T>>(type: TType, key: StringKey<T[TType]>): Promise<void> {
|
||||
return this.storage.createIndex(type, key);
|
||||
}
|
||||
|
||||
|
@ -1,4 +1,3 @@
|
||||
/* eslint-disable unicorn/no-process-exit */
|
||||
import { existsSync } from 'node:fs';
|
||||
import type { WriteStream } from 'node:tty';
|
||||
import type { IComponentsManagerBuilderOptions } from 'componentsjs';
|
||||
@ -145,6 +144,7 @@ export class AppRunner {
|
||||
public runCliSync({ argv, stderr = process.stderr }: { argv?: CliArgv; stderr?: WriteStream }): void {
|
||||
this.runCli(argv).catch((error): never => {
|
||||
stderr.write(createErrorMessage(error));
|
||||
// eslint-disable-next-line unicorn/no-process-exit
|
||||
process.exit(1);
|
||||
});
|
||||
}
|
||||
|
@ -76,8 +76,9 @@ export class YargsCliExtractor extends CliExtractor {
|
||||
yArgv.check((args): boolean => {
|
||||
for (const [ name, options ] of Object.entries(this.yargsArgOptions)) {
|
||||
if (options.type !== 'array' && Array.isArray(args[name])) {
|
||||
// eslint-disable-next-line ts/restrict-template-expressions
|
||||
throw new Error(`Multiple values for --${name} (-${options.alias}) were provided where only one is allowed`);
|
||||
throw new Error(
|
||||
`Multiple values for --${name} (-${options.alias as string}) were provided where only one is allowed`,
|
||||
);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
|
@ -68,7 +68,8 @@ export interface V6MigrationInitializerArgs {
|
||||
/**
|
||||
* Storages for which all entries need to be removed.
|
||||
*/
|
||||
cleanupStorages: KeyValueStorage<string, unknown>[];
|
||||
// eslint-disable-next-line ts/no-explicit-any
|
||||
cleanupStorages: KeyValueStorage<string, any>[];
|
||||
/**
|
||||
* The storage that will contain the account data in the new format.
|
||||
* Wrong typings to prevent Components.js typing issues.
|
||||
|
@ -61,10 +61,9 @@ export class HandlerServerConfigurator extends ServerConfigurator {
|
||||
*/
|
||||
private createErrorMessage(error: unknown): string {
|
||||
if (!isError(error)) {
|
||||
// eslint-disable-next-line ts/restrict-template-expressions
|
||||
return `Unknown error: ${error}.\n`;
|
||||
return `Unknown error: ${error as string}.\n`;
|
||||
}
|
||||
if (this.showStackTrace && error.stack) {
|
||||
if (this.showStackTrace && isError(error) && error.stack) {
|
||||
return `${error.stack}\n`;
|
||||
}
|
||||
return `${error.name}: ${error.message}\n`;
|
||||
|
@ -86,7 +86,6 @@ export type IndexedQuery<T extends IndexTypeCollection<T>, TType extends keyof T
|
||||
(T[TType][K] extends `${typeof INDEX_ID_KEY}:${infer U}` ? IndexedQuery<T, U, Prev[TDepth]> : never)
|
||||
};
|
||||
|
||||
/* eslint-disable ts/method-signature-style */
|
||||
/**
|
||||
* A storage solution that allows for more complex queries than a key/value storage
|
||||
* and allows setting indexes on specific keys.
|
||||
@ -101,7 +100,7 @@ export interface IndexedStorage<T extends IndexTypeCollection<T>> {
|
||||
* @param type - The type to define.
|
||||
* @param description - A description of the values stored in objects of that type.
|
||||
*/
|
||||
defineType<TType extends StringKey<T>>(type: TType, description: T[TType]): Promise<void>;
|
||||
defineType: <TType extends StringKey<T>>(type: TType, description: T[TType]) => Promise<void>;
|
||||
|
||||
/**
|
||||
* Creates an index on a key of the given type, to allow for better queries involving those keys.
|
||||
@ -110,7 +109,7 @@ export interface IndexedStorage<T extends IndexTypeCollection<T>> {
|
||||
* @param type - The type to create an index on.
|
||||
* @param key - The key of that type to create an index on.
|
||||
*/
|
||||
createIndex<TType extends StringKey<T>>(type: TType, key: StringKey<T[TType]>): Promise<void>;
|
||||
createIndex: <TType extends StringKey<T>>(type: TType, key: StringKey<T[TType]>) => Promise<void>;
|
||||
|
||||
/**
|
||||
* Creates an object of the given type.
|
||||
@ -121,7 +120,7 @@ export interface IndexedStorage<T extends IndexTypeCollection<T>> {
|
||||
*
|
||||
* @returns A representation of the newly created object, including its new identifier.
|
||||
*/
|
||||
create<TType extends StringKey<T>>(type: TType, value: CreateTypeObject<T[TType]>): Promise<TypeObject<T[TType]>>;
|
||||
create: <TType extends StringKey<T>>(type: TType, value: CreateTypeObject<T[TType]>) => Promise<TypeObject<T[TType]>>;
|
||||
|
||||
/**
|
||||
* Returns `true` if the object of the given type with the given identifier exists.
|
||||
@ -131,7 +130,7 @@ export interface IndexedStorage<T extends IndexTypeCollection<T>> {
|
||||
*
|
||||
* @returns Whether this object exists.
|
||||
*/
|
||||
has<TType extends StringKey<T>>(type: TType, id: string): Promise<boolean>;
|
||||
has: <TType extends StringKey<T>>(type: TType, id: string) => Promise<boolean>;
|
||||
|
||||
/**
|
||||
* Returns the object of the given type with the given identifier.
|
||||
@ -141,7 +140,7 @@ export interface IndexedStorage<T extends IndexTypeCollection<T>> {
|
||||
*
|
||||
* @returns A representation of the object, or `undefined` if there is no object of that type with that identifier.
|
||||
*/
|
||||
get<TType extends StringKey<T>>(type: TType, id: string): Promise<TypeObject<T[TType]> | undefined>;
|
||||
get: <TType extends StringKey<T>>(type: TType, id: string) => Promise<TypeObject<T[TType]> | undefined>;
|
||||
|
||||
/**
|
||||
* Finds all objects matching a specific {@link IndexedQuery}.
|
||||
@ -151,7 +150,7 @@ export interface IndexedStorage<T extends IndexTypeCollection<T>> {
|
||||
*
|
||||
* @returns A list of objects matching the query.
|
||||
*/
|
||||
find<TType extends StringKey<T>>(type: TType, query: IndexedQuery<T, TType>): Promise<(TypeObject<T[TType]>)[]>;
|
||||
find: <TType extends StringKey<T>>(type: TType, query: IndexedQuery<T, TType>) => Promise<(TypeObject<T[TType]>)[]>;
|
||||
|
||||
/**
|
||||
* Similar to {@link IndexedStorage.find}, but only returns the identifiers of the found objects.
|
||||
@ -161,7 +160,7 @@ export interface IndexedStorage<T extends IndexTypeCollection<T>> {
|
||||
*
|
||||
* @returns A list of identifiers of the matching objects.
|
||||
*/
|
||||
findIds<TType extends StringKey<T>>(type: TType, query: IndexedQuery<T, TType>): Promise<string[]>;
|
||||
findIds: <TType extends StringKey<T>>(type: TType, query: IndexedQuery<T, TType>) => Promise<string[]>;
|
||||
|
||||
/**
|
||||
* Sets the value of a specific object.
|
||||
@ -170,7 +169,7 @@ export interface IndexedStorage<T extends IndexTypeCollection<T>> {
|
||||
* @param type - The type of the object to set.
|
||||
* @param value - The new value for the object.
|
||||
*/
|
||||
set<TType extends StringKey<T>>(type: TType, value: TypeObject<T[TType]>): Promise<void>;
|
||||
set: <TType extends StringKey<T>>(type: TType, value: TypeObject<T[TType]>) => Promise<void>;
|
||||
|
||||
/**
|
||||
* Sets the value of one specific field in an object.
|
||||
@ -180,8 +179,8 @@ export interface IndexedStorage<T extends IndexTypeCollection<T>> {
|
||||
* @param key - The key to update.
|
||||
* @param value - The new value for the given key.
|
||||
*/
|
||||
setField<TType extends StringKey<T>, TKey extends StringKey<T[TType]>>(
|
||||
type: TType, id: string, key: TKey, value: ValueType<T[TType][TKey]>): Promise<void>;
|
||||
setField: <TType extends StringKey<T>, TKey extends StringKey<T[TType]>>(
|
||||
type: TType, id: string, key: TKey, value: ValueType<T[TType][TKey]>) => Promise<void>;
|
||||
|
||||
/**
|
||||
* Deletes the given object.
|
||||
@ -190,12 +189,12 @@ export interface IndexedStorage<T extends IndexTypeCollection<T>> {
|
||||
* @param type - The type of the object to delete.
|
||||
* @param id - The identifier of the object.
|
||||
*/
|
||||
delete<TType extends StringKey<T>>(type: TType, id: string): Promise<void>;
|
||||
delete: <TType extends StringKey<T>>(type: TType, id: string) => Promise<void>;
|
||||
|
||||
/**
|
||||
* Returns an iterator over all objects of the given type.
|
||||
*
|
||||
* @param type - The type to iterate over.
|
||||
*/
|
||||
entries<TType extends StringKey<T>>(type: TType): AsyncIterableIterator<TypeObject<T[TType]>>;
|
||||
entries: <TType extends StringKey<T>>(type: TType) => AsyncIterableIterator<TypeObject<T[TType]>>;
|
||||
}
|
||||
|
@ -386,8 +386,9 @@ export class WrappedIndexedStorage<T extends IndexTypeCollection<T>> implements
|
||||
if (relation) {
|
||||
const objs = this.getContainingRecord(root, type, id);
|
||||
if (partial[relation.child.key] && objs[id][relation.child.key] !== partial[relation.child.key]) {
|
||||
// eslint-disable-next-line ts/restrict-template-expressions
|
||||
this.logger.error(`Trying to modify reference key ${objs[id][relation.child.key]} on "${type}" ${id}`);
|
||||
this.logger.error(
|
||||
`Trying to modify reference key ${objs[id][relation.child.key] as string} on "${type}" ${id}`,
|
||||
);
|
||||
throw new NotImplementedHttpError('Changing reference keys of existing objects is not supported.');
|
||||
}
|
||||
oldObj = objs[id];
|
||||
@ -545,8 +546,7 @@ export class WrappedIndexedStorage<T extends IndexTypeCollection<T>> implements
|
||||
query: IndexedQuery<T, TType>,
|
||||
rootIds?: string[],
|
||||
): Promise<VirtualObject[]> {
|
||||
// eslint-disable-next-line ts/restrict-template-expressions
|
||||
this.logger.debug(`Executing "${type}" query ${JSON.stringify(query)}. Already found roots ${rootIds}.`);
|
||||
this.logger.debug(`Executing "${type}" query ${JSON.stringify(query)}. Already found roots ${rootIds?.join(',')}.`);
|
||||
|
||||
const indexedRoots = await this.findIndexedRoots(type, query, rootIds);
|
||||
|
||||
@ -665,8 +665,9 @@ export class WrappedIndexedStorage<T extends IndexTypeCollection<T>> implements
|
||||
Promise<void> {
|
||||
const indexKey = this.getIndexKey(type, key, value);
|
||||
const indexValues = await this.indexStorage.get(indexKey) ?? [];
|
||||
// eslint-disable-next-line ts/restrict-template-expressions
|
||||
this.logger.debug(`Updating index ${indexKey} by ${add ? 'adding' : 'removing'} ${rootId} from ${indexValues}`);
|
||||
this.logger.debug(
|
||||
`Updating index ${indexKey} by ${add ? 'adding' : 'removing'} ${rootId} from ${indexValues.join(',')}`,
|
||||
);
|
||||
|
||||
if (add) {
|
||||
if (!indexValues.includes(rootId)) {
|
||||
|
@ -1,6 +1,5 @@
|
||||
// These two eslint lines are needed to store 'this' in a variable so it can be used
|
||||
// in the PassThrough of createQuotaGuard
|
||||
/* eslint-disable ts/no-this-alias */
|
||||
import { PassThrough } from 'node:stream';
|
||||
import type { RepresentationMetadata } from '../../http/representation/RepresentationMetadata';
|
||||
import type { ResourceIdentifier } from '../../http/representation/ResourceIdentifier';
|
||||
@ -87,6 +86,7 @@ export abstract class QuotaStrategy {
|
||||
*/
|
||||
public async createQuotaGuard(identifier: ResourceIdentifier): Promise<Guarded<PassThrough>> {
|
||||
let total = 0;
|
||||
// eslint-disable-next-line ts/no-this-alias
|
||||
const that = this;
|
||||
const { reporter } = this;
|
||||
|
||||
|
@ -15,6 +15,5 @@ export function isError(error: unknown): error is Error {
|
||||
* Creates a string representing the error message of this object.
|
||||
*/
|
||||
export function createErrorMessage(error: unknown): string {
|
||||
// eslint-disable-next-line ts/restrict-template-expressions
|
||||
return isError(error) ? error.message : `Unknown error: ${error}`;
|
||||
return isError(error) ? error.message : `Unknown error: ${error as string}`;
|
||||
}
|
||||
|
@ -6,8 +6,7 @@ import { AsyncHandler } from './AsyncHandler';
|
||||
*
|
||||
* The generic type extends `any` due to Components.js requirements.
|
||||
*/
|
||||
// eslint-disable-next-line ts/no-unnecessary-type-constraint
|
||||
export class StaticHandler<T extends unknown = void> extends AsyncHandler<unknown, T> {
|
||||
export class StaticHandler<T = void> extends AsyncHandler<unknown, T> {
|
||||
private readonly value?: T;
|
||||
|
||||
public constructor(value?: T) {
|
||||
@ -16,7 +15,6 @@ export class StaticHandler<T extends unknown = void> extends AsyncHandler<unknow
|
||||
}
|
||||
|
||||
public async handle(): Promise<T> {
|
||||
// eslint-disable-next-line ts/no-unnecessary-type-assertion
|
||||
return this.value!;
|
||||
}
|
||||
}
|
||||
|
@ -138,8 +138,8 @@ describe('A server migrating from v6', (): void => {
|
||||
it('still supports the existing client credentials.', async(): Promise<void> => {
|
||||
// These are the values stored in the original assets
|
||||
const id = 'token_fd13b73d-2527-4280-82af-278e5b8fe607';
|
||||
// eslint-disable-next-line max-len
|
||||
const secret = 'a809d7ce5daf0e9acd457c91d712ff05038e4a87192e27191c837602bd4b370c633282864c133650b0e9a35b59018b064157532642f628affb2f79e81999e898';
|
||||
const secret = 'a809d7ce5daf0e9acd457c91d712ff05038e4a87192e27191c837602bd4b' +
|
||||
'370c633282864c133650b0e9a35b59018b064157532642f628affb2f79e81999e898';
|
||||
const tokenUrl = joinUrl(baseUrl, '.oidc/token');
|
||||
const dpopHeader = await createDpopHeader(tokenUrl, 'POST', await generateDpopKeyPair());
|
||||
const authString = `${encodeURIComponent(id)}:${encodeURIComponent(secret)}`;
|
||||
|
Loading…
x
Reference in New Issue
Block a user