Rules Hub
Coding Rules Library
Rule priority, scope & exceptions
Use this to align rules with the senior-level structure (P0/P1/P2, scope, exceptions/tradeoffs).
Prefer dropping a deprecated prop over adding bridging code to support it
If the only reason for awkward destructure/remap/cast logic is to keep supporting a deprecated prop, remove the prop and let callers use the modern API.
Bad example
| 1 | // eslint-disable-next-line @typescript-eslint/no-deprecated |
| 2 | const { PaperProps: externalPaperProps, ...rest } = (dialogProps ?? {}) as DeprecatedDialogProps; |
| 3 | return <Dialog {...rest} slotProps={{ paper: externalPaperProps }} />; |
Explanation (EN)
Keeping a deprecated prop alive forces a cast plus a lint-suppression and extra destructuring — complexity that exists only to support an API you are trying to retire.
Objašnjenje (HR)
Odrzavanje zastarjelog propa zivim prisiljava na cast plus potiskivanje lintera i dodatno destrukturiranje — slozenost koja postoji samo da podrzi API koji pokusavas ukloniti.
Good example
| 1 | return ( |
| 2 | <Dialog {...dialogProps} slotProps={dialogProps?.slotProps}> |
| 3 | {children} |
| 4 | </Dialog> |
| 5 | ); |
Explanation (EN)
Dropping the deprecated prop removes the cast, the lint suppression and the remap; callers pass the modern `slotProps` directly.
Objašnjenje (HR)
Uklanjanje zastarjelog propa uklanja cast, potiskivanje lintera i premapiranje; pozivatelji izravno prosljeduju moderan `slotProps`.
Exceptions / Tradeoffs (EN)
If the deprecated prop is part of a widely-consumed public API you cannot break yet, keep the bridge but localize and document it.
Iznimke / Tradeoffi (HR)
Ako je zastarjeli prop dio siroko koristenog javnog API-ja koji jos ne smijes razbiti, zadrzi most ali ga lokaliziraj i dokumentiraj.