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).
Don't import types that are already available globally
Skip explicit imports for types your tooling already exposes globally (e.g. React's JSX/React types under the automatic runtime). The import is dead noise.
Bad example
| 1 | import type { ReactNode } from 'react'; |
| 2 |
|
| 3 | function Wrapper(props: { children: ReactNode }) { |
| 4 | return props.children; |
| 5 | } |
Explanation (EN)
With the automatic JSX runtime and global React types configured, importing ReactNode adds a redundant line that the project setup already provides.
Objašnjenje (HR)
Uz automatski JSX runtime i globalno konfigurirane React tipove, uvoz ReactNode dodaje suvisan redak koji projektna konfiguracija ionako pruza.
Good example
| 1 | function Wrapper(props: { children: React.ReactNode }) { |
| 2 | return props.children; |
| 3 | } |
Explanation (EN)
Reference the globally available type directly. No import line to maintain and the intent is identical.
Objašnjenje (HR)
Koristi globalno dostupan tip izravno. Nema uvoznog retka za odrzavanje, a namjera je ista.
Notes (EN)
Confirm your tsconfig/JSX setup actually exposes the types globally before dropping the import.
Bilješke (HR)
Provjeri da tsconfig/JSX postavka stvarno izlaze tipove globalno prije nego maknes uvoz.