refactor: Bring lint config back to original strictness

This commit is contained in:
Joachim Van Herwegen 2023-10-30 14:32:21 +01:00
parent 7a007dc466
commit 3bb3004abb
52 changed files with 239 additions and 132 deletions

View File

@ -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}}

View File

@ -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

View File

@ -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;

View File

@ -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();

View File

@ -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';

View File

@ -18,7 +18,7 @@ import { readFile, writeFile } from 'fs-extra';
* @returns Promise with output string
*/
async function capitalizeListEntries(input: string): Promise<string> {
return input.replace(/^(\W*\* [a-z])/gmu, (match): string => match.toUpperCase());
return input.replaceAll(/^(\W*\* [a-z])/gmu, (match): string => match.toUpperCase());
}
/**

View File

@ -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]) {

View File

@ -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<RepresentationMetadata> { }
export abstract class MetadataGenerator extends AsyncHandler<RepresentationMetadata> {}

View File

@ -10,4 +10,4 @@ export type ValidatorInput = {
/**
* Generic interface for classes that validate Representations in some way.
*/
export abstract class Validator extends AsyncHandler<ValidatorInput, Representation> { }
export abstract class Validator extends AsyncHandler<ValidatorInput, Representation> {}

View File

@ -62,6 +62,7 @@ export class ConvertingErrorHandler extends ErrorHandler {
private async extractErrorDetails({ error, request }: ErrorHandlerArgs): Promise<PreparedArguments> {
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);

View File

@ -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);
}
}

View File

@ -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();
}

View File

@ -20,7 +20,7 @@ export class HtmlViewEntry {
public constructor(
public readonly route: InteractionRoute,
public readonly filePath: string,
) { }
) {}
}
/**

View File

@ -25,4 +25,4 @@ export interface InteractionHandlerInput {
/**
* Handler used for IDP interactions.
*/
export abstract class InteractionHandler extends AsyncHandler<InteractionHandlerInput, Representation> { }
export abstract class InteractionHandler extends AsyncHandler<InteractionHandlerInput, Representation> {}

View File

@ -38,4 +38,4 @@ export interface JsonInteractionHandlerInput {
* designed to be used for IDP/OIDC interactions.
*/
export abstract class JsonInteractionHandler<TOut extends Dict<Json> = Dict<Json>>
extends AsyncHandler<JsonInteractionHandlerInput, JsonRepresentation<TOut>> { }
extends AsyncHandler<JsonInteractionHandlerInput, JsonRepresentation<TOut>> {}

View File

@ -160,7 +160,7 @@ export class BaseResourcesGenerator implements TemplatedResourcesGenerator {
private async groupLinks(folderPath: string, mapper: FileIdentifierMapper):
Promise<Record<string, { link: TemplateResourceLink; meta?: TemplateResourceLink }>> {
const files = await fsPromises.readdir(folderPath);
const links: Record<string, { link: TemplateResourceLink; meta?: TemplateResourceLink }> = { };
const links: Record<string, { link: TemplateResourceLink; meta?: TemplateResourceLink }> = {};
for (const name of files) {
const link = await this.toTemplateLink(joinFilePath(folderPath, name), mapper);
const { path } = link.identifier;

View File

@ -21,7 +21,7 @@ export class StaticAssetEntry {
public constructor(
public readonly relativeUrl: string,
public readonly filePath: string,
) { }
) {}
}
/**

View File

@ -5,4 +5,4 @@ import type { NotificationHandlerInput } from '../NotificationHandler';
/**
* Creates a {@link Notification} based on the provided input.
*/
export abstract class NotificationGenerator extends AsyncHandler<NotificationHandlerInput, Notification> { }
export abstract class NotificationGenerator extends AsyncHandler<NotificationHandlerInput, Notification> {}

View File

@ -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<NotificationSerializerInput, Representation> { }
export abstract class NotificationSerializer extends AsyncHandler<NotificationSerializerInput, Representation> {}

View File

@ -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<void> {

View File

@ -65,7 +65,7 @@ export class MaxKeyLengthStorage<T> implements KeyValueStorage<string, T> {
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}`);
}

View File

@ -38,7 +38,7 @@ export function isGuarded<T extends NodeJS.EventEmitter>(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 => {

View File

@ -38,7 +38,7 @@ const logger = getLoggerFor('HeaderUtil');
export function transformQuotedStrings(input: string): { result: string; replacements: Record<string, string> } {
let idx = 0;
const replacements: Record<string, string> = {};
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}`);

View File

@ -173,7 +173,6 @@ async function findNextSorted<T>(iterators: AsyncIterator<T>[], results: (T | un
export async function* sortedAsyncMerge<T>(iterators: AsyncIterator<T>[], comparator?: (left: T, right: T) => number):
AsyncIterable<T> {
if (!comparator) {
// eslint-disable-next-line style/no-extra-parens
comparator = (left, right): number => left < right ? -1 : (left > right ? 1 : 0);
}

View File

@ -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, '/');
}
/**

View File

@ -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, '-');
}
/**

View File

@ -51,7 +51,7 @@ export type VocabularyTerm<T> = T extends Vocabulary<any, infer TKey> ? T['terms
*/
function createValueVocabulary<TBase extends string, TLocal extends string>(baseUri: TBase, localNames: TLocal[]):
ValueVocabulary<TBase, TLocal> {
const expanded: Partial<ExpandedRecord<TBase, TLocal>> = { };
const expanded: Partial<ExpandedRecord<TBase, TLocal>> = {};
// Expose the listed local names as properties
for (const localName of localNames) {
expanded[localName] = `${baseUri}${localName}`;

View File

@ -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) ]));
}

View File

@ -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"
}
]
}

View File

@ -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<void> => {

View File

@ -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 ]));

View File

@ -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);

View File

@ -72,7 +72,7 @@ describe('A WebAclReader', (): void => {
});
it('handles all input.', async(): Promise<void> => {
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<void> => {

View File

@ -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;

View File

@ -60,7 +60,7 @@ describe('A BasicResponseWriter', (): void => {
it('serializes metadata if there is metadata.', async(): Promise<void> => {
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<void>((resolve): void => {

View File

@ -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<void> => {
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({});
});
});

View File

@ -15,7 +15,7 @@ describe('A ContentTypeMetadataWriter', (): void => {
it('adds no header if there is no relevant metadata.', async(): Promise<void> => {
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<void> => {

View File

@ -37,7 +37,7 @@ describe('RangeMetadataWriter', (): void => {
it('does nothing if there is no range metadata.', async(): Promise<void> => {
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<void> => {

View File

@ -15,7 +15,7 @@ describe('A WacAllowMetadataWriter', (): void => {
it('adds no header if there is no relevant metadata.', async(): Promise<void> => {
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<void> => {

View File

@ -16,13 +16,13 @@ describe('A WwwAuthMetadataWriter', (): void => {
it('adds no header if there is no relevant metadata.', async(): Promise<void> => {
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<void> => {
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<void> => {

View File

@ -12,6 +12,6 @@ describe('An OidcControlHandler', (): void => {
});
it('returns an empty object if there is no OIDC interaction.', async(): Promise<void> => {
await expect(handler.handle({ } as any)).resolves.toEqual({ json: { }});
await expect(handler.handle({} as any)).resolves.toEqual({ json: {}});
});
});

View File

@ -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);
});

View File

@ -17,7 +17,7 @@ describe('A PromptHandler', (): void => {
});
it('errors if there is no interaction.', async(): Promise<void> => {
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<void> => {

View File

@ -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;
}
}

View File

@ -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<AccessMode>(
[[ target, new Set([ AccessMode.read, AccessMode.write ]) ]],

View File

@ -485,7 +485,7 @@ describe('A FileDataAccessor', (): void => {
});
it('can delete the root container.', async(): Promise<void> => {
cache.data = { };
cache.data = {};
await expect(accessor.deleteResource({ path: `${base}` })).resolves.toBeUndefined();
expect(cache.data).toBeUndefined();
});

View File

@ -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 => {

View File

@ -29,7 +29,7 @@ describe('A BaseTypedRepresentationConverter', (): void => {
});
it('can not handle input without a Content-Type.', async(): Promise<void> => {
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);
});

View File

@ -55,7 +55,7 @@ describe('A ChainedConverter', (): void => {
it('needs at least 1 converter.', async(): Promise<void> => {
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<void> => {
@ -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');

View File

@ -43,7 +43,7 @@ describe('A RdfToQuadConverter', (): void => {
});
it('may not handle application/json to quad conversion.', async(): Promise<void> => {
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<void> => {

View File

@ -39,7 +39,7 @@ describe('An RdfPatcher,', (): void => {
};
patcher.handle.mockImplementation(
async(input: RepresentationPatcherInput<RdfDatasetRepresentation>):
Promise<RdfDatasetRepresentation> => Promise.resolve(input.representation!),
Promise<RdfDatasetRepresentation> => input.representation!,
);
rdfPatcher = new RdfPatcher(patcher);

View File

@ -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 => {