Rules Hub
Code Ruleset
Rule priority, scope & exceptions
Use this to align rules with the senior-level structure (P0/P1/P2, scope, exceptions/tradeoffs).
Don't reach for newer framework APIs that break supported versions
Use a tested render adapter or compatible package entry for every supported React major; a dynamic-import catch is not sufficient proof of compatibility.
Bad example
| 1 | import { createRoot } from "react-dom/client"; |
| 2 | createRoot(container).render(<App />); |
Explanation (EN)
An unconditional react-dom/client import cannot be resolved by React 17 installations.
Objašnjenje (HR)
Good example
| 1 | interface RenderAdapter { |
| 2 | render(container: Element, content: React.ReactNode): () => void; |
| 3 | } |
| 4 | function mount(container: Element, adapter: RenderAdapter) { |
| 5 | return adapter.render(container, <App />); |
| 6 | } |
Explanation (EN)
The host supplies its version-compatible render and unmount implementation; test each advertised host version.
Objašnjenje (HR)
Notes (EN)
Verify the supported React versions, peer dependencies and bundler resolution before selecting a render entry point; test each promised consumer configuration.
Exceptions / Tradeoffs (EN)
A dynamic import of a missing subpath can fail at build time even inside try/catch. Do not swallow createRoot initialization failures and retry a different rendering system. Version-specific entries or a caller-provided adapter may be clearer.