Skip to content

Commit

Permalink
chore: Update eslint dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
joachimvh committed Jan 24, 2022
1 parent 65d1eeb commit af04912
Show file tree
Hide file tree
Showing 26 changed files with 1,716 additions and 1,791 deletions.
4 changes: 4 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,10 @@ module.exports = {
'unicorn/no-fn-reference-in-iterator': 'off',
'unicorn/no-object-as-default-parameter': 'off',
'unicorn/numeric-separators-style': 'off',
// At function only supported in Node v16.6.0
'unicorn/prefer-at': 'off',
// Does not make sense for more complex cases
'unicorn/prefer-object-from-entries': 'off',
// Can get ugly with large single statements
'unicorn/prefer-ternary': 'off',
'yield-star-spacing': [ 'error', 'after' ],
Expand Down
3,345 changes: 1,634 additions & 1,711 deletions package-lock.json

Large diffs are not rendered by default.

16 changes: 8 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -141,17 +141,17 @@
"@types/jest": "^27.0.0",
"@types/set-cookie-parser": "^2.4.0",
"@types/supertest": "^2.0.11",
"@typescript-eslint/eslint-plugin": "^4.28.1",
"@typescript-eslint/parser": "^4.28.1",
"@typescript-eslint/eslint-plugin": "^5.3.0",
"@typescript-eslint/parser": "^5.3.0",
"cheerio": "^1.0.0-rc.10",
"componentsjs-generator": "^2.6.0",
"eslint": "^7.29.0",
"eslint-config-es": "^3.20.3",
"eslint-import-resolver-typescript": "^2.4.0",
"eslint-plugin-import": "^2.23.4",
"eslint-plugin-jest": "^24.3.6",
"eslint": "^8.4.1",
"eslint-config-es": "4.1.0",
"eslint-import-resolver-typescript": "^2.5.0",
"eslint-plugin-import": "^2.25.3",
"eslint-plugin-jest": "^25.3.0",
"eslint-plugin-tsdoc": "^0.2.14",
"eslint-plugin-unused-imports": "^1.1.1",
"eslint-plugin-unused-imports": "^2.0.0",
"fs-extra": "^10.0.0",
"husky": "^4.3.8",
"jest": "^27.0.6",
Expand Down
2 changes: 1 addition & 1 deletion src/identity/configuration/IdentityProviderFactory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ export class IdentityProviderFactory implements ProviderFactory {
// Cast necessary due to typing conflict between jose 2.x and 3.x
config.jwks = await this.generateJwks() as any;
config.cookies = {
...config.cookies ?? {},
...config.cookies,
keys: await this.generateCookieKeys(),
};

Expand Down
2 changes: 1 addition & 1 deletion test/integration/Identity.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -374,7 +374,7 @@ describe('A Solid server with IDP', (): void => {

expect(res.status).toBe(200);
// https://solid.github.io/authentication-panel/solid-oidc/#discovery
expect(jsonBody.solid_oidc_supported).toEqual('https://solidproject.org/TR/solid-oidc');
expect(jsonBody.solid_oidc_supported).toBe('https://solidproject.org/TR/solid-oidc');
});

it('should return correct error output.', async(): Promise<void> => {
Expand Down
6 changes: 3 additions & 3 deletions test/integration/RepresentationConverter.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ describe('A ChainedConverter', (): void => {
identifier: { path: 'path' },
});

await expect(readableToString(result.data)).resolves.toEqual('<http://test.com/s> <http://test.com/p> <http://test.com/o>.\n');
expect(result.metadata.contentType).toEqual('text/turtle');
await expect(readableToString(result.data)).resolves.toBe('<http://test.com/s> <http://test.com/p> <http://test.com/o>.\n');
expect(result.metadata.contentType).toBe('text/turtle');
});

it('can convert from turtle to JSON-LD.', async(): Promise<void> => {
Expand All @@ -42,6 +42,6 @@ describe('A ChainedConverter', (): void => {
expect(JSON.parse(await readableToString(result.data))).toEqual(
[{ '@id': 'http://test.com/s', 'http://test.com/p': [{ '@id': 'http://test.com/o' }]}],
);
expect(result.metadata.contentType).toEqual('application/ld+json');
expect(result.metadata.contentType).toBe('application/ld+json');
});
});
2 changes: 1 addition & 1 deletion test/integration/RequestParser.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ describe('A BasicRequestParser with simple input parsers', (): void => {
metadata: expect.any(RepresentationMetadata),
},
});
expect(result.body?.metadata.contentType).toEqual('text/turtle');
expect(result.body?.metadata.contentType).toBe('text/turtle');

await expect(arrayifyStream(result.body.data)).resolves.toEqual(
[ '<http://test.com/s> <http://test.com/p> <http://test.com/o>.' ],
Expand Down
2 changes: 1 addition & 1 deletion test/unit/http/output/BasicResponseWriter.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ describe('A BasicResponseWriter', (): void => {
response.on('end', (): void => {
expect(response._isEndCalled()).toBeTruthy();
expect(response._getStatusCode()).toBe(201);
expect(response._getData()).toEqual('<http://test.com/s> <http://test.com/p> <http://test.com/o>.');
expect(response._getData()).toBe('<http://test.com/s> <http://test.com/p> <http://test.com/o>.');
resolve();
});
});
Expand Down
10 changes: 5 additions & 5 deletions test/unit/http/representation/RepresentationMetadata.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ describe('A RepresentationMetadata', (): void => {
describe('constructor', (): void => {
it('creates a blank node if no identifier was given.', async(): Promise<void> => {
metadata = new RepresentationMetadata();
expect(metadata.identifier.termType).toEqual('BlankNode');
expect(metadata.identifier.termType).toBe('BlankNode');
expect(metadata.quads()).toHaveLength(0);
});

Expand All @@ -51,13 +51,13 @@ describe('A RepresentationMetadata', (): void => {

it('converts string to content type.', async(): Promise<void> => {
metadata = new RepresentationMetadata('text/turtle');
expect(metadata.contentType).toEqual('text/turtle');
expect(metadata.contentType).toBe('text/turtle');

metadata = new RepresentationMetadata({ path: 'identifier' }, 'text/turtle');
expect(metadata.contentType).toEqual('text/turtle');
expect(metadata.contentType).toBe('text/turtle');

metadata = new RepresentationMetadata(new RepresentationMetadata(), 'text/turtle');
expect(metadata.contentType).toEqual('text/turtle');
expect(metadata.contentType).toBe('text/turtle');
});

it('copies an other metadata object.', async(): Promise<void> => {
Expand Down Expand Up @@ -275,7 +275,7 @@ describe('A RepresentationMetadata', (): void => {
expect(metadata.contentType).toBeUndefined();
metadata.contentType = 'a/b';
expect(metadata.get(CONTENT_TYPE)).toEqualRdfTerm(literal('a/b'));
expect(metadata.contentType).toEqual('a/b');
expect(metadata.contentType).toBe('a/b');
metadata.contentType = undefined;
expect(metadata.contentType).toBeUndefined();
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ describe('An IdentityProviderFactory', (): void => {
expect(config.jwks).toEqual({ keys: [ expect.objectContaining({ kty: 'RSA' }) ]});
expect(config.routes).toEqual(routes);

expect((config.interactions?.url as any)()).toEqual('/idp/');
expect((config.interactions?.url as any)()).toBe('/idp/');
expect((config.audiences as any)(null, null, {}, 'access_token')).toBe('solid');
expect((config.audiences as any)(null, null, { clientId: 'clientId' }, 'client_credentials')).toBe('clientId');

Expand Down
4 changes: 2 additions & 2 deletions test/unit/logging/LogUtil.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@ describe('LogUtil', (): void => {

it('allows creating a lazy logger for a string label.', async(): Promise<void> => {
expect(getLoggerFor('MyLabel')).toBeInstanceOf(LazyLogger);
expect((getLoggerFor('MyLabel') as any).label).toEqual('MyLabel');
expect((getLoggerFor('MyLabel') as any).label).toBe('MyLabel');
});

it('allows creating a lazy logger for a class instance.', async(): Promise<void> => {
expect(getLoggerFor(new VoidLogger())).toBeInstanceOf(LazyLogger);
expect((getLoggerFor(new VoidLogger()) as any).label).toEqual('VoidLogger');
expect((getLoggerFor(new VoidLogger()) as any).label).toBe('VoidLogger');
});

it('allows setting the global logger factory.', async(): Promise<void> => {
Expand Down
2 changes: 1 addition & 1 deletion test/unit/logging/WinstonLoggerFactory.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ describe('WinstonLoggerFactory', (): void => {
const logger = factory.createLogger('MyLabel');
expect(logger).toBeInstanceOf(WinstonLogger);
const innerLogger: Logger = (logger as any).logger;
expect(innerLogger.level).toEqual('debug');
expect(innerLogger.level).toBe('debug');
expect(innerLogger.format).toBeTruthy();
expect(innerLogger.transports).toHaveLength(1);
});
Expand Down
4 changes: 2 additions & 2 deletions test/unit/storage/DataAccessorBasedStore.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ describe('A DataAccessorBasedStore', (): void => {
const result = await store.getRepresentation(resourceID);
expect(result).toMatchObject({ binary: true });
expect(await arrayifyStream(result.data)).toEqual([ resourceData ]);
expect(result.metadata.contentType).toEqual('text/plain');
expect(result.metadata.contentType).toBe('text/plain');
expect(result.metadata.get('AUXILIARY')?.value).toBe(auxiliaryStrategy.getAuxiliaryIdentifier(resourceID).path);
});

Expand Down Expand Up @@ -690,7 +690,7 @@ describe('A DataAccessorBasedStore', (): void => {
{ path: root },
]);
expect(accessor.data[`${root}resource`]).toBeUndefined();
expect(accessor.data[`${root}resource.dummy`]).not.toBeUndefined();
expect(accessor.data[`${root}resource.dummy`]).toBeDefined();
expect(logger.error).toHaveBeenCalledTimes(1);
expect(logger.error).toHaveBeenLastCalledWith(
'Error deleting auxiliary resource http://test.com/resource.dummy: auxiliary error!',
Expand Down
6 changes: 3 additions & 3 deletions test/unit/storage/conversion/ConversionUtil.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,16 +109,16 @@ describe('ConversionUtil', (): void => {
describe('#matchesMediaPreferences', (): void => {
it('returns false if there are no matches.', async(): Promise<void> => {
const preferences: ValuePreferences = { 'a/x': 1, 'b/x': 0.5, 'c/x': 0 };
expect(matchesMediaPreferences('c/x', preferences)).toEqual(false);
expect(matchesMediaPreferences('c/x', preferences)).toBe(false);
});

it('returns true if there are matches.', async(): Promise<void> => {
const preferences: ValuePreferences = { 'a/x': 1, 'b/x': 0.5, 'c/x': 0 };
expect(matchesMediaPreferences('b/x', preferences)).toEqual(true);
expect(matchesMediaPreferences('b/x', preferences)).toBe(true);
});

it('matches anything if there are no preferences.', async(): Promise<void> => {
expect(matchesMediaPreferences('a/a')).toEqual(true);
expect(matchesMediaPreferences('a/a')).toBe(true);
});

it('does not match internal types if not in the preferences.', async(): Promise<void> => {
Expand Down
8 changes: 4 additions & 4 deletions test/unit/storage/conversion/QuadToRdfConverter.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ describe('A QuadToRdfConverter', (): void => {
binary: true,
metadata: expect.any(RepresentationMetadata),
});
expect(result.metadata.contentType).toEqual('text/turtle');
expect(result.metadata.contentType).toBe('text/turtle');
await expect(readableToString(result.data)).resolves.toEqual(
`<http://test.com/s> <http://test.com/p> <http://test.com/o>.
`,
Expand All @@ -78,7 +78,7 @@ describe('A QuadToRdfConverter', (): void => {
metadata);
const preferences: RepresentationPreferences = { type: { 'text/turtle': 1 }};
const result = await converter.handle({ identifier, representation, preferences });
expect(result.metadata.contentType).toEqual('text/turtle');
expect(result.metadata.contentType).toBe('text/turtle');
await expect(readableToString(result.data)).resolves.toEqual(
`@prefix dc: <http://purl.org/dc/terms/>.
@prefix test: <http://test.com/>.
Expand All @@ -97,7 +97,7 @@ test:s dc:modified test:o.
metadata);
const preferences: RepresentationPreferences = { type: { 'text/turtle': 1 }};
const result = await converter.handle({ identifier, representation, preferences });
expect(result.metadata.contentType).toEqual('text/turtle');
expect(result.metadata.contentType).toBe('text/turtle');
await expect(readableToString(result.data)).resolves.toEqual(
`<> <#abc> <def/ghi>.
`,
Expand All @@ -118,7 +118,7 @@ test:s dc:modified test:o.
binary: true,
metadata: expect.any(RepresentationMetadata),
});
expect(result.metadata.contentType).toEqual('application/ld+json');
expect(result.metadata.contentType).toBe('application/ld+json');
await expect(readableToString(result.data)).resolves.toEqual(
`[
{
Expand Down
2 changes: 1 addition & 1 deletion test/unit/storage/keyvalue/WrappedExpiringStorage.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ describe('A WrappedExpiringStorage', (): void => {

it('returns data if it has not expired.', async(): Promise<void> => {
source.get.mockResolvedValueOnce(createExpires('data!', tomorrow));
await expect(storage.get('key')).resolves.toEqual('data!');
await expect(storage.get('key')).resolves.toBe('data!');
});

it('deletes expired data when trying to get it.', async(): Promise<void> => {
Expand Down
54 changes: 27 additions & 27 deletions test/unit/util/PathUtil.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,17 +25,17 @@ import {
describe('PathUtil', (): void => {
describe('#normalizeFilePath', (): void => {
it('normalizes POSIX paths.', async(): Promise<void> => {
expect(normalizeFilePath('/foo/bar/../baz')).toEqual('/foo/baz');
expect(normalizeFilePath('/foo/bar/../baz')).toBe('/foo/baz');
});

it('normalizes Windows paths.', async(): Promise<void> => {
expect(normalizeFilePath('c:\\foo\\bar\\..\\baz')).toEqual('c:/foo/baz');
expect(normalizeFilePath('c:\\foo\\bar\\..\\baz')).toBe('c:/foo/baz');
});
});

describe('#joinFilePath', (): void => {
it('joins POSIX paths.', async(): Promise<void> => {
expect(joinFilePath('/foo/bar/', '..', '/baz')).toEqual('/foo/baz');
expect(joinFilePath('/foo/bar/', '..', '/baz')).toBe('/foo/baz');
});

it('joins Windows paths.', async(): Promise<void> => {
Expand All @@ -45,11 +45,11 @@ describe('PathUtil', (): void => {

describe('#absoluteFilePath', (): void => {
it('does not change absolute posix paths.', async(): Promise<void> => {
expect(absoluteFilePath('/foo/bar/')).toEqual('/foo/bar/');
expect(absoluteFilePath('/foo/bar/')).toBe('/foo/bar/');
});

it('converts absolute win32 paths to posix paths.', async(): Promise<void> => {
expect(absoluteFilePath('C:\\foo\\bar')).toEqual('C:/foo/bar');
expect(absoluteFilePath('C:\\foo\\bar')).toBe('C:/foo/bar');
});

it('makes relative paths absolute.', async(): Promise<void> => {
Expand All @@ -59,70 +59,70 @@ describe('PathUtil', (): void => {

describe('#ensureTrailingSlash', (): void => {
it('makes sure there is always exactly 1 slash.', async(): Promise<void> => {
expect(ensureTrailingSlash('http://test.com')).toEqual('http://test.com/');
expect(ensureTrailingSlash('http://test.com/')).toEqual('http://test.com/');
expect(ensureTrailingSlash('http://test.com//')).toEqual('http://test.com/');
expect(ensureTrailingSlash('http://test.com///')).toEqual('http://test.com/');
expect(ensureTrailingSlash('http://test.com')).toBe('http://test.com/');
expect(ensureTrailingSlash('http://test.com/')).toBe('http://test.com/');
expect(ensureTrailingSlash('http://test.com//')).toBe('http://test.com/');
expect(ensureTrailingSlash('http://test.com///')).toBe('http://test.com/');
});
});

describe('#trimTrailingSlashes', (): void => {
it('removes all trailing slashes.', async(): Promise<void> => {
expect(trimTrailingSlashes('http://test.com')).toEqual('http://test.com');
expect(trimTrailingSlashes('http://test.com/')).toEqual('http://test.com');
expect(trimTrailingSlashes('http://test.com//')).toEqual('http://test.com');
expect(trimTrailingSlashes('http://test.com///')).toEqual('http://test.com');
expect(trimTrailingSlashes('http://test.com')).toBe('http://test.com');
expect(trimTrailingSlashes('http://test.com/')).toBe('http://test.com');
expect(trimTrailingSlashes('http://test.com//')).toBe('http://test.com');
expect(trimTrailingSlashes('http://test.com///')).toBe('http://test.com');
});
});

describe('#getExtension', (): void => {
it('returns the extension of a path.', async(): Promise<void> => {
expect(getExtension('/a/b.txt')).toEqual('txt');
expect(getExtension('/a/btxt')).toEqual('');
expect(getExtension('/a/b.txt')).toBe('txt');
expect(getExtension('/a/btxt')).toBe('');
});
});

describe('#toCanonicalUriPath', (): void => {
it('encodes only the necessary parts.', async(): Promise<void> => {
expect(toCanonicalUriPath('/a%20path&/name')).toEqual('/a%20path%26/name');
expect(toCanonicalUriPath('/a%20path&/name')).toBe('/a%20path%26/name');
});

it('leaves the query string untouched.', async(): Promise<void> => {
expect(toCanonicalUriPath('/a%20path&/name?abc=def&xyz')).toEqual('/a%20path%26/name?abc=def&xyz');
expect(toCanonicalUriPath('/a%20path&/name?abc=def&xyz')).toBe('/a%20path%26/name?abc=def&xyz');
});
});

describe('#decodeUriPathComponents', (): void => {
it('decodes all parts of a path.', async(): Promise<void> => {
expect(decodeUriPathComponents('/a%20path&/name')).toEqual('/a path&/name');
expect(decodeUriPathComponents('/a%20path&/name')).toBe('/a path&/name');
});

it('leaves the query string untouched.', async(): Promise<void> => {
expect(decodeUriPathComponents('/a%20path&/name?abc=def&xyz')).toEqual('/a path&/name?abc=def&xyz');
expect(decodeUriPathComponents('/a%20path&/name?abc=def&xyz')).toBe('/a path&/name?abc=def&xyz');
});
});

describe('#encodeUriPathComponents', (): void => {
it('encodes all parts of a path.', async(): Promise<void> => {
expect(encodeUriPathComponents('/a%20path&/name')).toEqual('/a%2520path%26/name');
expect(encodeUriPathComponents('/a%20path&/name')).toBe('/a%2520path%26/name');
});

it('leaves the query string untouched.', async(): Promise<void> => {
expect(encodeUriPathComponents('/a%20path&/name?abc=def&xyz')).toEqual('/a%2520path%26/name?abc=def&xyz');
expect(encodeUriPathComponents('/a%20path&/name?abc=def&xyz')).toBe('/a%2520path%26/name?abc=def&xyz');
});
});

describe('#isContainerPath', (): void => {
it('returns true if the path ends with a slash.', async(): Promise<void> => {
expect(isContainerPath('/a/b')).toEqual(false);
expect(isContainerPath('/a/b/')).toEqual(true);
expect(isContainerPath('/a/b')).toBe(false);
expect(isContainerPath('/a/b/')).toBe(true);
});
});

describe('#isContainerIdentifier', (): void => {
it('works af isContainerPath but for identifiers.', async(): Promise<void> => {
expect(isContainerIdentifier({ path: '/a/b' })).toEqual(false);
expect(isContainerIdentifier({ path: '/a/b/' })).toEqual(true);
expect(isContainerIdentifier({ path: '/a/b' })).toBe(false);
expect(isContainerIdentifier({ path: '/a/b/' })).toBe(true);
});
});

Expand Down Expand Up @@ -159,8 +159,8 @@ describe('PathUtil', (): void => {
const regex = createSubdomainRegexp('http://test.com/foo/');
expect(regex.exec('http://test.com/foo/')![1]).toBeUndefined();
expect(regex.exec('http://test.com/foo/bar')![1]).toBeUndefined();
expect(regex.exec('http://alice.test.com/foo/')![1]).toEqual('alice');
expect(regex.exec('http://alice.bob.test.com/foo/')![1]).toEqual('alice.bob');
expect(regex.exec('http://alice.test.com/foo/')![1]).toBe('alice');
expect(regex.exec('http://alice.bob.test.com/foo/')![1]).toBe('alice.bob');
expect(regex.exec('http://test.com/')).toBeNull();
expect(regex.exec('http://alicetest.com/foo/')).toBeNull();
});
Expand Down
Loading

0 comments on commit af04912

Please sign in to comment.