From d1bf02861e61211e36cf4b86328f5529de330663 Mon Sep 17 00:00:00 2001 From: patrick Date: Tue, 7 May 2024 13:50:10 +0200 Subject: [PATCH] more lint fixes --- @types/fsify/index.d.ts | 4 ++-- packages/react/react/src/hooks/setup.ts | 4 ++-- .../use-strict-lifecycle/src/lifecycle.ts | 8 +++---- .../debug/src/call-stack/debug/module.ts | 8 +++---- .../interfaces/src/debug/debug-runtime.ts | 4 ++-- packages/universal/interfaces/src/protocol.ts | 10 ++++----- packages/universal/interfaces/src/runtime.ts | 12 +++++----- packages/universal/interfaces/src/tag.ts | 10 ++++----- packages/universal/interfaces/src/tagged.ts | 4 ++-- packages/universal/renderer/src/renderer.ts | 8 +++---- .../universal/resource/tests/resource.spec.ts | 4 ++-- packages/universal/shared/src/env.ts | 4 ++-- packages/universal/shared/src/types.ts | 4 ++-- packages/universal/verify/index.ts | 2 +- packages/vue/vue-testing-utils/src/testing.ts | 12 +++++----- .../src/rollup/plugins/external.ts | 22 ++++++++++--------- .../src/rollup/plugins/import-meta.ts | 11 +++++----- .../dev-compile/src/rollup/plugins/replace.ts | 8 +++---- .../src/rollup/plugins/typescript.ts | 21 +++++++++--------- workspace/dev-compile/src/rollup/rollup.ts | 2 +- workspace/unstable-release/src/workspaces.js | 3 ++- 21 files changed, 85 insertions(+), 80 deletions(-) diff --git a/@types/fsify/index.d.ts b/@types/fsify/index.d.ts index 1dc07be2..640db27a 100644 --- a/@types/fsify/index.d.ts +++ b/@types/fsify/index.d.ts @@ -16,8 +16,8 @@ export interface Options { */ cwd?: string; /** - * A persistent fsify tree remains on the file system after the process exits. - * Defaults to true. + * A persistent fsify tree remains on the file system after the process + * exits. Defaults to true. */ persistent?: boolean; /** diff --git a/packages/react/react/src/hooks/setup.ts b/packages/react/react/src/hooks/setup.ts index 576e9abf..33997394 100644 --- a/packages/react/react/src/hooks/setup.ts +++ b/packages/react/react/src/hooks/setup.ts @@ -152,8 +152,8 @@ interface ScheduledHandler { * Creates a {@linkcode ScheduledHandler} that will keep track of the * synchronization functions to run. * - * This function sets up a `useEffect` to run the handlers. This `useEffect` has - * a dependency on a `useState` that represents the set of handlers. The + * This function sets up a `useEffect` to run the handlers. This `useEffect` + * has a dependency on a `useState` that represents the set of handlers. The * `useState` invalidates whenever a handler is added or whenever * {@linkcode scheduleDep} is explicitly run. * diff --git a/packages/react/use-strict-lifecycle/src/lifecycle.ts b/packages/react/use-strict-lifecycle/src/lifecycle.ts index 6d4e4afd..447d83e8 100644 --- a/packages/react/use-strict-lifecycle/src/lifecycle.ts +++ b/packages/react/use-strict-lifecycle/src/lifecycle.ts @@ -64,10 +64,10 @@ * * ## The Solution * - * The `useLifecycle` hook gives you a way to create a new instance of something - * when the component is first instantiated, clean it up when the component is - * unmounted, and create a brand **new** instance when the component is - * reactivated. + * The `useLifecycle` hook gives you a way to create a new instance of + * something when the component is first instantiated, clean it up when the + * component is unmounted, and create a brand **new** instance when the + * component is reactivated. * * TL;DR It works almost the same way that per-component state in React works, * but gives you a fresh copy whenever React re-attaches the component. diff --git a/packages/universal/debug/src/call-stack/debug/module.ts b/packages/universal/debug/src/call-stack/debug/module.ts index 1334b1da..24c5b003 100644 --- a/packages/universal/debug/src/call-stack/debug/module.ts +++ b/packages/universal/debug/src/call-stack/debug/module.ts @@ -37,8 +37,8 @@ function stripLeadingSlash(path: string) { /** * The whole `Stack` system is only intended to be used for logging, so the - * edge-cases where this normalization wouldn't work (verbatim paths on Windows) - * shouldn't matter. + * edge-cases where this normalization wouldn't work (verbatim paths on + * Windows) shouldn't matter. */ function normalizePath(...pathParts: (string | null | undefined)[]): string { return pathParts @@ -48,8 +48,8 @@ function normalizePath(...pathParts: (string | null | undefined)[]): string { } /** - * This function takes two paths and returns the suffix of the target that comes - * after any shared prefix with the source. + * This function takes two paths and returns the suffix of the target that + * comes after any shared prefix with the source. * * For example, if the source is `/src/app/foo/bar` and the target is * `/src/app/baz/qux`, this function will return `baz/qux`. diff --git a/packages/universal/interfaces/src/debug/debug-runtime.ts b/packages/universal/interfaces/src/debug/debug-runtime.ts index 0dab2f41..4b1da48d 100644 --- a/packages/universal/interfaces/src/debug/debug-runtime.ts +++ b/packages/universal/interfaces/src/debug/debug-runtime.ts @@ -26,8 +26,8 @@ export interface DebugRuntime { readonly callerStack: CallerStackFn; /** - * Mark the current function as a debug entry point. The immediate caller of a - * debug entry point becomes the call stack associated with any debug + * Mark the current function as a debug entry point. The immediate caller of + * a debug entry point becomes the call stack associated with any debug * information generated for that entry point. * * @param options.caller Optionally specify an explicit caller. By default, diff --git a/packages/universal/interfaces/src/protocol.ts b/packages/universal/interfaces/src/protocol.ts index bb1270ba..8013de86 100644 --- a/packages/universal/interfaces/src/protocol.ts +++ b/packages/universal/interfaces/src/protocol.ts @@ -65,9 +65,9 @@ export interface FormulaTag extends TagMethods { * necessarily mean that the formula is static, because a formula has no * children before it was first initialized. * - * Data structures built on `FormulaTag` should always read the formula before - * attempting to read the children if they plan to rely on the absence of - * children as a strong indicator of staticness. + * Data structures built on `FormulaTag` should always read the formula + * before attempting to read the children if they plan to rely on the absence + * of children as a strong indicator of staticness. */ children: () => ReadonlySet; } @@ -137,8 +137,8 @@ export type SubscriptionTarget = CellTag | FormulaTag; * * NOTE: In previous versions of Starbeam, it was legal to change the tag after * the tagged object was initially created. However, this made it impossible to - * use an tagged object's tag as a key in a WeakMap, which meant that the tagged - * object itself had to be passed around even when it was semantically + * use an tagged object's tag as a key in a WeakMap, which meant that the + * tagged object itself had to be passed around even when it was semantically * unimportant. * * These days, the `[TAG]` property must not change once it has been read. For diff --git a/packages/universal/interfaces/src/runtime.ts b/packages/universal/interfaces/src/runtime.ts index 63ce8c73..08f888fd 100644 --- a/packages/universal/interfaces/src/runtime.ts +++ b/packages/universal/interfaces/src/runtime.ts @@ -5,8 +5,8 @@ import type { Timestamp } from "./timestamp.js"; import type { Unsubscribe } from "./utils.js"; /** - * The runtime is the interface that defines the core operations of the reactive - * system. + * The runtime is the interface that defines the core operations of the + * reactive system. * * ## Cells and Formulas * @@ -24,8 +24,8 @@ import type { Unsubscribe } from "./utils.js"; * * ## Lifetime Management * - * - `onFinalize(object, handler)`: Registers a finalizer handler for an object. - * - `finalize(object)`: Finalizes an object. + * - `onFinalize(object, handler)`: Registers a finalizer handler for an + * object. - `finalize(object)`: Finalizes an object. * - `link(parent, child)`: Link two objects together: when the parent is * finalized, the child will be finalized as well. */ @@ -50,8 +50,8 @@ export interface Runtime { readonly update: (formula: FormulaTag) => void; /** - * Subscribe to notifications that the given tag has updates ready ("readiness - * notifications"). + * Subscribe to notifications that the given tag has updates ready + * ("readiness notifications"). * * The second parameter to `subscribe` is a callback that will be called * *immediately* when the tag is updated. diff --git a/packages/universal/interfaces/src/tag.ts b/packages/universal/interfaces/src/tag.ts index 2698cea8..e0c86e37 100644 --- a/packages/universal/interfaces/src/tag.ts +++ b/packages/universal/interfaces/src/tag.ts @@ -8,13 +8,13 @@ import type { Timestamp } from "./timestamp.js"; export type TagSnapshot = ReadonlySet; /** - * Cell is the fundamental mutable reactive value. All subscriptions in Starbeam - * are ultimately subscriptions to cells, and all mutations in Starbeam are - * ultimately mutations to cells. + * Cell is the fundamental mutable reactive value. All subscriptions in + * Starbeam are ultimately subscriptions to cells, and all mutations in + * Starbeam are ultimately mutations to cells. * * If a cell has `undefined` dependencies, that means that the cell cannot - * change anymore. This allows it to be removed from any formulas that depend on - * it. + * change anymore. This allows it to be removed from any formulas that depend + * on it. */ export interface CellTag { readonly type: "cell"; diff --git a/packages/universal/interfaces/src/tagged.ts b/packages/universal/interfaces/src/tagged.ts index 13d44534..5a35700c 100644 --- a/packages/universal/interfaces/src/tagged.ts +++ b/packages/universal/interfaces/src/tagged.ts @@ -14,8 +14,8 @@ export type HasTag = T | Tagged; * * NOTE: In previous versions of Starbeam, it was legal to change the tag after * the tagged object was initially created. However, this made it impossible to - * use an tagged object's tag as a key in a WeakMap, which meant that the tagged - * object itself had to be passed around even when it was semantically + * use an tagged object's tag as a key in a WeakMap, which meant that the + * tagged object itself had to be passed around even when it was semantically * unimportant. */ export interface Tagged { diff --git a/packages/universal/renderer/src/renderer.ts b/packages/universal/renderer/src/renderer.ts index 8ce18f9a..e8cbbd0f 100644 --- a/packages/universal/renderer/src/renderer.ts +++ b/packages/universal/renderer/src/renderer.ts @@ -14,8 +14,8 @@ import type { IntoResourceBlueprint } from "./resource.js"; * and returns a value. * * In the simplest case, you can simply call setup with a function with no - * parameters. The function will run during the setup phase, and return a stable - * result for the lifetime of the component. + * parameters. The function will run during the setup phase, and return a + * stable result for the lifetime of the component. * * You can also make use of the {@linkcode Lifecycle} to use resources, get * services or register code to run during the _idle_ or _layout_ phase. @@ -26,8 +26,8 @@ export type SetupBlueprint = (lifecycle: Lifecycle) => T; * `ReactiveBlueprint` is a function that takes a {@linkcode Lifecycle} and * returns an optionally reactive value. You can pass it to * {@linkcode useReactive} or {@linkcode setupReactive}. These functions will - * instantiate the blueprint during the setup phase and return a stable reactive - * value. + * instantiate the blueprint during the setup phase and return a stable + * reactive value. * * If you pass a `ReactiveBlueprint` to {@linkcode useReactive}, you must also * pass dependencies to {@linkcode useReactive}. If the dependencies change, diff --git a/packages/universal/resource/tests/resource.spec.ts b/packages/universal/resource/tests/resource.spec.ts index 6caa9c64..a879a752 100644 --- a/packages/universal/resource/tests/resource.spec.ts +++ b/packages/universal/resource/tests/resource.spec.ts @@ -565,8 +565,8 @@ class ResourceWrapper { }; /** - * The `act` method takes an action definition and thoroughly tests the action - * by performing this sequence of steps **twice**: + * The `act` method takes an action definition and thoroughly tests the + * action by performing this sequence of steps **twice**: * * 1. Verify that the event list is empty. * 2. Run the action. diff --git a/packages/universal/shared/src/env.ts b/packages/universal/shared/src/env.ts index b50cfdf9..99597f1f 100644 --- a/packages/universal/shared/src/env.ts +++ b/packages/universal/shared/src/env.ts @@ -33,8 +33,8 @@ export interface Lifetime { /** * Like {@linkcode pushFinalizationScope}, but does not add the scope to the * parent scope when complete. This is useful for scopes that represent - * long-lived stacks, such as async functions or reactive resources (which can - * have nested scopes that evolve over time). + * long-lived stacks, such as async functions or reactive resources (which + * can have nested scopes that evolve over time). */ mountFinalizationScope: (child?: object) => () => FinalizationScope; diff --git a/packages/universal/shared/src/types.ts b/packages/universal/shared/src/types.ts index 1eb2d02d..194afd1a 100644 --- a/packages/universal/shared/src/types.ts +++ b/packages/universal/shared/src/types.ts @@ -1,5 +1,5 @@ /** - * A registration function takes a handler function and returns a function that, - * when called, removes the handler. + * A registration function takes a handler function and returns a function + * that, when called, removes the handler. */ export type Unregister = () => void; diff --git a/packages/universal/verify/index.ts b/packages/universal/verify/index.ts index 268f5ade..f8e8b950 100644 --- a/packages/universal/verify/index.ts +++ b/packages/universal/verify/index.ts @@ -26,7 +26,7 @@ export { export { type TypeOf } from "./src/assertions/types.js"; export { type Expectation, VerificationError } from "./src/verify.js"; -export const expected: typeof expectedDev = import.meta.env.DEV ? expectedDev : null as any +export const expected: typeof expectedDev = import.meta.env.DEV ? expectedDev : null as unknown as typeof expectedDev export const hasType: typeof hasTypeDev = import.meta.env.DEV ? hasTypeDev : (noop as typeof hasTypeDev) export const isOneOf: typeof isOneOfDev = import.meta.env.DEV ? isOneOfDev : (noop as typeof isOneOfDev) diff --git a/packages/vue/vue-testing-utils/src/testing.ts b/packages/vue/vue-testing-utils/src/testing.ts index ef4f2f1c..564f13a6 100644 --- a/packages/vue/vue-testing-utils/src/testing.ts +++ b/packages/vue/vue-testing-utils/src/testing.ts @@ -80,17 +80,17 @@ function defComponent( /** * Define a Vue component for testing with specified props. * - * This component should not be rendered directly in testing. Instead, it should - * be invoked from the app (specified via {@linkcode App}) or a descendant of - * the app. + * This component should not be rendered directly in testing. Instead, it + * should be invoked from the app (specified via {@linkcode App}) or a + * descendant of the app. * * @param props The props of the component, as passed to * {@linkcode defineComponent} in Vue. * @param definition The setup function of the component. * - * The `definition` parameter may be may either be specified as a plain function - * that takes props as specified by the `props` parameter, or it may be - * specified as: + * The `definition` parameter may be may either be specified as a plain + * function that takes props as specified by the `props` parameter, or it may + * be specified as: * * `{ setup: (props) => () => VNodeChild }` */ diff --git a/workspace/dev-compile/src/rollup/plugins/external.ts b/workspace/dev-compile/src/rollup/plugins/external.ts index 6c04ac98..c20da2dd 100644 --- a/workspace/dev-compile/src/rollup/plugins/external.ts +++ b/workspace/dev-compile/src/rollup/plugins/external.ts @@ -24,7 +24,8 @@ import type { RollupPlugin } from "../utils.js"; * import is "inline", it is combined with the built package's main file and * further optimized. * - * In general, it's better to inline an import if any of the following are true: + * In general, it's better to inline an import if any of the following are + * true: * * 1. It is only used by this package. * 2. Its exports are easy to optimize by a minifier in production builds (e.g. @@ -40,12 +41,13 @@ import type { RollupPlugin } from "../utils.js"; * 1. Relative imports: If the import starts with a `.`, then it is an inline * import. * 2. Custom rules: If the `starbeam:inline` key in `package.json` specifies a - * rule for a dependency, use it. You can use custom rules to override any of - * the default rules below. + * rule for a dependency, use it. You can use custom rules to override any + * of the default rules below. * 3. [TODO] Custom workspace rules: If the `starbeam:inline` key in the * `package.json` for the workspace root specifies a rule for a dependency, * use it. - * 4. Helper libraries: If the import is one of the well-known helper libraries, + * 4. Helper libraries: If the import is one of the well-known helper + * libraries, * then it is an inline import. * 5. Absolute imports: If the import starts with `/`, then it is an inline * import. This is because absolute imports are usually relative imports @@ -108,8 +110,8 @@ import type { RollupPlugin } from "../utils.js"; * * ### Rules Object * - * Each key in the object is a rule pattern, and the value is either "inline" or - * "external". + * Each key in the object is a rule pattern, and the value is either "inline" + * or "external". * * Example: * @@ -129,8 +131,8 @@ import type { RollupPlugin } from "../utils.js"; * In this example, the `react` dependency is externalized, and the `lodash` * dependency is inlined. * - * The default behavior is to externalize all dependencies, so you don't need to - * specify "external" in a rules object unless you want to supersede a later + * The default behavior is to externalize all dependencies, so you don't need + * to specify "external" in a rules object unless you want to supersede a later * rule. * * Example: @@ -157,8 +159,8 @@ import type { RollupPlugin } from "../utils.js"; * ### Rule Objects in a Rules Array * * When you have a lot of inline rules and only a handful of externals - * overrides, it's nice to be able to avoid repeating `: "inline"` over and over - * again. + * overrides, it's nice to be able to avoid repeating `: "inline"` over and + * over again. * * In this situation, you can include rule objects in a rules array. * diff --git a/workspace/dev-compile/src/rollup/plugins/import-meta.ts b/workspace/dev-compile/src/rollup/plugins/import-meta.ts index 69f5e5f1..2caea686 100644 --- a/workspace/dev-compile/src/rollup/plugins/import-meta.ts +++ b/workspace/dev-compile/src/rollup/plugins/import-meta.ts @@ -13,11 +13,12 @@ import { createReplacePlugin } from "./replace.js"; * * Replacements: * - * | source | replacement rule | - * | ---------------------- | ------------------------------------------------ | - * | `import.meta.env.MODE` | the specified mode (string) | - * | `import.meta.env.DEV` | true if the mode is "development" (boolean) | - * | `import.meta.env.PROD` | true if the mode is "production" (boolean) | + * | source | replacement rule + * | | ---------------------- | + * ------------------------------------------------ | | `import.meta.env.MODE` + * | the specified mode (string) | | `import.meta.env.DEV` + * | true if the mode is "development" (boolean) | | + * `import.meta.env.PROD` | true if the mode is "production" (boolean) | * * It is possible for both `DEV` and `PROD` to be false (if the specified mode * is something other than `"development"` or `"production"`). In general, this diff --git a/workspace/dev-compile/src/rollup/plugins/replace.ts b/workspace/dev-compile/src/rollup/plugins/replace.ts index 5f08f448..c13d1ee7 100644 --- a/workspace/dev-compile/src/rollup/plugins/replace.ts +++ b/workspace/dev-compile/src/rollup/plugins/replace.ts @@ -26,8 +26,8 @@ const { default: MagicString } = await import("magic-string"); * }; * ``` * - * This will replace any instances of `import.meta.hello` in source modules with - * the content `"world"`. + * This will replace any instances of `import.meta.hello` in source modules + * with the content `"world"`. * * The main purpose of this plugin is to replace dynamic variables with * build-time constant values, which can then be further processed by a @@ -36,8 +36,8 @@ const { default: MagicString } = await import("magic-string"); * For example, the `importMeta` plugin replaces `import.meta.env.DEV` with * `true` in development mode and `false` in production mode. In production, * source code guarded with `if (import.meta.env.DEV)` will be emitted as `if - * (false)`. The subsequent minification pass will remove the entire `if` block, - * including its contents. + * (false)`. The subsequent minification pass will remove the entire `if` + * block, including its contents. * * @param {(id: string) => boolean} test * @param {Record} replacements @param {boolean} sourcemap diff --git a/workspace/dev-compile/src/rollup/plugins/typescript.ts b/workspace/dev-compile/src/rollup/plugins/typescript.ts index 8635f42b..a3215c12 100644 --- a/workspace/dev-compile/src/rollup/plugins/typescript.ts +++ b/workspace/dev-compile/src/rollup/plugins/typescript.ts @@ -31,7 +31,8 @@ const rollupTS = * into normal enums. * - All import paths that refer to non-existent JavaScript modules (type-only * modules) are imported using `import type`. - * - All imports that do not refer to a JavaScript value are imported as part of + * - All imports that do not refer to a JavaScript value are imported as part + * of * an `import type` statement or are annotated with `type` (i.e. `import { * map, type MapFn } from "map"`). * @@ -48,11 +49,11 @@ const rollupTS = * * * - * We also recommend the use of `@typescript-eslint/consistent-type-imports` and - * `@typescript-eslint/no-import-type-side-effects`. These auto-fixable lints - * will error if you don't use `import type` on an import statement that is - * never used as a value. These lints will also ensure that any named imports - * that are only used as types are annotated with `type`. + * We also recommend the use of `@typescript-eslint/consistent-type-imports` + * and `@typescript-eslint/no-import-type-side-effects`. These auto-fixable + * lints will error if you don't use `import type` on an import statement that + * is never used as a value. These lints will also ensure that any named + * imports that are only used as types are annotated with `type`. * * If you're using vscode, you can enable "source.fixAll" in * `editor.codeActionOnSave` and imports will automatically be updated if you @@ -61,8 +62,8 @@ const rollupTS = * ## Type Checking * * > **TL;DR** This plugin does **not** typecheck your code. It is intended to - * > be run after verifying your code using tools such as `tsc` and `eslint` and - * > after successfully running your tests. + * > be run after verifying your code using tools such as `tsc` and `eslint` + * and > after successfully running your tests. * * Now for the longer version... * @@ -84,8 +85,8 @@ const rollupTS = * * > Adding to the confusion, the tool that you use to *verify* your TypeScript * > code is called `tsc`. Even more confusingly, `tsc` is intended to be a - * > good-enough reference compiler for TypeScript code. In practice, though, it - * > makes more sense to use `tsc` as part of a comprehensive *verification* + * > good-enough reference compiler for TypeScript code. In practice, though, + * it > makes more sense to use `tsc` as part of a comprehensive *verification* * > strategy and to use other tools (such as `esbuild` or `swc`) to compile * > your TypeScript code. * diff --git a/workspace/dev-compile/src/rollup/rollup.ts b/workspace/dev-compile/src/rollup/rollup.ts index 5357bc0e..3d9b2392 100644 --- a/workspace/dev-compile/src/rollup/rollup.ts +++ b/workspace/dev-compile/src/rollup/rollup.ts @@ -6,12 +6,12 @@ import type { PackageInfo } from "@starbeam-dev/core"; import { Package, rootAt } from "@starbeam-dev/core"; import type { RollupOptions } from "rollup"; import copy from 'rollup-plugin-copy' +import prettier from 'rollup-plugin-prettier'; import externals from "./plugins/external.js"; import importMeta from "./plugins/import-meta.js"; import typescript from "./plugins/typescript.js"; import type { RollupPlugin } from "./utils.js"; -import prettier from 'rollup-plugin-prettier'; const MODES = ["development", "production", undefined] as const; diff --git a/workspace/unstable-release/src/workspaces.js b/workspace/unstable-release/src/workspaces.js index 871f6fee..27ff5dc6 100644 --- a/workspace/unstable-release/src/workspaces.js +++ b/workspace/unstable-release/src/workspaces.js @@ -6,7 +6,8 @@ import { readPackageJson } from "./read-package-json.js"; /** * All publishable packages are in packages/* * - * We could read package.json#workspaces, but then we'd have more to filter out. + * We could read package.json#workspaces, but then we'd have more to filter + * out. */ export async function listPublicWorkspaces() { let filePaths = await globby(["packages/**/package.json"], {