Skip to content

Commit

Permalink
fix new linting errors
Browse files Browse the repository at this point in the history
  • Loading branch information
bdemann committed Dec 11, 2024
1 parent 1191b6e commit f71f048
Show file tree
Hide file tree
Showing 10 changed files with 53 additions and 54 deletions.
3 changes: 1 addition & 2 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import eslint from '@eslint/js';
import tseslint from 'typescript-eslint';
import tseslintParser from '@typescript-eslint/parser';
import prettier from 'eslint-config-prettier';
import simpleImportSort from 'eslint-plugin-simple-import-sort';
import tseslint from 'typescript-eslint';

export default tseslint.config(
// Base ESLint configuration
Expand Down Expand Up @@ -64,7 +64,6 @@ export default tseslint.config(
eqeqeq: 'error',
'@typescript-eslint/no-unused-vars': [
'error',
// Ignore argument variables starting with _
{
argsIgnorePattern: '^_',
caughtErrorsIgnorePattern: '^_',
Expand Down
8 changes: 4 additions & 4 deletions tests/end_to_end/http_server/tfjs/src/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ async function init(): Promise<void> {

tf.env().platform = {
fetch,
now: () => Number(ic.time()), // TODO time probably off (look into nano vs milli)
encode: (text) => Buffer.from(text),
decode: (bytes) => Buffer.from(bytes).toString(),
isTypedArray: ((array: any) => {
now: (): number => Number(ic.time()), // TODO time probably off (look into nano vs milli)
encode: (text: string): Buffer => Buffer.from(text),
decode: (bytes: Uint8Array): string => Buffer.from(bytes).toString(),
isTypedArray: ((array: any): boolean => {
return (array instanceof Float32Array ||
array instanceof Int32Array ||
array instanceof Uint8Array ||
Expand Down
12 changes: 6 additions & 6 deletions type_tests/candid/constructed/opt.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,21 +20,21 @@ import {
testCandidType(Opt(float32));
testSerializable(Opt(float32));

const testTypeMapping = Opt(float32);
const _testTypeMapping = Opt(float32);
export type TestTypeMapping = AssertType<
NotAnyAndExact<
TypeMapping<typeof testTypeMapping>,
TypeMapping<typeof _testTypeMapping>,
RequireExactlyOne<{ Some: number; None: null }>
>
>;

testCandidType(Opt(Opt(float32)));
testSerializable(Opt(Opt(float32)));

const testTypeMappingDouble = Opt(Opt(float32));
const _testTypeMappingDouble = Opt(Opt(float32));
export type TestTypeMappingDouble = AssertType<
NotAnyAndExact<
TypeMapping<typeof testTypeMappingDouble>,
TypeMapping<typeof _testTypeMappingDouble>,
RequireExactlyOne<{
Some: RequireExactlyOne<{ Some: number; None: null }>;
None: null;
Expand All @@ -45,10 +45,10 @@ export type TestTypeMappingDouble = AssertType<
testCandidType(Opt(Opt(Opt(float32))));
testSerializable(Opt(Opt(Opt(float32))));

const testTypeMappingTriple = Opt(Opt(Opt(float32)));
const _testTypeMappingTriple = Opt(Opt(Opt(float32)));
export type TestTypeMappingTriple = AssertType<
NotAnyAndExact<
TypeMapping<typeof testTypeMappingTriple>,
TypeMapping<typeof _testTypeMappingTriple>,
RequireExactlyOne<{
Some: RequireExactlyOne<{
Some: RequireExactlyOne<{ Some: number; None: null }>;
Expand Down
44 changes: 22 additions & 22 deletions type_tests/candid/constructed/vec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,105 +28,105 @@ import {
testCandidType(Vec(float32));
testSerializable(Vec(float32));

const testTypeMapping = Vec(float32);
const _testTypeMapping = Vec(float32);
export type TestTypeMapping = AssertType<
NotAnyAndExact<TypeMapping<typeof testTypeMapping>, number[]>
NotAnyAndExact<TypeMapping<typeof _testTypeMapping>, number[]>
>;

testCandidType(Vec(Vec(float32)));
testSerializable(Vec(Vec(float32)));

const testTypeMappingDouble = Vec(Vec(float32));
const _testTypeMappingDouble = Vec(Vec(float32));
export type TestTypeMappingDouble = AssertType<
NotAnyAndExact<TypeMapping<typeof testTypeMappingDouble>, number[][]>
NotAnyAndExact<TypeMapping<typeof _testTypeMappingDouble>, number[][]>
>;

testCandidType(Vec(Vec(Vec(float32))));
testSerializable(Vec(Vec(Vec(float32))));

const testTypeMappingTriple = Vec(Vec(Vec(float32)));
const _testTypeMappingTriple = Vec(Vec(Vec(float32)));
export type TestTypeMappingTriple = AssertType<
NotAnyAndExact<TypeMapping<typeof testTypeMappingTriple>, number[][][]>
NotAnyAndExact<TypeMapping<typeof _testTypeMappingTriple>, number[][][]>
>;

// test nat64

testCandidType(Vec(nat64));
testSerializable(Vec(nat64));

const testTypeMappingNat64 = Vec(nat64);
const _testTypeMappingNat64 = Vec(nat64);
export type TestTypeMappingNat64 = AssertType<
NotAnyAndExact<TypeMapping<typeof testTypeMappingNat64>, BigUint64Array>
NotAnyAndExact<TypeMapping<typeof _testTypeMappingNat64>, BigUint64Array>
>;

// test nat32

testCandidType(Vec(nat32));
testSerializable(Vec(nat32));

const testTypeMappingNat32 = Vec(nat32);
const _testTypeMappingNat32 = Vec(nat32);
export type TestTypeMappingNat32 = AssertType<
NotAnyAndExact<TypeMapping<typeof testTypeMappingNat32>, Uint32Array>
NotAnyAndExact<TypeMapping<typeof _testTypeMappingNat32>, Uint32Array>
>;

// test nat16

testCandidType(Vec(nat16));
testSerializable(Vec(nat16));

const testTypeMappingNat16 = Vec(nat16);
const _testTypeMappingNat16 = Vec(nat16);
export type TestTypeMappingNat16 = AssertType<
NotAnyAndExact<TypeMapping<typeof testTypeMappingNat16>, Uint16Array>
NotAnyAndExact<TypeMapping<typeof _testTypeMappingNat16>, Uint16Array>
>;

// test nat8

testCandidType(Vec(nat8));
testSerializable(Vec(nat8));

const testTypeMappingNat8 = Vec(nat8);
const _testTypeMappingNat8 = Vec(nat8);
export type TestTypeMappingNat8 = AssertType<
NotAnyAndExact<TypeMapping<typeof testTypeMappingNat8>, Uint8Array>
NotAnyAndExact<TypeMapping<typeof _testTypeMappingNat8>, Uint8Array>
>;

// test int64

testCandidType(Vec(int64));
testSerializable(Vec(int64));

const testTypeMappingInt64 = Vec(int64);
const _testTypeMappingInt64 = Vec(int64);
export type TestTypeMappingInt64 = AssertType<
NotAnyAndExact<TypeMapping<typeof testTypeMappingInt64>, BigInt64Array>
NotAnyAndExact<TypeMapping<typeof _testTypeMappingInt64>, BigInt64Array>
>;

// test int32

testCandidType(Vec(int32));
testSerializable(Vec(int32));

const testTypeMappingInt32 = Vec(int32);
const _testTypeMappingInt32 = Vec(int32);
export type TestTypeMappingInt32 = AssertType<
NotAnyAndExact<TypeMapping<typeof testTypeMappingInt32>, Int32Array>
NotAnyAndExact<TypeMapping<typeof _testTypeMappingInt32>, Int32Array>
>;

// test int16

testCandidType(Vec(int16));
testSerializable(Vec(int16));

const testTypeMappingInt16 = Vec(int16);
const _testTypeMappingInt16 = Vec(int16);
export type TestTypeMappingInt16 = AssertType<
NotAnyAndExact<TypeMapping<typeof testTypeMappingInt16>, Int16Array>
NotAnyAndExact<TypeMapping<typeof _testTypeMappingInt16>, Int16Array>
>;

// test int8

testCandidType(Vec(int8));
testSerializable(Vec(int8));

const testTypeMappingInt8 = Vec(int8);
const _testTypeMappingInt8 = Vec(int8);
export type TestTypeMappingInt8 = AssertType<
NotAnyAndExact<TypeMapping<typeof testTypeMappingInt8>, Int8Array>
NotAnyAndExact<TypeMapping<typeof _testTypeMappingInt8>, Int8Array>
>;

// test Vec<T> type
Expand Down
4 changes: 2 additions & 2 deletions type_tests/candid/manual.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { AssertType, NotAnyAndExact, testCandidType } from '../assert_type';

testCandidType(Manual(text));

const testTypeMapping = Manual(text);
const _testTypeMapping = Manual(text);
export type TestTypeMapping = AssertType<
NotAnyAndExact<TypeMapping<typeof testTypeMapping>, void>
NotAnyAndExact<TypeMapping<typeof _testTypeMapping>, void>
>;
4 changes: 2 additions & 2 deletions type_tests/canister_methods/init.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ const Reaction = Variant({

init(
[bool, nat, text, User, Reaction],
(param0, param1, param2, param3, param4) => {
(param0, param1, param2, param3, _param4) => {
type _Param0 = AssertType<NotAnyAndExact<typeof param0, boolean>>;
type _Param1 = AssertType<NotAnyAndExact<typeof param1, bigint>>;
type _Param2 = AssertType<NotAnyAndExact<typeof param2, string>>;
Expand All @@ -35,7 +35,7 @@ init(
>;
type _Param4 = AssertType<
NotAnyAndExact<
typeof param4,
typeof _param4,
RequireExactlyOne<{
Happy: null;
Sad: null;
Expand Down
4 changes: 2 additions & 2 deletions type_tests/canister_methods/post_upgrade.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ const Reaction = Variant({

postUpgrade(
[bool, nat, text, User, Reaction],
(param0, param1, param2, param3, param4) => {
(param0, param1, param2, param3, _param4) => {
type _Param0 = AssertType<NotAnyAndExact<typeof param0, boolean>>;
type _Param1 = AssertType<NotAnyAndExact<typeof param1, bigint>>;
type _Param2 = AssertType<NotAnyAndExact<typeof param2, string>>;
Expand All @@ -35,7 +35,7 @@ postUpgrade(
>;
type _Param4 = AssertType<
NotAnyAndExact<
typeof param4,
typeof _param4,
RequireExactlyOne<{
Happy: null;
Sad: null;
Expand Down
4 changes: 2 additions & 2 deletions type_tests/canister_methods/query.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ const Reaction = Variant({
query(
[bool, nat, text, User, Reaction],
text,
(param0, param1, param2, param3, param4) => {
(param0, param1, param2, param3, _param4) => {
type _Param0 = AssertType<NotAnyAndExact<typeof param0, boolean>>;
type _Param1 = AssertType<NotAnyAndExact<typeof param1, bigint>>;
type _Param2 = AssertType<NotAnyAndExact<typeof param2, string>>;
Expand All @@ -39,7 +39,7 @@ query(
>;
type _Param4 = AssertType<
NotAnyAndExact<
typeof param4,
typeof _param4,
RequireExactlyOne<{
Happy: null;
Sad: null;
Expand Down
4 changes: 2 additions & 2 deletions type_tests/canister_methods/update.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ const Reaction = Variant({
update(
[bool, nat, text, User, Reaction],
text,
(param0, param1, param2, param3, param4) => {
(param0, param1, param2, param3, _param4) => {
type _Param0 = AssertType<NotAnyAndExact<typeof param0, boolean>>;
type _Param1 = AssertType<NotAnyAndExact<typeof param1, bigint>>;
type _Param2 = AssertType<NotAnyAndExact<typeof param2, string>>;
Expand All @@ -39,7 +39,7 @@ update(
>;
type _Param4 = AssertType<
NotAnyAndExact<
typeof param4,
typeof _param4,
RequireExactlyOne<{
Happy: null;
Sad: null;
Expand Down
20 changes: 10 additions & 10 deletions type_tests/stable_structures/stable_b_tree_map.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,43 +7,43 @@ import { AssertType, NotAnyAndExact } from '../assert_type';
// TODO these tests just make sure that the basic methods are there
// TODO we want to maybe test that the type arguments work correctly as well

let mapText = StableBTreeMap<text, text>(0);
let _mapText = StableBTreeMap<text, text>(0);

export type TestContainsKey = AssertType<
NotAnyAndExact<typeof mapText.containsKey, (key: any) => boolean>
NotAnyAndExact<typeof _mapText.containsKey, (key: any) => boolean>
>;

export type TestGet = AssertType<
NotAnyAndExact<typeof mapText.get, (key: any) => any | null>
NotAnyAndExact<typeof _mapText.get, (key: any) => any | null>
>;

export type TestInsert = AssertType<
NotAnyAndExact<typeof mapText.insert, (key: any, value: any) => any | null>
NotAnyAndExact<typeof _mapText.insert, (key: any, value: any) => any | null>
>;

export type TestIsEmpty = AssertType<
NotAnyAndExact<typeof mapText.isEmpty, () => boolean>
NotAnyAndExact<typeof _mapText.isEmpty, () => boolean>
>;

export type TestItems = AssertType<
NotAnyAndExact<typeof mapText.items, () => [any, any][]>
NotAnyAndExact<typeof _mapText.items, () => [any, any][]>
>;

export type TestKeys = AssertType<
NotAnyAndExact<typeof mapText.keys, () => any[]>
NotAnyAndExact<typeof _mapText.keys, () => any[]>
>;

export type TestLen = AssertType<
NotAnyAndExact<typeof mapText.len, () => bigint>
NotAnyAndExact<typeof _mapText.len, () => bigint>
>;

export type TestRemove = AssertType<
NotAnyAndExact<typeof mapText.remove, (key: any) => any | null>
NotAnyAndExact<typeof _mapText.remove, (key: any) => any | null>
>;

export type TestValues = AssertType<
NotAnyAndExact<
typeof mapText.values,
typeof _mapText.values,
(startIndex?: number, length?: number) => any[]
>
>;

0 comments on commit f71f048

Please sign in to comment.