Skip to content

Commit

Permalink
More infra cleanup
Browse files Browse the repository at this point in the history
The infra updates also revealed lint errors that I corrected.
  • Loading branch information
wycats committed Sep 29, 2023
1 parent 626e1f6 commit c41f68b
Show file tree
Hide file tree
Showing 82 changed files with 350 additions and 295 deletions.
4 changes: 2 additions & 2 deletions demos/react-jsnation-workshop/src/components/steps/Step5.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -158,12 +158,12 @@ function Profile({ user }: { user: LocalUser | undefined }): JSX.Element {
}

class LocalUser {
#id: number;
readonly id: number;
#resource: InvalidatableAsync<ApiUser>;
#invalidate: Marker;

constructor(id: number, data: InvalidatableAsync<ApiUser>, marker: Marker) {
this.#id = id;
this.id = id;
this.#resource = data;
this.#invalidate = marker;
}
Expand Down
4 changes: 2 additions & 2 deletions demos/react-jsnation-workshop/src/components/steps/Step6.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -173,12 +173,12 @@ function Profile({ user }: { user: LocalUser | undefined }): JSX.Element {
}

class LocalUser {
#id: number;
readonly id: number;
#resource: InvalidatableAsync<ApiUser>;
#invalidate: Marker;

constructor(id: number, data: InvalidatableAsync<ApiUser>, marker: Marker) {
this.#id = id;
this.id = id;
this.#resource = data;
this.#invalidate = marker;
}
Expand Down
1 change: 1 addition & 0 deletions demos/react-jsnation/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"root": true,
"ignorePatterns": ["node_modules", "dist", "html", "tests"],
"plugins": ["@starbeam"],
"overrides": [
{
Expand Down
2 changes: 1 addition & 1 deletion demos/react-jsnation/tests/.eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"overrides": [
{
"extends": ["plugin:@starbeam/loose"],
"files": ["**/*.ts"],
"files": ["**/*.{tsx,ts}"],
"parserOptions": {
"project": "tsconfig.json"
}
Expand Down
2 changes: 1 addition & 1 deletion demos/react-jsnation/tests/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"type": "module",
"starbeam": {
"jsx": "react",
"source": "ts",
"source": "tsx",
"type": "tests"
},
"scripts": {
Expand Down
4 changes: 2 additions & 2 deletions demos/react-stock-ticker/src/components/Header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export default function Header(): JSX.Element {
event.preventDefault();

const { search } = Object.fromEntries(
new FormData(event.currentTarget)
new FormData(event.currentTarget),
) as {
search: string;
};
Expand Down Expand Up @@ -86,6 +86,6 @@ export default function Header(): JSX.Element {
</div>
</header>
),
[]
[],
);
}
4 changes: 3 additions & 1 deletion packages/preact/preact-testing-utils/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@
"main": "dist/index.cjs",
"types": "dist/index.d.ts"
},
"starbeam:type": "library:test-support",
"starbeam": {
"type": "library:test-support"
},
"scripts": {
"test:lint": "eslint . --max-warnings 0",
"test:specs": "vitest --run",
Expand Down
2 changes: 1 addition & 1 deletion packages/preact/preact-testing-utils/tests/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"version": "1.0.0",
"type": "module",
"starbeam": {
"source": "ts",
"source": "tsx",
"type": "tests"
},
"scripts": {
Expand Down
4 changes: 3 additions & 1 deletion packages/preact/preact-utils/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@
"main": "dist/index.cjs",
"types": "dist/index.d.ts"
},
"starbeam:type": "library:public",
"starbeam": {
"type": "library:public"
},
"scripts": {
"test:lint": "eslint . --max-warnings 0",
"test:specs": "vitest --run",
Expand Down
4 changes: 1 addition & 3 deletions packages/preact/preact-utils/src/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -266,12 +266,10 @@ class AugmentHandler<F extends AnyFn> implements Handler {
}
}

#name: string;
#handled = false;
#original: F;

private constructor(name: string, original: F) {
this.#name = name;
private constructor(_name: string, original: F) {
this.#original = original;
}

Expand Down
2 changes: 1 addition & 1 deletion packages/preact/preact-utils/tests/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"version": "1.0.0",
"type": "module",
"starbeam": {
"source": "ts",
"source": "tsx",
"type": "tests"
},
"scripts": {
Expand Down
2 changes: 1 addition & 1 deletion packages/preact/preact/tests/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"version": "1.0.0",
"type": "module",
"starbeam": {
"source": "ts",
"source": "tsx",
"type": "tests"
},
"scripts": {
Expand Down
2 changes: 1 addition & 1 deletion packages/react/react/tests/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"version": "1.0.0",
"type": "module",
"starbeam": {
"source": "ts",
"source": "tsx",
"type": "tests"
},
"scripts": {
Expand Down
4 changes: 3 additions & 1 deletion packages/react/test-utils/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@
"main": "dist/index.cjs",
"types": "dist/index.d.ts"
},
"starbeam:type": "library:test-support",
"starbeam": {
"type": "library:test-support"
},
"scripts": {
"test:lint": "eslint . --max-warnings 0",
"test:types": "tsc -b"
Expand Down
1 change: 1 addition & 0 deletions packages/react/test-utils/src/modes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,7 @@ export class SetupTestRoot<Props, T> {

if (lastChecked === undefined || current === undefined) {
if (lastChecked !== current) {
// eslint-disable-next-line no-console
console.error("Expected current value to equal last checked value", {
lastChecked,
current,
Expand Down
4 changes: 3 additions & 1 deletion packages/react/use-strict-lifecycle/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@
"main": "dist/index.cjs",
"types": "dist/index.d.ts"
},
"starbeam:type": "library:public",
"starbeam": {
"type": "library:public"
},
"scripts": {
"doc": "node ./scripts/doc.js",
"doc:all": "node ./scripts/docs.js",
Expand Down
2 changes: 1 addition & 1 deletion packages/react/use-strict-lifecycle/tests/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"version": "1.0.0",
"type": "module",
"starbeam": {
"source": "ts",
"source": "tsx",
"type": "tests"
},
"scripts": {
Expand Down
4 changes: 3 additions & 1 deletion packages/universal/collections/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@
"main": "dist/index.cjs",
"types": "dist/index.d.ts"
},
"starbeam:type": "library:public",
"starbeam": {
"type": "library:public"
},
"scripts": {
"test:lint": "eslint . --max-warnings 0",
"test:specs": "vitest --run",
Expand Down
2 changes: 1 addition & 1 deletion packages/universal/collections/tests/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"version": "1.0.0",
"type": "module",
"starbeam": {
"source": "ts",
"source": "tsx",
"type": "tests"
},
"scripts": {
Expand Down
4 changes: 3 additions & 1 deletion packages/universal/core-utils/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@
"main": "dist/index.cjs",
"types": "dist/index.d.ts"
},
"starbeam:type": "library:public",
"starbeam": {
"type": "library:public"
},
"scripts": {
"test:lint": "eslint . --max-warnings 0",
"test:specs": "vitest --run",
Expand Down
2 changes: 1 addition & 1 deletion packages/universal/core-utils/tests/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"version": "1.0.0",
"type": "module",
"starbeam": {
"source": "ts",
"source": "tsx",
"type": "tests"
},
"scripts": {
Expand Down
3 changes: 2 additions & 1 deletion packages/universal/core/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
// eslint-disable-next-line no-console
console.warn(
"WARNING: @starbeam/core has been renamed to @starbeam/universal. Please update your imports to refer to @starbeam/universal."
"WARNING: @starbeam/core has been renamed to @starbeam/universal. Please update your imports to refer to @starbeam/universal.",
);
export * from "@starbeam/universal";
34 changes: 34 additions & 0 deletions packages/universal/debug/src/logger.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
/**
* This API might gain additional features. For now, its primary purpose is to provide a
* sanctioned way to log to the console that is overtly different from explicit
* calls to `console.log` (which make it more difficult to identify errant console.logs).
*/
export class Logger {
static console(): Logger {
return new Logger(console);
}

static of(logger: typeof console): Logger {
return new Logger(logger);
}

#logger: typeof console;

private constructor(logger: typeof console) {
this.#logger = logger;
}

group(...args: unknown[]): void {
this.#logger.group(...args);
}

groupEnd(): void {
this.#logger.groupEnd();
}

info(...args: unknown[]): void {
this.#logger.info(...args);
}
}

export const LOGGER = Logger.console();
31 changes: 17 additions & 14 deletions packages/universal/debug/src/tag.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,20 @@ import type { Description, HasTag } from "@starbeam/interfaces";
import { DEBUG, UNKNOWN_REACTIVE_VALUE } from "@starbeam/reactive";
import { getDependencies, getTag, lastUpdated } from "@starbeam/tags";

import { LOGGER } from "./logger.js";
import { Tree } from "./tree.js";

export const debugReactive = (
tag: HasTag,
{
implementation = false,
}: { implementation?: boolean; source?: boolean; id?: boolean } = {}
}: { implementation?: boolean; source?: boolean; id?: boolean } = {},
): string => {
const dependencies = getDependencies(tag);
const descriptions = new Set(
dependencies.map((dependency) =>
getDesc(dependency.description, implementation)
)
getDesc(dependency.description, implementation),
),
);

const nodes = [...descriptions]
Expand All @@ -35,29 +36,31 @@ export const logReactive = (
implementation?: boolean;
source?: boolean;
id?: boolean;
} = {}
} = {},
): void => {
const debug = debugReactive(tag, options);

if (options.label) {
console.group(options.label);
LOGGER.group(options.label);
}

console.group(
describe(getTag(tag).description, { id: options.id }),
`(updated at ${lastUpdated(tag).at})`
);
console.info(debug);
console.groupEnd();
{
LOGGER.group(
describe(getTag(tag).description, { id: options.id }),
`(updated at ${lastUpdated(tag).at})`,
);
LOGGER.info(debug);
LOGGER.groupEnd();
}

if (options.label) {
console.groupEnd();
LOGGER.groupEnd();
}
};

function describe(
description: Description | undefined,
options?: { id: boolean | undefined }
options?: { id: boolean | undefined },
): string {
return description && DEBUG
? DEBUG.describe(description, options)
Expand All @@ -66,7 +69,7 @@ function describe(

function getDesc(
description: Description | undefined,
showImplementation: boolean
showImplementation: boolean,
): Description | undefined {
return showImplementation ? description : DEBUG?.getUserFacing(description);
}
2 changes: 1 addition & 1 deletion packages/universal/debug/tests/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"version": "1.0.0",
"type": "module",
"starbeam": {
"source": "ts",
"source": "tsx",
"type": "tests"
},
"scripts": {
Expand Down
4 changes: 3 additions & 1 deletion packages/universal/modifier/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@
"main": "dist/index.cjs",
"types": "dist/index.d.ts"
},
"starbeam:type": "library:public",
"starbeam": {
"type": "library:public"
},
"scripts": {
"test:lint": "eslint . --max-warnings 0",
"test:types": "tsc -b"
Expand Down
4 changes: 3 additions & 1 deletion packages/universal/reactive/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@
"main": "dist/index.cjs",
"types": "dist/index.d.ts"
},
"starbeam:type": "library:public",
"starbeam": {
"type": "library:public"
},
"scripts": {
"test:lint": "eslint . --max-warnings 0",
"test:specs": "vitest --run",
Expand Down
2 changes: 1 addition & 1 deletion packages/universal/reactive/tests/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"version": "1.0.0",
"type": "module",
"starbeam": {
"source": "ts",
"source": "tsx",
"type": "tests"
},
"scripts": {
Expand Down
4 changes: 3 additions & 1 deletion packages/universal/renderer/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@
"main": "dist/index.cjs",
"types": "dist/index.d.ts"
},
"starbeam:type": "library:public",
"starbeam": {
"type": "library:public"
},
"scripts": {
"test:lint": "eslint . --max-warnings 0",
"test:specs": "vitest --run",
Expand Down
Loading

0 comments on commit c41f68b

Please sign in to comment.