From e241c0561d6654022370ef62966fbafe4a9542a7 Mon Sep 17 00:00:00 2001 From: Emmanuel Oloyede Date: Wed, 11 Oct 2023 10:59:19 +0100 Subject: [PATCH] ci: add eslint max-len (#1734) Co-authored-by: alvrs --- .eslintrc | 5 ++++- packages/block-logs-stream/src/blockRangeToLogs.ts | 4 +++- packages/dev-tools/src/recs/ComponentsPage.tsx | 6 +++++- packages/protocol-parser/src/errors.ts | 3 ++- packages/protocol-parser/src/hexToPackedCounter.test.ts | 1 + packages/protocol-parser/src/hexToSchema.test.ts | 1 + packages/protocol-parser/src/hexToSchema.ts | 3 ++- packages/recs/src/Indexer.ts | 3 ++- packages/store-sync/src/logToTable.test.ts | 2 ++ packages/store-sync/src/sqlite/sqliteTableToSql.test.ts | 1 + 10 files changed, 23 insertions(+), 6 deletions(-) diff --git a/.eslintrc b/.eslintrc index 79bd6ef23f..8c8261853c 100644 --- a/.eslintrc +++ b/.eslintrc @@ -6,5 +6,8 @@ "eslint:recommended", "plugin:@typescript-eslint/eslint-recommended", "plugin:@typescript-eslint/recommended" - ] + ], + "rules": { + "max-len": ["error", { "code": 180, "comments": 180 }] + } } diff --git a/packages/block-logs-stream/src/blockRangeToLogs.ts b/packages/block-logs-stream/src/blockRangeToLogs.ts index 56912638c7..825320f14d 100644 --- a/packages/block-logs-stream/src/blockRangeToLogs.ts +++ b/packages/block-logs-stream/src/blockRangeToLogs.ts @@ -31,7 +31,9 @@ export type BlockRangeToLogsResult = Ope >; /** - * Takes in an observable of `Observable<{ startBlock: bigint, endBlock: bigint }>` and uses a viem `publicClient` to get logs for the contract `address` and matching `events` and emits the logs as they are fetched. + * Takes in an observable of `Observable<{ startBlock: bigint, endBlock: bigint }>` + * and uses a viem `publicClient` to get logs for the contract `address` and + * matching `events` and emits the logs as they are fetched. * * @param {BlockRangeToLogsOptions} options See `BlockRangeToLogsOptions`. * @returns {BlockRangeToLogsResult} An operator function that transforms a stream of block ranges into a stream of fetched logs. diff --git a/packages/dev-tools/src/recs/ComponentsPage.tsx b/packages/dev-tools/src/recs/ComponentsPage.tsx index 2cd10b8e02..ef95a1bb5b 100644 --- a/packages/dev-tools/src/recs/ComponentsPage.tsx +++ b/packages/dev-tools/src/recs/ComponentsPage.tsx @@ -44,7 +44,11 @@ export function ComponentsPage() {
- + {selectedComponent ? ( {getComponentName(selectedComponent)} ) : ( diff --git a/packages/protocol-parser/src/errors.ts b/packages/protocol-parser/src/errors.ts index e88e39d400..1071b89564 100644 --- a/packages/protocol-parser/src/errors.ts +++ b/packages/protocol-parser/src/errors.ts @@ -49,7 +49,8 @@ export class SchemaStaticLengthMismatchError extends MUDError { override name = "SchemaStaticLengthMismatchError"; constructor(schemaData: Hex, definedLength: number, summedLength: number) { super( - `Schema "${schemaData}" static data length (${definedLength}) did not match the summed length of all static fields (${summedLength}). Is \`staticAbiTypeToByteLength\` up to date with Solidity schema types?` + `Schema "${schemaData}" static data length (${definedLength}) did not match the summed length of all static fields (${summedLength}). ` + + `Is \`staticAbiTypeToByteLength\` up to date with Solidity schema types?` ); } } diff --git a/packages/protocol-parser/src/hexToPackedCounter.test.ts b/packages/protocol-parser/src/hexToPackedCounter.test.ts index dc98665345..82537cc018 100644 --- a/packages/protocol-parser/src/hexToPackedCounter.test.ts +++ b/packages/protocol-parser/src/hexToPackedCounter.test.ts @@ -28,6 +28,7 @@ describe("hexToPackedCounter", () => { expect(() => hexToPackedCounter("0x0000000000000000000000000000400000000020000000002000000000000040") ).toThrowErrorMatchingInlineSnapshot( + // eslint-disable-next-line max-len '"PackedCounter \\"0x0000000000000000000000000000400000000020000000002000000000000040\\" total bytes length (64) did not match the summed length of all field byte lengths (128)."' ); }); diff --git a/packages/protocol-parser/src/hexToSchema.test.ts b/packages/protocol-parser/src/hexToSchema.test.ts index f978a8d7b6..a73b132bbf 100644 --- a/packages/protocol-parser/src/hexToSchema.test.ts +++ b/packages/protocol-parser/src/hexToSchema.test.ts @@ -61,6 +61,7 @@ describe("hexToSchema", () => { it("throws if schema static field lengths do not match", () => { expect(() => hexToSchema("0x002502045f2381c3c4c500000000000000000000000000000000000000000000")).toThrow( + // eslint-disable-next-line max-len 'Schema "0x002502045f2381c3c4c500000000000000000000000000000000000000000000" static data length (37) did not match the summed length of all static fields (36). Is `staticAbiTypeToByteLength` up to date with Solidity schema types?' ); }); diff --git a/packages/protocol-parser/src/hexToSchema.ts b/packages/protocol-parser/src/hexToSchema.ts index b56897f91c..ff16f1e5cc 100644 --- a/packages/protocol-parser/src/hexToSchema.ts +++ b/packages/protocol-parser/src/hexToSchema.ts @@ -27,7 +27,8 @@ export function hexToSchema(data: Hex): Schema { const actualStaticDataLength = staticFields.reduce((acc, fieldType) => acc + staticAbiTypeToByteLength[fieldType], 0); if (actualStaticDataLength !== staticDataLength) { console.warn( - `Schema "${data}" static data length (${staticDataLength}) did not match the summed length of all static fields (${actualStaticDataLength}). Is \`staticAbiTypeToByteLength\` up to date with Solidity schema types?` + `Schema "${data}" static data length (${staticDataLength}) did not match the summed length of all static fields (${actualStaticDataLength}). ` + + `Is \`staticAbiTypeToByteLength\` up to date with Solidity schema types?` ); throw new SchemaStaticLengthMismatchError(data, staticDataLength, actualStaticDataLength); } diff --git a/packages/recs/src/Indexer.ts b/packages/recs/src/Indexer.ts index bf7d39a472..8f5d70400f 100644 --- a/packages/recs/src/Indexer.ts +++ b/packages/recs/src/Indexer.ts @@ -7,7 +7,8 @@ import { Component, ComponentValue, Entity, EntitySymbol, Indexer, Metadata, Sch * * @remarks * An indexed component keeps a "reverse mapping" from {@link ComponentValue} to the Set of {@link createEntity Entities} with this value. - * This adds a performance overhead to modifying component values and a memory overhead since in the worst case there is one Set per entity (if every entity has a different component value). + * This adds a performance overhead to modifying component values and a memory overhead since in the worst case there is one + * Set per entity (if every entity has a different component value). * In return the performance for querying for entities with a given component value is close to O(1) (instead of O(#entities) in a regular non-indexed component). * As a rule of thumb only components that are added to many entities and are queried with {@link HasValue} a lot should be indexed (eg. the Position component). * diff --git a/packages/store-sync/src/logToTable.test.ts b/packages/store-sync/src/logToTable.test.ts index 05145b366b..8fb7475552 100644 --- a/packages/store-sync/src/logToTable.test.ts +++ b/packages/store-sync/src/logToTable.test.ts @@ -11,9 +11,11 @@ describe("logToTable", () => { tableId: "0x74626d756473746f72650000000000005461626c657300000000000000000000", keyTuple: ["0x74626d756473746f72650000000000005461626c657300000000000000000000"], staticData: + // eslint-disable-next-line max-len "0x0060030220202000000000000000000000000000000000000000000000000000002001005f000000000000000000000000000000000000000000000000000000006003025f5f5fc4c40000000000000000000000000000000000000000000000", encodedLengths: "0x000000000000000000000000000000000000022000000000a0000000000002c0", // "0x00000000000000000000000000000000000000a00000000220000000000002c0", dynamicData: + // eslint-disable-next-line max-len "0x00000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000077461626c654964000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000500000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000e00000000000000000000000000000000000000000000000000000000000000120000000000000000000000000000000000000000000000000000000000000016000000000000000000000000000000000000000000000000000000000000001a0000000000000000000000000000000000000000000000000000000000000000b6669656c644c61796f757400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000096b6579536368656d610000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000b76616c7565536368656d610000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000012616269456e636f6465644b65794e616d657300000000000000000000000000000000000000000000000000000000000000000000000000000000000000000014616269456e636f6465644669656c644e616d6573000000000000000000000000", }, }) diff --git a/packages/store-sync/src/sqlite/sqliteTableToSql.test.ts b/packages/store-sync/src/sqlite/sqliteTableToSql.test.ts index 8d7b2bfa70..c07270f84e 100644 --- a/packages/store-sync/src/sqlite/sqliteTableToSql.test.ts +++ b/packages/store-sync/src/sqlite/sqliteTableToSql.test.ts @@ -15,6 +15,7 @@ describe("sqliteTableToSql", () => { const sql = sqliteTableToSql(table); expect(sql).toMatchInlineSnapshot( + // eslint-disable-next-line max-len '"create table if not exists \\"some table\\" (\\"x\\" integer not null, \\"y\\" integer not null, \\"name\\" text default \'\' not null, \\"block_number\\" blob default \'1000\' not null, constraint \\"some table__primaryKey\\" primary key (\\"x\\", \\"y\\"))"' ); });