Skip to content

Commit 8f3edef

Browse files
Merge pull request #2456 from o1-labs/leon/oxlint-too-loud
improvement: turn off no-unused-vars everywhere except `src/lib`, and fixed `no-unused-vars` in `src/lib`
2 parents 322acd7 + 3029ed1 commit 8f3edef

File tree

10 files changed

+50
-114
lines changed

10 files changed

+50
-114
lines changed

.oxlintrc.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
{
2-
"extends": "oxlint/recommended",
2+
"extends": ["oxlint/recommended"],
33
"rules": {
44
"erasing-op": "off",
55
"no-new-array": "off",
66
"no-this-alias": "off",
77
"no-unsafe-finally": "off",
88
"no-unused-labels": "off",
99
"no-useless-escape": "off",
10-
"no-wrapper-object-types": "off"
10+
"no-wrapper-object-types": "off",
11+
"no-unused-vars": "off"
1112
},
1213
"ignorePatterns": [
1314
"_build/",

src/lib/.oxlintrc.json

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"extends": ["oxlint/recommended"],
3+
"rules": {
4+
"erasing-op": "off",
5+
"no-new-array": "off",
6+
"no-this-alias": "off",
7+
"no-unsafe-finally": "off",
8+
"no-unused-labels": "off",
9+
"no-useless-escape": "off",
10+
"no-wrapper-object-types": "off"
11+
}
12+
}

src/lib/proof-system/lazy-mode.unit-test.ts

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,12 @@
1-
import { Field } from '../provable/field.js';
1+
import { spawn } from 'child_process';
2+
import { basename, dirname, join } from 'path';
3+
import { fileURLToPath } from 'url';
4+
import { wasm } from '../../bindings.js';
25
import { Cache } from '../proof-system/cache.js';
36
import { ZkProgram } from '../proof-system/zkprogram.js';
4-
import { Spec, fieldWithRng } from '../testing/equivalent.js';
5-
import { Random } from '../testing/property.js';
7+
import { Field } from '../provable/field.js';
68
import { assert } from '../provable/gadgets/common.js';
79
import { Gadgets } from '../provable/gadgets/gadgets.js';
8-
import { wasm } from '../../bindings.js';
9-
import { spawn } from 'child_process';
10-
import { fileURLToPath } from 'url';
11-
import { dirname, join, basename } from 'path';
1210

1311
// Path resolution for subprocess execution
1412
const __filename = fileURLToPath(import.meta.url);
@@ -22,10 +20,6 @@ function getMemory() {
2220
};
2321
}
2422

25-
let uint = (n: number | bigint): Spec<bigint, Field> => {
26-
return fieldWithRng(Random.bignat((1n << BigInt(n)) - 1n));
27-
};
28-
2923
// Dummy circuit
3024
let LazyMode = ZkProgram({
3125
name: 'lazy-mode',
@@ -82,7 +76,11 @@ function runSubprocess(lazyMode: boolean): Promise<void> {
8276
});
8377
child.on('exit', (code) => {
8478
console.log(`(Parent) Process lazyMode=${lazyMode} exited with code ${code}`);
85-
code === 0 ? resolve() : reject(new Error(`Test failed for lazyMode=${lazyMode}`));
79+
if (code === 0) {
80+
resolve();
81+
} else {
82+
reject(new Error(`Test failed for lazyMode=${lazyMode}`));
83+
}
8684
});
8785
});
8886
}

src/lib/proof-system/recursive.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
import { InferProvable } from '../provable/types/struct.js';
1+
import { From } from '../../bindings/lib/provable-generic.js';
2+
import { Bool } from '../provable/bool.js';
23
import { Provable } from '../provable/provable.js';
34
import { ProvableType } from '../provable/types/provable-intf.js';
5+
import { InferProvable } from '../provable/types/struct.js';
6+
import { mapObject, mapToObject, zip } from '../util/arrays.js';
47
import { Tuple } from '../util/types.js';
58
import { Proof } from './proof.js';
6-
import { mapObject, mapToObject, zip } from '../util/arrays.js';
79
import { Undefined, Void } from './zkprogram.js';
8-
import { Bool } from '../provable/bool.js';
9-
import { From } from '../../bindings/lib/provable-generic.js';
1010

1111
export { Recursive };
1212

@@ -69,7 +69,7 @@ function Recursive<
6969

7070
let methodKeys: MethodKey[] = Object.keys(methods);
7171

72-
let regularRecursiveProvers = mapToObject(methodKeys, (key, i) => {
72+
let regularRecursiveProvers = mapToObject(methodKeys, (key) => {
7373
return async function proveRecursively_(
7474
conditionAndConfig: Bool | { condition: Bool; domainLog2?: number },
7575
publicInput: PublicInput,

src/lib/provable/gadgets/blake2b.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import { FlexibleBytes } from '../bytes.js';
44
import { Bytes } from '../wrapped-classes.js';
55
import { Gadgets } from './gadgets.js';
66
import { assert } from '../../util/errors.js';
7-
import { Provable } from '../provable.js';
87
import { wordToBytes } from './bit-slices.js';
98

109
export { BLAKE2B };

src/lib/provable/group.ts

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
1-
import { Field } from './field.js';
2-
import { FieldVar } from './core/fieldvar.js';
3-
import { Scalar } from './scalar.js';
4-
import { Fp } from '../../bindings/crypto/finite-field.js';
51
import { GroupAffine, Pallas, PallasAffine } from '../../bindings/crypto/elliptic-curve.js';
6-
import { Provable } from './provable.js';
7-
import { Bool } from './bool.js';
2+
import { Fp } from '../../bindings/crypto/finite-field.js';
83
import { assert } from '../util/assert.js';
4+
import { FieldVar } from './core/fieldvar.js';
5+
import { Field } from './field.js';
96
import { add, scaleField, scaleShifted } from './gadgets/native-curve.js';
7+
import { Provable } from './provable.js';
8+
import { Scalar } from './scalar.js';
109

1110
export { Group };
1211

@@ -265,7 +264,7 @@ class Group {
265264
*
266265
* Returns an empty array.
267266
*/
268-
static toAuxiliary(g?: Group) {
267+
static toAuxiliary(_?: Group) {
269268
return [];
270269
}
271270

src/lib/provable/packed.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
1-
import { mapValue, provableFromClass } from './types/provable-derivers.js';
2-
import { HashInput, ProvableExtended } from './types/struct.js';
3-
import { Unconstrained } from './types/unconstrained.js';
1+
import { Poseidon, ProvableHashable, packToFields } from './crypto/poseidon.js';
42
import { Field } from './field.js';
53
import { assert } from './gadgets/common.js';
6-
import { Poseidon, ProvableHashable, packToFields } from './crypto/poseidon.js';
74
import { Provable } from './provable.js';
85
import { fields, modifiedField } from './types/fields.js';
6+
import { mapValue, provableFromClass } from './types/provable-derivers.js';
97
import { ProvableType, WithProvable } from './types/provable-intf.js';
8+
import { HashInput } from './types/struct.js';
9+
import { Unconstrained } from './types/unconstrained.js';
1010

11-
export { Packed, Hashed };
11+
export { Hashed, Packed };
1212

1313
/**
1414
* `Packed<T>` is a "packed" representation of any type `T`.

src/lib/provable/test/blake2b.unit-test.ts

Lines changed: 6 additions & 7 deletions
Large diffs are not rendered by default.

src/lib/provable/test/group.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Bool, Group, Scalar, Provable } from 'o1js';
1+
import { Bool, Group, Provable, Scalar } from 'o1js';
22

33
describe('group', () => {
44
let g = Group({ x: -1, y: 2 });
@@ -359,7 +359,7 @@ describe('group', () => {
359359
});
360360

361361
it('sub', () => {
362-
let y = Provable.witness(Group, () => g).assertEquals(Provable.witness(Group, () => g));
362+
Provable.witness(Group, () => g).assertEquals(Provable.witness(Group, () => g));
363363
g.assertEquals(g);
364364
});
365365
});

src/lib/provable/test/string.unit-test.ts

Lines changed: 1 addition & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -40,66 +40,6 @@ describe('Circuit String', () => {
4040
});
4141
});
4242

43-
/* describe('#contains', () => {
44-
test('returns true when str contains other str', () => {
45-
const str = CircuitString.fromString(
46-
'Everything we hear is an opinion, not a fact. Everything we see is a perspective, not the truth'
47-
);
48-
const contained_str = CircuitString.fromString(
49-
'Everything we hear is an opinion, not a fact.'
50-
);
51-
expect(str.contains(contained_str)).toEqual(new Bool(true));
52-
53-
await Provable.runAndCheck(() => {
54-
const str = CircuitString.fromString(
55-
'Everything we hear is an opinion, not a fact. Everything we see is a perspective, not the truth'
56-
);
57-
const contained_str = CircuitString.fromString(
58-
'Everything we hear is an opinion, not a fact.'
59-
);
60-
expect(str.contains(contained_str)).toEqual(new Bool(true));
61-
});
62-
});
63-
64-
test('returns false when str does not contain other str', () => {
65-
const str = CircuitString.fromString('abcdefghijklmnop');
66-
const not_contained_str = CircuitString.fromString('defhij');
67-
expect(str.contains(not_contained_str)).toEqual(new Bool(false));
68-
69-
await Provable.runAndCheck(() => {
70-
const str = CircuitString.fromString('abcdefghijklmnop');
71-
const not_contained_str = CircuitString.fromString('defhij');
72-
expect(str.contains(not_contained_str)).toEqual(new Bool(false));
73-
});
74-
});
75-
76-
describe('compatibility with implementing classes', () => {
77-
test('string8 may contain string', () => {
78-
const str = CircuitString8.fromString('abcd');
79-
const contained_str = CircuitString.fromString('ab');
80-
expect(str.contains(contained_str)).toEqual(new Bool(true));
81-
82-
await Provable.runAndCheck(() => {
83-
const str = CircuitString8.fromString('abcd');
84-
const contained_str = CircuitString.fromString('ab');
85-
expect(str.contains(contained_str)).toEqual(new Bool(true));
86-
});
87-
});
88-
89-
test('string may contain string8', () => {
90-
const str = CircuitString.fromString('abcd');
91-
const contained_str = CircuitString8.fromString('ab');
92-
expect(str.contains(contained_str)).toEqual(new Bool(true));
93-
94-
await Provable.runAndCheck(() => {
95-
const str = CircuitString.fromString('abcd');
96-
const contained_str = CircuitString8.fromString('ab');
97-
expect(str.contains(contained_str)).toEqual(new Bool(true));
98-
});
99-
});
100-
});
101-
}); */
102-
10343
describe('#toString', () => {
10444
test('serializes to string', async () => {
10545
const js_str =
@@ -158,23 +98,11 @@ describe('Circuit String', () => {
15898
});
15999
});
160100

161-
/* describe('CircuitString8', async () => {
162-
test('cannot create more than 8 chars', () => {
163-
expect(() => {
164-
await Provable.runAndCheck(() => {
165-
Provable.witness(CircuitString8, () => {
166-
return CircuitString8.fromString('More than eight chars');
167-
});
168-
});
169-
}).toThrow();
170-
});
171-
}); */
172-
173101
describe.skip('with invalid input', () => {
174102
test('cannot use a character out of range', () => {
175103
expect(() => {
176104
Provable.runAndCheck(() => {
177-
const str = Provable.witness(CircuitString, () => {
105+
Provable.witness(CircuitString, () => {
178106
return CircuitString.fromCharacters([
179107
new Character(Field(100)),
180108
new Character(Field(10000)),

0 commit comments

Comments
 (0)