Skip to content

Commit a7f5b94

Browse files
Copilotrubensworks
andcommitted
Update @rubensworks/eslint-config from 1.0.1 to 1.2.0 (#159)
Agent-Logs-Url: https://github.com/LinkedSoftwareDependencies/Components.js/sessions/3a1755d4-cde4-46b9-888f-a2c602d2fd9a Co-authored-by: rubensworks <440384+rubensworks@users.noreply.github.com>
1 parent 8b53b48 commit a7f5b94

21 files changed

Lines changed: 263 additions & 83 deletions

lib/construction/strategy/ConstructionStrategyCommonJs.ts

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ export class ConstructionStrategyCommonJs implements IConstructionStrategy<any>
5757
if (typeof object !== 'function') {
5858
throw new Error(`Attempted to construct ${options.requireElement} from module ${options.requireName} that does not have a constructor`);
5959
}
60-
object = new (Function.prototype.bind.apply(object, <[any, ...any]>[{}].concat(options.args)))();
60+
object = new (Function.prototype.bind.apply(object, <[any, ...any]>[{}, ...options.args ]))();
6161
}
6262

6363
return object;
@@ -72,25 +72,22 @@ export class ConstructionStrategyCommonJs implements IConstructionStrategy<any>
7272
*/
7373
public requireCurrentRunningModuleIfCurrent(moduleState: IModuleState, requireName: string): { value: any } | false {
7474
const pckg = moduleState.packageJsons[moduleState.mainModulePath];
75-
if (pckg) {
76-
if (requireName === pckg.name) {
77-
const mainPath: string = Path.posix.join(moduleState.mainModulePath, pckg.main);
78-
const required = this.req(mainPath);
79-
if (required) {
80-
return { value: required };
81-
}
75+
if (pckg && requireName === pckg.name) {
76+
const mainPath: string = Path.posix.join(moduleState.mainModulePath, pckg.main);
77+
const required = this.req(mainPath);
78+
if (required) {
79+
return { value: required };
8280
}
8381
}
8482
return false;
8583
}
8684

8785
public createHash(options: ICreationStrategyHashOptions<any>): any {
88-
return options.entries.reduce((data: Record<string, any>, entry: { key: string; value: any } | undefined) => {
89-
if (entry) {
90-
data[entry.key] = entry.value;
91-
}
92-
return data;
93-
}, {});
86+
return Object.fromEntries(
87+
options.entries
88+
.filter((entry): entry is { key: string; value: any } => entry !== undefined)
89+
.map(entry => [ entry.key, entry.value ]),
90+
);
9491
}
9592

9693
public createArray(options: ICreationStrategyArrayOptions<any>): any {

lib/construction/strategy/ConstructionStrategyCommonJsString.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ export class ConstructionStrategyCommonJsString implements IConstructionStrategy
5454
this.getCurrentRunningModuleMain(options.moduleState),
5555
)}` :
5656
options.requireName;
57-
let serialization = `require('${resultingRequirePath.replace(/\\/gu, '/')}')`;
57+
let serialization = `require('${resultingRequirePath.replaceAll('\\', '/')}')`;
5858

5959
// Determine the child of the require'd element
6060
if (options.requireElement) {

lib/loading/ComponentRegistry.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ export class ComponentRegistry {
3737
*/
3838
public async registerAvailableModules(): Promise<void> {
3939
await Promise.all(Object.values(this.moduleState.componentModules)
40-
.flatMap(Object.values)
40+
.flatMap(x => Object.values(x))
4141
.map((moduleResourceUrl: string) => this.registerModule(moduleResourceUrl)));
4242
}
4343

lib/preprocess/ConfigPreprocessorComponent.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -289,10 +289,8 @@ export class ConfigPreprocessorComponent implements IConfigPreprocessor<ICompone
289289
// Emit warning on undefined parameters inside the component's scope
290290
const prefix = handleResponse.component.value;
291291
for (const property of Object.keys(config.property)) {
292-
if (property.startsWith(prefix)) {
293-
if (!validParameters[property]) {
294-
this.logger.warn(`Detected potentially invalid component parameter '${property}' in a config`);
295-
}
292+
if (property.startsWith(prefix) && !validParameters[property]) {
293+
this.logger.warn(`Detected potentially invalid component parameter '${property}' in a config`);
296294
}
297295
}
298296
}

lib/preprocess/ConfigPreprocessorOverride.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ export class ConfigPreprocessorOverride implements IConfigPreprocessor<Resource[
148148
while (change) {
149149
change = false;
150150
for (const [ id, chain ] of Object.entries(overrideChains)) {
151-
let next = chain[chain.length - 1];
151+
let next = chain.at(-1)!;
152152
// If the next part of the chain is found in `overrideChains` we can merge them and remove the tail entry
153153
while (overrideChains[next.value]) {
154154
change = true;
@@ -158,7 +158,7 @@ export class ConfigPreprocessorOverride implements IConfigPreprocessor<Resource[
158158
// In case of a cycle there will be a point where next equals the first element,
159159
// at which point it will delete itself.
160160
delete overrideChains[next.value];
161-
next = chain[chain.length - 1];
161+
next = chain.at(-1)!;
162162
}
163163
// Reset the loop since we are modifying the object we are iterating over
164164
if (change) {
@@ -175,7 +175,7 @@ export class ConfigPreprocessorOverride implements IConfigPreprocessor<Resource[
175175
* @param chains - The override chains to check.
176176
*/
177177
protected validateChains(chains: Resource[][]): void {
178-
const targets = chains.map((chain): string => chain[chain.length - 1].value);
178+
const targets = chains.map((chain): string => chain.at(-1)!.value);
179179
for (let i = 0; i < targets.length; ++i) {
180180
const duplicateIdx = targets.findIndex((target, idx): boolean => idx > i && target === targets[i]);
181181
if (duplicateIdx > 0) {
@@ -231,18 +231,18 @@ export class ConfigPreprocessorOverride implements IConfigPreprocessor<Resource[
231231
* @param chain - The chain to find the target of.
232232
*/
233233
protected getChainTarget(chain: Resource[]): Resource {
234-
const target = chain[chain.length - 1];
234+
const target = chain.at(-1)!;
235235
const types = uniqueTypes(target, this.componentResources);
236236
if (!types || types.length === 0) {
237-
throw new ErrorResourcesContext(`Missing type for override target ${target.value} of Override ${chain[chain.length - 2].value}`, {
237+
throw new ErrorResourcesContext(`Missing type for override target ${target.value} of Override ${chain.at(-2)!.value}`, {
238238
target,
239-
override: chain[chain.length - 2],
239+
override: chain.at(-2),
240240
});
241241
}
242242
if (types.length > 1) {
243-
throw new ErrorResourcesContext(`Found multiple types for override target ${target.value} of Override ${chain[chain.length - 2].value}`, {
243+
throw new ErrorResourcesContext(`Found multiple types for override target ${target.value} of Override ${chain.at(-2)!.value}`, {
244244
target,
245-
override: chain[chain.length - 2],
245+
override: chain.at(-2),
246246
});
247247
}
248248
return target;

lib/preprocess/ParameterHandler.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ export class ParameterHandler {
5353
});
5454
}
5555
value = this.objectLoader.createCompactedResource({
56-
list: values.flatMap(subValue => <Resource[]> subValue.list),
56+
list: values.flatMap(subValue => subValue.list!),
5757
});
5858
}
5959

lib/preprocess/constructorargumentsmapping/ConstructorArgumentsElementMappingHandlerList.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ export class ConstructorArgumentsElementMappingHandlerList implements IConstruct
2626
// Recursively handle all field values.
2727
const ret = mapper.objectLoader.createCompactedResource({});
2828
ret.list = [];
29-
for (const argument of (<Resource[]> constructorArgs.list)) {
29+
for (const argument of constructorArgs.list!) {
3030
if (argument.property.fields || argument.property.elements) {
3131
ret.list.push(mapper
3232
.applyConstructorArgumentsParameters(configRoot, argument, configElement, genericsContext));

lib/preprocess/overridesteps/OverrideUtil.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ export type OverrideStepFieldName = `${typeof OVERRIDE_STEP_FIELD_NAMES[number]}
1212
* @param step - Override step to get the fields from.
1313
* @param expected - For each field, how many are expected. The value can be undefined if there is no fixed amount.
1414
*/
15-
export function extractOverrideStepFields(step: Resource, expected: { [key in OverrideStepFieldName]?: number } = {}):
15+
export function extractOverrideStepFields(step: Resource, expected: {[key in OverrideStepFieldName]?: number } = {}):
1616
Record<OverrideStepFieldName, Resource[]> {
1717
// Type is not correct yet now but will be completed in the loop below
1818
const result = <Record<OverrideStepFieldName, Resource[]>> {};
@@ -57,7 +57,8 @@ export function getPropertyResourceList(config: Resource, parameter: Resource):
5757

5858
// Having multiple lists can happen if multiple config files add elements to the same list
5959
const list = properties.flatMap(prop => prop.list);
60-
if (list.some(res => res === undefined)) {
60+
// eslint-disable-next-line unicorn/no-useless-undefined
61+
if (list.includes(undefined)) {
6162
throw new ErrorResourcesContext(`Invalid target in Override step targeting ${config.value}: ${parameter.value} does not reference a list`, {
6263
config,
6364
});

lib/rdf/RdfStreamIncluder.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,6 @@ export class RdfStreamIncluder extends Transform {
100100
* @param iri A potential IRI.
101101
*/
102102
public static isValidIri(iri: string): boolean {
103-
return Boolean(/:((\/\/)|(.*:))/u.exec(iri));
103+
return Boolean(/:((\/\/)|(.*:))/u.test(iri));
104104
}
105105
}

lib/util/ErrorResourcesContext.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,6 @@ export class ErrorResourcesContext extends Error {
5757
}
5858
}
5959

60-
// eslint-disable-next-line @typescript-eslint/consistent-indexed-object-style
6160
export interface IErrorContext {
6261
[key: string]: Resource | Resource[] | string | undefined | IErrorContext | IParamValueConflict;
6362
}

0 commit comments

Comments
 (0)