Skip to content

feat(lint): @astryx/no-unguarded-ime-keydown — enforce IME composition guards - #4909

Merged
nynexman4464 merged 1 commit into
nynexman4464/fix/ime-composition-guardsfrom
nynexman4464/lint/no-unguarded-ime-keydown
Aug 17, 2026
Merged

nynexman4464 merged 1 commit into
nynexman4464/fix/ime-composition-guardsfrom
nynexman4464/lint/no-unguarded-ime-keydown

Conversation

@nynexman4464

Copy link
Copy Markdown
Contributor

Why

The IME-composition bug keeps coming back one component at a time (#4860, then the six sites in the parent PR) because nothing enforces the guard — each fix has been reactive, after a user hit it. This rule makes IME-composition safety a property CI checks, so new editable surfaces (including AI-generated code) can't reintroduce it silently. Closes #4892.

What

Flags an onKeyDown on an editable surface — <input>/<textarea>/contentEditable, role="textbox"|"searchbox"|"combobox", or a known Astryx text-input component — that branches on command keys without a composition guard. It's a pragmatic AST + source-text-scan heuristic (matching the sibling rules), not dataflow:

  • Excludes non-composable <input> types (checkbox/number/date/…) and non-editable roles (button/link/menuitem/tab/option), so e.g. a <button role="combobox"> trigger isn't a false positive.
  • Resolves the handler from an inline function or a same-file identifier.
  • Treats any isImeKeyEvent( / .isComposing / 229 mention in the handler as guarded — deliberately favouring false-negatives over noise (a chatty rule gets disabled).

Enabled at error in both tiers: with the parent PR fixing every editable command-key handler in core, this locks the door behind us.

Risk

Low. Known false-negatives are documented (variable-keyed comparisons, cross-file handler indirection, spread role/type); it points at the canonical utils/ime#isImeKeyEvent as the fix.

Testing

17 rule tests (valid: guarded handlers, Tab-only, buttons; invalid: the real Selector/Typeahead shapes). Verified against the pre-fix code that the rule flags exactly the six originally-identified files, and zero after the fix. Full 301-test plugin suite green; real repo eslint (strict/CI) passes on all six fixed components.

Third of a 3-PR stack (shared base → editable-field fixes → this).

@cixzhang

@vercel

vercel Bot commented Aug 11, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
astryx Ready Ready Preview Aug 17, 2026 10:09pm

Request Review

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Meta Open Source bot. label Aug 11, 2026
@nynexman4464
nynexman4464 force-pushed the nynexman4464/lint/no-unguarded-ime-keydown branch from 0df0b2a to 8dcbaa4 Compare August 11, 2026 22:23
@github-actions

github-actions Bot commented Aug 11, 2026 •

Copy link
Copy Markdown
Contributor

PR Analysis Report

📚 Storybook Preview

View Storybook for this PR
GitHub Pages may take up to a minute to hydrate after deploy.

🧪 Sandbox Preview

View Sandbox for this PR
GitHub Pages may take up to a minute to hydrate after deploy.

Modified Components

DateInput (@astryxdesign/core) · View in Storybook
Metric Before After Delta
Bundle Size (ESM) N/A N/A N/A
Lines of Code N/A 527 -
Complexity N/A Very High (85) -
DateTimeInput (@astryxdesign/core) · View in Storybook
Metric Before After Delta
Bundle Size (ESM) N/A N/A N/A
Lines of Code N/A 837 -
Complexity N/A Very High (157) -
MultiSelector (@astryxdesign/core) · View in Storybook
Metric Before After Delta
Bundle Size (ESM) N/A N/A N/A
Lines of Code N/A 1455 -
Complexity N/A Very High (184) -
NumberInput (@astryxdesign/core) · View in Storybook
Metric Before After Delta
Bundle Size (ESM) N/A N/A N/A
Lines of Code N/A 768 -
Complexity N/A Very High (164) -
Selector (@astryxdesign/core) · View in Storybook
Metric Before After Delta
Bundle Size (ESM) N/A N/A N/A
Lines of Code N/A 1502 -
Complexity N/A Very High (157) -
TimeInput (@astryxdesign/core) · View in Storybook
Metric Before After Delta
Bundle Size (ESM) N/A N/A N/A
Lines of Code N/A 485 -
Complexity N/A Very High (82) -
Typeahead (@astryxdesign/core) · View in Storybook
Metric Before After Delta
Bundle Size (ESM) N/A N/A N/A
Lines of Code N/A 1124 -
Complexity N/A Very High (162) -

Bundle Size Summary

Package Size (ESM) Size (CJS) Gzipped
@astryxdesign/core N/A 4.8KB 1.2KB

Accessibility Audit

Status: No accessibility violations detected.


Generated by PR Enrichment workflow | Storybook | Sandbox | View full report

github-actions Bot added a commit that referenced this pull request Aug 11, 2026
@nynexman4464
nynexman4464 force-pushed the nynexman4464/lint/no-unguarded-ime-keydown branch from 8dcbaa4 to 5442408 Compare August 11, 2026 23:47
@nynexman4464
nynexman4464 force-pushed the nynexman4464/lint/no-unguarded-ime-keydown branch from 5442408 to ffcc49b Compare August 17, 2026 15:21
github-actions Bot added a commit that referenced this pull request Aug 17, 2026
@nynexman4464
nynexman4464 force-pushed the nynexman4464/lint/no-unguarded-ime-keydown branch from ffcc49b to c3e039f Compare August 17, 2026 15:44
github-actions Bot added a commit that referenced this pull request Aug 17, 2026
New ESLint rule in the internal @AstryX plugin. Flags an onKeyDown on an
editable surface (input/textarea/contentEditable, role textbox/searchbox/
combobox, or a known Astryx text-input component) that branches on command
keys (Enter/Escape/arrows/Home/End/PageUp/PageDown, or legacy keyCode) without
an IME composition guard (isImeKeyEvent / isComposing / keyCode 229). This
makes IME-composition safety a property CI enforces rather than a bug we keep
rediscovering one component at a time.

Pragmatic AST + source-text-scan heuristic (matching sibling rules), not
dataflow: it resolves the handler from an inline function or a same-file
identifier, excludes non-composable input types (checkbox/number/date/...) and
non-editable roles (button/link/menuitem/tab/option), and treats any
isImeKeyEvent(/.isComposing/229 mention in the handler as guarded (favouring
false-negatives over noise).

Enabled at 'error' in both tiers: every editable command-key handler in core
now guards composition (the six sites fixed in the parent commit), so this
prevents regressions. Verified against the pre-fix code that it flags exactly
those six files, and zero after the fix. 17 rule tests; canonical guard is
utils/ime#isImeKeyEvent.

Closes #4892.
@nynexman4464
nynexman4464 force-pushed the nynexman4464/lint/no-unguarded-ime-keydown branch from c3e039f to 48f182c Compare August 17, 2026 22:06
@nynexman4464
nynexman4464 merged commit ba74b44 into main Aug 17, 2026
19 checks passed
github-actions Bot added a commit that referenced this pull request Aug 17, 2026
@github-actions
github-actions Bot deleted the nynexman4464/lint/no-unguarded-ime-keydown branch August 18, 2026 06:11

This branch was successfully deployed

1 active deployment
Preview — 48f182c0 Deployed Aug 17, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Meta Open Source bot.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

i18n: systematically guard IME composition across text-input components

2 participants