Skip to content

Commit df83d8f

Browse files
authored
Merge pull request #163 from ethdebug/imports
Add #-prefixed path aliases to format and pointers packages
2 parents 2118361 + 21e532e commit df83d8f

37 files changed

+189
-71
lines changed

.eslintrc.json

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,36 @@
1111
"@typescript-eslint/no-namespace": "off",
1212
"@typescript-eslint/no-empty-object-type": "off",
1313
"no-console": "warn",
14-
"require-yield": "off"
14+
"require-yield": "off",
15+
"no-restricted-imports": [
16+
"error",
17+
{
18+
"patterns": [
19+
{
20+
"group": ["../types/*/index*", "../types/*/index"],
21+
"message": "Use #types/* alias instead of relative imports"
22+
},
23+
{
24+
"group": [
25+
"../materials/*",
26+
"../data/*",
27+
"../pointer/*",
28+
"../program/*",
29+
"../type/*"
30+
],
31+
"message": "Use #types/* alias instead of relative imports"
32+
},
33+
{
34+
"group": ["../../test/*", "../../../test/*"],
35+
"message": "Use #test/* alias instead of relative imports"
36+
},
37+
{
38+
"group": ["../describe*"],
39+
"message": "Use #describe alias instead of relative imports"
40+
}
41+
]
42+
}
43+
]
1544
},
1645
"env": {
1746
"node": true,

packages/format/package.json

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,41 @@
99
"files": [
1010
"dist"
1111
],
12+
"imports": {
13+
"#describe": {
14+
"types": "./src/describe.ts",
15+
"default": "./dist/src/describe.js"
16+
},
17+
"#schemas": {
18+
"types": "./src/schemas/index.ts",
19+
"default": "./dist/src/schemas/index.js"
20+
},
21+
"#types": {
22+
"types": "./src/types/index.ts",
23+
"default": "./dist/src/types/index.js"
24+
},
25+
"#types/data": {
26+
"types": "./src/types/data/index.ts",
27+
"default": "./dist/src/types/data/index.js"
28+
},
29+
"#types/materials": {
30+
"types": "./src/types/materials/index.ts",
31+
"default": "./dist/src/types/materials/index.js"
32+
},
33+
"#types/pointer": {
34+
"types": "./src/types/pointer/index.ts",
35+
"default": "./dist/src/types/pointer/index.js"
36+
},
37+
"#types/program": {
38+
"types": "./src/types/program/index.ts",
39+
"default": "./dist/src/types/program/index.js"
40+
},
41+
"#types/type": {
42+
"types": "./src/types/type/index.ts",
43+
"default": "./dist/src/types/type/index.js"
44+
},
45+
"#test/*": "./test/*.ts"
46+
},
1247
"scripts": {
1348
"prepare:yamls": "node ./bin/generate-schema-yamls.js",
1449
"prepare": "yarn prepare:yamls && tsc",

packages/format/src/index.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
export * from "./describe.js";
2-
export { schemas, schemaIds, type Schema } from "./schemas/index.js";
1+
export * from "#describe";
2+
export { schemas, schemaIds, type Schema } from "#schemas";
33

4-
export * from "./types/index.js";
4+
export * from "#types";

packages/format/src/schemas/examples.test.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
import { expect, describe, it } from "vitest";
22

3-
import { schemaExtensions } from "../../test/extensions.js";
3+
import { schemaExtensions } from "#test/extensions";
44
import { schemas } from "./index.js";
5-
import type { JSONSchema } from "../describe.js";
5+
import type { JSONSchema } from "#describe";
66

77
// loads schemas into global hyperjump json schema validator
8-
import "../../test/hyperjump.js";
8+
import "#test/hyperjump";
99

1010
const idsOfSchemasAllowedToOmitExamples = new Set([
1111
"schema:ethdebug/format/type",

packages/format/src/schemas/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { describeSchema } from "../describe.js";
1+
import { describeSchema } from "#describe";
22
import { schemaYamls } from "./yamls.js";
33
export type { Schema } from "./yamls.js";
44

packages/format/src/schemas/validity.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import {
88
import { schemas } from "./index.js";
99

1010
// loads schemas into global hyperjump json schema validator
11-
import "../../test/hyperjump.js";
11+
import "#test/hyperjump";
1212

1313
const printErrors = (output: { errors?: OutputUnit[] }): string =>
1414
output

packages/format/src/types/data/index.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { testSchemaGuards } from "../../../test/guards.js";
1+
import { testSchemaGuards } from "#test/guards";
22

33
import { Data } from "./index.js";
44

packages/format/src/types/index.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
export * from "./data/index.js";
2-
export * from "./materials/index.js";
3-
export * from "./type/index.js";
4-
export * from "./pointer/index.js";
5-
export * from "./program/index.js";
1+
export * from "#types/data";
2+
export * from "#types/materials";
3+
export * from "#types/type";
4+
export * from "#types/pointer";
5+
export * from "#types/program";

packages/format/src/types/materials/index.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { testSchemaGuards } from "../../../test/guards.js";
1+
import { testSchemaGuards } from "#test/guards";
22
import { Materials } from "./index.js";
33

44
testSchemaGuards("ethdebug/format/materials", [

packages/format/src/types/materials/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Data } from "../data/index.js";
1+
import { Data } from "#types/data";
22

33
export namespace Materials {
44
export type Id = number | string;

0 commit comments

Comments
 (0)