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 import types that are already available globally
Use the configured type scope; do not remove React type imports merely because the automatic JSX runtime is enabled.
Bad example
| 1 | import type { ReactNode } from 'react'; |
| 2 |
|
| 3 | function Wrapper(props: { children: ReactNode }) { |
| 4 | return props.children; |
| 5 | } |
Explanation (EN)
An import is redundant only when a verified global declaration already supplies that exact type.
Objašnjenje (HR)
Import je suvišan samo ako provjerena globalna deklaracija već daje upravo taj tip.
Good example
| 1 | import type { ReactNode } from "react"; |
| 2 | function Wrapper(props: { children: ReactNode }) { |
| 3 | return props.children; |
| 4 | } |
Explanation (EN)
An explicit module type import is correct when ambient availability is not part of the project contract.
Objašnjenje (HR)
Izričit import tipa iz modula ispravan je kada globalna dostupnost nije dio ugovora projekta.
Notes (EN)
Remove a redundant type import only after verifying that the exact identifier remains available under the actual tsconfig and module settings.
Bilješke (HR)
Suvišan type import ukloni tek nakon provjere da isti identifikator ostaje dostupan uz stvarni tsconfig i postavke modula.
Exceptions / Tradeoffs (EN)
Automatic JSX transformation does not guarantee ambient React namespace types. Explicit named or namespace type imports are valid and often clearer in modules.