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

@@ -1,5 +1,5 @@
import { EventEmitter } from 'events';
import type { ServerResponse, IncomingMessage, Server } from 'http';
import type { IncomingMessage, Server, ServerResponse } from 'http';
import { Readable } from 'stream';
import type { Logger } from '../../../src/logging/Logger';
import { getLoggerFor } from '../../../src/logging/LogUtil';

View File

@@ -9,7 +9,6 @@ import { WebSocketServerConfigurator } from '../../../src/server/WebSocketServer
import { flushPromises } from '../../util/Util';
jest.mock('ws', (): any => ({
// eslint-disable-next-line @typescript-eslint/naming-convention
WebSocketServer: jest.fn().mockImplementation((): any => ({
handleUpgrade(upgradeRequest: any, socket: any, head: any, callback: any): void {
callback(socket, upgradeRequest);

View File

@@ -37,7 +37,7 @@ describe('A KeyValueChannelStorage', (): void => {
internalStorage = internalMap as any;
locker = {
withWriteLock: jest.fn(async <T,>(rid: ResourceIdentifier, whileLocked: () => T | Promise<T>):
withWriteLock: jest.fn(async <T>(rid: ResourceIdentifier, whileLocked: () => T | Promise<T>):
Promise<T> => whileLocked()),
withReadLock: jest.fn(),
};

View File

@@ -27,7 +27,6 @@ describe('A ListeningActivityHandler', (): void => {
let storage: jest.Mocked<NotificationChannelStorage>;
let emitter: ActivityEmitter;
let notificationHandler: jest.Mocked<NotificationHandler>;
let handler: ListeningActivityHandler;
beforeEach(async(): Promise<void> => {
jest.clearAllMocks();
@@ -49,8 +48,8 @@ describe('A ListeningActivityHandler', (): void => {
handleSafe: jest.fn().mockResolvedValue(undefined),
} as any;
// eslint-disable-next-line @typescript-eslint/no-unused-vars
handler = new ListeningActivityHandler(storage, emitter, notificationHandler);
// eslint-disable-next-line no-new
new ListeningActivityHandler(storage, emitter, notificationHandler);
});
it('calls the NotificationHandler if there is an event.', async(): Promise<void> => {

View File

@@ -12,6 +12,7 @@ import type {
import { INTERNAL_QUADS } from '../../../../src/util/ContentTypes';
import { readableToString } from '../../../../src/util/StreamUtil';
import { NOTIFY } from '../../../../src/util/Vocabularies';
const { namedNode, quad } = DataFactory;
describe('A NotificationDescriber', (): void => {

View File

@@ -6,6 +6,7 @@ import type { HttpResponse } from '../../../../../src/server/HttpResponse';
import { WebhookWebId } from '../../../../../src/server/notifications/WebhookChannel2023/WebhookWebId';
import { readableToString } from '../../../../../src/util/StreamUtil';
import { SOLID } from '../../../../../src/util/Vocabularies';
const { namedNode, quad } = DataFactory;
describe('A WebhookWebId', (): void => {

View File

@@ -15,7 +15,6 @@ import {
import { NotImplementedHttpError } from '../../../../../src/util/errors/NotImplementedHttpError';
jest.mock('ws', (): any => ({
// eslint-disable-next-line @typescript-eslint/naming-convention
WebSocketServer: jest.fn().mockImplementation((): any => ({
handleUpgrade(upgradeRequest: any, socket: any, head: any, callback: any): void {
callback(socket, upgradeRequest);

View File

@@ -3,7 +3,6 @@ import {
AbsolutePathInteractionRoute,
} from '../../../../../src/identity/interaction/routing/AbsolutePathInteractionRoute';
import type { NotificationChannel } from '../../../../../src/server/notifications/NotificationChannel';
import {
generateWebSocketUrl,
} from '../../../../../src/server/notifications/WebSocketChannel2023/WebSocket2023Util';

View File

@@ -1,8 +1,8 @@
import type { HttpRequest,
import type { HttpHandler,
HttpRequest,
HttpResponse,
TargetExtractor,
ResourceIdentifier,
HttpHandler } from '../../../../src';
TargetExtractor } from '../../../../src';
import { joinUrl } from '../../../../src';
import { RouterHandler } from '../../../../src/server/util/RouterHandler';