Skip to content

Commit aa55496

Browse files
Copilotrubensworks
andauthored
Fix remaining 96 ESLint errors across lib and test files
Agent-Logs-Url: https://github.com/LinkedSoftwareDependencies/Components.js/sessions/5baf6678-c4cb-41cb-91d2-eeaff51497c2 Co-authored-by: rubensworks <440384+rubensworks@users.noreply.github.com>
1 parent b5a7597 commit aa55496

30 files changed

Lines changed: 269 additions & 94 deletions

eslint.config.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,15 @@ module.exports = config([
3737
'unused-imports/no-unused-vars': [ 'error', { args: 'none' }],
3838
},
3939
},
40+
{
41+
// PrefetchedDocumentLoader imports JSON files which need import/extensions disabled;
42+
// the disable comments between imports break the newline-after-import chain detection
43+
files: [ 'lib/rdf/PrefetchedDocumentLoader.ts' ],
44+
rules: {
45+
'import/extensions': 'off',
46+
'import/newline-after-import': 'off',
47+
},
48+
},
4049
{
4150
// Specific rules for test files
4251
files: [ '**/test/**/*.ts' ],

lib/construction/strategy/IConstructionStrategy.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,7 @@ export interface ICreationStrategySupplierOptions<TInstance> {
108108
supplier: () => Promise<TInstance>;
109109
}
110110

111+
// eslint-disable-next-line unused-imports/no-unused-vars
111112
export interface ICreationStrategyPrimitiveOptions<TInstance> {
112113
/**
113114
* Creation settings.
@@ -119,6 +120,7 @@ export interface ICreationStrategyPrimitiveOptions<TInstance> {
119120
value: string | number | any;
120121
}
121122

123+
// eslint-disable-next-line unused-imports/no-unused-vars
122124
export interface ICreationStrategyVariableOptions<TInstance> {
123125
/**
124126
* Creation settings.

lib/preprocess/overridesteps/OverrideMapEntry.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,8 @@ export class OverrideMapEntry implements IOverrideStep {
7171
* @param entries - List of key/value map entries.
7272
* @param key - Key of the entry to find.
7373
* @param properties - URIs used to link the key and value of a map entry.
74+
* @param properties.key - URI used to link the key of a map entry.
75+
* @param properties.value - URI used to link the value of a map entry.
7476
*/
7577
protected findEntryIndex(entries: Resource[], key: Resource, properties: { key: Resource; value: Resource }): number {
7678
for (const [ i, entry ] of entries.entries()) {

lib/preprocess/parameterproperty/ParameterPropertyHandlerRange.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,8 @@ export class ParameterPropertyHandlerRange implements IParameterPropertyHandler
6262
*
6363
* @param value The value.
6464
* @param type The parameter's range.
65-
* @param genericsContext Context for generic types.
6665
* @param errorContext The context for error reporting.
66+
* @param genericsContext Context for generic types.
6767
* @return IParamValueConflict A conflict value if there was an error, or undefined if there was no error
6868
*/
6969
public hasValueType(

lib/rdf/PrefetchedDocumentLoader.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ import type { IJsonLdContext } from 'jsonld-context-parser';
22
import { FetchDocumentLoader } from 'jsonld-context-parser';
33
import semverMajor from 'semver/functions/major';
44
import type { Logger } from 'winston';
5-
import contextJson from '../../components/context.json'; // eslint-disable-line import/extensions
6-
import packageJson from '../../package.json'; // eslint-disable-line import/extensions
5+
import contextJson from '../../components/context.json';
6+
import packageJson from '../../package.json';
77

88
/**
99
* A document loader that first loads from a precomputed set of contexts,

test/integration/instantiateFile-test.ts

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import { IRIS_DOAP, IRIS_OO, IRIS_RDF } from '../../lib/rdf/Iris';
77

88
const quad = require('rdf-quad');
99

10+
// eslint-disable-next-line jest/no-mocks-import
1011
const Hello = require('../../__mocks__/helloworld').Hello;
1112

1213
jest.mock<typeof import('winston')>('winston', () => ({
@@ -31,10 +32,10 @@ describe('construction with component configs as files', () => {
3132
let manager: ComponentsManager<any>;
3233
beforeEach(async() => {
3334
moduleState = <any> {
34-
mainModulePath: `${__dirname}/../../__mocks__`,
35+
mainModulePath: Path.join(__dirname, '../../__mocks__'),
3536
importPaths: {
36-
'http://example.org/': `${__dirname}/../`,
37-
'https://linkedsoftwaredependencies.org/bundles/npm/example/^1.0.0/config/': `${__dirname}/../assets/`,
37+
'http://example.org/': `${Path.join(__dirname, '..')}/`,
38+
'https://linkedsoftwaredependencies.org/bundles/npm/example/^1.0.0/config/': `${Path.join(__dirname, '../assets')}/`,
3839
},
3940
packageJsons: {},
4041
};
@@ -403,7 +404,9 @@ describe('construction with component configs as files', () => {
403404
mainModulePath: __dirname,
404405
moduleState,
405406
async moduleLoader(registry) {
406-
await registry.registerModule(Path.join(__dirname, '../assets/module-inheritableparams-subclassmapping.jsonld'));
407+
await registry.registerModule(
408+
Path.join(__dirname, '../assets/module-inheritableparams-subclassmapping.jsonld'),
409+
);
407410
},
408411
});
409412
});
@@ -510,7 +513,9 @@ describe('construction with component configs as files', () => {
510513
mainModulePath: __dirname,
511514
moduleState,
512515
async moduleLoader(registry) {
513-
await registry.registerModule(Path.join(__dirname, '../assets/module-inheritableparams-subclassmapping-dynamicentries.jsonld'));
516+
await registry.registerModule(
517+
Path.join(__dirname, '../assets/module-inheritableparams-subclassmapping-dynamicentries.jsonld'),
518+
);
514519
},
515520
});
516521
});
@@ -567,7 +572,9 @@ describe('construction with component configs as files', () => {
567572
mainModulePath: __dirname,
568573
moduleState,
569574
async moduleLoader(registry) {
570-
await registry.registerModule(Path.join(__dirname, '../assets/module-inheritableparams-dynamicentries.jsonld'));
575+
await registry.registerModule(
576+
Path.join(__dirname, '../assets/module-inheritableparams-dynamicentries.jsonld'),
577+
);
571578
},
572579
});
573580
});

test/integration/instantiateResourceConfigComponent-test.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import * as Path from 'node:path';
12
import { mocked } from 'jest-mock';
23
import type { Resource, RdfObjectLoader } from 'rdf-object';
34
import { ComponentsManager } from '../../lib/ComponentsManager';
@@ -20,9 +21,9 @@ describe('construction with component configs as Resource', () => {
2021
let settings: IConstructionSettings;
2122
beforeEach(async() => {
2223
manager = await ComponentsManager.build({
23-
mainModulePath: `${__dirname}/../../__mocks__`,
24+
mainModulePath: Path.join(__dirname, '../../__mocks__'),
2425
moduleState: <any> {
25-
mainModulePath: `${__dirname}/../../__mocks__`,
26+
mainModulePath: Path.join(__dirname, '../../__mocks__'),
2627
packageJsons: {},
2728
},
2829
async moduleLoader() {

test/integration/instantiateResourceConfigComponentMapped-test.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import * as Path from 'node:path';
12
import { mocked } from 'jest-mock';
23
import type { Resource, RdfObjectLoader } from 'rdf-object';
34
import { ComponentsManager } from '../../lib/ComponentsManager';
@@ -13,6 +14,7 @@ jest.mock<typeof import('n3')>('n3', () => ({
1314
Util: { type: 'UTIL' },
1415
}));
1516

17+
// eslint-disable-next-line jest/no-mocks-import
1618
const Hello = require('../../__mocks__/helloworld').Hello;
1719

1820
describe('construction with mapped component configs as Resource', () => {
@@ -22,9 +24,9 @@ describe('construction with mapped component configs as Resource', () => {
2224
let settings: IConstructionSettings;
2325
beforeEach(async() => {
2426
manager = await ComponentsManager.build({
25-
mainModulePath: `${__dirname}/../../__mocks__`,
27+
mainModulePath: Path.join(__dirname, '../../__mocks__'),
2628
moduleState: <any> {
27-
mainModulePath: `${__dirname}/../../__mocks__`,
29+
mainModulePath: Path.join(__dirname, '../../__mocks__'),
2830
packageJsons: {},
2931
},
3032
async moduleLoader() {

test/integration/instantiateResourceConfigRaw-test.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import * as Path from 'node:path';
12
import type { RdfObjectLoader } from 'rdf-object';
23
import { ComponentsManager } from '../../lib/ComponentsManager';
34
import type { IConfigConstructorPool } from '../../lib/construction/IConfigConstructorPool';
@@ -11,6 +12,7 @@ jest.mock<typeof import('n3')>('n3', () => ({
1112
Util: { type: 'UTIL' },
1213
}));
1314

15+
// eslint-disable-next-line jest/no-mocks-import
1416
const Hello = require('../../__mocks__/helloworld').Hello;
1517

1618
describe('construction with component configs as Resource', () => {
@@ -20,9 +22,9 @@ describe('construction with component configs as Resource', () => {
2022
let settings: IConstructionSettings;
2123
beforeEach(async() => {
2224
manager = await ComponentsManager.build({
23-
mainModulePath: `${__dirname}/../../__mocks__`,
25+
mainModulePath: Path.join(__dirname, '../../__mocks__'),
2426
moduleState: <any> {
25-
mainModulePath: `${__dirname}/../../__mocks__`,
27+
mainModulePath: Path.join(__dirname, '../../__mocks__'),
2628
packageJsons: {},
2729
},
2830
async moduleLoader() {

test/unit/construction/ConfigConstructor-test.ts

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import * as fs from 'node:fs';
2+
import * as Path from 'node:path';
23
import { DataFactory } from 'rdf-data-factory';
34
import { Resource, RdfObjectLoader } from 'rdf-object';
45
import { ConfigConstructor } from '../../../lib/construction/ConfigConstructor';
@@ -11,7 +12,6 @@ const DF = new DataFactory();
1112

1213
describe('ConfigConstructor', () => {
1314
let objectLoader: RdfObjectLoader;
14-
let componentResources: Record<string, Resource>;
1515
let configConstructorPool: jest.Mocked<ConfigConstructorPool<any>>;
1616
let constructor: ConfigConstructor<any>;
1717
let constructionStrategy: IConstructionStrategy<any>;
@@ -21,10 +21,9 @@ describe('ConfigConstructor', () => {
2121
beforeEach(async() => {
2222
objectLoader = new RdfObjectLoader({
2323
uniqueLiterals: true,
24-
context: JSON.parse(fs.readFileSync(`${__dirname}/../../../components/context.jsonld`, 'utf8')),
24+
context: JSON.parse(fs.readFileSync(Path.join(__dirname, '../../../components/context.jsonld'), 'utf8')),
2525
});
2626
await objectLoader.context;
27-
componentResources = {};
2827
configConstructorPool = <any> {
2928
instantiate: jest.fn(() => 'INSTANCE'),
3029
};
@@ -40,7 +39,7 @@ describe('ConfigConstructor', () => {
4039
moduleState = <any> {
4140
mainModulePath: __dirname,
4241
importPaths: {
43-
'http://example.org/': `${__dirname}/`,
42+
'http://example.org/': `${Path.resolve(__dirname)}/`,
4443
},
4544
};
4645
constructor = new ConfigConstructor({
@@ -105,7 +104,7 @@ describe('ConfigConstructor', () => {
105104
undefined: '"true"',
106105
});
107106
await expect(constructor.getArgumentValue(resource, settings)).resolves.toBeUndefined();
108-
expect(constructionStrategy.createUndefined).toHaveBeenCalled();
107+
expect(constructionStrategy.createUndefined).toHaveBeenCalledWith(expect.anything());
109108
});
110109
});
111110

0 commit comments

Comments
 (0)