Skip to content

Latest commit

 

History

History
39 lines (20 loc) · 681 Bytes

react-router-no-literals.md

File metadata and controls

39 lines (20 loc) · 681 Bytes

Forbid use of literals in React Router components to reference route paths. (react-router-link-to-constant)

This rule aims to encourage the declaration of route names as constant symbols.

Rule Details

Examples of incorrect code for this rule:

<Route path="home">Home</Link>

<Route path={"home"}>Home</Link>

<Link to="home">Home</Link>

<Link to={"home"}>Home</Link>

this.props.history.push('home');

history.push('home');

Examples of correct code for this rule:

<Route path={ROUTES.HOME}>Home</Link>

<Link to={ROUTES.HOME}>Home</Link>

<Route {...props}>Home</Route>

this.props.history.push(ROUTES.HOME);

history.push(ROUTES.HOME);