From 7f4f3f0bcc3c6fd2ad5a4ad244665fa4d8e97263 Mon Sep 17 00:00:00 2001 From: Yehuda Katz Date: Thu, 31 Oct 2024 14:49:03 -0700 Subject: [PATCH] Improve benchmark setup (#1647) * Improve benchmark setup The main improvement is cloning from your local `.git` directory rather than the remote. There are also some minor ergonomic improvements to the output. * Fix lint error * Fix typescript errors in js files * Silence a bunch of lint warnings --- benchmark/benchmarks/krausest/vite.config.mts | 22 ++++-- bin/setup-bench.mjs | 46 +++++------- package.json | 2 +- .../@glimmer-workspace/build/lib/config.js | 7 +- .../test-utils/lib/guard.ts | 1 + packages/@glimmer-workspace/tsconfig.json | 4 +- packages/@glimmer/debug/lib/debug.ts | 2 +- packages/@glimmer/debug/lib/metadata.ts | 1 + packages/@glimmer/debug/lib/stack-check.ts | 1 + packages/@glimmer/global-context/index.ts | 1 + .../lib/compile/wire-format/api.d.ts | 4 +- .../interfaces/lib/runtime/arguments.d.ts | 1 + .../interfaces/lib/runtime/environment.d.ts | 1 + .../@glimmer/manager/lib/internal/defaults.ts | 1 + .../@glimmer/manager/lib/public/component.ts | 2 + .../@glimmer/manager/lib/public/helper.ts | 1 + .../@glimmer/manager/lib/public/modifier.ts | 1 + .../@glimmer/manager/lib/util/args-proxy.ts | 1 + .../manager/test/capabilities-test.ts | 73 ++++++++++++++++--- .../@glimmer/manager/test/managers-test.ts | 1 + .../@glimmer/node/lib/serialize-builder.ts | 2 + .../lib/opcode-builder/helpers/components.ts | 2 + .../lib/opcode-builder/helpers/resolution.ts | 6 +- packages/@glimmer/owner/index.ts | 1 + .../@glimmer/syntax/lib/generation/util.ts | 1 + .../@glimmer/syntax/lib/traversal/traverse.ts | 3 + .../syntax/test/legacy-interop-test.ts | 1 + .../@glimmer/syntax/test/plugin-node-test.ts | 2 + packages/@glimmer/syntax/test/support.ts | 3 + packages/@glimmer/util/lib/assert.ts | 2 +- packages/@glimmer/util/lib/debug-to-string.ts | 2 + packages/@glimmer/util/lib/immediate.ts | 22 ++++-- packages/@glimmer/util/lib/simple-cast.ts | 2 +- packages/@glimmer/util/test/immediate-test.ts | 4 +- packages/@glimmer/validator/lib/debug.ts | 1 + packages/@glimmer/validator/lib/utils.ts | 1 + .../@glimmer/validator/test/tracking-test.ts | 3 + pnpm-lock.yaml | 62 ++-------------- 38 files changed, 169 insertions(+), 124 deletions(-) diff --git a/benchmark/benchmarks/krausest/vite.config.mts b/benchmark/benchmarks/krausest/vite.config.mts index ae34fe4b7..7a5bdb1c7 100644 --- a/benchmark/benchmarks/krausest/vite.config.mts +++ b/benchmark/benchmarks/krausest/vite.config.mts @@ -15,7 +15,10 @@ const packagePath = (name: string) => { }; export default defineConfig({ - plugins: [benchmark()], + plugins: [importMeta(), benchmark()], + preview: { + strictPort: true, + }, resolve: { alias: { '@glimmer-workspace/benchmark-env': '@glimmer-workspace/benchmark-env/index.ts', @@ -27,6 +30,19 @@ export default defineConfig({ }, }); +function importMeta(): Plugin { + return { + name: 'define custom import.meta.env', + async transform(code) { + if (code.includes('import.meta.env.VM_LOCAL_DEV')) { + return code.replace(/import.meta.env.VM_LOCAL_DEV/g, 'false'); + } + return undefined; + }, + enforce: 'pre', + }; +} + function benchmark(): Plugin { return { enforce: 'pre', @@ -34,15 +50,11 @@ function benchmark(): Plugin { resolveId(id) { if (id === '@glimmer/env') { return '\0@glimmer/env'; - } else if (id === '@glimmer/local-debug-flags') { - return '\0@glimmer/local-debug-flags'; } }, load(id) { if (id === '\0@glimmer/env') { return `export const DEBUG = false;`; - } else if (id === '\0@glimmer/local-debug-flags') { - return `export const LOCAL_SHOULD_LOG = false;`; } /** @type {string | undefined} */ let result: string | undefined; diff --git a/bin/setup-bench.mjs b/bin/setup-bench.mjs index 40d5378a3..fabab8c1b 100644 --- a/bin/setup-bench.mjs +++ b/bin/setup-bench.mjs @@ -1,6 +1,10 @@ import 'zx/globals'; import os from 'node:os'; import { join } from 'node:path'; +import chalk from 'chalk'; + +const ROOT = new URL('..', import.meta.url).pathname; +$.verbose = true; /* @@ -80,21 +84,6 @@ const isMacOs = os.platform() === 'darwin'; const BENCHMARK_FOLDER = join(pwd, benchmarkFolder); -const rawUpstreamUrl = await $`git ls-remote --get-url upstream`; -const rawOriginUrl = await $`git ls-remote --get-url origin`; -let originUrlStr = rawOriginUrl.toString().trim(); -let upstreamUrlStr = rawUpstreamUrl.toString().trim(); - -if (upstreamUrlStr === 'upstream') { - // if we not inside fork, falling back to origin - upstreamUrlStr = originUrlStr; -} - -if (FORK_NAME && FORK_NAME !== 'glimmerjs/glimmer-vm') { - // if PR from fork, we need to resolve fork's commit - originUrlStr = originUrlStr.replace('glimmerjs/glimmer-vm', FORK_NAME); -} - const CONTROL_PORT = 4020; const EXPERIMENT_PORT = 4021; const CONTROL_URL = `http://localhost:${CONTROL_PORT}`; @@ -105,15 +94,15 @@ const EXPERIMENT_URL = `http://localhost:${EXPERIMENT_PORT}`; // setup experiment await within(async () => { await cd(EXPERIMENT_DIR); - await $`git clone ${originUrlStr} .`; + await $`git clone ${join(ROOT, '.git')} .`; await $`git checkout ${experimentBranchName}`; await $`rm -rf ./benchmark`; await $`cp -r ${BENCHMARK_FOLDER} ./benchmark`; - console.info('installing experiment source'); - await $`pnpm install --no-frozen-lockfile`.quiet(); - console.info('building experiment source, may take a while'); - await $`pnpm build`.quiet(); + console.info(`$ pnpm install --frozen-lockfile ${chalk.gray('[experiment]')}`); + await $`pnpm install --frozen-lockfile`.quiet(); + console.info(`$ pnpm build ${chalk.gray('[experiment]')}`); + await spinner(() => $`pnpm build`.quiet()); if (isMacOs) { await $`find ./packages -name 'package.json' -exec sed -i '' 's|"main": "index.ts",|"main": "./dist/prod/index.js","module": "./dist/prod/index.js",|g' {} \\;`; @@ -132,15 +121,16 @@ await within(async () => { // setup control await within(async () => { await cd(CONTROL_DIR); - await $`git clone ${upstreamUrlStr} .`; - await $`git checkout ${controlBranchName}`; + await $`git clone ${join(ROOT, '.git')} .`; + await $`git fetch origin`; + await $`git reset --hard origin/${controlBranchName}`; await $`rm -rf ./benchmark`; await $`cp -r ${BENCHMARK_FOLDER} ./benchmark`; - console.info('installing control source'); - await $`pnpm install --no-frozen-lockfile`.quiet(); - console.info('building control source, may take a while'); - await $`pnpm build`.quiet(); + console.info(`$ pnpm install --frozen-lockfile ${chalk.gray('[control]')}`); + await $`pnpm install --frozen-lockfile`.quiet(); + console.info(`$ pnpm build ${chalk.gray('[control]')}`); + await spinner(() => $`pnpm build`.quiet()); if (isMacOs) { await $`find ./packages -name 'package.json' -exec sed -i '' 's|"main": "index.ts",|"main": "./dist/prod/index.js","module": "./dist/prod/index.js",|g' {} \\;`; @@ -157,8 +147,8 @@ await within(async () => { }); console.info({ - upstreamUrlStr, - originUrlStr, + control: controlBranchName, + experiment: experimentBranchName, EXPERIMENT_DIR, CONTROL_DIR, }); diff --git a/package.json b/package.json index a44f8cc4d..dd0403f28 100644 --- a/package.json +++ b/package.json @@ -106,7 +106,7 @@ "typescript": "^5.0.4", "vite": "^5.0.12", "xo": "^0.54.2", - "zx": "^7.2.3" + "zx": "^8.1.9" }, "changelog": { "repo": "glimmerjs/glimmer-vm", diff --git a/packages/@glimmer-workspace/build/lib/config.js b/packages/@glimmer-workspace/build/lib/config.js index 78e008bf0..d006ed64a 100644 --- a/packages/@glimmer-workspace/build/lib/config.js +++ b/packages/@glimmer-workspace/build/lib/config.js @@ -256,9 +256,8 @@ export class Package { } /** - * @typedef {object} Formats - * @property {boolean} [ esm ] enabled by default - * @property {boolean} [ cjs ] enabled by default until eslint-plugin-ember and ember-source no longer need it + * @typedef {{esm?: boolean, cjs?: boolean}} Formats + * @param {Formats} [formats] enabled by default * * @returns {import("rollup").RollupOptions[] | import("rollup").RollupOptions} */ @@ -371,7 +370,7 @@ export class Package { typescript(this.#package, { target: ScriptTarget.ES2021, module: ModuleKind.CommonJS, - moduleResolution: ModuleResolutionKind.NodeJs, + moduleResolution: ModuleResolutionKind.Node16, }), ], })); diff --git a/packages/@glimmer-workspace/test-utils/lib/guard.ts b/packages/@glimmer-workspace/test-utils/lib/guard.ts index 5f38aea5a..0ec5cd4d3 100644 --- a/packages/@glimmer-workspace/test-utils/lib/guard.ts +++ b/packages/@glimmer-workspace/test-utils/lib/guard.ts @@ -1,6 +1,7 @@ import type { Expand, Maybe, Present } from '@glimmer/interfaces'; import { isPresent } from '@glimmer/util'; +// eslint-disable-next-line @typescript-eslint/no-explicit-any export type NTuple = T['length'] extends N ? T : NTuple; diff --git a/packages/@glimmer-workspace/tsconfig.json b/packages/@glimmer-workspace/tsconfig.json index 893afe5de..ecfbdabf9 100644 --- a/packages/@glimmer-workspace/tsconfig.json +++ b/packages/@glimmer-workspace/tsconfig.json @@ -2,16 +2,14 @@ "compilerOptions": { "composite": true, "baseUrl": "..", - + "allowJs": true, "target": "esnext", "module": "esnext", "moduleResolution": "bundler", "allowSyntheticDefaultImports": true, "experimentalDecorators": true, "verbatimModuleSyntax": true, - "outDir": "../../ts-dist/@glimmer-workspace", - "strict": true, "suppressImplicitAnyIndexErrors": false, "useDefineForClassFields": false, diff --git a/packages/@glimmer/debug/lib/debug.ts b/packages/@glimmer/debug/lib/debug.ts index 33fc53403..ad2ef20b2 100644 --- a/packages/@glimmer/debug/lib/debug.ts +++ b/packages/@glimmer/debug/lib/debug.ts @@ -96,7 +96,7 @@ export function debug( let metadata = opcodeMetadata(op.type, isMachine); if (!metadata) { - throw new Error(`Missing Opcode Metadata for ${op}`); + throw new Error(`Missing Opcode Metadata for ${op.type}`); } let out = Object.create(null); diff --git a/packages/@glimmer/debug/lib/metadata.ts b/packages/@glimmer/debug/lib/metadata.ts index 43399637e..c89ef2250 100644 --- a/packages/@glimmer/debug/lib/metadata.ts +++ b/packages/@glimmer/debug/lib/metadata.ts @@ -19,6 +19,7 @@ export const OPERAND_TYPES = [ ]; function isOperandType(s: string): s is OperandType { + // eslint-disable-next-line @typescript-eslint/no-explicit-any return OPERAND_TYPES.indexOf(s as any) !== -1; } diff --git a/packages/@glimmer/debug/lib/stack-check.ts b/packages/@glimmer/debug/lib/stack-check.ts index a0b81969a..19ef8a413 100644 --- a/packages/@glimmer/debug/lib/stack-check.ts +++ b/packages/@glimmer/debug/lib/stack-check.ts @@ -290,6 +290,7 @@ class SafeStringChecker implements Checker { validate(value: unknown): value is SafeString { return ( + // eslint-disable-next-line @typescript-eslint/no-explicit-any typeof value === 'object' && value !== null && typeof (value as any).toHTML === 'function' ); } diff --git a/packages/@glimmer/global-context/index.ts b/packages/@glimmer/global-context/index.ts index 3c458dff1..01c67a833 100644 --- a/packages/@glimmer/global-context/index.ts +++ b/packages/@glimmer/global-context/index.ts @@ -1,3 +1,4 @@ +/* eslint-disable @typescript-eslint/no-explicit-any */ /** * This package contains global context functions for Glimmer. These functions * are set by the embedding environment and must be set before initial render. diff --git a/packages/@glimmer/interfaces/lib/compile/wire-format/api.d.ts b/packages/@glimmer/interfaces/lib/compile/wire-format/api.d.ts index eecb62a15..8857fc8ea 100644 --- a/packages/@glimmer/interfaces/lib/compile/wire-format/api.d.ts +++ b/packages/@glimmer/interfaces/lib/compile/wire-format/api.d.ts @@ -66,7 +66,7 @@ export type ExpressionSexpOpcodeMap = { [TSexpOpcode in TupleExpression[0]]: Extract; }; -export interface SexpOpcodeMap extends ExpressionSexpOpcodeMap, StatementSexpOpcodeMap { } +export interface SexpOpcodeMap extends ExpressionSexpOpcodeMap, StatementSexpOpcodeMap {} export type SexpOpcode = keyof SexpOpcodeMap; export namespace Core { @@ -372,7 +372,7 @@ export type SerializedTemplateBlock = [ hasDebug: boolean, // upvars upvars: string[], - lexicalSymbols?: string[] + lexicalSymbols?: string[], ]; /** diff --git a/packages/@glimmer/interfaces/lib/runtime/arguments.d.ts b/packages/@glimmer/interfaces/lib/runtime/arguments.d.ts index cb1b32d27..92a1c045a 100644 --- a/packages/@glimmer/interfaces/lib/runtime/arguments.d.ts +++ b/packages/@glimmer/interfaces/lib/runtime/arguments.d.ts @@ -67,6 +67,7 @@ export interface ArgumentsDebug { } export interface ArgumentError { + // eslint-disable-next-line @typescript-eslint/no-explicit-any error: any; } diff --git a/packages/@glimmer/interfaces/lib/runtime/environment.d.ts b/packages/@glimmer/interfaces/lib/runtime/environment.d.ts index 219e3924f..25750fb5f 100644 --- a/packages/@glimmer/interfaces/lib/runtime/environment.d.ts +++ b/packages/@glimmer/interfaces/lib/runtime/environment.d.ts @@ -45,5 +45,6 @@ export interface Environment { isInteractive: boolean; debugRenderTree?: DebugRenderTree | undefined; + // eslint-disable-next-line @typescript-eslint/no-explicit-any isArgumentCaptureError?: ((error: any) => boolean) | undefined; } diff --git a/packages/@glimmer/manager/lib/internal/defaults.ts b/packages/@glimmer/manager/lib/internal/defaults.ts index 445a4950c..886578437 100644 --- a/packages/@glimmer/manager/lib/internal/defaults.ts +++ b/packages/@glimmer/manager/lib/internal/defaults.ts @@ -10,6 +10,7 @@ type FnArgs = | [...Args['positional'], Args['named']] | [...Args['positional']]; +// eslint-disable-next-line @typescript-eslint/no-explicit-any type AnyFunction = (...args: any[]) => unknown; interface State { diff --git a/packages/@glimmer/manager/lib/public/component.ts b/packages/@glimmer/manager/lib/public/component.ts index 45a8a6eb3..f99d2cd4c 100644 --- a/packages/@glimmer/manager/lib/public/component.ts +++ b/packages/@glimmer/manager/lib/public/component.ts @@ -126,6 +126,7 @@ export class CustomComponentManager throw new Error( `Custom component managers must have a \`capabilities\` property that is the result of calling the \`capabilities('3.13')\` (imported via \`import { capabilities } from '@ember/component';\`). Received: \`${JSON.stringify( delegate.capabilities + // eslint-disable-next-line @typescript-eslint/no-base-to-string )}\` for: \`${delegate}\`` ); } @@ -150,6 +151,7 @@ export class CustomComponentManager } getDebugName(definition: ComponentDefinitionState): string { + // eslint-disable-next-line @typescript-eslint/no-base-to-string return typeof definition === 'function' ? definition.name : definition.toString(); } diff --git a/packages/@glimmer/manager/lib/public/helper.ts b/packages/@glimmer/manager/lib/public/helper.ts index caed64299..7790fb7f6 100644 --- a/packages/@glimmer/manager/lib/public/helper.ts +++ b/packages/@glimmer/manager/lib/public/helper.ts @@ -82,6 +82,7 @@ export class CustomHelperManager implements InternalHel throw new Error( `Custom helper managers must have a \`capabilities\` property that is the result of calling the \`capabilities('3.23')\` (imported via \`import { capabilities } from '@ember/helper';\`). Received: \`${JSON.stringify( delegate.capabilities + // eslint-disable-next-line @typescript-eslint/no-base-to-string )}\` for: \`${delegate}\`` ); } diff --git a/packages/@glimmer/manager/lib/public/modifier.ts b/packages/@glimmer/manager/lib/public/modifier.ts index ad598d31c..54dd886fc 100644 --- a/packages/@glimmer/manager/lib/public/modifier.ts +++ b/packages/@glimmer/manager/lib/public/modifier.ts @@ -85,6 +85,7 @@ export class CustomModifierManager throw new Error( `Custom modifier managers must have a \`capabilities\` property that is the result of calling the \`capabilities('3.22')\` (imported via \`import { capabilities } from '@ember/modifier';\`). Received: \`${JSON.stringify( delegate.capabilities + // eslint-disable-next-line @typescript-eslint/no-base-to-string )}\` for: \`${delegate}\`` ); } diff --git a/packages/@glimmer/manager/lib/util/args-proxy.ts b/packages/@glimmer/manager/lib/util/args-proxy.ts index f660542fe..7730a12bf 100644 --- a/packages/@glimmer/manager/lib/util/args-proxy.ts +++ b/packages/@glimmer/manager/lib/util/args-proxy.ts @@ -112,6 +112,7 @@ class PositionalArgsProxy implements ProxyHandler<[]> { return valueForRef(positional[parsed]!); } + // eslint-disable-next-line @typescript-eslint/no-explicit-any return (target as any)[prop]; } diff --git a/packages/@glimmer/manager/test/capabilities-test.ts b/packages/@glimmer/manager/test/capabilities-test.ts index fbfa965bd..86aef75d3 100644 --- a/packages/@glimmer/manager/test/capabilities-test.ts +++ b/packages/@glimmer/manager/test/capabilities-test.ts @@ -1,3 +1,4 @@ +import type { InternalComponentManager } from '@glimmer/interfaces'; import { capabilityFlagsFrom, managerHasCapability } from '@glimmer/manager'; import { InternalComponentCapabilities } from '@glimmer/vm'; @@ -83,39 +84,87 @@ QUnit.test('allows querying bitmap for a capability', (assert) => { }); assert.true( - managerHasCapability({} as any, capabilities, InternalComponentCapabilities.dynamicLayout) + managerHasCapability( + {} as InternalComponentManager, + capabilities, + InternalComponentCapabilities.dynamicLayout + ) ); assert.false( - managerHasCapability({} as any, capabilities, InternalComponentCapabilities.dynamicTag) + managerHasCapability( + {} as InternalComponentManager, + capabilities, + InternalComponentCapabilities.dynamicTag + ) ); assert.true( - managerHasCapability({} as any, capabilities, InternalComponentCapabilities.prepareArgs) + managerHasCapability( + {} as InternalComponentManager, + capabilities, + InternalComponentCapabilities.prepareArgs + ) ); assert.false( - managerHasCapability({} as any, capabilities, InternalComponentCapabilities.createArgs) + managerHasCapability( + {} as InternalComponentManager, + capabilities, + InternalComponentCapabilities.createArgs + ) ); assert.false( - managerHasCapability({} as any, capabilities, InternalComponentCapabilities.attributeHook) + managerHasCapability( + {} as InternalComponentManager, + capabilities, + InternalComponentCapabilities.attributeHook + ) ); assert.true( - managerHasCapability({} as any, capabilities, InternalComponentCapabilities.elementHook) + managerHasCapability( + {} as InternalComponentManager, + capabilities, + InternalComponentCapabilities.elementHook + ) ); assert.true( - managerHasCapability({} as any, capabilities, InternalComponentCapabilities.dynamicScope) + managerHasCapability( + {} as InternalComponentManager, + capabilities, + InternalComponentCapabilities.dynamicScope + ) ); assert.false( - managerHasCapability({} as any, capabilities, InternalComponentCapabilities.createCaller) + managerHasCapability( + {} as InternalComponentManager, + capabilities, + InternalComponentCapabilities.createCaller + ) ); assert.true( - managerHasCapability({} as any, capabilities, InternalComponentCapabilities.updateHook) + managerHasCapability( + {} as InternalComponentManager, + capabilities, + InternalComponentCapabilities.updateHook + ) ); assert.false( - managerHasCapability({} as any, capabilities, InternalComponentCapabilities.createInstance) + managerHasCapability( + {} as InternalComponentManager, + capabilities, + InternalComponentCapabilities.createInstance + ) ); assert.false( - managerHasCapability({} as any, capabilities, InternalComponentCapabilities.willDestroy) + managerHasCapability( + {} as InternalComponentManager, + capabilities, + InternalComponentCapabilities.willDestroy + ) ); assert.false( - managerHasCapability({} as any, capabilities, InternalComponentCapabilities.hasSubOwner) + managerHasCapability( + {} as InternalComponentManager, + capabilities, + InternalComponentCapabilities.hasSubOwner + ) ); }); diff --git a/packages/@glimmer/manager/test/managers-test.ts b/packages/@glimmer/manager/test/managers-test.ts index 70e201892..1d7834975 100644 --- a/packages/@glimmer/manager/test/managers-test.ts +++ b/packages/@glimmer/manager/test/managers-test.ts @@ -1,3 +1,4 @@ +/* eslint-disable @typescript-eslint/no-explicit-any */ import type { ComponentManager, HelperManager, diff --git a/packages/@glimmer/node/lib/serialize-builder.ts b/packages/@glimmer/node/lib/serialize-builder.ts index baa8c1dac..15080c325 100644 --- a/packages/@glimmer/node/lib/serialize-builder.ts +++ b/packages/@glimmer/node/lib/serialize-builder.ts @@ -1,3 +1,4 @@ +/* eslint-disable @typescript-eslint/no-unsafe-enum-comparison */ import type { Bounds, ElementBuilder, @@ -88,6 +89,7 @@ class SerializeBuilder extends NewElementBuilder implements ElementBuilder { if (tagName === 'TITLE' || tagName === 'SCRIPT' || tagName === 'STYLE') { return super.__appendText(string); } else if (string === '') { + // eslint-disable-next-line @typescript-eslint/no-explicit-any return this.__appendComment('% %') as any as SimpleText; } else if (current && current.nodeType === TEXT_NODE) { this.__appendComment('%|%'); diff --git a/packages/@glimmer/opcode-compiler/lib/opcode-builder/helpers/components.ts b/packages/@glimmer/opcode-compiler/lib/opcode-builder/helpers/components.ts index 2273c88ea..0006e2d79 100644 --- a/packages/@glimmer/opcode-compiler/lib/opcode-builder/helpers/components.ts +++ b/packages/@glimmer/opcode-compiler/lib/opcode-builder/helpers/components.ts @@ -267,6 +267,7 @@ function InvokeStaticComponent( } if (hasCapability(capabilities, InternalComponentCapabilities.createInstance)) { + // eslint-disable-next-line @typescript-eslint/no-explicit-any op(Op.CreateComponent, (blocks.has('default') as any) | 0, $s0); } @@ -399,6 +400,7 @@ export function invokePreparedComponent( op(Op.BeginComponentTransaction, $s0); op(Op.PushDynamicScope); + // eslint-disable-next-line @typescript-eslint/no-explicit-any op(Op.CreateComponent, (hasBlock as any) | 0, $s0); // this has to run after createComponent to allow diff --git a/packages/@glimmer/opcode-compiler/lib/opcode-builder/helpers/resolution.ts b/packages/@glimmer/opcode-compiler/lib/opcode-builder/helpers/resolution.ts index 1f4a62c30..a243222d4 100644 --- a/packages/@glimmer/opcode-compiler/lib/opcode-builder/helpers/resolution.ts +++ b/packages/@glimmer/opcode-compiler/lib/opcode-builder/helpers/resolution.ts @@ -87,7 +87,8 @@ export function resolveComponent( assert(!meta.isStrictMode, 'Strict mode errors should already be handled at compile time'); throw new Error( - `Attempted to resolve a component in a strict mode template, but that value was not in scope: ${meta.upvars![expr[1]] ?? '{unknown variable}' + `Attempted to resolve a component in a strict mode template, but that value was not in scope: ${ + meta.upvars![expr[1]] ?? '{unknown variable}' }` ); } @@ -393,7 +394,8 @@ function lookupBuiltInHelper( // Keyword helper did not exist, which means that we're attempting to use a // value of some kind that is not in scope throw new Error( - `Attempted to resolve a ${type} in a strict mode template, but that value was not in scope: ${meta.upvars![expr[1]] ?? '{unknown variable}' + `Attempted to resolve a ${type} in a strict mode template, but that value was not in scope: ${ + meta.upvars![expr[1]] ?? '{unknown variable}' }` ); } diff --git a/packages/@glimmer/owner/index.ts b/packages/@glimmer/owner/index.ts index ce786acf5..36ebd28e0 100644 --- a/packages/@glimmer/owner/index.ts +++ b/packages/@glimmer/owner/index.ts @@ -1,3 +1,4 @@ +// eslint-disable-next-line @typescript-eslint/no-explicit-any export const OWNER: unique symbol = Symbol('OWNER') as any; interface OwnedObject { diff --git a/packages/@glimmer/syntax/lib/generation/util.ts b/packages/@glimmer/syntax/lib/generation/util.ts index 5da9b18f0..ffaf637e9 100644 --- a/packages/@glimmer/syntax/lib/generation/util.ts +++ b/packages/@glimmer/syntax/lib/generation/util.ts @@ -1,3 +1,4 @@ +/* eslint-disable @typescript-eslint/no-unsafe-enum-comparison */ import type * as ASTv1 from '../v1/api'; const enum Char { diff --git a/packages/@glimmer/syntax/lib/traversal/traverse.ts b/packages/@glimmer/syntax/lib/traversal/traverse.ts index 80a86afc8..40bd1ce9c 100644 --- a/packages/@glimmer/syntax/lib/traversal/traverse.ts +++ b/packages/@glimmer/syntax/lib/traversal/traverse.ts @@ -67,6 +67,7 @@ function getNodeHandler( visitor: NodeVisitor, nodeType: N['type'] ): NodeTraversal | undefined { + // eslint-disable-next-line deprecation/deprecation if (visitor.Program) { if ( (nodeType === 'Template' && !visitor.Template) || @@ -76,6 +77,7 @@ function getNodeHandler( `The 'Program' visitor node is deprecated. Use 'Template' or 'Block' instead (node was '${nodeType}') ` ); + // eslint-disable-next-line deprecation/deprecation return visitor.Program as NodeTraversal; } } @@ -186,6 +188,7 @@ function visitKey( // TODO: dynamically check the results by having a table of // expected node types in value space, not just type space + // eslint-disable-next-line @typescript-eslint/no-explicit-any assignKey(node, key, value, result as any); } } diff --git a/packages/@glimmer/syntax/test/legacy-interop-test.ts b/packages/@glimmer/syntax/test/legacy-interop-test.ts index 367f8a394..7aaa379f2 100644 --- a/packages/@glimmer/syntax/test/legacy-interop-test.ts +++ b/packages/@glimmer/syntax/test/legacy-interop-test.ts @@ -1,3 +1,4 @@ +/* eslint-disable deprecation/deprecation */ import { builders as b } from '@glimmer/syntax'; QUnit.module('[glimmer-syntax] AST nodes legacy interop'); diff --git a/packages/@glimmer/syntax/test/plugin-node-test.ts b/packages/@glimmer/syntax/test/plugin-node-test.ts index e4cf8f7fc..a3028701d 100644 --- a/packages/@glimmer/syntax/test/plugin-node-test.ts +++ b/packages/@glimmer/syntax/test/plugin-node-test.ts @@ -48,6 +48,7 @@ test('deprecated program visitor', (assert) => { return { name: 'plugin', visitor: { + // eslint-disable-next-line deprecation/deprecation Program(node: AST.Program) { assert.step(node.type); }, @@ -69,6 +70,7 @@ test('deprecated program visitor', (assert) => { }); test('can support the legacy AST transform API via ASTPlugin', (assert) => { + // eslint-disable-next-line @typescript-eslint/no-explicit-any function ensurePlugin(FunctionOrPlugin: any): ASTPluginBuilder { if (FunctionOrPlugin.prototype && FunctionOrPlugin.prototype.transform) { return (env: ASTPluginEnvironment) => { diff --git a/packages/@glimmer/syntax/test/support.ts b/packages/@glimmer/syntax/test/support.ts index 8dbe6d0c8..9571c9326 100644 --- a/packages/@glimmer/syntax/test/support.ts +++ b/packages/@glimmer/syntax/test/support.ts @@ -30,6 +30,7 @@ type FromEntries = { }; function fromEntries(entries: T): FromEntries { + // eslint-disable-next-line @typescript-eslint/no-explicit-any const out: any = {}; for (const [key, value] of entries) { @@ -40,7 +41,9 @@ function fromEntries(entries: T): FromEntrie } export function astEqual( + // eslint-disable-next-line @typescript-eslint/no-explicit-any actual: any | null | undefined, + // eslint-disable-next-line @typescript-eslint/no-explicit-any expected: any | null | undefined, message?: string, parseOptions?: PreprocessOptions diff --git a/packages/@glimmer/util/lib/assert.ts b/packages/@glimmer/util/lib/assert.ts index 783613865..755d6d78b 100644 --- a/packages/@glimmer/util/lib/assert.ts +++ b/packages/@glimmer/util/lib/assert.ts @@ -4,7 +4,7 @@ import { LOCAL_LOGGER } from '../index'; // let alreadyWarned = false; -export function debugAssert(test: any, msg: string): asserts test { +export function debugAssert(test: unknown, msg: string): asserts test { // if (!alreadyWarned) { // alreadyWarned = true; // Logger.warn("Don't leave debug assertions on in public builds"); diff --git a/packages/@glimmer/util/lib/debug-to-string.ts b/packages/@glimmer/util/lib/debug-to-string.ts index d0c5bbe4a..5c053321e 100644 --- a/packages/@glimmer/util/lib/debug-to-string.ts +++ b/packages/@glimmer/util/lib/debug-to-string.ts @@ -26,6 +26,7 @@ if (import.meta.env.DEV) { obj.toString !== Object.prototype.toString && obj.toString !== Function.prototype.toString ) { + // eslint-disable-next-line @typescript-eslint/no-base-to-string name = obj.toString(); } @@ -47,6 +48,7 @@ if (import.meta.env.DEV) { return name || className; }; + // eslint-disable-next-line @typescript-eslint/no-explicit-any let getPrimitiveName = (value: any) => { return String(value); }; diff --git a/packages/@glimmer/util/lib/immediate.ts b/packages/@glimmer/util/lib/immediate.ts index 692c4337a..b60a36ed2 100644 --- a/packages/@glimmer/util/lib/immediate.ts +++ b/packages/@glimmer/util/lib/immediate.ts @@ -61,7 +61,7 @@ export function isHandle(value: number) { } export function isNonPrimitiveHandle(value: number) { - return value > ImmediateConstants.ENCODED_UNDEFINED_HANDLE; + return (value as ImmediateConstants) > ImmediateConstants.ENCODED_UNDEFINED_HANDLE; } export function constants(...values: unknown[]): unknown[] { @@ -70,14 +70,16 @@ export function constants(...values: unknown[]): unknown[] { export function isSmallInt(value: number) { return ( - value % 1 === 0 && value <= ImmediateConstants.MAX_INT && value >= ImmediateConstants.MIN_INT + value % 1 === 0 && + (value as ImmediateConstants) <= ImmediateConstants.MAX_INT && + (value as ImmediateConstants) >= ImmediateConstants.MIN_INT ); } export function encodeNegative(num: number) { if (LOCAL_DEBUG) { assert( - num % 1 === 0 && num >= ImmediateConstants.MIN_INT && num < 0, + num % 1 === 0 && (num as ImmediateConstants) >= ImmediateConstants.MIN_INT && num < 0, `Could not encode negative: ${num}` ); } @@ -88,7 +90,9 @@ export function encodeNegative(num: number) { export function decodeNegative(num: number) { if (LOCAL_DEBUG) { assert( - num % 1 === 0 && num < ~ImmediateConstants.MAX_INT && num >= ImmediateConstants.MIN_SMI, + num % 1 === 0 && + num < ~ImmediateConstants.MAX_INT && + (num as ImmediateConstants) >= ImmediateConstants.MIN_SMI, `Could not decode negative: ${num}` ); } @@ -99,7 +103,7 @@ export function decodeNegative(num: number) { export function encodePositive(num: number) { if (LOCAL_DEBUG) { assert( - num % 1 === 0 && num >= 0 && num <= ImmediateConstants.MAX_INT, + num % 1 === 0 && num >= 0 && (num as ImmediateConstants) <= ImmediateConstants.MAX_INT, `Could not encode positive: ${num}` ); } @@ -121,7 +125,7 @@ export function decodePositive(num: number) { export function encodeHandle(num: number) { if (LOCAL_DEBUG) { assert( - num % 1 === 0 && num >= 0 && num <= ImmediateConstants.MAX_SMI, + num % 1 === 0 && num >= 0 && (num as ImmediateConstants) <= ImmediateConstants.MAX_SMI, `Could not encode handle: ${num}` ); } @@ -132,7 +136,7 @@ export function encodeHandle(num: number) { export function decodeHandle(num: number) { if (LOCAL_DEBUG) { assert( - num % 1 === 0 && num <= ImmediateConstants.MAX_SMI && num >= 0, + num % 1 === 0 && (num as ImmediateConstants) <= ImmediateConstants.MAX_SMI && num >= 0, `Could not decode handle: ${num}` ); } @@ -147,7 +151,9 @@ export function encodeImmediate(num: number) { export function decodeImmediate(num: number) { num |= 0; - return num > ImmediateConstants.SIGN_BIT ? decodePositive(num) : decodeNegative(num); + return (num as ImmediateConstants) > ImmediateConstants.SIGN_BIT + ? decodePositive(num) + : decodeNegative(num); } // Warm diff --git a/packages/@glimmer/util/lib/simple-cast.ts b/packages/@glimmer/util/lib/simple-cast.ts index 4a35fbebf..884ef7de1 100644 --- a/packages/@glimmer/util/lib/simple-cast.ts +++ b/packages/@glimmer/util/lib/simple-cast.ts @@ -74,7 +74,7 @@ export function castToBrowser( return null; } - if (typeof document === undefined) { + if (typeof document === 'undefined') { throw new Error('Attempted to cast to a browser node in a non-browser context'); } diff --git a/packages/@glimmer/util/test/immediate-test.ts b/packages/@glimmer/util/test/immediate-test.ts index 43f6d6e8b..30fdbf7f2 100644 --- a/packages/@glimmer/util/test/immediate-test.ts +++ b/packages/@glimmer/util/test/immediate-test.ts @@ -10,7 +10,9 @@ module('immediate encoding tests', () => { let encoded = encodeImmediate(val); assert.strictEqual(val, decodeImmediate(encoded), 'correctly encoded and decoded'); - const isSMI = encoded >= ImmediateConstants.MIN_SMI && encoded <= ImmediateConstants.MAX_SMI; + const isSMI = + (encoded as ImmediateConstants) >= ImmediateConstants.MIN_SMI && + (encoded as ImmediateConstants) <= ImmediateConstants.MAX_SMI; assert.true(isSMI, 'encoded as an SMI'); assert.step(`testing ${val}`); } diff --git a/packages/@glimmer/validator/lib/debug.ts b/packages/@glimmer/validator/lib/debug.ts index d68e108bb..9b86376f6 100644 --- a/packages/@glimmer/validator/lib/debug.ts +++ b/packages/@glimmer/validator/lib/debug.ts @@ -212,6 +212,7 @@ if (import.meta.env.DEV) { if (updateStackBegin !== -1) { let start = nthIndex(e.stack, '\n', 1, updateStackBegin); let end = nthIndex(e.stack, '\n', 4, updateStackBegin); + // eslint-disable-next-line deprecation/deprecation e.stack = e.stack.substr(0, start) + e.stack.substr(end); } } diff --git a/packages/@glimmer/validator/lib/utils.ts b/packages/@glimmer/validator/lib/utils.ts index d481f05d6..5b83f54a8 100644 --- a/packages/@glimmer/validator/lib/utils.ts +++ b/packages/@glimmer/validator/lib/utils.ts @@ -4,6 +4,7 @@ export type UnionToIntersection = (U extends unknown ? (k: U) => void : never ? I : never; +// eslint-disable-next-line @typescript-eslint/no-explicit-any export type AnyKey = keyof any; export type Indexable = Record; diff --git a/packages/@glimmer/validator/test/tracking-test.ts b/packages/@glimmer/validator/test/tracking-test.ts index d238e8ae8..eb513ac3e 100644 --- a/packages/@glimmer/validator/test/tracking-test.ts +++ b/packages/@glimmer/validator/test/tracking-test.ts @@ -398,6 +398,7 @@ module('@glimmer/validator: tracking', () => { if (import.meta.env.DEV) { test('createCache throws an error in import.meta.env.DEV mode if users to use with a non-function', (assert) => { assert.throws( + // eslint-disable-next-line @typescript-eslint/no-explicit-any () => createCache(123 as any), /Error: createCache\(\) must be passed a function as its first parameter. Called with: 123/u ); @@ -405,6 +406,7 @@ module('@glimmer/validator: tracking', () => { test('getValue throws an error in import.meta.env.DEV mode if users to use with a non-cache', (assert) => { assert.throws( + // eslint-disable-next-line @typescript-eslint/no-explicit-any () => getValue(123 as any), /Error: getValue\(\) can only be used on an instance of a cache created with createCache\(\). Called with: 123/u ); @@ -423,6 +425,7 @@ module('@glimmer/validator: tracking', () => { test('isConst throws an error in import.meta.env.DEV mode if users attempt to use with a non-cache', (assert) => { assert.throws( + // eslint-disable-next-line @typescript-eslint/no-explicit-any () => isConst(123 as any), /Error: isConst\(\) can only be used on an instance of a cache created with createCache\(\). Called with: 123/u ); diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 5601d4f67..55accf086 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -217,8 +217,8 @@ importers: specifier: ^0.54.2 version: 0.54.2(eslint-import-resolver-typescript@3.6.1)(webpack@5.94.0) zx: - specifier: ^7.2.3 - version: 7.2.3 + specifier: ^8.1.9 + version: 8.1.9 benchmark/benchmarks/krausest: dependencies: @@ -4420,10 +4420,6 @@ packages: resolution: {integrity: sha512-WGi6THl5HXdXq5RishLkAUPxk4XjYWbmLhEC14hpE92ER3AtZUUUu8SSIy1ntCtYamW8KaEpBlhJ6H6jubjDug==} dev: true - /@types/ps-tree@1.1.6: - resolution: {integrity: sha512-PtrlVaOaI44/3pl3cvnlK+GxOM3re2526TJvPvh7W+keHIXdV4TE0ylpPBAcvFQCbGitaTXwL9u+RF7qtVeazQ==} - dev: true - /@types/qs@6.9.7: resolution: {integrity: sha512-FGa1F62FT09qcrueBA6qYTrJPVDzah9a+493+o2PCXsesWHIn27G98TsSMs3WPNbZIEj4+VJf6saSFpvD+3Zsw==} dev: true @@ -4489,10 +4485,6 @@ packages: resolution: {integrity: sha512-d0XxK3YTObnWVp6rZuev3c49+j4Lo8g4L1ZRm9z5L0xpoZycUPshHgczK5gsUMaZOstjVYYi09p5gYvUtfChYw==} dev: true - /@types/which@3.0.3: - resolution: {integrity: sha512-2C1+XoY0huExTbs8MQv1DuS5FS86+SEjdM9F/+GS61gg5Hqbtj8ZiDSx8MfWcyei907fIPbfPGCOrNUTnVHY1g==} - dev: true - /@types/yauzl@2.10.3: resolution: {integrity: sha512-oJoftv0LSuaDZE3Le4DbKX+KS9G36NzOeSap90UIK0yMA/NhKJhqlSGtNDORNRaIbQfzjXDrQa0ytJ6mNRGz/Q==} requiresBuild: true @@ -10073,11 +10065,6 @@ packages: /functions-have-names@1.2.3: resolution: {integrity: sha512-xckBUXyTIqT97tq2x2AMb+g163b5JFysYk0x4qxNFwbfQkmNZoiRHb6sPzI9/QV33WeuvVYBUIiD4NzNIyqaRQ==} - /fx@31.0.0: - resolution: {integrity: sha512-OoeYSPKqNKmfnH4s+rGYI0c8OZmqqOOXsUtqy0YyHqQQoQSDiDs3m3M9uXKx5OQR+jDx7/FhYqpO3kl/As/xgg==} - hasBin: true - dev: true - /gauge@4.0.4: resolution: {integrity: sha512-f9m+BEN5jkg6a0fZjleidjN51VE1X+mPFQ2DJ0uv1V39oCLCbsGe6yjbBnp7eK7z/+GAon99a3nHuqbuuthyPg==} engines: {node: ^12.13.0 || ^14.15.0 || >=16.0.0} @@ -13271,15 +13258,6 @@ packages: whatwg-url: 5.0.0 dev: true - /node-fetch@3.3.1: - resolution: {integrity: sha512-cRVc/kyto/7E5shrWca1Wsea4y6tL9iYJE5FBCius3JQfb/4P4I295PfhgbJQBLTx6lATE4z+wK0rPM4VS2uow==} - engines: {node: ^12.20.0 || ^14.13.1 || >=16.0.0} - dependencies: - data-uri-to-buffer: 4.0.1 - fetch-blob: 3.2.0 - formdata-polyfill: 4.0.10 - dev: true - /node-fetch@3.3.2: resolution: {integrity: sha512-dRB78srN/l6gqWulah9SrxeYnxeddIG30+GOqK/9OlLVyLg3HPnr6SqOWTWOXKRwC2eGYCkZ59NNuSgvSrpgOA==} engines: {node: ^12.20.0 || ^14.13.1 || >=16.0.0} @@ -17242,7 +17220,7 @@ packages: hasBin: true dependencies: esbuild: 0.18.20 - get-tsconfig: 4.7.2 + get-tsconfig: 4.8.1 source-map-support: 0.5.21 optionalDependencies: fsevents: 2.3.3 @@ -18018,11 +17996,6 @@ packages: - uglify-js dev: true - /webpod@0.0.2: - resolution: {integrity: sha512-cSwwQIeg8v4i3p4ajHhwgR7N6VyxAf+KYSSsY6Pd3aETE+xEU4vbitz7qQkB0I321xnhDdgtxuiSfk5r/FVtjg==} - hasBin: true - dev: true - /websocket-driver@0.7.4: resolution: {integrity: sha512-b17KeDIQVjvb0ssuSDF2cYXSg2iztliJ4B9WdsuB6J952qCPKmnVq4DyW5motImXHDC1cBT/1UezrJVsKw5zjg==} engines: {node: '>=0.8.0'} @@ -18088,14 +18061,6 @@ packages: dependencies: isexe: 2.0.0 - /which@3.0.1: - resolution: {integrity: sha512-XA1b62dzQzLfaEOSQFTCOd5KFf/1VSzZo7/7TUjnya6u0vGGKzU96UQBZTAThCb2j4/xjBAyii1OhRLJEivHvg==} - engines: {node: ^14.17.0 || ^16.13.0 || >=18.0.0} - hasBin: true - dependencies: - isexe: 2.0.0 - dev: true - /which@4.0.0: resolution: {integrity: sha512-GlaYyEb07DPxYCKhKzplCWBJtvxZcZMrL+4UkrTSJHHPyZU4mYYTv3qaOe77H7EODLSSopAUFAc6W8U4yqvscg==} engines: {node: ^16.13.0 || >=18.0.0} @@ -18422,26 +18387,13 @@ packages: /zod@3.23.8: resolution: {integrity: sha512-XBx9AXhXktjUqnepgTiE5flcKIYWi/rme0Eaj+5Y0lftuGBq+jyRu/md4WnuxqgP1ubdpNCsYEYPxrzVHD8d6g==} - /zx@7.2.3: - resolution: {integrity: sha512-QODu38nLlYXg/B/Gw7ZKiZrvPkEsjPN3LQ5JFXM7h0JvwhEdPNNl+4Ao1y4+o3CLNiDUNcwzQYZ4/Ko7kKzCMA==} - engines: {node: '>= 16.0.0'} + /zx@8.1.9: + resolution: {integrity: sha512-UHuLHphHmsBYKkAchkSrEN4nzDyagafqC9HUxtc1J7eopaScW6H9dsLJ1lmkAntnLtDTGoM8fa+jrJrXiIfKFA==} + engines: {node: '>= 12.17.0'} hasBin: true - dependencies: + optionalDependencies: '@types/fs-extra': 11.0.4 - '@types/minimist': 1.2.2 '@types/node': 20.9.4 - '@types/ps-tree': 1.1.6 - '@types/which': 3.0.3 - chalk: 5.3.0 - fs-extra: 11.2.0 - fx: 31.0.0 - globby: 13.2.2 - minimist: 1.2.8 - node-fetch: 3.3.1 - ps-tree: 1.2.0 - webpod: 0.0.2 - which: 3.0.1 - yaml: 2.3.2 dev: true settings: