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

@@ -90,7 +90,6 @@ jest.mock('../../../src/init/cluster/SingleThreaded', (): any => ({
}));
jest.mock('componentsjs', (): any => ({
// eslint-disable-next-line @typescript-eslint/naming-convention
ComponentsManager: {
build: jest.fn(async(): Promise<ComponentsManager<App>> => manager),
},
@@ -439,7 +438,7 @@ describe('AppRunner', (): void => {
it('checks for threading issues when starting in multithreaded mode.', async(): Promise<void> => {
const createdApp = await new AppRunner().createCli();
expect(createdApp).toBe(app);
expect(listSingleThreadedComponentsMock).toHaveBeenCalled();
expect(listSingleThreadedComponentsMock).toHaveBeenCalledWith();
});
it('throws an error if there are threading issues detected.', async(): Promise<void> => {

View File

@@ -1,7 +1,7 @@
import { writeJson } from 'fs-extra';
import { AccountStore } from '../../../src/identity/interaction/account/util/AccountStore';
import { PasswordStore } from '../../../src/identity/interaction/password/util/PasswordStore';
import { PodCreator } from '../../../src/identity/interaction/pod/util/PodCreator';
import type { AccountStore } from '../../../src/identity/interaction/account/util/AccountStore';
import type { PasswordStore } from '../../../src/identity/interaction/password/util/PasswordStore';
import type { PodCreator } from '../../../src/identity/interaction/pod/util/PodCreator';
import { SeededAccountInitializer } from '../../../src/init/SeededAccountInitializer';
import { mockFileSystem } from '../../util/Util';

View File

@@ -1,4 +1,4 @@
import { YargsParameter, YargsCliExtractor } from '../../../../src/init/cli/YargsCliExtractor';
import { YargsCliExtractor, YargsParameter } from '../../../../src/init/cli/YargsCliExtractor';
const error = jest.spyOn(console, 'error').mockImplementation(jest.fn());
const log = jest.spyOn(console, 'log').mockImplementation(jest.fn());
@@ -76,7 +76,6 @@ describe('A YargsCliExtractor', (): void => {
// This can probably be fixed by changing jest setup to already load the custom env before loading the tests,
// but does not seem worth it just for this test.
const { env } = process;
// eslint-disable-next-line @typescript-eslint/naming-convention
process.env = { ...env, TEST_ENV_PORT: '3333' };
extractor = new YargsCliExtractor(parameters, { loadFromEnv: true, envVarPrefix: 'TEST_ENV' });
const argv = [ 'node', 'script', '-b', 'http://localhost:3333/' ];

View File

@@ -22,7 +22,6 @@ function mockComponentsManagerFn(length: number): jest.Mocked<ComponentsManager<
}
jest.mock('jsonld-context-parser/lib/ContextParser', (): any => ({
// eslint-disable-next-line @typescript-eslint/naming-convention
ContextParser: jest.fn().mockImplementation((): any => ({
parse: jest.fn(async(): Promise<any> => ({
expandTerm: jest.fn((): any => myExpandTerm()),
@@ -31,11 +30,9 @@ jest.mock('jsonld-context-parser/lib/ContextParser', (): any => ({
}));
jest.mock('componentsjs', (): any => ({
// eslint-disable-next-line @typescript-eslint/naming-convention
ComponentsManager: {
build: jest.fn(async(props: any): Promise<ComponentsManager<any>> => mockComponentsManagerFn(props.length)),
},
// eslint-disable-next-line @typescript-eslint/naming-convention
PrefetchedDocumentLoader: jest.fn().mockImplementation((): any => ({
load: jest.fn(),
})),

View File

@@ -10,6 +10,6 @@ describe('A WorkerManager', (): void => {
const wm = new WorkerManager(cm);
Object.assign(cm, { spawnWorkers: jest.fn() });
await wm.handle();
expect(cm.spawnWorkers).toHaveBeenCalled();
expect(cm.spawnWorkers).toHaveBeenCalledWith();
});
});

View File

@@ -2,7 +2,7 @@ import { BasicRepresentation } from '../../../../src/http/representation/BasicRe
import type { Representation } from '../../../../src/http/representation/Representation';
import { RepresentationMetadata } from '../../../../src/http/representation/RepresentationMetadata';
import { SingleContainerJsonStorage } from '../../../../src/init/migration/SingleContainerJsonStorage';
import { ResourceStore } from '../../../../src/storage/ResourceStore';
import type { ResourceStore } from '../../../../src/storage/ResourceStore';
import { NotFoundHttpError } from '../../../../src/util/errors/NotFoundHttpError';
import { isContainerIdentifier } from '../../../../src/util/PathUtil';
import { LDP } from '../../../../src/util/Vocabularies';

View File

@@ -1,4 +1,5 @@
import { ACCOUNT_TYPE, AccountLoginStorage } from '../../../../src/identity/interaction/account/util/LoginStorage';
import type { AccountLoginStorage } from '../../../../src/identity/interaction/account/util/LoginStorage';
import { ACCOUNT_TYPE } from '../../../../src/identity/interaction/account/util/LoginStorage';
import {
CLIENT_CREDENTIALS_STORAGE_TYPE,
} from '../../../../src/identity/interaction/client-credentials/util/BaseClientCredentialsStore';
@@ -6,7 +7,7 @@ import { PASSWORD_STORAGE_TYPE } from '../../../../src/identity/interaction/pass
import { OWNER_STORAGE_TYPE, POD_STORAGE_TYPE } from '../../../../src/identity/interaction/pod/util/BasePodStore';
import { WEBID_STORAGE_TYPE } from '../../../../src/identity/interaction/webid/util/BaseWebIdStore';
import { V6MigrationInitializer } from '../../../../src/init/migration/V6MigrationInitializer';
import { KeyValueStorage } from '../../../../src/storage/keyvalue/KeyValueStorage';
import type { KeyValueStorage } from '../../../../src/storage/keyvalue/KeyValueStorage';
type Account = {
webId: string;