Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: enforce the recommended linting rules for some files #279

Merged
merged 1 commit into from
Sep 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 25 additions & 13 deletions .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,29 @@
"prettier"
],
"parser": "@typescript-eslint/parser",
"rules": {
"prefer-const": "warn",
"no-var": "warn",
"no-self-assign": "warn",
"no-case-declarations": "warn",
"no-constant-condition": "warn",
"no-empty": "warn",
"@typescript-eslint/no-non-null-asserted-optional-chain": "warn",
"@typescript-eslint/no-explicit-any": "warn",
"@typescript-eslint/no-namespace": "warn",
"@typescript-eslint/ban-types": "warn",
"@typescript-eslint/no-unused-vars": "warn"
}
"overrides": [
{
// These are files with more lenient lint config because they have not been "fixed" yet
// Once a directory here is fixed, it should be removed from here so the strict rules applies
"files": [
"src/keri/app/**",
"src/keri/core/**",
"src/keri/end/**",
"examples/integration-scripts/**"
],
"rules": {
"prefer-const": "warn",
"no-var": "warn",
"no-self-assign": "warn",
"no-case-declarations": "warn",
"no-constant-condition": "warn",
"no-empty": "warn",
"@typescript-eslint/no-non-null-asserted-optional-chain": "warn",
"@typescript-eslint/no-explicit-any": "warn",
"@typescript-eslint/no-namespace": "warn",
"@typescript-eslint/ban-types": "warn",
"@typescript-eslint/no-unused-vars": "warn"
}
}
]
}
14 changes: 7 additions & 7 deletions test/app/clienting.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -360,18 +360,18 @@ describe('SignifyClient', () => {
'EGFi9pCcRaLK8dPh5S7JP9Em62fBMiR1l4gW1ZazuuAO'
);

let heads = new Headers();
const heads = new Headers();
heads.set('Content-Type', 'application/json');
let treqInit = {
const treqInit = {
headers: heads,
method: 'POST',
body: JSON.stringify({ foo: true }),
};
let turl = 'http://example.com/test';
let treq = await client.createSignedRequest('aid1', turl, treqInit);
let tres = await fetch(treq);
const turl = 'http://example.com/test';
const treq = await client.createSignedRequest('aid1', turl, treqInit);
await fetch(treq);
lastCall = fetchMock.mock.calls[fetchMock.mock.calls.length - 1]!;
let resReq = lastCall[0] as Request;
const resReq = lastCall[0] as Request;
assert.equal(resReq.url, 'http://example.com/test');
assert.equal(resReq.method, 'POST');
lastBody = await resReq.json();
Expand All @@ -398,7 +398,7 @@ describe('SignifyClient', () => {
true
);

let aid = await client.identifiers().get('aid1');
const aid = await client.identifiers().get('aid1');
const keeper = client.manager!.get(aid);
const signer = keeper.signers[0];
const created = lastHeaders
Expand Down
8 changes: 4 additions & 4 deletions test/app/credentialing.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -548,7 +548,7 @@ describe('Ipex', () => {
const ipex = client.ipex();

const holder = 'ELjSFdrTdCebJlmvbFNX9-TLhR2PO0_60al1kQp5_e6k';
const [_, acdc] = Saider.saidify(mockCredential.sad);
const [, acdc] = Saider.saidify(mockCredential.sad);

// Create iss
const vs = versify(Ident.KERI, undefined, Serials.JSON, 0);
Expand All @@ -562,7 +562,7 @@ describe('Ipex', () => {
dt: mockCredential.sad.a.dt,
};

const [issSaider, iss] = Saider.saidify(_iss);
const [, iss] = Saider.saidify(_iss);
const iserder = new Serder(iss);
const anc = interact({
pre: mockCredential.sad.i,
Expand Down Expand Up @@ -848,7 +848,7 @@ describe('Ipex', () => {
const ipex = client.ipex();

const holder = 'ELjSFdrTdCebJlmvbFNX9-TLhR2PO0_60al1kQp5_e6k';
const [_, acdc] = Saider.saidify(mockCredential.sad);
const [, acdc] = Saider.saidify(mockCredential.sad);

const [offer, offerSigs, offerEnd] = await ipex.offer({
senderName: 'multisig',
Expand Down Expand Up @@ -898,7 +898,7 @@ describe('Ipex', () => {
await ipex.submitOffer('multisig', offer, offerSigs, offerEnd, [
holder,
]);
let lastCall = fetchMock.mock.calls[fetchMock.mock.calls.length - 1]!;
const lastCall = fetchMock.mock.calls[fetchMock.mock.calls.length - 1]!;
assert.equal(
lastCall[0],
'http://127.0.0.1:3901/identifiers/multisig/ipex/offer'
Expand Down
2 changes: 1 addition & 1 deletion test/app/delegating.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ describe('delegate', () => {
},
};
assert.equal(
lastCall[1]!.body?.toString()!,
lastCall[1]?.body?.toString(),
JSON.stringify(expectedBody)
);
});
Expand Down
9 changes: 4 additions & 5 deletions test/app/exchanging.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import { strict as assert } from 'assert';
import {
b,
d,
Dict,
Diger,
exchange,
Ilks,
Expand Down Expand Up @@ -234,7 +233,7 @@ describe('exchange', () => {
b: [],
c: [],
a: [],
} as Dict<any>;
};

const serder = new Serder(ked0);
const siger = skp0.sign(b(serder.raw), 0);
Expand All @@ -251,13 +250,13 @@ describe('exchange', () => {
s: '0',
bt: toad.toString(16),
b: [],
} as Dict<any>;
};
const vcp = new Serder(ked1);

const embeds = {
icp: [serder, siger.qb64],
vcp: [vcp, undefined],
} as Dict<any>;
};

[exn, end] = exchange(
'/multisig/vcp',
Expand Down Expand Up @@ -373,7 +372,7 @@ describe('exchange', () => {
b: [],
c: [],
a: [],
} as Dict<any>;
};

const serder = new Serder(ked0);

Expand Down
2 changes: 1 addition & 1 deletion test/core/counter.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ describe('int to b64 and back', () => {
});

// verify all Codes have hs > 0 and ss > 0 and fs = hs + ss and not fs % 4
Counter.Sizes.forEach((val, _) => {
Counter.Sizes.forEach((val) => {
assert.equal(
val.hs > 0 &&
val.ss > 0 &&
Expand Down
1 change: 0 additions & 1 deletion test/core/eventing.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import { Saider } from '../../src/keri/core/saider';
import { Diger } from '../../src/keri/core/diger';
import { b, d, Ilks } from '../../src/keri/core/core';
import { Siger } from '../../src/keri/core/siger';
import { randomBytes } from 'crypto';

describe('key event function', () => {
it('incept should create inception events', async () => {
Expand Down
3 changes: 1 addition & 2 deletions test/core/prefixer.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import libsodium from 'libsodium-wrappers-sumo';
import {
Dict,
Ident,
Ilks,
Serials,
Expand Down Expand Up @@ -50,7 +49,7 @@ describe('Prefixer', () => {
wt: toad.toString(16), // hex string no leading zeros lowercase
w: wits, // list of qb64 may be empty
c: cnfg, // list of config ordered mappings may be empty
} as Dict<any>;
};

prefixer = new Prefixer({ code: MtrDex.Blake3_256 }, ked);
assert.equal(
Expand Down
12 changes: 3 additions & 9 deletions test/core/saider.test.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,4 @@
import {
Dict,
Ident,
Serials,
versify,
Versionage,
} from '../../src/keri/core/core';
import { Ident, Serials, versify, Versionage } from '../../src/keri/core/core';
import { strict as assert } from 'assert';
import { MtrDex } from '../../src/keri/core/matter';
import libsodium from 'libsodium-wrappers-sumo';
Expand All @@ -30,8 +24,8 @@ describe('Saider', () => {
i: 'EB0_D51cTh_q6uOQ-byFiv5oNXZ-cxdqCqBAa4JmBLtb',
name: 'John Jones',
role: 'Founder',
} as Dict<any>,
} as Dict<any>;
},
};
const saider = new Saider({}, sad4); // default version string code, kind, and label
assert.equal(saider.code, code);
assert.equal(
Expand Down
19 changes: 8 additions & 11 deletions test/core/serder.test.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,4 @@
import {
deversify,
Dict,
Ilks,
Serials,
Version,
} from '../../src/keri/core/core';
import { deversify, Ilks, Serials, Version } from '../../src/keri/core/core';
import { strict as assert } from 'assert';
import { Salter, Tier } from '../../src/keri/core/salter';
import { MtrDex } from '../../src/keri/core/matter';
Expand Down Expand Up @@ -72,7 +66,7 @@ describe('Serder', () => {
b: [],
c: [],
a: [],
} as Dict<any>;
};

const serder = new Serder(ked0);
assert.equal(
Expand All @@ -92,9 +86,12 @@ describe('Serder', () => {
aid0 = new Prefixer({ code: MtrDex.Blake3_256 }, ked0);
assert.equal(aid0.qb64, 'ECHOi6qRaswNpvytpCtpvEh2cB2aLAwVHBLFinno3YVW');

const ked1 = ked0;
ked1.a = { n: 'Lenksjö' };
const serder1 = new Serder(ked1);
const serder1 = new Serder({
...ked0,
a: {
n: 'Lenksjö',
},
});
assert.equal(serder1.ked.v, 'KERI10JSON000139_');
});
});
Loading