Skip to content

ember-cli-update to 6.11#2532

Open
RobbieTheWagner wants to merge 4 commits intomainfrom
latest-blueprints
Open

ember-cli-update to 6.11#2532
RobbieTheWagner wants to merge 4 commits intomainfrom
latest-blueprints

Conversation

@RobbieTheWagner
Copy link
Member

@RobbieTheWagner RobbieTheWagner commented Feb 27, 2026

Summary by CodeRabbit

  • Chores

    • Modernized config files to ES module style and updated development tooling, linting, and build configs.
    • Updated package scripts, dependency adjustments, and changed .gitignore to allow tracking compiled declarations.
  • Style / Docs

    • Minor header/comment URL updates in editorconfig and robots.txt.
  • Types

    • Various typing improvements and lint directives; added a ColorMatch type and multiple signature/type refinements.
  • Behavior

    • Input components updated to accept array-style buffers and optional regex for completion checks.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Feb 27, 2026

📝 Walkthrough

Walkthrough

Migrate configuration files from CommonJS to ES modules, update ESLint and Babel configs, switch Type tooling from Glint to ember-tsc, adjust dependencies and scripts, modify .gitignore, bump an Ember blueprint version, and add/modify several TypeScript declaration typings and ESLint directives.

Changes

Cohort / File(s) Summary
Module System & Build Configs
babel.config.mjs, .stylelintrc.mjs
Converted configs from CommonJS to ES module syntax (module.exportsexport default); babel.config.mjs now uses import for path helpers and @embroider/compat/babel, replaces require/__dirname with import.meta-based resolution and removes compilerPath.
ESLint config rewrite
eslint.config.mjs
Reworked to use defineConfig([...]) and globalIgnores(...), switched parser to @babel/eslint-parser/experimental-worker, moved ignore patterns into globalIgnores, and merged per-file globals into language options.
Dependency & Tooling changes
package.json
Replaced Glint core packages with @glint/ember-tsc, added @glint/tsserver-plugin, updated lint:types script to ember-tsc --noEmit, bumped ember-inputmask, updated babel template compilation plugin, and removed ember-auto-import and tracked-built-ins.
TypeScript config
tsconfig.json
Removed glint environment settings and reordered types to include @glint/ember-tsc/types before ember-source/types.
.gitignore & simple docs
.gitignore, .editorconfig, public/robots.txt
Removed declarations/ from ignore entries; normalized header comment URLs to https:// in .editorconfig and public/robots.txt.
Ember CLI update
config/ember-cli-update.json
Bumped @ember/app-blueprint version from 6.8.3 to 6.11.0.
Type definitions — signatures & typings additions
types/nearest-color/index.d.ts, types/ember-local-storage/index.d.ts, types/ember-cognito/test-support/index.d.ts
Added ColorMatch interface and narrowed from input to Record<string,string> in nearest-color; adjusted options parameter types between {} and object in several typings affecting type strictness.
Type definitions — lint-only edits
types/global.d.ts, types/throttle-debounce/index.d.ts, types/ember-animated/motions/move.d.ts, types/ember-set-body-class/helpers/set-body-class.d.ts, types/ember-event-helpers/helpers/stop-propagation.d.ts
Inserted ESLint disable/ignore comments and minor comment additions; no runtime or public API changes.
Removed global augmentation
types/swach/index.d.ts
Deleted global augmentation of Array<T> with Ember.ArrayPrototypeExtensions, removed import Ember from 'ember' and the empty export {}.
Component signature updates
app/components/alpha-input.gts, app/components/hex-input.gts, app/components/rgb-input.gts
Changed isComplete buffer parameter type from Buffer to Array<string> and made opts.regex optional in all three components; adjusted internal usage to join buffer and cast regex where used.
Misc config style
.stylelintrc.mjs
Switched export to export default and removed 'use strict' and an extra blank line.
.editorconfig & robots
.editorconfig, public/robots.txt
Updated header comments to use full https:// URLs.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Possibly related PRs

Poem

🐰
Hopping through modules, I swap and I mend,
CommonJS whispers goodbye as ES modules ascend.
Types trimmed and lint hushed, dependencies pruned,
Blueprints bumped, declarations tuned — the rabbit is amused.

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'ember-cli-update to 6.11' directly reflects the main change: updating @ember/app-blueprint from 6.8.3 to 6.11.0 in config/ember-cli-update.json, along with related tooling migrations.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch latest-blueprints

Tip

Try Coding Plans. Let us write the prompt for your AI agent so you can ship faster (with fewer bugs).
Share your feedback on Discord.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (2)
types/throttle-debounce/index.d.ts (1)

1-8: Consider using a more specific function type.

The Function type is overly permissive. A more type-safe alternative would be (...args: unknown[]) => unknown or even a generic signature. However, this is acceptable for a third-party library shim.

♻️ Optional: More specific callback type
-/* eslint-disable `@typescript-eslint/no-unsafe-function-type` */
 declare module 'throttle-debounce' {
+  type AnyFunction = (...args: unknown[]) => unknown;
+
   export function debounce(
     delay: number,
     atBegin?: boolean,
-    callback?: Function
+    callback?: AnyFunction
   );
-  export function debounce(delay: number, callback?: Function);
+  export function debounce(delay: number, callback?: AnyFunction);
 }
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@types/throttle-debounce/index.d.ts` around lines 1 - 8, Replace the
overly-broad Function type in the throttle-debounce declaration with a more
specific callback signature: change the callback parameter types in both
overloaded declarations of debounce (the exported function debounce) from
Function to a typed function such as (...args: unknown[]) => unknown or a
generic like <T extends any[]>(...args: T) => unknown; update both overloads
(debounce(delay: number, atBegin?: boolean, callback?: Function) and
debounce(delay: number, callback?: Function)) to use the chosen specific
signature so callers get better type safety.
package.json (1)

121-123: Inconsistent version constraint on @glint/template.

Line 122 uses a tilde (~1.7.4) constraint while the other @glint/* packages use caret (^). This restricts @glint/template to only patch updates. If this is intentional (e.g., to avoid a known issue in newer minor versions), consider adding a comment explaining why. Otherwise, align with the caret constraint for consistency.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@package.json` around lines 121 - 123, The package constraint for
`@glint/template` is inconsistent (uses "~1.7.4") compared to the other `@glint`
packages (`@glint/ember-tsc` and `@glint/tsserver-plugin` which use "^"); either
change the `@glint/template` version constraint to "^1.7.4" to match the caret
semantics used by the other `@glint` packages, or if the tilde is deliberate, add
an inline comment in package.json explaining the reason for pinning to
patch-only versions to avoid future confusion.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@types/nearest-color/index.d.ts`:
- Around line 2-4: Add a proper exported ColorMatch type and tighten the
availableColors parameter: declare and export an interface ColorMatch with
properties name: string, value: string, rgb: [number, number, number], and
distance: number, change the from function signature to accept availableColors:
Array<string> | Record<string, string> (instead of object), and keep the return
type (string) => ColorMatch | string so TypeScript recognizes the returned match
shape for the exported from function.

---

Nitpick comments:
In `@package.json`:
- Around line 121-123: The package constraint for `@glint/template` is
inconsistent (uses "~1.7.4") compared to the other `@glint` packages
(`@glint/ember-tsc` and `@glint/tsserver-plugin` which use "^"); either change the
`@glint/template` version constraint to "^1.7.4" to match the caret semantics used
by the other `@glint` packages, or if the tilde is deliberate, add an inline
comment in package.json explaining the reason for pinning to patch-only versions
to avoid future confusion.

In `@types/throttle-debounce/index.d.ts`:
- Around line 1-8: Replace the overly-broad Function type in the
throttle-debounce declaration with a more specific callback signature: change
the callback parameter types in both overloaded declarations of debounce (the
exported function debounce) from Function to a typed function such as (...args:
unknown[]) => unknown or a generic like <T extends any[]>(...args: T) =>
unknown; update both overloads (debounce(delay: number, atBegin?: boolean,
callback?: Function) and debounce(delay: number, callback?: Function)) to use
the chosen specific signature so callers get better type safety.

ℹ️ Review info

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 8e02162 and bbac281.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (15)
  • .editorconfig
  • .gitignore
  • .stylelintrc.mjs
  • app/services/.gitkeep
  • babel.config.mjs
  • config/ember-cli-update.json
  • eslint.config.mjs
  • package.json
  • public/robots.txt
  • tsconfig.json
  • types/ember-animated/motions/move.d.ts
  • types/ember-set-body-class/helpers/set-body-class.d.ts
  • types/global.d.ts
  • types/nearest-color/index.d.ts
  • types/throttle-debounce/index.d.ts
💤 Files with no reviewable changes (1)
  • .gitignore

Comment on lines 2 to 4
export function from(
availableColors: Array<string> | Object
availableColors: Array<string> | object
): (string) => ColorMatch | string;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

# Verify whether ColorMatch is declared anywhere else in repo
rg -n --type=ts '\binterface\s+ColorMatch\b|\btype\s+ColorMatch\b|declare module .nearest-color.'

# Inspect current declaration file in full
fd 'index.d.ts' types | xargs -I{} sh -c 'echo "---- {} ----"; cat -n "{}"'

Repository: shipshapecode/swach

Length of output: 3186


🏁 Script executed:

# Find package.json to check nearest-color version
fd 'package.json' | head -5 | xargs grep -l 'nearest-color' 2>/dev/null || echo "Not found in package.json"

# Also check if there's a types/ directory README or any docs
fd 'README|readme' types/nearest-color/ 2>/dev/null || echo "No readme in types/nearest-color"

Repository: shipshapecode/swach

Length of output: 75


🏁 Script executed:

# Extract nearest-color dependency info from package.json
rg '"nearest-color"' -A 2 -B 2 package.json

Repository: shipshapecode/swach

Length of output: 219


🌐 Web query:

nearest-color npm package documentation types ColorMatch 0.4.4

💡 Result:

nearest-color@0.4.4 (the actual library) does not ship TypeScript declarations, so you won’t find a ColorMatch type in its own docs/package. (npmjs.com)

For TypeScript, the ColorMatch type comes from DefinitelyTyped via @types/nearest-color (published as 0.4.1, intended for the nearest-color package). (npmjs.com)

Where to see the ColorMatch type definition

  • After installing, open: node_modules/@types/nearest-color/index.d.ts (npmjs.com)
  • Install: npm i -D @types/nearest-color`` (npmjs.com)

Citations:


🏁 Script executed:

# Check if `@types/nearest-color` is listed in package.json
rg '@types/nearest-color' package.json

# Check the actual types definition from the official `@types` package
# First, let's see if node_modules exists and what's available
fd '@types.*nearest-color' node_modules 2>/dev/null || echo "Not installed or node_modules not available"

# Also check the devDependencies section
rg -A 20 '"devDependencies"' package.json | head -30

Repository: shipshapecode/swach

Length of output: 923


🏁 Script executed:

# Continue looking through devDependencies for `@types` packages
rg -A 100 '"devDependencies"' package.json | grep '@types' | head -20

Repository: shipshapecode/swach

Length of output: 236


🌐 Web query:

@types/nearest-color index.d.ts ColorMatch definition github

💡 Result:

Web search failed: Server error: no LLM provider could handle the message


🏁 Script executed:

# Let's check the DefinitelyTyped repo directly via common paths
# or look for any documentation about what ColorMatch should be

# First, check if there are any comments or references to ColorMatch elsewhere
rg 'ColorMatch' --type ts --type js -B 2 -A 2

# Also check if there's a tsconfig or similar that might configure type roots
fd 'tsconfig' | head -5 | xargs cat 2>/dev/null || echo "No tsconfig found"

Repository: shipshapecode/swach

Length of output: 1692


🏁 Script executed:

# Let's look for what the actual `@types/nearest-color` would define
# by checking if we can find any usage patterns or if there's a copy somewhere

# Search for any nearest-color related code that might hint at the structure
rg 'nearest-color|ColorMatch' --type ts --type js -B 3 -A 3 | head -50

Repository: shipshapecode/swach

Length of output: 1774


🏁 Script executed:

# Look at the actual usage in nearest-color.ts service to understand the return type structure
cat -n app/services/nearest-color.ts

# Also check the color-picker.ts to see how the result is used
sed -n '1,50p' electron-app/src/color-picker.ts | cat -n

Repository: shipshapecode/swach

Length of output: 2569


🏁 Script executed:

# Let's check if there are any lint/TypeScript errors in the build
fd 'tsconfig' -type f | xargs grep -l 'nearest-color' 2>/dev/null

# Check if there are any test files that might show the expected type
fd 'test.*nearest-color|nearest-color.*test' --type f

Repository: shipshapecode/swach

Length of output: 233


🏁 Script executed:

# Check the actual return type structure used in the codebase
rg 'ColorMatch|getColorName.*=>|nearest\(' app/ electron-app/ --type ts -A 3 -B 1 | head -60

Repository: shipshapecode/swach

Length of output: 364


🏁 Script executed:

# Check the actual DefinitelyTyped definition by looking at TS error or checking if types should come from `@types`
# Let's see what the proper approach is - either install `@types` or define it locally

# Search for how other local type definitions are structured
find types -name '*.d.ts' -exec grep -l 'interface\|type' {} \; | head -3 | xargs cat

# Also check if the repo ever had `@types/nearest-color` or references to it
git log --all --oneline -- package.json 2>/dev/null | head -5 || echo "Git history not available"

Repository: shipshapecode/swach

Length of output: 2543


🏁 Script executed:

# Let's check the `@types/nearest-color` to see the actual standard definition
# by looking up the DefinitelyTyped repository definition online or checking what nearest-color actually returns

# First, let's verify what the actual expected structure is based on usage
rg 'nearestColor|\.name|\.value|\.rgb|\.distance' app/ electron-app/ -B 2 -A 2 | head -60

Repository: shipshapecode/swach

Length of output: 3047


Define ColorMatch with all required properties; current declaration is incomplete and fails type checking.

Line 4 references an undeclared ColorMatch type, causing TypeScript errors. The actual nearest-color library returns an object with name, value, rgb, and distance properties. Also, line 3 can be tightened from object to Record<string, string> for safety.

✅ Suggested fix
 declare module 'nearest-color' {
+  export interface ColorMatch {
+    name: string;
+    value: string;
+    rgb: { r: number; g: number; b: number };
+    distance: number;
+  }
+
   export function from(
-    availableColors: Array<string> | object
-  ): (string) => ColorMatch | string;
+    availableColors: Array<string> | Record<string, string>
+  ): (needle: string) => ColorMatch | string;
 }
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
export function from(
availableColors: Array<string> | Object
availableColors: Array<string> | object
): (string) => ColorMatch | string;
declare module 'nearest-color' {
export interface ColorMatch {
name: string;
value: string;
rgb: { r: number; g: number; b: number };
distance: number;
}
export function from(
availableColors: Array<string> | Record<string, string>
): (needle: string) => ColorMatch | string;
}
🧰 Tools
🪛 GitHub Actions: Linting

[error] 4-4: 'ColorMatch' is an 'error' type that acts as 'any' and overrides all other types in this union type (no-redundant-type-constituents)

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@types/nearest-color/index.d.ts` around lines 2 - 4, Add a proper exported
ColorMatch type and tighten the availableColors parameter: declare and export an
interface ColorMatch with properties name: string, value: string, rgb: [number,
number, number], and distance: number, change the from function signature to
accept availableColors: Array<string> | Record<string, string> (instead of
object), and keep the return type (string) => ColorMatch | string so TypeScript
recognizes the returned match shape for the exported from function.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🧹 Nitpick comments (1)
types/nearest-color/index.d.ts (1)

2-11: LGTM! The ColorMatch interface and improved type safety address the previous review concerns.

The interface correctly defines all properties (name, value, rgb, distance) matching the library's actual return structure, and Record<string, string> is appropriately more specific than object.

Optional: Consider adding export to the interface so consumers can directly import ColorMatch for explicit type annotations:

-  interface ColorMatch {
+  export interface ColorMatch {

Without the export, the type is still correctly inferred when using the from() function, so this is a nice-to-have rather than a requirement.

,

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@types/nearest-color/index.d.ts` around lines 2 - 11, Add an export to the
ColorMatch interface so consumers can import the type directly: update the
declaration of ColorMatch to be exported (export interface ColorMatch) alongside
the existing exported from() function; this is a non-breaking, type-only change
that enables explicit annotations and improves DX when referencing ColorMatch in
user code or tests.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@types/ember-cognito/test-support/index.d.ts`:
- Line 12: Change the ambient declaration for mockCognitoUser by removing the
default parameter initializer; replace `options: object = {}` with an optional
parameter `options?: object` in the declaration of the function
`mockCognitoUser` so the `.d.ts` file does not contain a parameter default value
and still conveys that the argument is optional and returns `MockUser`.

In `@types/ember-local-storage/index.d.ts`:
- Line 5: The ambient declaration uses an invalid default parameter initializer
`options: object = {}`; replace it with optional parameter syntax (e.g.,
`options?: object`) in the declaration so the `.d.ts` file compiles—locate the
function/constructor declaration that contains the `options` parameter and
change its signature from using `= {}` to `?` (reference the `options` parameter
in the types/ember-local-storage index.d.ts diff).

---

Nitpick comments:
In `@types/nearest-color/index.d.ts`:
- Around line 2-11: Add an export to the ColorMatch interface so consumers can
import the type directly: update the declaration of ColorMatch to be exported
(export interface ColorMatch) alongside the existing exported from() function;
this is a non-breaking, type-only change that enables explicit annotations and
improves DX when referencing ColorMatch in user code or tests.

ℹ️ Review info

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between bbac281 and 60a5f81.

📒 Files selected for processing (5)
  • types/ember-cognito/test-support/index.d.ts
  • types/ember-event-helpers/helpers/stop-propagation.d.ts
  • types/ember-local-storage/index.d.ts
  • types/nearest-color/index.d.ts
  • types/swach/index.d.ts
💤 Files with no reviewable changes (1)
  • types/swach/index.d.ts

export const MockUser = EmberObject.extend({ create() {} });
export const mockAuth = any;
export declare function mockCognitoUser(options: {} = {}): MockUser;
export declare function mockCognitoUser(options: object = {}): MockUser;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

🧩 Analysis chain

🏁 Script executed:

# First, let's check the specific file mentioned
cd . && ls -la types/ember-cognito/test-support/index.d.ts 2>/dev/null && cat -n types/ember-cognito/test-support/index.d.ts

Repository: shipshapecode/swach

Length of output: 820


🏁 Script executed:

# Also run the verification script to check for similar issues
rg -nP --glob '*.d.ts' '\b(?:export\s+)?(?:declare\s+)?function\b[^\n]*\([^)]*=\s*[^)]*\)'

Repository: shipshapecode/swach

Length of output: 184


🌐 Web query:

TypeScript declaration files .d.ts default parameter initializer best practices

💡 Result:

Key rule: you can’t encode runtime default values in .d.ts

In a declaration file, parameter initializers are not allowed (because there’s no implementation), so alpha = 1.0 is a syntax error in .d.ts. Use types + docs instead. [1], [5], [10]

Recommended patterns

1) Model “has a default” as an optional parameter

// implementation: function axpy(x, y, alpha = 1.0) { ... }
export function axpy(x: Float32Array, y: Float32Array, alpha?: number): void;

This matches how TypeScript models “argument may be omitted”. [7]

2) If there are multiple optional knobs, prefer an options bag

export interface AxpyOptions {
  alpha?: number; // default: 1.0
}

export function axpy(x: Float32Array, y: Float32Array, options?: AxpyOptions): void;

This keeps call sites readable as options grow (and avoids long ordered optional params). [1]

3) Document the default value (since the type system won’t)

Use JSDoc (works well in editors/tooling):

/** `@param` alpha Default is 1.0 */
export function axpy(x: Float32Array, y: Float32Array, alpha?: number): void;

The need for documentation here is exactly because .d.ts files are type-only. [10]

4) Avoid overload explosions; use optional params where possible

Prefer alpha?: number (or an options bag) over many overloads that only differ by presence/absence of trailing args. [2]

5) Don’t try to “fake” defaults with types

Avoid patterns like alpha: number | undefined unless you specifically need to allow explicit undefined in a non-optional position; in most APIs, alpha?: number is the cleanest declaration for a defaulted parameter. (TypeScript treats omitted args as undefined at runtime anyway.) [7]


Sources

[1] Google TypeScript Style Guide – parameter initializers & guidance on using them sparingly / prefer destructuring for many optional params: https://google.github.io/styleguide/tsguide.html
[2] TypeScript Handbook (Declaration Files) – “Do’s and Don’ts” (optional params vs overloads): https://deepwiki.com/microsoft/TypeScript-Handbook/5-declaration-files
[5] Stack Overflow – “A parameter initializer is only allowed in a function or constructor implementation” in .d.ts: https://stackoverflow.com/questions/41057285/is-it-possible-to-declare-default-function-parameters-in-typescript-declaration
[7] TypeScript Handbook (New Handbook) – optional parameters & default parameters behavior: https://microsoft.github.io/TypeScript-New-Handbook/everything/
[10] TypeScript Handbook – .d.ts files are type-only and don’t emit JS: https://www.typescriptlang.org/docs/handbook/2/type-declarations


Remove default parameter initializer from ambient declaration.

On Line 12, options: object = {} violates TypeScript declaration file rules. Parameter initializers are not allowed in .d.ts files; use an optional parameter instead.

Proposed fix
-  export declare function mockCognitoUser(options: object = {}): MockUser;
+  export declare function mockCognitoUser(options?: object): MockUser;
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
export declare function mockCognitoUser(options: object = {}): MockUser;
export declare function mockCognitoUser(options?: object): MockUser;
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@types/ember-cognito/test-support/index.d.ts` at line 12, Change the ambient
declaration for mockCognitoUser by removing the default parameter initializer;
replace `options: object = {}` with an optional parameter `options?: object` in
the declaration of the function `mockCognitoUser` so the `.d.ts` file does not
contain a parameter default value and still conveys that the argument is
optional and returns `MockUser`.

key: string,
modelName?: string,
options: {} = {}
options: object = {}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

🧩 Analysis chain

🏁 Script executed:

# First, let's find and examine the specific file
find . -name "index.d.ts" -path "*/ember-local-storage/*" -type f

Repository: shipshapecode/swach

Length of output: 101


🏁 Script executed:

# Run the verification script from the review comment
rg -nP --glob '*.d.ts' '\b(?:export\s+)?(?:declare\s+)?function\b[^\n]*\([^)]*=\s*[^)]*\)' | head -20

Repository: shipshapecode/swach

Length of output: 184


🏁 Script executed:

# Also let's search more broadly for declare functions with initializers
rg -n 'declare function' --glob '*.d.ts' -A 2 | head -50

Repository: shipshapecode/swach

Length of output: 1400


🏁 Script executed:

# Let's read the actual ember-local-storage declaration file
cat -n types/ember-local-storage/index.d.ts

Repository: shipshapecode/swach

Length of output: 261


🏁 Script executed:

# Let's also check if TypeScript actually allows default parameters in declare functions
# by looking at the tsconfig and any compilation settings
find . -name "tsconfig.json" -o -name "tsconfig.*.json" | head -5

Repository: shipshapecode/swach

Length of output: 387


🏁 Script executed:

# Let's check the tsconfig to see if there are any settings that might affect this
cat tsconfig.json

Repository: shipshapecode/swach

Length of output: 586


🏁 Script executed:

# Let's verify if TypeScript would actually flag this as an error
# by looking for any compilation errors or test output
find . -type f -name "*.json" -path "*/node_modules/.bin" -prune -o -type f -name "*.log" -print | grep -i "error\|test" | head -10

Repository: shipshapecode/swach

Length of output: 45


🌐 Web query:

TypeScript declaration file default parameters ambient function declare syntax rules

💡 Result:

In TypeScript declaration files (.d.ts), you generally cannot write runtime default parameter initializers (e.g. alpha = 1.0) because declarations describe types only and have no function body/implementation.

1) Ambient/overload signatures: no = value

In a .d.ts, this is not allowed:

declare function axpy(x: Float32Array, y: Float32Array, alpha = 1.0): void;
//            ❌ parameter initializer only allowed in an implementation

Ambient function declarations do not permit default parameter values; use optional parameters (?) instead. [1]

2) What to do instead: mark the parameter optional (and/or overload)

Option A — optional parameter

declare function axpy(
  x: Float32Array,
  y: Float32Array,
  alpha?: number
): void;

Option B — overloads (most explicit call shapes)

declare function axpy(x: Float32Array, y: Float32Array): void;
declare function axpy(x: Float32Array, y: Float32Array, alpha: number): void;

Also note: overload signatures cannot specify default values either—only optional (?) is allowed. [1]

3) If you want to communicate the default value

TypeScript has no standard type-level way to encode “defaults to 1.0” in a .d.ts. Common practice is to document it with comments/JSDoc (for editor hints), while keeping the type as optional. (This limitation is the same issue described in the VS Code error you saw.) [2]

4) What is allowed in .d.ts: default generic type parameters

Don’t confuse value defaults with generic type parameter defaults—those are allowed in declarations:

declare function create<T = HTMLDivElement>(element?: T): T;

[3]

Sources: ambient declarations / no default parameter values [1], .d.ts default parameter question + error context [2], generic type parameter defaults in declarations [3].

[1] https://gist.github.com/robertknight/9ec6ea9f32d2c120cb1c
[2] https://stackoverflow.com/questions/41057285/is-it-possible-to-declare-default-function-parameters-in-typescript-declaration
[3] https://www.typescriptlang.org/docs/handbook/release-notes/typescript-2-3.html


🏁 Script executed:

# Let's check if there are TypeScript compilation errors in the project
# Look for any .tsbuildinfo or compilation output
find . -name "*.tsbuildinfo" -o -name "dist" -type d | head -5

Repository: shipshapecode/swach

Length of output: 479


🏁 Script executed:

# Let's specifically look at the ember-cognito file which also has the same issue
cat -n types/ember-cognito/test-support/index.d.ts

Repository: shipshapecode/swach

Length of output: 728


🏁 Script executed:

# Check if there's any build or test output that shows TypeScript errors
ls -la | grep -i "build\|dist\|error"

Repository: shipshapecode/swach

Length of output: 133


Use optional parameter syntax in declaration files.

On Line 5, the parameter syntax options: object = {} is invalid in ambient function declarations. TypeScript does not allow default parameter initializers in .d.ts files; use optional parameter syntax instead.

Proposed fix
-    options: object = {}
+    options?: object
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
options: object = {}
options?: object
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@types/ember-local-storage/index.d.ts` at line 5, The ambient declaration uses
an invalid default parameter initializer `options: object = {}`; replace it with
optional parameter syntax (e.g., `options?: object`) in the declaration so the
`.d.ts` file compiles—locate the function/constructor declaration that contains
the `options` parameter and change its signature from using `= {}` to `?`
(reference the `options` parameter in the types/ember-local-storage index.d.ts
diff).

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3

🧹 Nitpick comments (3)
package.json (2)

91-91: Remove throttle-debounce from either dependencies or devDependencies.

It is declared in both sections with the same version (^5.0.2). Packages needed only at runtime should be in dependencies; those needed only during development should be in devDependencies. Keep one source of truth to prevent future version drift.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@package.json` at line 91, The package "throttle-debounce" is declared twice;
remove the duplicate entry so it exists only in the appropriate section (either
dependencies or devDependencies) depending on runtime need — locate
"throttle-debounce": "^5.0.2" in package.json and delete the occurrence in the
incorrect section so there is a single source of truth for that dependency.

33-33: Consider completing the Glint v2 migration by updating ambient types from v1 to v2 environment setup.

@glint/ember-tsc is installed and @glint/ember-tsc/types is correctly wired in tsconfig.json. However, types/global.d.ts currently imports @glint/environment-ember-loose, which is the v1 environment. For a complete v2 migration, update to @glint/environment-ember-template-imports or @glint/environment-ember-loose/v2 (whichever matches your template strategy) to align with the v2 tooling.

Since the repository contains no standalone .hbs templates, this update is compatible with your current setup.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@package.json` at line 33, Update the ambient Glint environment import in
types/global.d.ts from the v1 package to a v2 package: replace the current
import of '@glint/environment-ember-loose' with either
'@glint/environment-ember-template-imports' or
'@glint/environment-ember-loose/v2' (choose the one matching your template
strategy) so the ambient types align with the installed '@glint/ember-tsc' v2
wiring referenced in tsconfig.json; ensure the import statement in
types/global.d.ts is the only change and run the type checker (ember-tsc) to
verify no remaining ambient type errors.
eslint.config.mjs (1)

15-15: Update the parser import to the main entrypoint before Babel 8 upgrades.

@babel/eslint-parser/experimental-worker is removed in Babel 8. Change to @babel/eslint-parser on line 15. No constraints in babel.config.mjs require the worker entrypoint, and this repo already uses ESLint 9.39.3, which satisfies Babel 8's requirement.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@eslint.config.mjs` at line 15, Replace the experimental worker parser import
with the main entrypoint: update the import statement that currently references
'@babel/eslint-parser/experimental-worker' to import from '@babel/eslint-parser'
(i.e., change the module specifier in the existing import declaration so the
parser uses the main '@babel/eslint-parser' package).
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@app/components/alpha-input.gts`:
- Around line 58-63: Update the isComplete signature and logic so opts.regex
accepts RegExp|string|undefined and you don't cast to string: change the
parameter type in isComplete to opts: { regex?: RegExp | string } (or include
undefined) and then detect if opts.regex is a RegExp, a string, or missing;
construct the test RegExp by using opts.regex directly when it's already a
RegExp, new RegExp(opts.regex) when it's a string, and fall back to
this.alphaRegex when undefined/invalid before calling .test(value); apply the
same pattern to the analogous methods in rgb-input.gts and hex-input.gts to
avoid unsafe new RegExp(undefined) behavior.

In `@app/components/hex-input.gts`:
- Around line 54-55: The isComplete method currently force-casts opts.regex to
string and constructs a RegExp unconditionally; instead, guard for undefined and
accept a RegExp instance: update the parameter type (regex?: string|RegExp) or
handle both cases inside isComplete, return false if opts.regex is not provided,
and when provided, if it's already a RegExp use it directly, otherwise construct
a RegExp from the string; reference the isComplete method and opts.regex and the
component prop hexRegex (which is a RegExp) so the fix prevents new
RegExp(undefined) and resolves the string/RegExp mismatch.

In `@app/components/rgb-input.gts`:
- Around line 79-82: The isComplete method currently force-casts opts.regex and
builds a RegExp from it which fails if opts.regex is undefined; update
isComplete to use a safe fallback pattern when opts.regex is missing (e.g., a
regex string that matches three comma-separated integers for RGB), e.g. compute
const pattern = opts.regex ?? '...default pattern...' and then use new
RegExp(pattern).test(buffer.join('')) so isComplete uses opts.regex when
provided and a robust default otherwise; reference the isComplete(buffer, opts)
function and the opts.regex parameter when making the change.

---

Nitpick comments:
In `@eslint.config.mjs`:
- Line 15: Replace the experimental worker parser import with the main
entrypoint: update the import statement that currently references
'@babel/eslint-parser/experimental-worker' to import from '@babel/eslint-parser'
(i.e., change the module specifier in the existing import declaration so the
parser uses the main '@babel/eslint-parser' package).

In `@package.json`:
- Line 91: The package "throttle-debounce" is declared twice; remove the
duplicate entry so it exists only in the appropriate section (either
dependencies or devDependencies) depending on runtime need — locate
"throttle-debounce": "^5.0.2" in package.json and delete the occurrence in the
incorrect section so there is a single source of truth for that dependency.
- Line 33: Update the ambient Glint environment import in types/global.d.ts from
the v1 package to a v2 package: replace the current import of
'@glint/environment-ember-loose' with either
'@glint/environment-ember-template-imports' or
'@glint/environment-ember-loose/v2' (choose the one matching your template
strategy) so the ambient types align with the installed '@glint/ember-tsc' v2
wiring referenced in tsconfig.json; ensure the import statement in
types/global.d.ts is the only change and run the type checker (ember-tsc) to
verify no remaining ambient type errors.

ℹ️ Review info

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 60a5f81 and fcd638c.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (5)
  • app/components/alpha-input.gts
  • app/components/hex-input.gts
  • app/components/rgb-input.gts
  • eslint.config.mjs
  • package.json

Comment on lines +58 to +63
isComplete(buffer: Array<string>, opts: { regex?: string }): boolean {
const value = buffer.join('');

return Boolean(value.length) && new RegExp(opts.regex).test(value);
return (
Boolean(value.length) && new RegExp(opts.regex as string).test(value)
);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

🧩 Analysis chain

🏁 Script executed:

# First, let's locate and examine the file
fd "alpha-input" --type f

Repository: shipshapecode/swach

Length of output: 93


🏁 Script executed:

# Read the alpha-input.gts file to see the actual code
cat -n app/components/alpha-input.gts

Repository: shipshapecode/swach

Length of output: 3154


🏁 Script executed:

# Search for other uses of isComplete
rg "isComplete" --type ts --type gts -B 2 -A 2

Repository: shipshapecode/swach

Length of output: 90


🏁 Script executed:

# Search for isComplete with proper file types
rg "isComplete" -B 2 -A 2

Repository: shipshapecode/swach

Length of output: 1711


🏁 Script executed:

# Let's look at rgb-input.gts and hex-input.gts to see the pattern
cat -n app/components/rgb-input.gts | head -100

Repository: shipshapecode/swach

Length of output: 3231


🏁 Script executed:

# Check hex-input.gts
cat -n app/components/hex-input.gts | head -80

Repository: shipshapecode/swach

Length of output: 2796


🏁 Script executed:

# Test what happens with new RegExp(undefined)
node -e "console.log(new RegExp(undefined)); console.log(new RegExp(undefined).test('hello'));"

Repository: shipshapecode/swach

Length of output: 74


🏁 Script executed:

# Check if regex is always passed in the options, or could be undefined
rg "OneWayInputMask" -A 15 | grep -E "(regex|options)"

Repository: shipshapecode/swach

Length of output: 392


Fix type annotation and unsafe regex cast in completion validation.

The opts parameter is typed as { regex?: string } but receives a RegExp instance (line 38). When casting as string with opts.regex as string, if regex were undefined, new RegExp(undefined) would create /(?:)/, matching any input unexpectedly.

Update the type signature to accept RegExp | string | undefined, and handle each case explicitly with a fallback to this.alphaRegex:

Suggested fix
-  isComplete(buffer: Array<string>, opts: { regex?: string }): boolean {
+  isComplete(buffer: Array<string>, opts: { regex?: string | RegExp }): boolean {
     const value = buffer.join('');
-
-    return (
-      Boolean(value.length) && new RegExp(opts.regex as string).test(value)
-    );
+    const pattern =
+      opts.regex instanceof RegExp
+        ? opts.regex
+        : opts.regex
+          ? new RegExp(opts.regex)
+          : this.alphaRegex;
+
+    return Boolean(value.length) && pattern.test(value);
   }

Note: The same issue exists in rgb-input.gts (line 79) and hex-input.gts (line 54).

📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
isComplete(buffer: Array<string>, opts: { regex?: string }): boolean {
const value = buffer.join('');
return Boolean(value.length) && new RegExp(opts.regex).test(value);
return (
Boolean(value.length) && new RegExp(opts.regex as string).test(value)
);
isComplete(buffer: Array<string>, opts: { regex?: string | RegExp }): boolean {
const value = buffer.join('');
const pattern =
opts.regex instanceof RegExp
? opts.regex
: opts.regex
? new RegExp(opts.regex)
: this.alphaRegex;
return Boolean(value.length) && pattern.test(value);
}
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@app/components/alpha-input.gts` around lines 58 - 63, Update the isComplete
signature and logic so opts.regex accepts RegExp|string|undefined and you don't
cast to string: change the parameter type in isComplete to opts: { regex?:
RegExp | string } (or include undefined) and then detect if opts.regex is a
RegExp, a string, or missing; construct the test RegExp by using opts.regex
directly when it's already a RegExp, new RegExp(opts.regex) when it's a string,
and fall back to this.alphaRegex when undefined/invalid before calling
.test(value); apply the same pattern to the analogous methods in rgb-input.gts
and hex-input.gts to avoid unsafe new RegExp(undefined) behavior.

Comment on lines +54 to +55
isComplete(buffer: Array<string>, opts: { regex?: string }): boolean {
return new RegExp(opts.regex as string).test(buffer.join(''));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

🧩 Analysis chain

🏁 Script executed:

# First, let's find and read the hex-input.gts file
find . -name "hex-input.gts" -type f

Repository: shipshapecode/swach

Length of output: 93


🏁 Script executed:

# Also search for any references to ember-inputmask in the codebase
rg "ember-inputmask" --type ts --type js --type gts -A 3 -B 3

Repository: shipshapecode/swach

Length of output: 90


🏁 Script executed:

# Check the package.json to confirm the version of ember-inputmask
cat package.json | grep -A 2 -B 2 "inputmask"

Repository: shipshapecode/swach

Length of output: 237


🏁 Script executed:

# Read the hex-input.gts file to see the isComplete method
cat -n ./app/components/hex-input.gts

Repository: shipshapecode/swach

Length of output: 3079


🏁 Script executed:

# Search for isComplete usage in the codebase to understand how it's called
rg "isComplete" -g "*.gts" -g "*.ts" -g "*.js" -A 5 -B 5

Repository: shipshapecode/swach

Length of output: 3806


🌐 Web query:

ember-inputmask v4.0.3 isComplete callback signature opts.regex documentation

💡 Result:

In Inputmask (the library wrapped by ember-inputmask), the isComplete option is a hook you can override with this signature:

  • isComplete(buffer: string[], opts: Options): boolean [1]

When you use the "Regex" mask/alias, the regex you configured is available as:

  • opts.regex (a string) [1]

The Inputmask docs/examples show opts.regex being used exactly this way:

$(selector).inputmask("Regex", {
  regex: "[0-9]*",
  isComplete: function (buffer, opts) {
    return new RegExp(opts.regex).test(buffer.join(""));
  }
});
``` [2]

**Sources:** [1] Type definitions for Inputmask options/signatures, including `isComplete(buffer, opts)` and `opts.regex`. [2] Inputmask documentation example showing `isComplete(buffer, opts)` using `opts.regex`.

---

🏁 Script executed:

```shell
# Let's verify the behavior of RegExp with undefined
node << 'EOF'
// Test what happens when RegExp is constructed with undefined
try {
  const result = new RegExp(undefined);
  console.log("RegExp(undefined):", result);
  console.log("Test 'undefined' string:", result.test("undefined"));
  console.log("Test other string:", result.test("hello"));
} catch (e) {
  console.log("Error:", e.message);
}
EOF

Repository: shipshapecode/swach

Length of output: 142


Guard optional opts.regex before building RegExp.

Line 55 force-casts an optional value (opts.regex as string) without checking if it's defined. If opts.regex is undefined, new RegExp(undefined) creates the permissive regex /(?:)/ that matches any string, causing completion checks to incorrectly succeed on invalid input.

Additionally, the type annotation declares regex?: string, but the component passes regex=this.hexRegex where hexRegex is a RegExp object, creating a type mismatch masked by the cast.

Suggested fix
-  isComplete(buffer: Array<string>, opts: { regex?: string }): boolean {
-    return new RegExp(opts.regex as string).test(buffer.join(''));
+  isComplete(buffer: Array<string>, opts: { regex?: string | RegExp }): boolean {
+    const pattern =
+      opts.regex instanceof RegExp
+        ? opts.regex
+        : opts.regex
+          ? new RegExp(opts.regex)
+          : this.hexRegex;
+
+    return pattern.test(buffer.join(''));
   }
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
isComplete(buffer: Array<string>, opts: { regex?: string }): boolean {
return new RegExp(opts.regex as string).test(buffer.join(''));
isComplete(buffer: Array<string>, opts: { regex?: string | RegExp }): boolean {
const pattern =
opts.regex instanceof RegExp
? opts.regex
: opts.regex
? new RegExp(opts.regex)
: this.hexRegex;
return pattern.test(buffer.join(''));
}
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@app/components/hex-input.gts` around lines 54 - 55, The isComplete method
currently force-casts opts.regex to string and constructs a RegExp
unconditionally; instead, guard for undefined and accept a RegExp instance:
update the parameter type (regex?: string|RegExp) or handle both cases inside
isComplete, return false if opts.regex is not provided, and when provided, if
it's already a RegExp use it directly, otherwise construct a RegExp from the
string; reference the isComplete method and opts.regex and the component prop
hexRegex (which is a RegExp) so the fix prevents new RegExp(undefined) and
resolves the string/RegExp mismatch.

Comment on lines +79 to +82
isComplete(buffer: Array<string>, opts: { regex?: string }): boolean {
const value = buffer.join('');

return Boolean(value.length) && new RegExp(opts.regex).test(value);
return Boolean(value.length) && new RegExp(opts.regex as string).test(value);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

🧩 Analysis chain

🏁 Script executed:

# First, let's locate and examine the file
find . -name "rgb-input.gts" -type f

Repository: shipshapecode/swach

Length of output: 93


🏁 Script executed:

# Let's examine the rgb-input.gts file
cat -n ./app/components/rgb-input.gts

Repository: shipshapecode/swach

Length of output: 4024


🏁 Script executed:

# Let's check the ember-inputmask package.json or dependency info
find . -name "package.json" -type f -exec grep -l "ember-inputmask" {} \;

Repository: shipshapecode/swach

Length of output: 77


🏁 Script executed:

# Let's check the package.json for ember-inputmask version
cat ./package.json | grep -A 2 -B 2 "ember-inputmask"

Repository: shipshapecode/swach

Length of output: 237


🌐 Web query:

ember-inputmask v4.0.3 isComplete callback opts.regex parameter

💡 Result:

In Inputmask v4.0.3 (which ember-inputmask wraps), the isComplete hook is called as:

  • isComplete(buffer, opts) -> boolean
  • opts is the resolved Inputmask options object for the current mask
  • When you use the "Regex" mask/alias and pass a regex option, that value is available as opts.regex inside isComplete (so you can re-test the buffer against the configured regex). Example from the Inputmask docs: new RegExp(opts.regex).test(buffer.join('')). [1]

Source

  1. Inputmask docs / README section “isComplete” showing Args => buffer, opts and the "Regex" example using opts.regex. [1]

🌐 Web query:

ember-inputmask OneWayInputMask isComplete callback options parameter passed

💡 Result:

In ember-inputmask, the OneWayInputMask component is just passing your config through to Inputmask, so the isComplete hook uses Inputmask’s native signature. The 2nd parameter (options / opts) is the resolved Inputmask options object for that mask instance (your passed options merged with defaults/alias options, etc.). [1][2]

Signature:

isComplete(buffer, opts) { ... }
  • buffer: the current mask buffer (array of characters)
  • opts: the Inputmask options object (mask/alias + merged defaults/options) [2]

Example:

<Inputmask
  `@mask`="99/99/9999"
  `@isComplete`={{(buffer, opts) => {
    // opts.mask, opts.placeholder, opts.clearIncomplete, opts.alias, etc.
    return buffer.join('').indexOf('_') === -1;
  }}}
/>

Sources:
[1] https://github.com/brandynbennett/ember-inputmask
[2] https://github.com/trendyminds/jquery.inputmask (docs excerpt showing isComplete(buffer, opts))


🌐 Web query:

Inputmask v4.0.3 isComplete callback opts.regex type RegExp string

💡 Result:

In Inputmask 4.x (including v4.0.3), the Regex/regex option is treated as a string pattern, so inside callbacks like isComplete(buffer, opts) you should expect opts.regex to be a string, not a RegExp object. The docs’ own example builds a RegExp from that string: new RegExp(opts.regex). [1]

If you start with a RegExp, pass its .source (and handle flags yourself), e.g.:

const re = /^[0-9]*$/i;

$(el).inputmask("Regex", {
  regex: re.source,                 // <- string
  isComplete(buffer, opts) {
    return new RegExp(opts.regex, re.flags).test(buffer.join(""));
  }
});

@types/inputmask also models regex?: string, matching this behavior. [2]

Sources: [1] [2]


🏁 Script executed:

# Let's search for other uses of isComplete in the codebase to understand the pattern
rg "isComplete" -A 3 -B 3

Repository: shipshapecode/swach

Length of output: 2341


🏁 Script executed:

# Let's examine the alpha-input.gts to see how it implements isComplete
cat -n ./app/components/alpha-input.gts | sed -n '1,100p'

Repository: shipshapecode/swach

Length of output: 3154


Add fallback regex handling for optional opts.regex parameter.

The isComplete method declares opts.regex as optional but the component always provides it. However, the type signature and the force cast create ambiguity. The current code lacks a fallback if opts.regex is ever undefined—new RegExp(undefined as string) would not validate RGB values correctly.

Suggested fix
-  isComplete(buffer: Array<string>, opts: { regex?: string }): boolean {
+  isComplete(buffer: Array<string>, opts: { regex?: string | RegExp }): boolean {
     const value = buffer.join('');
-
-    return Boolean(value.length) && new RegExp(opts.regex as string).test(value);
+    const pattern =
+      opts.regex instanceof RegExp
+        ? opts.regex
+        : opts.regex
+          ? new RegExp(opts.regex)
+          : this.rgbRegex;
+
+    return Boolean(value.length) && pattern.test(value);
   }
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@app/components/rgb-input.gts` around lines 79 - 82, The isComplete method
currently force-casts opts.regex and builds a RegExp from it which fails if
opts.regex is undefined; update isComplete to use a safe fallback pattern when
opts.regex is missing (e.g., a regex string that matches three comma-separated
integers for RGB), e.g. compute const pattern = opts.regex ?? '...default
pattern...' and then use new RegExp(pattern).test(buffer.join('')) so isComplete
uses opts.regex when provided and a robust default otherwise; reference the
isComplete(buffer, opts) function and the opts.regex parameter when making the
change.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant