From 3bb3004abb330c56fca3c503dd301362465647f2 Mon Sep 17 00:00:00 2001 From: Joachim Van Herwegen Date: Mon, 30 Oct 2023 14:32:21 +0100 Subject: [PATCH] refactor: Bring lint config back to original strictness --- .github/workflows/docker.yml | 2 +- documentation/mkdocs.yml | 2 +- eslint.config.js | 136 ++++++++++++++++-- jest.config.js | 2 +- scripts/finalizeRelease.ts | 2 +- scripts/formatChangelog.ts | 2 +- src/authorization/AcpReader.ts | 2 +- src/http/auxiliary/MetadataGenerator.ts | 2 +- src/http/auxiliary/Validator.ts | 2 +- .../output/error/ConvertingErrorHandler.ts | 1 + .../output/metadata/LinkRelMetadataWriter.ts | 2 +- .../output/metadata/WacAllowMetadataWriter.ts | 2 +- src/identity/interaction/HtmlViewHandler.ts | 2 +- .../interaction/InteractionHandler.ts | 2 +- .../interaction/JsonInteractionHandler.ts | 2 +- src/pods/generate/BaseResourcesGenerator.ts | 2 +- src/server/middleware/StaticAssetHandler.ts | 2 +- .../generate/NotificationGenerator.ts | 2 +- .../serialize/NotificationSerializer.ts | 2 +- src/storage/accessors/InMemoryDataAccessor.ts | 2 +- src/storage/keyvalue/MaxKeyLengthStorage.ts | 2 +- src/util/GuardedStream.ts | 2 +- src/util/HeaderUtil.ts | 2 +- src/util/IterableUtil.ts | 1 - src/util/PathUtil.ts | 2 +- src/util/StringUtil.ts | 2 +- src/util/Vocabularies.ts | 2 +- templates/scripts/util.js | 2 +- test/integration/config/server-file.json | 128 ++++++++--------- .../BearerWebIdExtractor.test.ts | 2 +- .../authorization/AuthAuxiliaryReader.test.ts | 2 +- .../ParentContainerReader.test.ts | 4 +- test/unit/authorization/WebAclReader.test.ts | 2 +- .../identifier/OriginalUrlExtractor.test.ts | 2 +- .../http/output/BasicResponseWriter.test.ts | 3 +- .../AuxiliaryLinkMetadataWriter.test.ts | 4 +- .../ContentTypeMetadataWriter.test.ts | 2 +- .../metadata/RangeMetadataWriter.test.ts | 2 +- .../metadata/WacAllowMetadataWriter.test.ts | 2 +- .../metadata/WwwAuthMetadataWriter.test.ts | 4 +- .../interaction/OidcControlHandler.test.ts | 2 +- .../interaction/login/LogoutHandler.test.ts | 2 +- .../interaction/oidc/PromptHandler.test.ts | 2 +- test/unit/logging/Logger.test.ts | 2 +- .../server/AuthorizingHttpHandler.test.ts | 2 +- .../accessors/FileDataAccessor.test.ts | 2 +- .../accessors/SparqlDataAccessor.test.ts | 2 +- .../BaseTypedRepresentationConverter.test.ts | 2 +- .../conversion/ChainedConverter.test.ts | 4 +- .../conversion/RdfToQuadConverter.test.ts | 2 +- test/unit/storage/patch/RdfPatcher.test.ts | 2 +- test/util/Util.ts | 2 +- 52 files changed, 239 insertions(+), 132 deletions(-) diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index a8eff7001..2a242263e 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -29,7 +29,7 @@ jobs: with: images: | solidproject/community-server - # edge will always be executed (without latest tag), semver only on tag push events (with latest tag) + # Edge will always be executed (without latest tag), semver only on tag push events (with latest tag) tags: | type=edge type=semver,pattern={{version}} diff --git a/documentation/mkdocs.yml b/documentation/mkdocs.yml index 043c731dd..afa440ea9 100644 --- a/documentation/mkdocs.yml +++ b/documentation/mkdocs.yml @@ -56,7 +56,7 @@ markdown_extensions: - pymdownx.smartsymbols - pymdownx.superfences: custom_fences: - # need to fork the theme to make changes https://github.com/squidfunk/mkdocs-material/issues/3665#issuecomment-1060019924 + # Need to fork the theme to make changes https://github.com/squidfunk/mkdocs-material/issues/3665#issuecomment-1060019924 - name: mermaid class: mermaid format: !!python/name:pymdownx.superfences.fence_code_format diff --git a/eslint.config.js b/eslint.config.js index 510288033..56ac16430 100644 --- a/eslint.config.js +++ b/eslint.config.js @@ -3,7 +3,7 @@ const jest = require('eslint-plugin-jest'); // Copied from https://github.com/antfu/eslint-config/blob/main/src/configs/typescript.ts // Doing it like this, so we can make sure these only try to trigger on *.ts files, -// preventing issues with the *.js files. +// Preventing issues with the *.js files. const typeAwareRules = { 'dot-notation': 'off', 'no-implied-eval': 'off', @@ -26,8 +26,7 @@ const typeAwareRules = { 'ts/unbound-method': 'error', }; -module.exports = antfu( - {}, +const configs = antfu( { // Don't want to lint test assets, or TS snippets in markdown files ignores: [ 'test/assets/*', '**/*.md/**/*.ts' ], @@ -56,6 +55,9 @@ module.exports = antfu( }, rules: { ...typeAwareRules, + 'ts/consistent-type-assertions': [ 'error', { + assertionStyle: 'as', + }], 'ts/naming-convention': [ 'error', { @@ -84,8 +86,22 @@ module.exports = antfu( prefix: [ 'T' ], }, ], + 'ts/explicit-function-return-type': [ 'error', { + allowExpressions: false, + allowTypedFunctionExpressions: false, + allowHigherOrderFunctions: false, + }], + 'ts/no-base-to-string': 'error', 'ts/no-floating-promises': [ 'error', { ignoreVoid: false }], 'ts/promise-function-async': 'error', + 'ts/no-unnecessary-boolean-literal-compare': 'error', + 'ts/no-unnecessary-qualifier': 'error', + 'ts/prefer-nullish-coalescing': 'error', + 'ts/prefer-readonly': 'error', + 'ts/prefer-reduce-type-parameter': 'error', + 'ts/prefer-regexp-exec': 'error', + 'ts/prefer-string-starts-ends-with': 'error', + 'ts/require-array-sort-compare': 'error', // These are not type specific, but we only care for TS files 'max-len': [ 'error', { code: 120, ignoreUrls: true }], @@ -104,16 +120,38 @@ module.exports = antfu( // Might want to enable this one but has a drastic impact on the already existing code 'antfu/consistent-list-newline': 'off', + 'arrow-body-style': [ 'error', 'as-needed', { requireReturnForObjectLiteral: false }], + 'capitalized-comments': [ 'error', 'always', { ignoreConsecutiveComments: true }], curly: [ 'error', 'all' ], + 'default-case': 'error', + eqeqeq: [ 'error', 'always' ], + 'for-direction': 'error', + 'func-style': [ 'error', 'declaration' ], + 'function-call-argument-newline': [ 'error', 'consistent' ], 'function-paren-newline': [ 'error', 'consistent' ], - 'jsdoc/no-multi-asterisks': [ 'error', { allowWhitespace: true }], + 'getter-return': [ 'error', { allowImplicit: true }], + 'grouped-accessor-pairs': [ 'error', 'getBeforeSet' ], + 'guard-for-in': 'error', + 'line-comment-position': [ 'error', { position: 'above' }], + 'linebreak-style': [ 'error', 'unix' ], + 'multiline-comment-style': [ 'error', 'separate-lines' ], // Need to override `allow` value 'no-console': [ 'error', { allow: [ '' ]}], 'no-constructor-return': 'error', + 'no-dupe-else-if': 'error', + 'no-else-return': [ 'error', { allowElseIf: false }], + 'no-implicit-coercion': 'error', + 'no-implicit-globals': 'error', + 'no-lonely-if': 'error', + 'no-plusplus': [ 'error', { allowForLoopAfterthoughts: true }], 'no-sync': [ 'error', { allowAtRootLevel: false }], - 'node/prefer-global/buffer': 'off', - 'node/prefer-global/process': 'off', + 'no-useless-concat': 'error', + 'no-useless-escape': 'error', + 'operator-assignment': [ 'error', 'always' ], + 'prefer-object-spread': 'error', + radix: 'error', 'require-unicode-regexp': 'error', + 'require-yield': 'error', 'sort-imports': [ 'error', { @@ -125,6 +163,14 @@ module.exports = antfu( }, ], + 'import/extensions': 'error', + + 'jsdoc/no-multi-asterisks': [ 'error', { allowWhitespace: true }], + + // Might want to enable these + 'node/prefer-global/buffer': 'off', + 'node/prefer-global/process': 'off', + 'style/array-bracket-spacing': [ 'error', 'always', { singleValue: true, objectsInArrays: false, @@ -133,24 +179,21 @@ module.exports = antfu( // Conflicts with style/object-curly-spacing 'style/block-spacing': 'off', 'style/brace-style': [ 'error', '1tbs', { allowSingleLine: false }], + 'style/generator-star-spacing': [ 'error', { before: false, after: true }], 'style/member-delimiter-style': [ 'error', { multiline: { delimiter: 'semi', requireLast: true }, singleline: { delimiter: 'semi', requireLast: false }, }], - 'style/no-extra-parens': [ 'error', 'all', { - conditionalAssign: false, - enforceForArrowConditionals: false, - ignoreJSX: 'all', - nestedBinaryExpressions: false, - returnAssign: false, - }], + 'style/no-extra-parens': [ 'error', 'functions' ], 'style/object-curly-spacing': [ 'error', 'always', { objectsInObjects: false, arraysInObjects: false, }], 'style/operator-linebreak': [ 'error', 'after' ], 'style/semi': [ 'error', 'always' ], + 'style/semi-style': [ 'error', 'last' ], 'style/space-before-function-paren': [ 'error', 'never' ], + 'style/switch-colon-spacing': 'error', 'style/quote-props': [ 'error', 'as-needed', { keywords: false, unnecessary: true, @@ -158,28 +201,80 @@ module.exports = antfu( }], 'style/yield-star-spacing': [ 'error', 'after' ], - 'test/prefer-lowercase-title': 'off', + 'ts/adjacent-overload-signatures': 'error', + 'ts/array-type': 'error', + 'ts/ban-ts-comment': [ 'error', { + 'ts-expect-error': true, + }], 'ts/consistent-indexed-object-style': [ 'error', 'record' ], 'ts/consistent-type-definitions': 'off', + 'ts/explicit-member-accessibility': 'error', 'ts/method-signature-style': 'error', + 'ts/no-confusing-non-null-assertion': 'error', 'ts/no-extraneous-class': [ 'error', { allowConstructorOnly: false, allowEmpty: false, allowStaticOnly: false, }], + 'ts/no-inferrable-types': [ 'error', { + ignoreParameters: false, + ignoreProperties: false, + }], + 'ts/prefer-for-of': 'error', + 'ts/prefer-function-type': 'error', + 'unicorn/better-regex': 'error', + 'unicorn/empty-brace-spaces': 'error', 'unicorn/consistent-function-scoping': 'error', 'unicorn/expiring-todo-comments': [ 'error', { ignoreDatesOnPullRequests: false, terms: [ 'todo' ], allowWarningComments: false, }], + 'unicorn/explicit-length-check': 'error', + 'unicorn/new-for-builtins': 'error', + 'unicorn/no-for-loop': 'error', + 'unicorn/no-invalid-remove-event-listener': 'error', + 'unicorn/no-lonely-if': 'error', + 'unicorn/no-nested-ternary': 'error', 'unicorn/no-process-exit': 'error', + 'unicorn/no-thenable': 'error', + 'unicorn/no-useless-fallback-in-spread': 'error', + 'unicorn/no-useless-length-check': 'error', + 'unicorn/no-useless-promise-resolve-reject': 'error', + 'unicorn/no-useless-spread': 'error', 'unicorn/no-useless-undefined': 'error', + 'unicorn/no-zero-fractions': 'error', + 'unicorn/prefer-array-find': 'error', 'unicorn/prefer-array-flat-map': 'error', - 'unicorn/prefer-node-protocol': 'off', + 'unicorn/prefer-array-index-of': 'error', + 'unicorn/prefer-array-some': 'error', + 'unicorn/prefer-at': 'error', + 'unicorn/prefer-code-point': 'error', + 'unicorn/prefer-date-now': 'error', + 'unicorn/prefer-default-parameters': 'error', + 'unicorn/prefer-math-trunc': 'error', + 'unicorn/prefer-native-coercion-functions': 'error', + 'unicorn/prefer-negative-index': 'error', + 'unicorn/prefer-object-from-entries': 'error', + 'unicorn/prefer-optional-catch-binding': 'error', + 'unicorn/prefer-reflect-apply': 'error', + 'unicorn/prefer-regexp-test': 'error', + 'unicorn/prefer-set-has': 'error', + 'unicorn/prefer-set-size': 'error', 'unicorn/prefer-spread': 'error', + 'unicorn/prefer-string-replace-all': 'error', + 'unicorn/prefer-string-slice': 'error', 'unicorn/require-array-join-separator': 'error', + 'unicorn/require-number-to-fixed-digits-argument': 'error', + + // Might want to enable these + 'unicorn/no-array-reduce': 'off', + 'unicorn/no-array-for-each': 'off', + 'unicorn/no-await-expression-member': 'off', + 'unicorn/no-negated-condition': 'off', + 'unicorn/no-object-as-default-parameter': 'off', + 'unicorn/prefer-node-protocol': 'off', 'unused-imports/no-unused-vars': [ 'error', @@ -216,6 +311,8 @@ module.exports = antfu( 'jest/prefer-strict-equal': 'off', 'jest/require-hook': 'off', + 'test/prefer-lowercase-title': 'off', + 'ts/naming-convention': 'off', 'ts/no-unsafe-argument': 'off', 'ts/no-unsafe-assignment': 'off', @@ -247,3 +344,12 @@ module.exports = antfu( }, }, ); + +// The default ignore list contains all `output` folders, which conflicts with our src/http/output folder +// See https://github.com/antfu/eslint-config/blob/29f29f1e16d0187f5c870102f910d798acd9b874/src/globs.ts#L53 +if (!configs[1].ignores.includes('**/output')) { + throw new Error('Unexpected data in config position. Check if antfu changed how it handles ignores.'); +} +delete configs[1].ignores; + +module.exports = configs; diff --git a/jest.config.js b/jest.config.js index 7fc0e0153..6b380ec5d 100644 --- a/jest.config.js +++ b/jest.config.js @@ -3,7 +3,7 @@ const v8 = require('v8'); // Several parts inspired by https://github.com/renovatebot/renovate/blob/main/package.json -const ci = !!process.env.CI; +const ci = Boolean(process.env.CI); const cpus = os.cpus(); const mem = os.totalmem(); diff --git a/scripts/finalizeRelease.ts b/scripts/finalizeRelease.ts index 899232353..953fc0d06 100644 --- a/scripts/finalizeRelease.ts +++ b/scripts/finalizeRelease.ts @@ -1,5 +1,5 @@ #!/usr/bin/env ts-node -/* eslint-disable no-console */ +/* eslint-disable import/extensions, no-console */ import * as readline from 'readline'; import simpleGit from 'simple-git'; import { version } from '../package.json'; diff --git a/scripts/formatChangelog.ts b/scripts/formatChangelog.ts index e961d5a64..d95b45d55 100644 --- a/scripts/formatChangelog.ts +++ b/scripts/formatChangelog.ts @@ -18,7 +18,7 @@ import { readFile, writeFile } from 'fs-extra'; * @returns Promise with output string */ async function capitalizeListEntries(input: string): Promise { - return input.replace(/^(\W*\* [a-z])/gmu, (match): string => match.toUpperCase()); + return input.replaceAll(/^(\W*\* [a-z])/gmu, (match): string => match.toUpperCase()); } /** diff --git a/src/authorization/AcpReader.ts b/src/authorization/AcpReader.ts index a3cead920..e33ab493b 100644 --- a/src/authorization/AcpReader.ts +++ b/src/authorization/AcpReader.ts @@ -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]) { diff --git a/src/http/auxiliary/MetadataGenerator.ts b/src/http/auxiliary/MetadataGenerator.ts index 6ef8463d4..52f63604b 100644 --- a/src/http/auxiliary/MetadataGenerator.ts +++ b/src/http/auxiliary/MetadataGenerator.ts @@ -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 { } +export abstract class MetadataGenerator extends AsyncHandler {} diff --git a/src/http/auxiliary/Validator.ts b/src/http/auxiliary/Validator.ts index 974cb4555..0c61f0fcf 100644 --- a/src/http/auxiliary/Validator.ts +++ b/src/http/auxiliary/Validator.ts @@ -10,4 +10,4 @@ export type ValidatorInput = { /** * Generic interface for classes that validate Representations in some way. */ -export abstract class Validator extends AsyncHandler { } +export abstract class Validator extends AsyncHandler {} diff --git a/src/http/output/error/ConvertingErrorHandler.ts b/src/http/output/error/ConvertingErrorHandler.ts index 561fa70d1..1a0687529 100644 --- a/src/http/output/error/ConvertingErrorHandler.ts +++ b/src/http/output/error/ConvertingErrorHandler.ts @@ -62,6 +62,7 @@ export class ConvertingErrorHandler extends ErrorHandler { private async extractErrorDetails({ error, request }: ErrorHandlerArgs): Promise { 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); diff --git a/src/http/output/metadata/LinkRelMetadataWriter.ts b/src/http/output/metadata/LinkRelMetadataWriter.ts index bb498d523..18853dbf3 100644 --- a/src/http/output/metadata/LinkRelMetadataWriter.ts +++ b/src/http/output/metadata/LinkRelMetadataWriter.ts @@ -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); } } diff --git a/src/http/output/metadata/WacAllowMetadataWriter.ts b/src/http/output/metadata/WacAllowMetadataWriter.ts index a02a89ca1..494d3220d 100644 --- a/src/http/output/metadata/WacAllowMetadataWriter.ts +++ b/src/http/output/metadata/WacAllowMetadataWriter.ts @@ -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(); } diff --git a/src/identity/interaction/HtmlViewHandler.ts b/src/identity/interaction/HtmlViewHandler.ts index ea567ca77..9f40f7b59 100644 --- a/src/identity/interaction/HtmlViewHandler.ts +++ b/src/identity/interaction/HtmlViewHandler.ts @@ -20,7 +20,7 @@ export class HtmlViewEntry { public constructor( public readonly route: InteractionRoute, public readonly filePath: string, - ) { } + ) {} } /** diff --git a/src/identity/interaction/InteractionHandler.ts b/src/identity/interaction/InteractionHandler.ts index 7964a6a18..d1423165d 100644 --- a/src/identity/interaction/InteractionHandler.ts +++ b/src/identity/interaction/InteractionHandler.ts @@ -25,4 +25,4 @@ export interface InteractionHandlerInput { /** * Handler used for IDP interactions. */ -export abstract class InteractionHandler extends AsyncHandler { } +export abstract class InteractionHandler extends AsyncHandler {} diff --git a/src/identity/interaction/JsonInteractionHandler.ts b/src/identity/interaction/JsonInteractionHandler.ts index e2e1e65eb..9846c95eb 100644 --- a/src/identity/interaction/JsonInteractionHandler.ts +++ b/src/identity/interaction/JsonInteractionHandler.ts @@ -38,4 +38,4 @@ export interface JsonInteractionHandlerInput { * designed to be used for IDP/OIDC interactions. */ export abstract class JsonInteractionHandler = Dict> - extends AsyncHandler> { } + extends AsyncHandler> {} diff --git a/src/pods/generate/BaseResourcesGenerator.ts b/src/pods/generate/BaseResourcesGenerator.ts index 7213d5df0..e4d50e049 100644 --- a/src/pods/generate/BaseResourcesGenerator.ts +++ b/src/pods/generate/BaseResourcesGenerator.ts @@ -160,7 +160,7 @@ export class BaseResourcesGenerator implements TemplatedResourcesGenerator { private async groupLinks(folderPath: string, mapper: FileIdentifierMapper): Promise> { const files = await fsPromises.readdir(folderPath); - const links: Record = { }; + const links: Record = {}; for (const name of files) { const link = await this.toTemplateLink(joinFilePath(folderPath, name), mapper); const { path } = link.identifier; diff --git a/src/server/middleware/StaticAssetHandler.ts b/src/server/middleware/StaticAssetHandler.ts index a34ad71dc..4f1df2e17 100644 --- a/src/server/middleware/StaticAssetHandler.ts +++ b/src/server/middleware/StaticAssetHandler.ts @@ -21,7 +21,7 @@ export class StaticAssetEntry { public constructor( public readonly relativeUrl: string, public readonly filePath: string, - ) { } + ) {} } /** diff --git a/src/server/notifications/generate/NotificationGenerator.ts b/src/server/notifications/generate/NotificationGenerator.ts index 800b85c01..19341a9b1 100644 --- a/src/server/notifications/generate/NotificationGenerator.ts +++ b/src/server/notifications/generate/NotificationGenerator.ts @@ -5,4 +5,4 @@ import type { NotificationHandlerInput } from '../NotificationHandler'; /** * Creates a {@link Notification} based on the provided input. */ -export abstract class NotificationGenerator extends AsyncHandler { } +export abstract class NotificationGenerator extends AsyncHandler {} diff --git a/src/server/notifications/serialize/NotificationSerializer.ts b/src/server/notifications/serialize/NotificationSerializer.ts index bdec92bff..b637cb7e1 100644 --- a/src/server/notifications/serialize/NotificationSerializer.ts +++ b/src/server/notifications/serialize/NotificationSerializer.ts @@ -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 { } +export abstract class NotificationSerializer extends AsyncHandler {} diff --git a/src/storage/accessors/InMemoryDataAccessor.ts b/src/storage/accessors/InMemoryDataAccessor.ts index 2da29c7a2..7c4551bda 100644 --- a/src/storage/accessors/InMemoryDataAccessor.ts +++ b/src/storage/accessors/InMemoryDataAccessor.ts @@ -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 { diff --git a/src/storage/keyvalue/MaxKeyLengthStorage.ts b/src/storage/keyvalue/MaxKeyLengthStorage.ts index 28d28520e..ff8314958 100644 --- a/src/storage/keyvalue/MaxKeyLengthStorage.ts +++ b/src/storage/keyvalue/MaxKeyLengthStorage.ts @@ -65,7 +65,7 @@ export class MaxKeyLengthStorage implements KeyValueStorage { 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}`); } diff --git a/src/util/GuardedStream.ts b/src/util/GuardedStream.ts index 9d5fcd5c3..d6b160984 100644 --- a/src/util/GuardedStream.ts +++ b/src/util/GuardedStream.ts @@ -38,7 +38,7 @@ export function isGuarded(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 => { diff --git a/src/util/HeaderUtil.ts b/src/util/HeaderUtil.ts index 84a108655..3d34ecc3c 100644 --- a/src/util/HeaderUtil.ts +++ b/src/util/HeaderUtil.ts @@ -38,7 +38,7 @@ const logger = getLoggerFor('HeaderUtil'); export function transformQuotedStrings(input: string): { result: string; replacements: Record } { let idx = 0; const replacements: Record = {}; - 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}`); diff --git a/src/util/IterableUtil.ts b/src/util/IterableUtil.ts index 2eb816672..665f51fd6 100644 --- a/src/util/IterableUtil.ts +++ b/src/util/IterableUtil.ts @@ -173,7 +173,6 @@ async function findNextSorted(iterators: AsyncIterator[], results: (T | un export async function* sortedAsyncMerge(iterators: AsyncIterator[], comparator?: (left: T, right: T) => number): AsyncIterable { if (!comparator) { - // eslint-disable-next-line style/no-extra-parens comparator = (left, right): number => left < right ? -1 : (left > right ? 1 : 0); } diff --git a/src/util/PathUtil.ts b/src/util/PathUtil.ts index af789b884..ca03e7162 100644 --- a/src/util/PathUtil.ts +++ b/src/util/PathUtil.ts @@ -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, '/'); } /** diff --git a/src/util/StringUtil.ts b/src/util/StringUtil.ts index b8bedd3e9..484ee7cd1 100644 --- a/src/util/StringUtil.ts +++ b/src/util/StringUtil.ts @@ -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, '-'); } /** diff --git a/src/util/Vocabularies.ts b/src/util/Vocabularies.ts index e69104572..978502114 100644 --- a/src/util/Vocabularies.ts +++ b/src/util/Vocabularies.ts @@ -51,7 +51,7 @@ export type VocabularyTerm = T extends Vocabulary ? T['terms */ function createValueVocabulary(baseUri: TBase, localNames: TLocal[]): ValueVocabulary { - const expanded: Partial> = { }; + const expanded: Partial> = {}; // Expose the listed local names as properties for (const localName of localNames) { expanded[localName] = `${baseUri}${localName}`; diff --git a/templates/scripts/util.js b/templates/scripts/util.js index 756c15461..4ba3a013b 100644 --- a/templates/scripts/util.js +++ b/templates/scripts/util.js @@ -4,7 +4,7 @@ * @param ids - IDs of the element (empty to retrieve all elements) */ export function getElements(...ids) { - ids = ids.length ? ids : [ ...document.querySelectorAll('[id]') ].map(e => e.id); + ids = ids.length > 0 ? ids : [ ...document.querySelectorAll('[id]') ].map(e => e.id); return Object.fromEntries(ids.map(id => [ id, document.getElementById(id) ])); } diff --git a/test/integration/config/server-file.json b/test/integration/config/server-file.json index 92ffcd788..5b0248885 100644 --- a/test/integration/config/server-file.json +++ b/test/integration/config/server-file.json @@ -1,64 +1,64 @@ -{ - "@context": "https://linkedsoftwaredependencies.org/bundles/npm/@solid/community-server/^7.0.0/components/context.jsonld", - "import": [ - "css:config/app/init/initialize-root.json", - "css:config/app/main/default.json", - "css:config/http/handler/default.json", - "css:config/http/middleware/default.json", - "css:config/http/notifications/disabled.json", - "css:config/http/server-factory/http.json", - "css:config/http/static/default.json", - "css:config/identity/access/public.json", - - "css:config/identity/handler/default.json", - "css:config/identity/oidc/default.json", - "css:config/identity/ownership/token.json", - "css:config/identity/pod/static.json", - "css:config/ldp/authentication/dpop-bearer.json", - "css:config/ldp/authorization/webacl.json", - "css:config/ldp/handler/default.json", - "css:config/ldp/metadata-parser/default.json", - "css:config/ldp/metadata-writer/default.json", - "css:config/ldp/modes/default.json", - "css:config/storage/backend/file.json", - "css:config/storage/key-value/resource-store.json", - "css:config/storage/location/root.json", - "css:config/storage/middleware/default.json", - "css:config/util/auxiliary/acl.json", - "css:config/util/identifiers/suffix.json", - "css:config/util/index/default.json", - "css:config/util/logging/winston.json", - "css:config/util/representation-conversion/default.json", - "css:config/util/resource-locker/file.json", - "css:config/util/variables/default.json" - ], - "@graph": [ - { - "@id": "urn:solid-server:test:Instances", - "@type": "RecordObject", - "record": [ - { - "RecordObject:_record_key": "app", - "RecordObject:_record_value": { "@id": "urn:solid-server:default:App" } - }, - { - "RecordObject:_record_key": "store", - "RecordObject:_record_value": { "@id": "urn:solid-server:default:ResourceStore_Backend" } - }, - { - "RecordObject:_record_key": "locker", - "RecordObject:_record_value": { "@id": "urn:solid-server:default:FileSystemResourceLocker" } - } - ] - }, - { - "@id": "urn:solid-server:default:EmailSender", - "@type": "BaseEmailSender", - "args_senderName": "Solid Server", - "args_emailConfig_host": "smtp.example.email", - "args_emailConfig_port": 587, - "args_emailConfig_auth_user": "alice@example.email", - "args_emailConfig_auth_pass": "NYEaCsqV7aVStRCbmC" - } - ] -} +{ + "@context": "https://linkedsoftwaredependencies.org/bundles/npm/@solid/community-server/^7.0.0/components/context.jsonld", + "import": [ + "css:config/app/init/initialize-root.json", + "css:config/app/main/default.json", + "css:config/http/handler/default.json", + "css:config/http/middleware/default.json", + "css:config/http/notifications/disabled.json", + "css:config/http/server-factory/http.json", + "css:config/http/static/default.json", + "css:config/identity/access/public.json", + + "css:config/identity/handler/default.json", + "css:config/identity/oidc/default.json", + "css:config/identity/ownership/token.json", + "css:config/identity/pod/static.json", + "css:config/ldp/authentication/dpop-bearer.json", + "css:config/ldp/authorization/webacl.json", + "css:config/ldp/handler/default.json", + "css:config/ldp/metadata-parser/default.json", + "css:config/ldp/metadata-writer/default.json", + "css:config/ldp/modes/default.json", + "css:config/storage/backend/file.json", + "css:config/storage/key-value/resource-store.json", + "css:config/storage/location/root.json", + "css:config/storage/middleware/default.json", + "css:config/util/auxiliary/acl.json", + "css:config/util/identifiers/suffix.json", + "css:config/util/index/default.json", + "css:config/util/logging/winston.json", + "css:config/util/representation-conversion/default.json", + "css:config/util/resource-locker/file.json", + "css:config/util/variables/default.json" + ], + "@graph": [ + { + "@id": "urn:solid-server:test:Instances", + "@type": "RecordObject", + "record": [ + { + "RecordObject:_record_key": "app", + "RecordObject:_record_value": { "@id": "urn:solid-server:default:App" } + }, + { + "RecordObject:_record_key": "store", + "RecordObject:_record_value": { "@id": "urn:solid-server:default:ResourceStore_Backend" } + }, + { + "RecordObject:_record_key": "locker", + "RecordObject:_record_value": { "@id": "urn:solid-server:default:FileSystemResourceLocker" } + } + ] + }, + { + "@id": "urn:solid-server:default:EmailSender", + "@type": "BaseEmailSender", + "args_senderName": "Solid Server", + "args_emailConfig_host": "smtp.example.email", + "args_emailConfig_port": 587, + "args_emailConfig_auth_user": "alice@example.email", + "args_emailConfig_auth_pass": "NYEaCsqV7aVStRCbmC" + } + ] +} diff --git a/test/unit/authentication/BearerWebIdExtractor.test.ts b/test/unit/authentication/BearerWebIdExtractor.test.ts index 6c8f5bc3b..67c005211 100644 --- a/test/unit/authentication/BearerWebIdExtractor.test.ts +++ b/test/unit/authentication/BearerWebIdExtractor.test.ts @@ -25,7 +25,7 @@ describe('A BearerWebIdExtractor', (): void => { describe('on a request without Authorization header', (): void => { const request = { method: 'GET', - headers: { }, + headers: {}, } as any as HttpRequest; it('throws an error.', async(): Promise => { diff --git a/test/unit/authorization/AuthAuxiliaryReader.test.ts b/test/unit/authorization/AuthAuxiliaryReader.test.ts index 8ed9f8f3d..7bdee3d81 100644 --- a/test/unit/authorization/AuthAuxiliaryReader.test.ts +++ b/test/unit/authorization/AuthAuxiliaryReader.test.ts @@ -44,7 +44,7 @@ describe('An AuthAuxiliaryReader', (): void => { const result = await reader.handle({ requestedModes, credentials }); expect(result.get(acl1)).toEqual({ read: true, append: true, write: true, control: true }); - expect(result.get(acl2)).toEqual({ }); + expect(result.get(acl2)).toEqual({}); const updatedMap = new IdentifierMap(); updatedMap.set(subject1, new Set([ AclMode.control ])); diff --git a/test/unit/authorization/ParentContainerReader.test.ts b/test/unit/authorization/ParentContainerReader.test.ts index 9040e5b8e..1067f5b1e 100644 --- a/test/unit/authorization/ParentContainerReader.test.ts +++ b/test/unit/authorization/ParentContainerReader.test.ts @@ -39,7 +39,7 @@ describe('A ParentContainerReader', (): void => { const result = await reader.handle({ requestedModes, credentials }); expect(result.get(target1)).toEqual({ create: true }); - expect(result.get(target2)).toEqual({ }); + expect(result.get(target2)).toEqual({}); const updatedMap = new IdentifierSetMultiMap(requestedModes); updatedMap.set(parent1, AccessMode.append); @@ -61,7 +61,7 @@ describe('A ParentContainerReader', (): void => { const result = await reader.handle({ requestedModes, credentials }); expect(result.get(target1)).toEqual({ delete: true, write: true }); - expect(result.get(target2)).toEqual({ }); + expect(result.get(target2)).toEqual({}); expect(result.get(target3)).toEqual({ write: true }); const updatedMap = new IdentifierSetMultiMap(requestedModes); diff --git a/test/unit/authorization/WebAclReader.test.ts b/test/unit/authorization/WebAclReader.test.ts index 28c088c8f..1975bf6b7 100644 --- a/test/unit/authorization/WebAclReader.test.ts +++ b/test/unit/authorization/WebAclReader.test.ts @@ -72,7 +72,7 @@ describe('A WebAclReader', (): void => { }); it('handles all input.', async(): Promise => { - await expect(reader.canHandle({ } as any)).resolves.toBeUndefined(); + await expect(reader.canHandle({} as any)).resolves.toBeUndefined(); }); it('returns undefined permissions for undefined credentials.', async(): Promise => { diff --git a/test/unit/http/input/identifier/OriginalUrlExtractor.test.ts b/test/unit/http/input/identifier/OriginalUrlExtractor.test.ts index e07c1b3fa..05763435c 100644 --- a/test/unit/http/input/identifier/OriginalUrlExtractor.test.ts +++ b/test/unit/http/input/identifier/OriginalUrlExtractor.test.ts @@ -8,7 +8,7 @@ interface CreateExtractorArgs { } // Helper function for instantiating an OriginalUrlExtractor -function createExtractor(args: CreateExtractorArgs = { }): OriginalUrlExtractor { +function createExtractor(args: CreateExtractorArgs = {}): OriginalUrlExtractor { const identifierStrategy = new SingleRootIdentifierStrategy(args.baseUrl ?? 'http://test.com'); const extractor = new OriginalUrlExtractor({ identifierStrategy, includeQueryString: args.includeQueryString }); return extractor; diff --git a/test/unit/http/output/BasicResponseWriter.test.ts b/test/unit/http/output/BasicResponseWriter.test.ts index 15629e2de..ed2acb579 100644 --- a/test/unit/http/output/BasicResponseWriter.test.ts +++ b/test/unit/http/output/BasicResponseWriter.test.ts @@ -60,7 +60,7 @@ describe('A BasicResponseWriter', (): void => { it('serializes metadata if there is metadata.', async(): Promise => { result = { statusCode: 201, metadata: new RepresentationMetadata() }; - metadataWriter.handle = jest.fn(); + jest.spyOn(metadataWriter, 'handle').mockImplementation(); await writer.handle({ response, result }); expect(metadataWriter.handle).toHaveBeenCalledTimes(1); expect(metadataWriter.handle).toHaveBeenLastCalledWith({ response, metadata: result.metadata }); @@ -77,6 +77,7 @@ describe('A BasicResponseWriter', (): void => { result = { statusCode: 201, data }; response = new PassThrough(); + // eslint-disable-next-line jest/prefer-spy-on response.writeHead = jest.fn(); const end = new Promise((resolve): void => { diff --git a/test/unit/http/output/metadata/AuxiliaryLinkMetadataWriter.test.ts b/test/unit/http/output/metadata/AuxiliaryLinkMetadataWriter.test.ts index dc41060b6..d93d16e0d 100644 --- a/test/unit/http/output/metadata/AuxiliaryLinkMetadataWriter.test.ts +++ b/test/unit/http/output/metadata/AuxiliaryLinkMetadataWriter.test.ts @@ -30,13 +30,13 @@ describe('A LinkRelMetadataWriter', (): void => { const metadata = new RepresentationMetadata(identifier); await expect(writer.handle({ response, metadata })).resolves.toBeUndefined(); - expect(response.getHeaders()).toEqual({ }); + expect(response.getHeaders()).toEqual({}); }); it('does not add link headers for blank node identifiers.', async(): Promise => { const response = createResponse() as HttpResponse; const metadata = new RepresentationMetadata(); await expect(writer.handle({ response, metadata })).resolves.toBeUndefined(); - expect(response.getHeaders()).toEqual({ }); + expect(response.getHeaders()).toEqual({}); }); }); diff --git a/test/unit/http/output/metadata/ContentTypeMetadataWriter.test.ts b/test/unit/http/output/metadata/ContentTypeMetadataWriter.test.ts index 5631498c2..5b9d00664 100644 --- a/test/unit/http/output/metadata/ContentTypeMetadataWriter.test.ts +++ b/test/unit/http/output/metadata/ContentTypeMetadataWriter.test.ts @@ -15,7 +15,7 @@ describe('A ContentTypeMetadataWriter', (): void => { it('adds no header if there is no relevant metadata.', async(): Promise => { const metadata = new RepresentationMetadata(); await expect(writer.handle({ response, metadata })).resolves.toBeUndefined(); - expect(response.getHeaders()).toEqual({ }); + expect(response.getHeaders()).toEqual({}); }); it('adds a Content-Type header with parameters if present.', async(): Promise => { diff --git a/test/unit/http/output/metadata/RangeMetadataWriter.test.ts b/test/unit/http/output/metadata/RangeMetadataWriter.test.ts index fbc1d441e..b69ad3778 100644 --- a/test/unit/http/output/metadata/RangeMetadataWriter.test.ts +++ b/test/unit/http/output/metadata/RangeMetadataWriter.test.ts @@ -37,7 +37,7 @@ describe('RangeMetadataWriter', (): void => { it('does nothing if there is no range metadata.', async(): Promise => { await expect(writer.handle({ response, metadata })).resolves.toBeUndefined(); - expect(response.getHeaders()).toEqual({ }); + expect(response.getHeaders()).toEqual({}); }); it('adds a content-length header if the size is known.', async(): Promise => { diff --git a/test/unit/http/output/metadata/WacAllowMetadataWriter.test.ts b/test/unit/http/output/metadata/WacAllowMetadataWriter.test.ts index 243868899..b2bb6cd5e 100644 --- a/test/unit/http/output/metadata/WacAllowMetadataWriter.test.ts +++ b/test/unit/http/output/metadata/WacAllowMetadataWriter.test.ts @@ -15,7 +15,7 @@ describe('A WacAllowMetadataWriter', (): void => { it('adds no header if there is no relevant metadata.', async(): Promise => { const metadata = new RepresentationMetadata(); await expect(writer.handle({ response, metadata })).resolves.toBeUndefined(); - expect(response.getHeaders()).toEqual({ }); + expect(response.getHeaders()).toEqual({}); }); it('adds a WAC-Allow header if there is relevant metadata.', async(): Promise => { diff --git a/test/unit/http/output/metadata/WwwAuthMetadataWriter.test.ts b/test/unit/http/output/metadata/WwwAuthMetadataWriter.test.ts index 6d6542487..3ec4e954b 100644 --- a/test/unit/http/output/metadata/WwwAuthMetadataWriter.test.ts +++ b/test/unit/http/output/metadata/WwwAuthMetadataWriter.test.ts @@ -16,13 +16,13 @@ describe('A WwwAuthMetadataWriter', (): void => { it('adds no header if there is no relevant metadata.', async(): Promise => { const metadata = new RepresentationMetadata(); await expect(writer.handle({ response, metadata })).resolves.toBeUndefined(); - expect(response.getHeaders()).toEqual({ }); + expect(response.getHeaders()).toEqual({}); }); it('adds no header if the status code is not 401.', async(): Promise => { const metadata = new RepresentationMetadata({ [HTTP.statusCodeNumber]: '403' }); await expect(writer.handle({ response, metadata })).resolves.toBeUndefined(); - expect(response.getHeaders()).toEqual({ }); + expect(response.getHeaders()).toEqual({}); }); it('adds a WWW-Authenticate header if the status code is 401.', async(): Promise => { diff --git a/test/unit/identity/interaction/OidcControlHandler.test.ts b/test/unit/identity/interaction/OidcControlHandler.test.ts index cd1f7bd03..1c4f18824 100644 --- a/test/unit/identity/interaction/OidcControlHandler.test.ts +++ b/test/unit/identity/interaction/OidcControlHandler.test.ts @@ -12,6 +12,6 @@ describe('An OidcControlHandler', (): void => { }); it('returns an empty object if there is no OIDC interaction.', async(): Promise => { - await expect(handler.handle({ } as any)).resolves.toEqual({ json: { }}); + await expect(handler.handle({} as any)).resolves.toEqual({ json: {}}); }); }); diff --git a/test/unit/identity/interaction/login/LogoutHandler.test.ts b/test/unit/identity/interaction/login/LogoutHandler.test.ts index a0c5027a4..d665479db 100644 --- a/test/unit/identity/interaction/login/LogoutHandler.test.ts +++ b/test/unit/identity/interaction/login/LogoutHandler.test.ts @@ -27,7 +27,7 @@ describe('A LogoutHandler', (): void => { expect(outputMetadata?.get(SOLID_HTTP.terms.accountCookie)?.value).toBe(cookie); const date = outputMetadata?.get(SOLID_HTTP.terms.accountCookieExpiration); expect(date).toBeDefined(); - expect(new Date(date!.value).getTime()).toBeLessThan(new Date().getTime()); + expect(new Date(date!.value).getTime()).toBeLessThan(Date.now()); expect(cookieStore.delete).toHaveBeenCalledTimes(1); expect(cookieStore.delete).toHaveBeenLastCalledWith(cookie); }); diff --git a/test/unit/identity/interaction/oidc/PromptHandler.test.ts b/test/unit/identity/interaction/oidc/PromptHandler.test.ts index b94484e2b..4f933b855 100644 --- a/test/unit/identity/interaction/oidc/PromptHandler.test.ts +++ b/test/unit/identity/interaction/oidc/PromptHandler.test.ts @@ -17,7 +17,7 @@ describe('A PromptHandler', (): void => { }); it('errors if there is no interaction.', async(): Promise => { - await expect(handler.handle({ } as any)).rejects.toThrow(BadRequestHttpError); + await expect(handler.handle({} as any)).rejects.toThrow(BadRequestHttpError); }); it('errors if the prompt is unsupported.', async(): Promise => { diff --git a/test/unit/logging/Logger.test.ts b/test/unit/logging/Logger.test.ts index 167ddd91e..e81073e33 100644 --- a/test/unit/logging/Logger.test.ts +++ b/test/unit/logging/Logger.test.ts @@ -3,7 +3,7 @@ import { BaseLogger, WrappingLogger } from '../../../src/logging/Logger'; import type { LogMetadata, SimpleLogger } from '../../../src/logging/Logger'; class DummyLogger extends BaseLogger { - log(): this { + public log(): this { return this; } } diff --git a/test/unit/server/AuthorizingHttpHandler.test.ts b/test/unit/server/AuthorizingHttpHandler.test.ts index 724b74792..df84ad037 100644 --- a/test/unit/server/AuthorizingHttpHandler.test.ts +++ b/test/unit/server/AuthorizingHttpHandler.test.ts @@ -17,7 +17,7 @@ import { IdentifierMap, IdentifierSetMultiMap } from '../../../src/util/map/Iden import { SOLID_META } from '../../../src/util/Vocabularies'; describe('An AuthorizingHttpHandler', (): void => { - const credentials = { }; + const credentials = {}; const target = { path: 'http://example.com/foo' }; const requestedModes: AccessMap = new IdentifierSetMultiMap( [[ target, new Set([ AccessMode.read, AccessMode.write ]) ]], diff --git a/test/unit/storage/accessors/FileDataAccessor.test.ts b/test/unit/storage/accessors/FileDataAccessor.test.ts index db16eff54..4982e5145 100644 --- a/test/unit/storage/accessors/FileDataAccessor.test.ts +++ b/test/unit/storage/accessors/FileDataAccessor.test.ts @@ -485,7 +485,7 @@ describe('A FileDataAccessor', (): void => { }); it('can delete the root container.', async(): Promise => { - cache.data = { }; + cache.data = {}; await expect(accessor.deleteResource({ path: `${base}` })).resolves.toBeUndefined(); expect(cache.data).toBeUndefined(); }); diff --git a/test/unit/storage/accessors/SparqlDataAccessor.test.ts b/test/unit/storage/accessors/SparqlDataAccessor.test.ts index 3ee8a3d1b..f2580d6ca 100644 --- a/test/unit/storage/accessors/SparqlDataAccessor.test.ts +++ b/test/unit/storage/accessors/SparqlDataAccessor.test.ts @@ -25,7 +25,7 @@ function simplifyQuery(query: string | string[]): string { if (Array.isArray(query)) { query = query.join(' '); } - return query.replace(/\n/gu, ' ').trim(); + return query.replaceAll('\n', ' ').trim(); } describe('A SparqlDataAccessor', (): void => { diff --git a/test/unit/storage/conversion/BaseTypedRepresentationConverter.test.ts b/test/unit/storage/conversion/BaseTypedRepresentationConverter.test.ts index 3f25a68de..863d7f919 100644 --- a/test/unit/storage/conversion/BaseTypedRepresentationConverter.test.ts +++ b/test/unit/storage/conversion/BaseTypedRepresentationConverter.test.ts @@ -29,7 +29,7 @@ describe('A BaseTypedRepresentationConverter', (): void => { }); it('can not handle input without a Content-Type.', async(): Promise => { - const args: RepresentationConverterArgs = { representation: { metadata: { }}, preferences: {}} as any; + const args: RepresentationConverterArgs = { representation: { metadata: {}}, preferences: {}} as any; const converter = new CustomTypedRepresentationConverter('*/*', 'b/b'); await expect(converter.canHandle(args)).rejects.toThrow(NotImplementedHttpError); }); diff --git a/test/unit/storage/conversion/ChainedConverter.test.ts b/test/unit/storage/conversion/ChainedConverter.test.ts index df0b7bc6f..e2a6463c7 100644 --- a/test/unit/storage/conversion/ChainedConverter.test.ts +++ b/test/unit/storage/conversion/ChainedConverter.test.ts @@ -55,7 +55,7 @@ describe('A ChainedConverter', (): void => { it('needs at least 1 converter.', async(): Promise => { expect((): any => new ChainedConverter([])).toThrow('At least 1 converter is required.'); - expect(new ChainedConverter([ new DummyConverter({ }, { }) ])).toBeInstanceOf(ChainedConverter); + expect(new ChainedConverter([ new DummyConverter({}, {}) ])).toBeInstanceOf(ChainedConverter); }); it('errors if there are no content-type or preferences.', async(): Promise => { @@ -106,7 +106,7 @@ describe('A ChainedConverter', (): void => { expect(result.metadata.contentType).toBe('b/b'); expect(result.metadata.get(POSIX.terms.size)?.value).toBe('500'); - args.preferences.type = { }; + args.preferences.type = {}; result = await converter.handle(args); expect(result.metadata.contentType).toBe('b/b'); expect(result.metadata.get(POSIX.terms.size)?.value).toBe('500'); diff --git a/test/unit/storage/conversion/RdfToQuadConverter.test.ts b/test/unit/storage/conversion/RdfToQuadConverter.test.ts index 7d4561a88..f965144fd 100644 --- a/test/unit/storage/conversion/RdfToQuadConverter.test.ts +++ b/test/unit/storage/conversion/RdfToQuadConverter.test.ts @@ -43,7 +43,7 @@ describe('A RdfToQuadConverter', (): void => { }); it('may not handle application/json to quad conversion.', async(): Promise => { - await expect(converter.getOutputTypes('application/json')).resolves.toEqual({ }); + await expect(converter.getOutputTypes('application/json')).resolves.toEqual({}); }); it('can handle turtle to quad conversions.', async(): Promise => { diff --git a/test/unit/storage/patch/RdfPatcher.test.ts b/test/unit/storage/patch/RdfPatcher.test.ts index 4e601d3b3..0a13b58f6 100644 --- a/test/unit/storage/patch/RdfPatcher.test.ts +++ b/test/unit/storage/patch/RdfPatcher.test.ts @@ -39,7 +39,7 @@ describe('An RdfPatcher,', (): void => { }; patcher.handle.mockImplementation( async(input: RepresentationPatcherInput): - Promise => Promise.resolve(input.representation!), + Promise => input.representation!, ); rdfPatcher = new RdfPatcher(patcher); diff --git a/test/util/Util.ts b/test/util/Util.ts index c1bfafe0a..f551fd8bf 100644 --- a/test/util/Util.ts +++ b/test/util/Util.ts @@ -143,7 +143,7 @@ export function mockFileSystem(rootFilepath?: string, time?: Date): { data: any return { folder: cache, name: 'data' }; } - const name = parts.slice(-1)[0]; + const name = parts.at(-1) as string; parts = parts.slice(0, -1); let folder = cache.data; parts.forEach((part): any => {