Use when refactoring Handsontable code - applying SOLID principles, Law of Demeter, plugin extraction, performance optimization, code modernization, and API redesign with backward compatibility preservation
Prefer conventions that work with zero configuration for the common case. When refactoring, eliminate config that duplicates what naming, location, or type conventions already express. Do not introduce new options or wiring when auto-discovery or lifecycle hooks can handle it.
isEnabled, enablePlugin, disablePlugin, updatePlugin, destroy) and declare required static properties.hot.getPlugin('{Name}')hot.getPlugin('{Name}') when you need another plugin's API. Never import a plugin class directly.Avoid deep access chains like this.hot.view.wt.wtTable.holder. Each layer should only talk to its immediate neighbors. If you find yourself reaching through multiple objects, introduce a method on the intermediate layer that provides what you need.
Plugin extraction: When logic in core.js or a large plugin grows beyond a single responsibility, move it into a dedicated plugin. Register new hooks so the extracted plugin communicates without tight coupling.
Performance:
arr.push(...largeArray) with a forEach loop -- spread causes stack overflow with 10k+ elements.batch(), batchRender(), suspendRender()/resumeRender().requestAnimationFrame.Modernization:
#privateFields instead of @private JSDoc annotations (exception: when # measurably hurts performance)..bind(this).?.) only when a value is genuinely optional by design, not as a blanket safety net.API redesign: When renaming or replacing an API, keep the old name working. See the backward compatibility section below.
These rules are non-negotiable when refactoring:
| Rule | Detail |
|---|---|
| Never change default setting values | Defaults in metaSchema.js must stay the same. |
| Keep legacy CSS class names | Add new class names alongside old ones. Old names stay in the DOM. |
| Keep legacy API names working | Old method/option/hook names continue to work with no console warnings (this is "legacy", not "deprecated"). |
| Deprecated APIs get one-time warning | Use deprecatedWarn() from src/helpers/console.js. The old API works until the next major release. |
| Removed hooks go on the removed list | So users see a clear error instead of silent failure. |
src/helpers/. Check what already exists before writing new utility functions.Refactored code must maintain full test coverage. For every change:
*.unit.js): test extracted helpers, strategies, and pure logic in isolation.*.spec.js): verify the feature still works end-to-end in the browser. All it() callbacks must be async.