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

@@ -52,6 +52,7 @@ class SimpleReadWriteLocker extends BaseReadWriteLocker {
}
}
/* eslint-disable ts/no-floating-promises */
describe('A BaseReadWriteLocker', (): void => {
let resourceLocker: ResourceLocker;
let countLocker: ResourceLocker;
@@ -163,7 +164,6 @@ describe('A BaseReadWriteLocker', (): void => {
// Otherwise the internal write lock might not be acquired yet
const delayedLockWrite = new Promise<void>((resolve): void => {
emitter.on('readStarted', (): void => {
// eslint-disable-next-line @typescript-eslint/no-floating-promises
locker.withWriteLock(resourceId, (): any => {
order.push('write');
resolve();
@@ -198,7 +198,6 @@ describe('A BaseReadWriteLocker', (): void => {
const delayedLockWrite = new Promise<void>((resolve): void => {
emitter.on('readStarted', (): void => {
// eslint-disable-next-line @typescript-eslint/no-floating-promises
locker.withWriteLock(resource2Id, (): any => {
order.push('write');
resolve();
@@ -233,7 +232,6 @@ describe('A BaseReadWriteLocker', (): void => {
const delayedLockWrite = new Promise<void>((resolve): void => {
emitter.on('readStarted', (): void => {
// eslint-disable-next-line @typescript-eslint/no-floating-promises
locker.withWriteLock(resourceId, (): any => {
order.push('write');
resolve();
@@ -243,7 +241,6 @@ describe('A BaseReadWriteLocker', (): void => {
const delayedLockRead2 = new Promise<void>((resolve): void => {
emitter.on('readStarted', (): void => {
// eslint-disable-next-line @typescript-eslint/no-floating-promises
locker.withReadLock(resourceId, async(): Promise<void> => {
order.push('read 2 start');
await promRead2;
@@ -287,7 +284,6 @@ describe('A BaseReadWriteLocker', (): void => {
// We want to make sure the read operation only starts while the write operation is busy
const delayedLockRead = new Promise<void>((resolve): void => {
emitter.on('writeStarted', (): void => {
// eslint-disable-next-line @typescript-eslint/no-floating-promises
locker.withReadLock(resourceId, (): any => {
order.push('read');
resolve();

View File

@@ -1,5 +1,5 @@
import { readdir } from 'fs-extra';
import { InternalServerError, FileSystemResourceLocker, joinFilePath } from '../../../../src';
import { FileSystemResourceLocker, InternalServerError, joinFilePath } from '../../../../src';
import { getTestFolder, removeFolder } from '../../../integration/Config';
// Due to the nature of using a file locking library, this is a unit test that writes to disk.

View File

@@ -3,7 +3,7 @@ import type { Redis } from 'ioredis';
import type { ReadWriteLocker, ResourceLocker } from '../../../../src';
import { InternalServerError } from '../../../../src';
import { RedisLocker } from '../../../../src/util/locking/RedisLocker';
import type { RedisResourceLock, RedisReadWriteLock } from '../../../../src/util/locking/scripts/RedisLuaScripts';
import type { RedisReadWriteLock, RedisResourceLock } from '../../../../src/util/locking/scripts/RedisLuaScripts';
import { flushPromises } from '../../../util/Util';
interface LockState {
@@ -99,6 +99,7 @@ const redis: jest.Mocked<Redis & RedisResourceLock & RedisReadWriteLock> = {
jest.mock('ioredis', (): any => jest.fn().mockImplementation((): Redis => redis));
/* eslint-disable ts/no-floating-promises */
describe('A RedisLocker', (): void => {
it('will generate keys with the given namespacePrefix.', async(): Promise<void> => {
const identifier = { path: 'http://test.com/resource' };
@@ -243,7 +244,6 @@ describe('A RedisLocker', (): void => {
// Otherwise the internal write lock might not be acquired yet
const delayedLockWrite = new Promise<void>((resolve): void => {
emitter.on('readStarted', (): void => {
// eslint-disable-next-line @typescript-eslint/no-floating-promises
locker.withWriteLock(resource1, (): any => {
order.push('write');
resolve();
@@ -278,7 +278,6 @@ describe('A RedisLocker', (): void => {
const delayedLockWrite = new Promise<void>((resolve): void => {
emitter.on('readStarted', (): void => {
// eslint-disable-next-line @typescript-eslint/no-floating-promises
locker.withWriteLock(resource2, (): any => {
order.push('write');
resolve();
@@ -313,7 +312,6 @@ describe('A RedisLocker', (): void => {
const delayedLockWrite = new Promise<void>((resolve): void => {
emitter.on('readStarted', (): void => {
// eslint-disable-next-line @typescript-eslint/no-floating-promises
locker.withWriteLock(resource1, (): any => {
order.push('write');
resolve();
@@ -323,7 +321,6 @@ describe('A RedisLocker', (): void => {
const delayedLockRead2 = new Promise<void>((resolve): void => {
emitter.on('readStarted', (): void => {
// eslint-disable-next-line @typescript-eslint/no-floating-promises
locker.withReadLock(resource1, async(): Promise<void> => {
order.push('read 2 start');
await promRead2;
@@ -367,7 +364,6 @@ describe('A RedisLocker', (): void => {
// We want to make sure the read operation only starts while the write operation is busy
const delayedLockRead = new Promise<void>((resolve): void => {
emitter.on('writeStarted', (): void => {
// eslint-disable-next-line @typescript-eslint/no-floating-promises
locker.withReadLock(resource1, (): any => {
order.push('read');
resolve();