File tree Expand file tree Collapse file tree 9 files changed +31
-44
lines changed
packages/plugin-react-router
v6-convert-component-to-element
v6-convert-switch-to-routes
v7-split-multi-segment-route Expand file tree Collapse file tree 9 files changed +31
-44
lines changed Original file line number Diff line number Diff line change 1- 'use strict' ;
1+ import * as v6ConvertSwitchToRoutes from './v6-convert-switch-to-routes/index.js' ;
2+ import * as v6ConvertComponentToElement from './v6-convert-component-to-element/index.js' ;
3+ import * as v7SplitMultiSegmentRoute from './v7-split-multi-segment-route/index.js' ;
24
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 = {
5+ export const rules = {
86 'v6-convert-switch-to-routes' : v6ConvertSwitchToRoutes ,
97 'v6-convert-component-to-element' : v6ConvertComponentToElement ,
108 'v7-split-multi-segment-route' : v7SplitMultiSegmentRoute ,
Original file line number Diff line number Diff line change 1- 'use strict ';
1+ import { types } from 'putout ';
22
3- const { types} = require ( 'putout' ) ;
43const {
54 JSXIdentifier,
65 JSXOpeningElement,
76 JSXElement,
87} = types ;
98
10- module . exports . report = ( ) => `Use 'element' instead of 'component'` ;
9+ export const report = ( ) => `Use 'element' instead of 'component'` ;
1110
1211const SELF_CLOSING = true ;
1312
14- module . exports . fix = ( path ) => {
13+ export const fix = ( path ) => {
1514 for ( const attr of path . node . attributes ) {
1615 if ( attr . name . name !== 'component' )
1716 continue ;
@@ -28,7 +27,7 @@ module.exports.fix = (path) => {
2827 }
2928} ;
3029
31- module . exports . traverse = ( { push} ) => ( {
30+ export const traverse = ( { push} ) => ( {
3231 JSXOpeningElement ( path ) {
3332 if ( path . node . name . name !== 'Route' )
3433 return ;
Original file line number Diff line number Diff line change 1- 'use strict' ;
1+ import { createTest } from '@putout/test' ;
2+ import * as plugin from './index.js' ;
23
3- const { createTest} = require ( '@putout/test' ) ;
4- const plugin = require ( '.' ) ;
5-
6- const test = createTest ( __dirname , {
4+ const test = createTest ( import . meta. url , {
75 plugins : [
86 [ 'react-router/convert-component-to-element' , plugin ] ,
97 ] ,
Original file line number Diff line number Diff line change 1- 'use strict ';
1+ import { operator } from 'putout ';
22
3- const { operator} = require ( 'putout' ) ;
43const { rename} = operator ;
54
6- module . exports . report = ( ) => `Use 'Routes' instead of 'Switch'` ;
5+ export const report = ( ) => `Use 'Routes' instead of 'Switch'` ;
76
8- module . exports . fix = ( path ) => {
7+ export const fix = ( path ) => {
98 rename ( path , 'Switch' , 'Routes' ) ;
109} ;
1110
12- module . exports . traverse = ( { push} ) => ( {
11+ export const traverse = ( { push} ) => ( {
1312 Program ( path ) {
1413 const { Switch} = path . scope . bindings ;
1514
Original file line number Diff line number Diff line change 1- 'use strict' ;
1+ import { createTest } from '@putout/test' ;
2+ import * as plugin from './index.js' ;
23
3- const { createTest} = require ( '@putout/test' ) ;
4- const plugin = require ( '.' ) ;
5-
6- const test = createTest ( __dirname , {
4+ const test = createTest ( import . meta. url , {
75 plugins : [
86 [ 'react-router/convert-switch-to-routes' , plugin ] ,
97 ] ,
Original file line number Diff line number Diff line change 1- 'use strict ';
1+ import { operator , types } from 'putout ';
22
3- const { operator, types} = require ( 'putout' ) ;
43const {
54 stringLiteral,
65 identifier,
@@ -15,9 +14,9 @@ const {
1514 getProperties,
1615} = operator ;
1716
18- module . exports . report = ( ) => `Split multi-segment splat <Route` ;
17+ export const report = ( ) => `Split multi-segment splat <Route` ;
1918
20- module . exports . match = ( ) => ( {
19+ export const match = ( ) => ( {
2120 '<Route path="__a" element={__b} />' : ( { __a} ) => {
2221 const { value} = __a ;
2322
@@ -41,7 +40,7 @@ module.exports.match = () => ({
4140 } ,
4241} ) ;
4342
44- module . exports . replace = ( ) => ( {
43+ export const replace = ( ) => ( {
4544 '<Route path="__a" element={__b} />' : ( { __a} ) => {
4645 const [ name , mask ] = __a . value . split ( `/` ) ;
4746
Original file line number Diff line number Diff line change 1- 'use strict' ;
1+ import { createTest } from '@putout/test' ;
2+ import * as plugin from './index.js' ;
23
3- const { createTest} = require ( '@putout/test' ) ;
4- const plugin = require ( '.' ) ;
5-
6- const test = createTest ( __dirname , {
4+ const test = createTest ( import . meta. url , {
75 plugins : [
86 [ 'v7-split-multi-segment-route' , plugin ] ,
97 ] ,
Original file line number Diff line number Diff line change 11{
22 "name" : " @putout/plugin-react-router" ,
33 "version" : " 3.1.0" ,
4- "type" : " commonjs " ,
4+ "type" : " module " ,
55 "author" :
" coderaiser <[email protected] > (https://github.com/coderaiser)" ,
66 "description" : " 🐊Putout plugin adds ability to migrate to latest ReactRouter" ,
77 "homepage" : " https://github.com/coderaiser/putout/tree/master/packages/plugin-react-router#readme" ,
3232 " react-router"
3333 ],
3434 "peerDependencies" : {
35- "putout" : " >=37 "
35+ "putout" : " >=39 "
3636 },
3737 "devDependencies" : {
3838 "@putout/eslint-flat" : " ^3.0.0" ,
4646 },
4747 "license" : " MIT" ,
4848 "engines" : {
49- "node" : " >=18 "
49+ "node" : " >=20 "
5050 },
5151 "publishConfig" : {
5252 "access" : " public"
Original file line number Diff line number Diff line change 1- 'use strict' ;
1+ import { createTest } from '@putout/test' ;
2+ import * as reactRouter from '../lib/index.js' ;
23
3- const { createTest} = require ( '@putout/test' ) ;
4- const reactRouter = require ( '..' ) ;
5-
6- const test = createTest ( __dirname , {
4+ const test = createTest ( import . meta. url , {
75 plugins : [
86 [ 'react-router' , reactRouter ] ,
97 ] ,
You can’t perform that action at this time.
0 commit comments