refactor: Bring lint config back to original strictness

This commit is contained in:
Joachim Van Herwegen
2023-10-30 14:32:21 +01:00
parent 7a007dc466
commit 3bb3004abb
52 changed files with 239 additions and 132 deletions

View File

@@ -85,7 +85,7 @@ export class AcpReader extends PermissionReader {
}
const modes = allowAccessModes(policies, context);
const permissionSet: PermissionSet = { };
const permissionSet: PermissionSet = {};
for (const aclMode of modes) {
if (aclMode in modesMap) {
for (const mode of modesMap[aclMode]) {

View File

@@ -4,4 +4,4 @@ import type { RepresentationMetadata } from '../representation/RepresentationMet
/**
* Generic interface for classes that add metadata to a RepresentationMetadata.
*/
export abstract class MetadataGenerator extends AsyncHandler<RepresentationMetadata> { }
export abstract class MetadataGenerator extends AsyncHandler<RepresentationMetadata> {}

View File

@@ -10,4 +10,4 @@ export type ValidatorInput = {
/**
* Generic interface for classes that validate Representations in some way.
*/
export abstract class Validator extends AsyncHandler<ValidatorInput, Representation> { }
export abstract class Validator extends AsyncHandler<ValidatorInput, Representation> {}

View File

@@ -62,6 +62,7 @@ export class ConvertingErrorHandler extends ErrorHandler {
private async extractErrorDetails({ error, request }: ErrorHandlerArgs): Promise<PreparedArguments> {
if (!this.showStackTrace) {
delete error.stack;
// eslint-disable-next-line ts/no-unsafe-member-access
delete (error as any).cause;
}
const representation = new BasicRepresentation([ error ], error.metadata, INTERNAL_ERROR, false);

View File

@@ -29,7 +29,7 @@ export class LinkRelMetadataWriter extends MetadataWriter {
const values = input.metadata.getAll(predicate)
.map((term): string => `<${term.value}>; rel="${relValue}"`);
if (values.length > 0) {
this.logger.debug(`Adding Link header ${values}`);
this.logger.debug(`Adding Link header ${values.join(',')}`);
addHeader(input.response, 'Link', values);
}
}

View File

@@ -33,7 +33,7 @@ export class WacAllowMetadataWriter extends MetadataWriter {
}
}
private aclToPermission(aclTerm: Term): string {
private aclToPermission(this: void, aclTerm: Term): string {
return aclTerm.value.slice(ACL.namespace.length).toLowerCase();
}

View File

@@ -20,7 +20,7 @@ export class HtmlViewEntry {
public constructor(
public readonly route: InteractionRoute,
public readonly filePath: string,
) { }
) {}
}
/**

View File

@@ -25,4 +25,4 @@ export interface InteractionHandlerInput {
/**
* Handler used for IDP interactions.
*/
export abstract class InteractionHandler extends AsyncHandler<InteractionHandlerInput, Representation> { }
export abstract class InteractionHandler extends AsyncHandler<InteractionHandlerInput, Representation> {}

View File

@@ -38,4 +38,4 @@ export interface JsonInteractionHandlerInput {
* designed to be used for IDP/OIDC interactions.
*/
export abstract class JsonInteractionHandler<TOut extends Dict<Json> = Dict<Json>>
extends AsyncHandler<JsonInteractionHandlerInput, JsonRepresentation<TOut>> { }
extends AsyncHandler<JsonInteractionHandlerInput, JsonRepresentation<TOut>> {}

View File

@@ -160,7 +160,7 @@ export class BaseResourcesGenerator implements TemplatedResourcesGenerator {
private async groupLinks(folderPath: string, mapper: FileIdentifierMapper):
Promise<Record<string, { link: TemplateResourceLink; meta?: TemplateResourceLink }>> {
const files = await fsPromises.readdir(folderPath);
const links: Record<string, { link: TemplateResourceLink; meta?: TemplateResourceLink }> = { };
const links: Record<string, { link: TemplateResourceLink; meta?: TemplateResourceLink }> = {};
for (const name of files) {
const link = await this.toTemplateLink(joinFilePath(folderPath, name), mapper);
const { path } = link.identifier;

View File

@@ -21,7 +21,7 @@ export class StaticAssetEntry {
public constructor(
public readonly relativeUrl: string,
public readonly filePath: string,
) { }
) {}
}
/**

View File

@@ -5,4 +5,4 @@ import type { NotificationHandlerInput } from '../NotificationHandler';
/**
* Creates a {@link Notification} based on the provided input.
*/
export abstract class NotificationGenerator extends AsyncHandler<NotificationHandlerInput, Notification> { }
export abstract class NotificationGenerator extends AsyncHandler<NotificationHandlerInput, Notification> {}

View File

@@ -14,4 +14,4 @@ export interface NotificationSerializerInput {
* This is a separate class between a generator and emitter,
* so that a specific notification channel type can add extra metadata to the Representation if needed.
*/
export abstract class NotificationSerializer extends AsyncHandler<NotificationSerializerInput, Representation> { }
export abstract class NotificationSerializer extends AsyncHandler<NotificationSerializerInput, Representation> {}

View File

@@ -30,7 +30,7 @@ export class InMemoryDataAccessor implements DataAccessor, SingleThreaded {
public constructor(identifierStrategy: IdentifierStrategy) {
this.identifierStrategy = identifierStrategy;
this.store = { entries: { }};
this.store = { entries: {}};
}
public async canHandle(): Promise<void> {

View File

@@ -65,7 +65,7 @@ export class MaxKeyLengthStorage<T> implements KeyValueStorage<string, T> {
const parts = key.split('/');
// Prevent non-hashed keys with the prefix to prevent false hits
if (parts[parts.length - 1].startsWith(this.hashPrefix)) {
if (parts.at(-1)?.startsWith(this.hashPrefix)) {
throw new NotImplementedHttpError(`Unable to store keys starting with ${this.hashPrefix}`);
}

View File

@@ -38,7 +38,7 @@ export function isGuarded<T extends NodeJS.EventEmitter>(stream: T): stream is G
function guardingErrorListener(this: Guarded, error: Error): void {
// Only fall back to this if no new listeners are attached since guarding started.
const errorListeners = this.listeners('error');
if (errorListeners[errorListeners.length - 1] === guardingErrorListener) {
if (errorListeners.at(-1) === guardingErrorListener) {
this[guardedErrors].push(error);
if (!this[guardedTimeout]) {
this[guardedTimeout] = setTimeout((): void => {

View File

@@ -38,7 +38,7 @@ const logger = getLoggerFor('HeaderUtil');
export function transformQuotedStrings(input: string): { result: string; replacements: Record<string, string> } {
let idx = 0;
const replacements: Record<string, string> = {};
const result = input.replace(/"(?:[^"\\]|\\.)*"/gu, (match): string => {
const result = input.replaceAll(/"(?:[^"\\]|\\.)*"/gu, (match): string => {
// Not all characters allowed in quoted strings, see BNF above
if (!QUOTED_STRING.test(match)) {
logger.warn(`Invalid quoted string in header: ${match}`);

View File

@@ -173,7 +173,6 @@ async function findNextSorted<T>(iterators: AsyncIterator<T>[], results: (T | un
export async function* sortedAsyncMerge<T>(iterators: AsyncIterator<T>[], comparator?: (left: T, right: T) => number):
AsyncIterable<T> {
if (!comparator) {
// eslint-disable-next-line style/no-extra-parens
comparator = (left, right): number => left < right ? -1 : (left > right ? 1 : 0);
}

View File

@@ -15,7 +15,7 @@ import { errorTermsToMetadata } from './errors/HttpErrorUtil';
* @returns The potentially changed path (POSIX).
*/
function windowsToPosixPath(path: string): string {
return path.replace(/\\+/gu, '/');
return path.replaceAll(/\\+/gu, '/');
}
/**

View File

@@ -16,7 +16,7 @@ export function splitCommaSeparated(input: string): string[] {
* @returns The sanitized output.
*/
export function sanitizeUrlPart(urlPart: string): string {
return urlPart.replace(/\W/gu, '-');
return urlPart.replaceAll(/\W/gu, '-');
}
/**

View File

@@ -51,7 +51,7 @@ export type VocabularyTerm<T> = T extends Vocabulary<any, infer TKey> ? T['terms
*/
function createValueVocabulary<TBase extends string, TLocal extends string>(baseUri: TBase, localNames: TLocal[]):
ValueVocabulary<TBase, TLocal> {
const expanded: Partial<ExpandedRecord<TBase, TLocal>> = { };
const expanded: Partial<ExpandedRecord<TBase, TLocal>> = {};
// Expose the listed local names as properties
for (const localName of localNames) {
expanded[localName] = `${baseUri}${localName}`;