refactor: Replace linting configurations

The previous package was outdated, preventing us from updating TS.
This one also lints YAML and JSON,
and applies many more rules to the test files,
explaining all the changes in this PR.
This commit is contained in:
Joachim Van Herwegen
2023-10-27 11:28:57 +02:00
parent 58daeb684f
commit 6248ed0938
327 changed files with 6424 additions and 3375 deletions

View File

@@ -18,5 +18,5 @@ export type ActivityEmitter =
/**
* A class implementation of {@link ActivityEmitter}.
*/
// eslint-disable-next-line @typescript-eslint/naming-convention
// eslint-disable-next-line ts/naming-convention
export const BaseActivityEmitter = createGenericEventEmitterClass<ActivityEmitter>();

View File

@@ -54,7 +54,9 @@ const CONTEXT_SHACL = 'https://w3c.github.io/shacl/shacl-jsonld-context/shacl.co
* The SHACL shape for the minimum requirements on a notification channel subscription request.
*/
export const DEFAULT_SUBSCRIPTION_SHACL = {
// eslint-disable-next-line ts/naming-convention
'@context': [ CONTEXT_SHACL ],
// eslint-disable-next-line ts/naming-convention
'@type': 'sh:NodeShape',
// Use the topic predicate to find the focus node
targetSubjectsOf: NOTIFY.topic,
@@ -109,6 +111,7 @@ export abstract class BaseChannelType implements NotificationChannelType {
property: [
...DEFAULT_SUBSCRIPTION_SHACL.property,
// Add type check
// eslint-disable-next-line ts/naming-convention
{ path: RDF.type, hasValue: { '@id': type.value }},
...additionalShaclProperties,
],
@@ -117,6 +120,7 @@ export abstract class BaseChannelType implements NotificationChannelType {
public getDescription(): SubscriptionService {
return {
// eslint-disable-next-line ts/naming-convention
'@context': [ CONTEXT_NOTIFICATION ],
id: this.path,
// At the time of writing, there is no base value for URIs in the notification context,
@@ -139,7 +143,7 @@ export abstract class BaseChannelType implements NotificationChannelType {
* Initiates the channel by first calling {@link validateSubscription} followed by {@link quadsToChannel}.
* Subclasses can override either function safely to impact the result of the function.
*/
// eslint-disable-next-line @typescript-eslint/no-unused-vars
// eslint-disable-next-line unused-imports/no-unused-vars
public async initChannel(data: Store, credentials: Credentials): Promise<NotificationChannel> {
const subject = await this.validateSubscription(data);
return this.quadsToChannel(data, subject);
@@ -255,6 +259,7 @@ export abstract class BaseChannelType implements NotificationChannelType {
*/
public async toJsonLd(channel: NotificationChannel): Promise<Record<string, unknown>> {
const result: Record<string, unknown> = {
// eslint-disable-next-line ts/naming-convention
'@context': [
CONTEXT_NOTIFICATION,
],
@@ -282,7 +287,7 @@ export abstract class BaseChannelType implements NotificationChannelType {
return new IdentifierSetMultiMap<AccessMode>([[{ path: channel.topic }, AccessMode.read ]]);
}
// eslint-disable-next-line @typescript-eslint/no-unused-vars
// eslint-disable-next-line unused-imports/no-unused-vars
public async completeChannel(channel: NotificationChannel): Promise<void> {
// Do nothing
}

View File

@@ -6,6 +6,7 @@ export const CONTEXT_NOTIFICATION = 'https://www.w3.org/ns/solid/notification/v1
* as defined in https://solidproject.org/TR/2022/notifications-protocol-20221231#data-model.
*/
export interface Notification {
// eslint-disable-next-line ts/naming-convention
'@context': [
typeof CONTEXT_ACTIVITYSTREAMS,
typeof CONTEXT_NOTIFICATION,

View File

@@ -9,6 +9,7 @@ import type { NotificationChannel } from './NotificationChannel';
* https://solidproject.org/TR/2022/notifications-protocol-20221231#subscription-service-data-model
*/
export interface SubscriptionService {
// eslint-disable-next-line ts/naming-convention
'@context': [ typeof CONTEXT_NOTIFICATION ];
id: string;
channelType: string;

View File

@@ -8,6 +8,7 @@ import { APPLICATION_LD_JSON, INTERNAL_QUADS } from '../../util/ContentTypes';
import { NOTIFY } from '../../util/Vocabularies';
import { StorageDescriber } from '../description/StorageDescriber';
import type { NotificationChannelType } from './NotificationChannelType';
const { namedNode, quad } = DataFactory;
/**

View File

@@ -123,7 +123,7 @@ export class NotificationSubscriber extends OperationHttpHandler {
// Complete the channel once the response has been sent out
endOfStream(response.data)
.then((): Promise<void> => this.channelType.completeChannel(channel))
.then(async(): Promise<void> => this.channelType.completeChannel(channel))
.catch((error): void => {
this.logger.error(`There was an issue completing notification channel ${channel.id}: ${
createErrorMessage(error)}`);
@@ -134,10 +134,10 @@ export class NotificationSubscriber extends OperationHttpHandler {
private async authorize(credentials: Credentials, channel: NotificationChannel): Promise<void> {
const requestedModes = await this.channelType.extractModes(channel);
this.logger.debug(`Retrieved required modes: ${[ ...requestedModes.entrySets() ]}`);
this.logger.debug(`Retrieved required modes: ${[ ...requestedModes.entrySets() ].join(',')}`);
const availablePermissions = await this.permissionReader.handleSafe({ credentials, requestedModes });
this.logger.debug(`Available permissions are ${[ ...availablePermissions.entries() ]}`);
this.logger.debug(`Available permissions are ${[ ...availablePermissions.entries() ].join(',')}`);
await this.authorizer.handleSafe({ credentials, requestedModes, availablePermissions });
this.logger.debug(`Authorization succeeded, creating notification channel`);

View File

@@ -88,6 +88,7 @@ export class WebhookEmitter extends NotificationEmitter {
const response = await fetch(webhookChannel.sendTo, {
method: 'POST',
headers: {
// eslint-disable-next-line ts/naming-convention
'content-type': representation.metadata.contentType!,
authorization: `DPoP ${dpopToken}`,
dpop: dpopProof,

View File

@@ -33,6 +33,7 @@ export class ActivityNotificationGenerator extends NotificationGenerator {
const state = this.eTagHandler.getETag(representation.metadata);
return {
// eslint-disable-next-line ts/naming-convention
'@context': [
CONTEXT_ACTIVITYSTREAMS,
CONTEXT_NOTIFICATION,

View File

@@ -43,6 +43,7 @@ export class AddRemoveNotificationGenerator extends NotificationGenerator {
}
return {
// eslint-disable-next-line ts/naming-convention
'@context': [
CONTEXT_ACTIVITYSTREAMS,
CONTEXT_NOTIFICATION,

View File

@@ -19,6 +19,7 @@ export class DeleteNotificationGenerator extends NotificationGenerator {
public async handle({ topic }: NotificationHandlerInput): Promise<Notification> {
return {
// eslint-disable-next-line ts/naming-convention
'@context': [
CONTEXT_ACTIVITYSTREAMS,
CONTEXT_NOTIFICATION,