Skip to content

Commit 8af6d22

Browse files
committed
feature: @putotu/plugin-react-router: v7-split-multi-segment-route: add (#221)
1 parent bcab9ae commit 8af6d22

File tree

19 files changed

+177
-22
lines changed

19 files changed

+177
-22
lines changed

packages/plugin-react-router/README.md

Lines changed: 38 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -11,24 +11,22 @@
1111
npm i putout @putout/plugin-react-router -D
1212
```
1313

14-
Update `.putout.json` with:
15-
16-
```json
17-
{
18-
"plugins": ["react-router"]
19-
}
20-
```
21-
2214
## Rules
2315

24-
Here is list of rules:
16+
-[v6-convert-switch-to-routers](#v6-convert-switch-to-routers);
17+
-[v6-convert-component-to-element](#v6-convert-component-to-element);
18+
-[v7-split-multi-segment-route](#v7-split-multi-segment-route);
19+
20+
## Config
2521

2622
```json
2723
{
2824
"rules": {
29-
"react-router/convert-switch-to-routers": "on",
30-
"react-router/convert-component-to-element": "on"
31-
}
25+
"react-router/v6-convert-switch-to-routers": "on",
26+
"react-router/v6-convert-component-to-element": "on",
27+
"react-router/v7-split-multi-segment-route": "on"
28+
},
29+
"plugins": ["react-router"]
3230
}
3331
```
3432

@@ -78,6 +76,34 @@ const routes = () => (
7876
<Route path="/" element={<Home/>}/>;
7977
```
8078

79+
## v7-split-multi-segment-route
80+
81+
> Split any multi-segment splat `<Route>` into a parent route with the path and a child route with the splat.
82+
>
83+
> (c) [reactrouter.com](https://reactrouter.com/upgrading/v6)
84+
85+
Checkout in 🐊[**Putout Editor**](https://putout.cloudcmd.io/#/gist/f7e4ee30936fee2eb0b9269e9b377561/5bb969962141c3d617576384203a8ab3c38c7b31).
86+
87+
### ❌ Example of incorrect code
88+
89+
```jsx
90+
<Routes>
91+
<Route path="/" element={<Home/>}/>
92+
<Route path="dashboard/*" element={<Dashboard/>}/>
93+
</Routes>;
94+
```
95+
96+
### ✅ Example of correct code
97+
98+
```jsx
99+
<Routes>
100+
<Route path="/" element={<Home/>}/>
101+
<Route path="dashboard">
102+
<Route path="*" element={<Dashboard/>}/>
103+
</Route>
104+
</Routes>;
105+
```
106+
81107
## License
82108

83109
MIT
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
'use strict';
2+
3+
const v6ConvertSwitchToRoutes = require('./v6-convert-switch-to-routes');
4+
const v6ConvertComponentToElement = require('./v6-convert-component-to-element');
5+
const v7SplitMultiSegmentRoute = require('./v7-split-multi-segment-route');
6+
7+
module.exports.rules = {
8+
'v6-convert-switch-to-routes': v6ConvertSwitchToRoutes,
9+
'v6-convert-component-to-element': v6ConvertComponentToElement,
10+
'v7-split-multi-segment-route': v7SplitMultiSegmentRoute,
11+
};

packages/plugin-react-router/lib/react-router.js

Lines changed: 0 additions & 9 deletions
This file was deleted.

packages/plugin-react-router/lib/convert-component-to-element/fixture/convert-component-to-element-fix.js renamed to packages/plugin-react-router/lib/v6-convert-component-to-element/fixture/convert-component-to-element-fix.js

File renamed without changes.

packages/plugin-react-router/lib/convert-component-to-element/fixture/convert-component-to-element.js renamed to packages/plugin-react-router/lib/v6-convert-component-to-element/fixture/convert-component-to-element.js

File renamed without changes.

packages/plugin-react-router/lib/convert-component-to-element/index.js renamed to packages/plugin-react-router/lib/v6-convert-component-to-element/index.js

File renamed without changes.

packages/plugin-react-router/lib/convert-component-to-element/index.spec.js renamed to packages/plugin-react-router/lib/v6-convert-component-to-element/index.spec.js

File renamed without changes.

packages/plugin-react-router/lib/convert-switch-to-routes/fixture/convert-switch-to-routes-fix.js renamed to packages/plugin-react-router/lib/v6-convert-switch-to-routes/fixture/convert-switch-to-routes-fix.js

File renamed without changes.

packages/plugin-react-router/lib/convert-switch-to-routes/fixture/convert-switch-to-routes.js renamed to packages/plugin-react-router/lib/v6-convert-switch-to-routes/fixture/convert-switch-to-routes.js

File renamed without changes.

packages/plugin-react-router/lib/convert-switch-to-routes/index.js renamed to packages/plugin-react-router/lib/v6-convert-switch-to-routes/index.js

File renamed without changes.

0 commit comments

Comments
 (0)