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).
Keep React type references namespaced, don't import them individually
With the react-jsx transform, React's types (FC, ReactNode, SVGProps, ...) are globally available — reference them as React.* instead of importing each one by name from 'react'.
Bad example
| 1 | import { FC, SVGProps } from 'react'; |
| 2 |
|
| 3 | const Icon: FC<SVGProps<SVGSVGElement>> = (props) => <svg {...props} />; |
Explanation (EN)
Importing individual React type names adds import churn and makes it unclear at a glance whether a type like SVGProps is a React type or a DOM type.
Objašnjenje (HR)
Uvoženje pojedinačnih React tipova stvara nepotreban import i otežava razlikovanje je li tip poput SVGProps React tip ili DOM tip.
Good example
| 1 | const Icon: React.FC<React.SVGProps<SVGSVGElement>> = (props) => <svg {...props} />; |
Explanation (EN)
Namespacing under React.* makes React types immediately recognizable and needs no import at all — the JSX types are globally ambient.
Objašnjenje (HR)
Korištenje React.* prefiksa čini React tipove odmah prepoznatljivima i uopće ne treba import — JSX tipovi su globalno dostupni.