refactor: Enable style/indent-binary-ops rule

This commit is contained in:
Joachim Van Herwegen 2024-03-12 16:24:21 +01:00
parent 73fbe80cff
commit 331f83d659
11 changed files with 27 additions and 21 deletions

View File

@ -66,8 +66,7 @@ module.exports = {
'style/block-spacing': 'off',
'style/brace-style': [ 'error', '1tbs', { allowSingleLine: false }],
'style/generator-star-spacing': [ 'error', { before: false, after: true }],
// Seems to be inconsistent in when it adds indentation and when it does not
'style/indent-binary-ops': 'off',
'style/indent-binary-ops': 'error',
'style/member-delimiter-style': [ 'error', {
multiline: { delimiter: 'semi', requireLast: true },
singleline: { delimiter: 'semi', requireLast: false },

View File

@ -102,7 +102,9 @@ export class ParentContainerReader extends PermissionReader {
// When an operation requests to delete a resource,
// the server MUST match Authorizations allowing the acl:Write access privilege
// on the resource and the containing container.
mergedPermission.delete = resourcePermission.write && containerPermission.write &&
mergedPermission.delete =
resourcePermission.write &&
containerPermission.write &&
resourcePermission.delete !== false;
return mergedPermission;

View File

@ -67,8 +67,10 @@ export class LinkRelObject {
if (this.objectAllowed(object)) {
if (this.ephemeral) {
metadata.add(this.value, namedNode(object), SOLID_META.terms.ResponseMetadata);
logger.debug(`"<${metadata.identifier.value}> <${this.value.value}> <${object}>." ` +
`will not be stored permanently in the metadata.`);
logger.debug(
`"<${metadata.identifier.value}> <${this.value.value}> <${object}>." ` +
`will not be stored permanently in the metadata.`,
);
} else {
metadata.add(this.value, namedNode(object));
}

View File

@ -79,10 +79,10 @@ export function getTypeWeight(type: string, preferred: ValuePreferences): number
// specific media types. If more than one media range applies to a
// given type, the most specific reference has precedence.
return preferred[type] ??
preferred[`${main}/${sub}`] ??
preferred[`${main}/*`] ??
preferred['*/*'] ??
0;
preferred[`${main}/${sub}`] ??
preferred[`${main}/*`] ??
preferred['*/*'] ??
0;
}
/**

View File

@ -84,7 +84,7 @@ export class ExtensionBasedMapper extends BaseFileIdentifierMapper {
const extension = getExtension(filePath).toLowerCase();
return mime.lookup(extension) ||
this.customTypes[extension] ||
await super.getContentTypeFromPath(filePath);
await super.getContentTypeFromPath(filePath);
}
/**

View File

@ -119,8 +119,8 @@ export function parseParameters(parameters: string[], replacements: Record<strin
// parameter = token "=" ( token / quoted-string )
// second part is optional for certain parameters
if (!(TOKEN.test(name) && (!rawValue || /^"\d+"$/u.test(rawValue) || TOKEN.test(rawValue)))) {
handleInvalidValue(`Invalid parameter value: ${name}=${replacements[rawValue] || rawValue} ` +
`does not match (token ( "=" ( token / quoted-string ))?). `, strict);
handleInvalidValue(`Invalid parameter value: ${name}=${replacements[rawValue] || rawValue
} does not match (token ( "=" ( token / quoted-string ))?). `, strict);
continue;
}
@ -177,8 +177,11 @@ function parseAcceptPart(part: string, replacements: Record<string, string>, str
weight = parseQValue(value);
} else {
if (!value && map !== extensionParams) {
handleInvalidValue(`Invalid Accept parameter ${name}: ` +
`Accept parameter values are not optional when preceding the q value`, strict);
handleInvalidValue(
`Invalid Accept parameter ${name}: ` +
`Accept parameter values are not optional when preceding the q value`,
strict,
);
continue;
}
map[name] = value || '';

View File

@ -7,8 +7,8 @@ export function isError(error: unknown): error is Error {
return types.isNativeError(error) ||
(Boolean(error) &&
typeof (error as Error).name === 'string' &&
typeof (error as Error).message === 'string' &&
(typeof (error as Error).stack === 'undefined' || typeof (error as Error).stack === 'string'));
typeof (error as Error).message === 'string' &&
(typeof (error as Error).stack === 'undefined' || typeof (error as Error).stack === 'string'));
}
/**

View File

@ -47,7 +47,7 @@ export class HttpError<T extends number = number> extends Error implements HttpE
public static isInstance(error: any): error is HttpError {
return isError(error) &&
typeof (error as HttpError).statusCode === 'number' &&
Boolean((error as HttpError).metadata);
Boolean((error as HttpError).metadata);
}
/**

View File

@ -41,6 +41,6 @@ export class ProcessHandler<TIn, TOut> extends AsyncHandler<TIn, TOut> {
*/
private canExecute(): boolean {
return this.clusterManager.isSingleThreaded() ||
(this.executeOnPrimary ? this.clusterManager.isPrimary() : this.clusterManager.isWorker());
(this.executeOnPrimary ? this.clusterManager.isPrimary() : this.clusterManager.isWorker());
}
}

View File

@ -25,7 +25,7 @@ export class StaticTemplateEngine<T extends Dict<any> = Dict<any>> extends Templ
public async canHandle({ contents, template }: TemplateEngineInput<T>): Promise<void> {
if (typeof template !== 'undefined') {
throw new TypeError('StaticTemplateEngine does not support template as handle input, ' +
'provide a template via the constructor instead!');
'provide a template via the constructor instead!');
}
return this.templateEngine.canHandle({ contents, template: this.template });
}

View File

@ -134,7 +134,7 @@ describe('A SparqlUpdatePatcher', (): void => {
it('handles composite INSERT/DELETE updates.', async(): Promise<void> => {
const query = 'INSERT DATA { :s1 :p1 :o1 . :s2 :p2 :o2 };' +
'DELETE WHERE { :s1 :p1 :o1 . :startS1 :startP1 :startO1 }';
'DELETE WHERE { :s1 :p1 :o1 . :startS1 :startP1 :startO1 }';
input.patch = getPatch(query);
const result = await patcher.handle(input);
expect(result.dataset).toBeRdfIsomorphic([
@ -153,7 +153,7 @@ describe('A SparqlUpdatePatcher', (): void => {
it('handles composite DELETE/INSERT updates.', async(): Promise<void> => {
const query = 'DELETE DATA { :s1 :p1 :o1 . :startS1 :startP1 :startO1 } ;' +
'INSERT DATA { :s1 :p1 :o1 . :s2 :p2 :o2 }';
'INSERT DATA { :s1 :p1 :o1 . :s2 :p2 :o2 }';
input.patch = getPatch(query);
const result = await patcher.handle(input);
expect(result.dataset).toBeRdfIsomorphic([