Skip to content

Commit d42ac83

Browse files
committed
Apply Prettier formatting
1 parent 73cf868 commit d42ac83

223 files changed

Lines changed: 3187 additions & 3389 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name: Continuous integration checks
22
on:
3-
- pull_request
3+
- pull_request
44

55
jobs:
66
run-tests:

.github/workflows/gh-pages.yml

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,8 @@ jobs:
2929
folder: ./packages/web/build
3030
branch: gh-pages
3131
# default deployer
32-
git-config-name: 'github-actions[bot]'
33-
git-config-email: 'github-actions[bot]@users.noreply.github.com'
32+
git-config-name: "github-actions[bot]"
33+
git-config-email: "github-actions[bot]@users.noreply.github.com"
3434
# don't break preview deployments
3535
clean-exclude: pr-preview
3636
force: false
37-
38-

README.md

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ This repository contains a
4646
with the formal JSON Schemas defined by this project (in YAML format).
4747

4848
This repository also contains the source materials for the following NPM packages:
49+
4950
- **@ethdebug/format** in
5051
[`packages/format/`](https://github.com/ethdebug/format/tree/main/packages/format)
5152
distributes the formal schemas for use in TypeScript
@@ -75,6 +76,7 @@ To build and run the site locally, please ensure you have Node.js
7576
(LTS or better) and `yarn` installed globally.
7677

7778
First, clone this repo and install the Node.js dependencies:
79+
7880
```console
7981
git clone https://github.com/ethdebug/format.git
8082
cd format
@@ -96,10 +98,12 @@ This project uses a dual-license approach:
9698

9799
- All other code and documentation in this repository is licensed under the [MIT License](LICENSE).
98100

99-
[^1]: See [Debugging data format -
100-
Wikipedia](https://en.wikipedia.org/wiki/Debugging_data_format)
101+
[^1]:
102+
See [Debugging data format -
103+
Wikipedia](https://en.wikipedia.org/wiki/Debugging_data_format)
101104

102105
[^2]: See [DWARF - Wikipedia](https://en.wikipedia.org/wiki/DWARF)
103106

104-
[^3]: See [Using type predicates](https://www.typescriptlang.org/docs/handbook/2/narrowing.html#using-type-predicates)
105-
section from TypeScript's Narrowing documentation.
107+
[^3]:
108+
See [Using type predicates](https://www.typescriptlang.org/docs/handbook/2/narrowing.html#using-type-predicates)
109+
section from TypeScript's Narrowing documentation.

bin/bundle-schema.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
import { addSchema } from "@hyperjump/json-schema/draft-2020-12";
22
import { bundle as bundleSchema } from "@hyperjump/json-schema/bundle";
33
import { schemas, describeSchema } from "@ethdebug/format";
4-
import type { JSONSchema } from "json-schema-typed/draft-2020-12"
4+
import type { JSONSchema } from "json-schema-typed/draft-2020-12";
55

66
async function main() {
77
const schema = { id: process.argv[2] }; // a bit brittle
88

99
if (!schema.id) {
1010
console.error(
11-
"Please provide a schema ID, e.g. `schema:ethdebug/format/pointer`"
11+
"Please provide a schema ID, e.g. `schema:ethdebug/format/pointer`",
1212
);
1313
process.exit(1);
1414
}

jest.config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ const config: Config = {
55
rootDir: "./",
66
extensionsToTreatAsEsm: [".ts"],
77
transform: {
8-
"^.+\\.tsx?$": ['ts-jest', { useESM: true, }],
8+
"^.+\\.tsx?$": ["ts-jest", { useESM: true }],
99
},
1010
projects: ["<rootDir>/packages/*"],
1111
};

lerna.json

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22
"$schema": "node_modules/lerna/schemas/lerna-schema.json",
33
"version": "independent",
44
"npmClient": "yarn",
5-
"packages": [
6-
"packages/*"
7-
],
5+
"packages": ["packages/*"],
86
"rejectCycles": true
97
}

packages/format/bin/generate-schema-yamls.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ const readSchemaYamls = (directory) => {
2626
}
2727

2828
return schemaYamls;
29-
}
29+
};
3030

3131
const schemaYamls = readSchemaYamls(schemasRoot);
3232
const rawSchemas = Object.entries(schemaYamls)
@@ -40,13 +40,13 @@ export type SchemaYamlsById = {
4040
[id: string]: string;
4141
};
4242
43-
export const schemaYamls: SchemaYamlsById = ${
44-
JSON.stringify(schemaYamls, undefined, 2)
45-
};
43+
export const schemaYamls: SchemaYamlsById = ${JSON.stringify(
44+
schemaYamls,
45+
undefined,
46+
2,
47+
)};
4648
47-
const rawSchemas = ${
48-
JSON.stringify(rawSchemas, undefined, 2)
49-
} as const;
49+
const rawSchemas = ${JSON.stringify(rawSchemas, undefined, 2)} as const;
5050
5151
export type Schema<Id extends keyof typeof rawSchemas> =
5252
(typeof rawSchemas)[Id];

packages/format/src/describe.ts

Lines changed: 36 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,16 @@ import * as YAML from "yaml";
22

33
import { schemaYamls } from "./schemas/yamls";
44

5-
import type { JSONSchema as JSONSchemaTyped } from "json-schema-typed/draft-2020-12"
5+
import type { JSONSchema as JSONSchemaTyped } from "json-schema-typed/draft-2020-12";
66

77
export type JSONSchema = Exclude<JSONSchemaTyped, boolean>;
88

99
export interface DescribeSchemaOptions<
10-
S extends SchemaReference = SchemaReference
10+
S extends SchemaReference = SchemaReference,
1111
> {
1212
schema: S;
1313
pointer?: SchemaPointer;
14-
};
14+
}
1515

1616
export interface SchemaInfo {
1717
id?: string; // root ID only
@@ -23,46 +23,42 @@ export interface SchemaInfo {
2323

2424
const parseOptions = {
2525
// merge keys were removed from YAML 1.2 spec but used by these schemas
26-
merge: true
26+
merge: true,
2727
};
2828

2929
export function describeSchema({
3030
schema,
31-
pointer
31+
pointer,
3232
}: DescribeSchemaOptions): SchemaInfo {
3333
if (typeof pointer === "string" && !pointer.startsWith("#")) {
3434
throw new Error("`pointer` option must start with '#'");
3535
}
3636

37-
const pointerOptions = pointer
38-
? { pointer }
39-
: {};
37+
const pointerOptions = pointer ? { pointer } : {};
4038

4139
if (referencesId(schema)) {
4240
return describeSchemaById({
43-
schema: typeof schema === "object"
44-
? schema
45-
: { id: schema },
46-
...pointerOptions
41+
schema: typeof schema === "object" ? schema : { id: schema },
42+
...pointerOptions,
4743
});
4844
}
4945

5046
if (referencesYaml(schema)) {
5147
return describeSchemaByYaml({
5248
schema,
53-
...pointerOptions
49+
...pointerOptions,
5450
});
5551
}
5652

5753
return describeSchemaByObject({
5854
schema,
59-
...pointerOptions
55+
...pointerOptions,
6056
});
6157
}
6258

6359
function describeSchemaById({
6460
schema: { id: referencedId },
65-
pointer: relativePointer
61+
pointer: relativePointer,
6662
}: DescribeSchemaOptions<SchemaById>): SchemaInfo {
6763
// we need to handle the case where the schema is referenced by an ID
6864
// with a pointer specified, possibly with a separate `pointer` field too
@@ -72,7 +68,7 @@ function describeSchemaById({
7268
? joinSchemaPointers([`#${rawReferencedPointer}`, relativePointer])
7369
: relativePointer;
7470

75-
const rootYaml = schemaYamls[id]
71+
const rootYaml = schemaYamls[id];
7672
if (!rootYaml) {
7773
throw new Error(`Unknown schema with $id "${id}"`);
7874
}
@@ -87,13 +83,13 @@ function describeSchemaById({
8783
...(pointer ? { pointer } : {}),
8884
yaml,
8985
schema,
90-
rootSchema
91-
}
86+
rootSchema,
87+
};
9288
}
9389

9490
function describeSchemaByYaml({
9591
schema: { yaml: referencedYaml },
96-
pointer
92+
pointer,
9793
}: DescribeSchemaOptions<SchemaByYaml>): SchemaInfo {
9894
const yaml = pointToYaml(referencedYaml, pointer);
9995

@@ -108,21 +104,21 @@ function describeSchemaByYaml({
108104
...(pointer ? { pointer } : {}),
109105
yaml,
110106
schema,
111-
rootSchema
112-
}
107+
rootSchema,
108+
};
113109
} else {
114110
return {
115111
...(pointer ? { pointer } : {}),
116112
yaml,
117113
schema,
118-
rootSchema
119-
}
114+
rootSchema,
115+
};
120116
}
121117
}
122118

123119
function describeSchemaByObject({
124120
schema: rootSchema,
125-
pointer
121+
pointer,
126122
}: DescribeSchemaOptions<object>): SchemaInfo {
127123
const rootYaml = YAML.stringify(rootSchema);
128124

@@ -138,24 +134,24 @@ function describeSchemaByObject({
138134
...(pointer ? { pointer } : {}),
139135
yaml,
140136
schema,
141-
rootSchema
142-
}
137+
rootSchema,
138+
};
143139
} else {
144140
return {
145141
...(pointer ? { pointer } : {}),
146142
yaml,
147143
schema,
148-
rootSchema
149-
}
144+
rootSchema,
145+
};
150146
}
151147
}
152148

153149
function joinSchemaPointers(
154-
pointers: (SchemaPointer | undefined)[]
150+
pointers: (SchemaPointer | undefined)[],
155151
): SchemaPointer | undefined {
156152
const joined = pointers
157153
.filter((pointer): pointer is SchemaPointer => typeof pointer === "string")
158-
.map(pointer => pointer.slice(1))
154+
.map((pointer) => pointer.slice(1))
159155
.join("");
160156

161157
if (joined.length === 0) {
@@ -165,10 +161,7 @@ function joinSchemaPointers(
165161
return `#${joined}`;
166162
}
167163

168-
function pointToYaml(
169-
yaml: string,
170-
pointer?: SchemaPointer
171-
): string {
164+
function pointToYaml(yaml: string, pointer?: SchemaPointer): string {
172165
if (!pointer) {
173166
return yaml;
174167
}
@@ -192,9 +185,8 @@ type Impossible<K extends keyof any> = {
192185
[P in K]: never;
193186
};
194187

195-
type NoExtraProperties<T, U extends T = T> =
196-
& U
197-
& Impossible<Exclude<keyof U, keyof T>>;
188+
type NoExtraProperties<T, U extends T = T> = U &
189+
Impossible<Exclude<keyof U, keyof T>>;
198190

199191
export type SchemaPointer = `#${string}`;
200192

@@ -215,7 +207,7 @@ export type SchemaByYaml = NoExtraProperties<{
215207
}>;
216208

217209
export function referencesId(
218-
schema: SchemaReference
210+
schema: SchemaReference,
219211
): schema is SchemaId | SchemaById {
220212
return (
221213
typeof schema === "string" ||
@@ -224,8 +216,11 @@ export function referencesId(
224216
}
225217

226218
export function referencesYaml(
227-
schema: SchemaReference
219+
schema: SchemaReference,
228220
): schema is SchemaByYaml {
229-
return typeof schema === "object" &&
230-
Object.keys(schema).length === 1 && "yaml" in schema;
221+
return (
222+
typeof schema === "object" &&
223+
Object.keys(schema).length === 1 &&
224+
"yaml" in schema
225+
);
231226
}

0 commit comments

Comments
 (0)