Handsontable dev

From handsontable/handsontable · View interactive version

Handsontable dev is an AI agent skill from the GitHub repository handsontable/handsontable. Use for ANY work touching the `handsontable/` core package: fixing bugs, adding features, modifying TypeScript types, removing as-casts, writing or debugging plugins, editors, renderers, validators, cell types, hooks, shortcuts, selection, helpers, index translations, or i18n. Also use for how-to qu

How to use this skill

Skill file

Handsontable Core Development

Dispatch table

Load handsontable-code-review (architecture dimension) first for every change, then the task-specific specialist. It is the design lens (SOLID, Law of Demeter, plugin decoupling, breaking changes); the task skill is the implementation guide.

| Task | Skill |

|---|---|

| Create / modify a plugin | handsontable-plugin-dev |

| Create / modify an editor | handsontable-editor-dev |

| Create / modify a renderer | handsontable-renderer-dev |

| Create / modify a validator | handsontable-validator-dev |

| Create / modify a cell type | handsontable-celltype-dev |

| Write a new E2E test | handsontable-playwright-e2e (Playwright, tests/e2e/) |

| Maintain a legacy E2E test (*.spec.js, frozen) | handsontable-e2e-testing |

| Write / modify unit tests (*.unit.js or *.unit.ts) | handsontable-unit-testing |

| Make a test actually prove behavior | test-writing-discipline |

| Build a demo / test page | handsontable-demo-page |

| Work on CSS / themes | handsontable-css-dev |

| Anything a user can see or operate (DOM, ARIA, keys, focus, announcements, theme colors and sizes) | handsontable-a11y, beside the task skill: write the accessibility plan before the code |

| Walkontable rendering engine | walkontable-dev / walkontable-testing |

| A rendering-engine geometry change needs a spec (viewport, overlays, sizing, scroll sync) | engine tier: edit an existing walkontable Jasmine spec, or add new coverage in tests/e2e/walkontable/*.spec.ts (walkontable-dev, Testing) |

| Lint violations | handsontable/AGENTS.md (Lint) + handsontable/.ai/CONVENTIONS.md |

| Coordinate translation (physical/visual/renderable) | coordinate-systems |

| i18n / translations | i18n-translations |

| Visual regression tests | visual-testing |

| Docs pages | writing-docs-pages |

Design rules from `handsontable-code-review`

Full checklist: its references/architecture.md.


File layout

src/plugins/{pluginName}/        index.ts, {pluginName}.ts, types.ts?, __tests__/,
                                 AGENTS.md + CLAUDE.md->AGENTS.md (required)
src/editors/{editorName}/        index.ts, {editorName}.ts
src/renderers/{rendererName}/    index.ts, {rendererName}.ts
src/validators/{validatorName}/  index.ts, {validatorName}.ts
src/cellTypes/{typeName}/        index.ts, {typeName}.ts

Unit tests are *.unit.js or *.unit.ts. New E2E is Playwright (tests/e2e/*.spec.ts); the Jasmine *.spec.js suite is frozen (edit existing specs, migrate broken ones to Playwright). .d.ts files are generated by npm run build:types into handsontable/tmp/.


TypeScript gotchas

1. Generalize the signature, add zero `as` casts

New code adds no as casts (as SomeType, <SomeType>value). Treat the urge to write one as a wrong type upstream. Exhaust these in order: (1) make the function/method signature generic; (2) make the shared entity generic; (3) narrow with a type guard; (4) use unknown only at a true I/O boundary. A cast is acceptable only when none apply (external/normalization boundary, known TS generic-inference gap) and carries a comment saying why. as unknown as T (double cast) is banned. Use unknown instead of any at boundaries, then narrow. After removing casts, rerun npm run test:types; some are load-bearing.

// ✗ function getFirst(items: unknown[]): SomeRow { return items[0] as SomeRow; }
// ✓ function getFirst<T>(items: T[]): T { return items[0]; }

Fix the type at its source. When the same cast repeats across consumers, make the shared structure generic with a permissive default so existing callers compile unchanged:

class TreeNode<T extends object = Record<string, unknown>> {
  data: T;
  walkDown(cb: (node: TreeNode<T>) => unknown) { /* ... */ }
}

Example: src/utils/dataStructures/tree.ts TreeNode<T>, consumed by nestedHeaders as TreeNode<HeaderNodeData>.

1a. DOM narrowing

Use isHTMLElement from src/helpers/dom/element.ts (for a Node | Element | null value) instead of x as HTMLElement, x instanceof HTMLElement, or a nodeType === Node.ELEMENT_NODE guard.

2. `.d.ts` files

Declarations are generated from source into handsontable/tmp/ only: hand-write no .d.ts anywhere (there is no separate types/ mirror) and edit nothing under tmp/. If a type is missing from the public API, fix the JSDoc/export in the .ts source and rerun npm run build:types.

3. `import type` for types

import type { HotInstance } from '../../core/types';

4. Import shared types from `core/`

| Type | Location |

|---|---|

| GridSettings, Events, HookKey | src/core/settings.ts |

| HotInstance | src/core/types.ts |

| Plugin-local types | the plugin's own types.ts |

Import these types; never paste a partial copy of GridSettings/HotInstance into the file you are editing (a local copy drifts from the real signature). When the existing type is too wide, narrow it with a generic parameter or type guard at the boundary. Consumers import the same types from the package (import type { GridSettings } from 'handsontable'); see docs/content/guides/tools-and-building/typescript-types/typescript-types.md.

Adding a new hook:

  1. Add the callback signature to GridSettings in src/core/settings.ts.
  2. Register the hook name in src/core/hooks/constants.ts / src/core/hooks/index.ts.
  3. Call Hooks.getSingleton().register('myHook') at module level in the plugin file.

5. Private fields use `#`, callbacks are arrow-function class fields

class MyPlugin extends BasePlugin {
  #map: HidingMap | null = null;
  #onAfterRender = (): void => { /* `this` is bound */ };
}

@private JSDoc tags and .bind(this) are forbidden.

6. Cognitive complexity ≤ 15 per function

Extract a helper to fix a violation.


Cross-cutting rules (enforced by ESLint)

| Rule | What to do |

|---|---|

| No throw new Error() | throwWithCause('...', cause) from src/helpers/errors.ts |

| No window / document / console globals | this.hot.rootWindow, this.hot.rootDocument, helpers from src/helpers/console.ts |

| No raw setTimeout / setInterval | this.hot._registerTimeout(fn, delay) (auto-clears on hot.destroy()) |

| No barrel imports | Import from the specific submodule path (plugins/index, editors/index, renderers/index, validators/index, cellTypes/index, i18n/index are off limits). Only src/registry.ts may use barrels. |

| No direct cross-plugin imports | Hooks or this.hot.getPlugin('Name') |

| it() in *.spec.js must be async | async with await when calling HOT rendering APIs |

| No native toLocaleLowerCase(locale) | localeLowerCase(value, locale) from helpers/string (enforced by no-restricted-syntax) |


JSDoc

jsdoc/require-jsdoc is error for src/**/*.ts and scripts/**/*.mjs: every class, method, function declaration, and class field needs a block. Test and type files (*.unit.ts, *.spec.ts, *.types.ts, *.d.ts) are exempt.


DOM and data gotchas


Registration wiring

| Component | Wire into |

|---|---|

| Plugin | src/plugins/index.ts |

| Editor | src/editors/index.ts + src/editors/factory.ts |

| Renderer | src/renderers/index.ts + src/renderers/factory.ts |

| Validator | src/validators/index.ts |

| Cell type | src/cellTypes/index.ts |

| Any new option / hook | src/dataMap/metaManager/metaSchema.ts + src/core/settings.ts (the settings JSON Schema regenerates from both on the next build or test run; src/settingsSchema/AGENTS.md) |


Build: type declarations

npm run build:types        # step 1: tsc emits tmp/**/*.d.ts
npm run downlevel:types    # step 2: rewrites post-TS-5.1 lib types to TS 5.1 equivalents

npm run build runs both. Run after any change to the public type surface (new export, changed parameter type, new GridSettings option). Wrappers consume handsontable/tmp/.

The dev compiler is TS 6, which infers ArrayIterator, IteratorObject (TS 5.6+) and WeakKey (TS 5.2+), absent from TS 5.1. scripts/downlevel-dts.mjs swaps them for IterableIterator<T> / object. CI job verify-emitted-types runs tsc@5.1.6 --noEmit against tmp/ and reports the leaked identifier as TS2304: Cannot find name '...'. Fix by either annotating the source with the TS 5.1 type (: IterableIterator<T>, WeakMap<object, V>) or adding a row to REPLACEMENTS in scripts/downlevel-dts.mjs.


Mandatory checklist for every change

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.