Skip to content

Commit

Permalink
ci: add eslint max-len (#1734)
Browse files Browse the repository at this point in the history
Co-authored-by: alvrs <[email protected]>
  • Loading branch information
techemmy and alvrs authored Oct 11, 2023
1 parent 42d4915 commit e241c05
Show file tree
Hide file tree
Showing 10 changed files with 23 additions and 6 deletions.
5 changes: 4 additions & 1 deletion .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,8 @@
"eslint:recommended",
"plugin:@typescript-eslint/eslint-recommended",
"plugin:@typescript-eslint/recommended"
]
],
"rules": {
"max-len": ["error", { "code": 180, "comments": 180 }]
}
}
4 changes: 3 additions & 1 deletion packages/block-logs-stream/src/blockRangeToLogs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,9 @@ export type BlockRangeToLogsResult<TAbiEvents extends readonly AbiEvent[]> = 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<AbiEvent[]>} options See `BlockRangeToLogsOptions`.
* @returns {BlockRangeToLogsResult<AbiEvent[]>} An operator function that transforms a stream of block ranges into a stream of fetched logs.
Expand Down
6 changes: 5 additions & 1 deletion packages/dev-tools/src/recs/ComponentsPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,11 @@ export function ComponentsPage() {

<details ref={detailsRef} className="pointer-events-none select-none">
<summary className="group pointer-events-auto cursor-pointer inline-flex">
<span className="inline-flex gap-2 px-3 py-2 items-center border-2 border-white/10 rounded group-hover:border-blue-700 group-hover:bg-blue-700 group-hover:text-white">
<span
className={
"inline-flex gap-2 px-3 py-2 items-center border-2 border-white/10 rounded group-hover:border-blue-700 group-hover:bg-blue-700 group-hover:text-white"
}
>
{selectedComponent ? (
<span className="font-mono">{getComponentName(selectedComponent)}</span>
) : (
Expand Down
3 changes: 2 additions & 1 deletion packages/protocol-parser/src/errors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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?`
);
}
}
Expand Down
1 change: 1 addition & 0 deletions packages/protocol-parser/src/hexToPackedCounter.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)."'
);
});
Expand Down
1 change: 1 addition & 0 deletions packages/protocol-parser/src/hexToSchema.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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?'
);
});
Expand Down
3 changes: 2 additions & 1 deletion packages/protocol-parser/src/hexToSchema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
3 changes: 2 additions & 1 deletion packages/recs/src/Indexer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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).
*
Expand Down
2 changes: 2 additions & 0 deletions packages/store-sync/src/logToTable.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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",
},
})
Expand Down
1 change: 1 addition & 0 deletions packages/store-sync/src/sqlite/sqliteTableToSql.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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\\"))"'
);
});
Expand Down

0 comments on commit e241c05

Please sign in to comment.