File tree 16 files changed +65
-89
lines changed
packages/plugin-react-hook-form
v5-remove-value-from-control
v6-convert-form-context-to-form-provider
v6-convert-trigger-validation-to-trigger
16 files changed +65
-89
lines changed Original file line number Diff line number Diff line change
1
+ import * as v7ApplyFormState from './v7-apply-form-state/index.js' ;
2
+ import * as v6ApplyClearErrors from './v6-apply-clear-errors/index.js' ;
3
+ import * as v6ConvertAsToRender from './v6-convert-as-to-render/index.js' ;
4
+ import * as v6ConvertFormContextToFormProvider from './v6-convert-form-context-to-form-provider/index.js' ;
5
+ import * as v6ConvertTriggerValidationToTrigger from './v6-convert-trigger-validation-to-trigger/index.js' ;
6
+ import * as v5RemoveValueFromControl from './v5-remove-value-from-control/index.js' ;
7
+
8
+ export const rules = {
9
+ 'v7-apply-form-state' : v7ApplyFormState ,
10
+ 'v6-apply-clear-errors' : v6ApplyClearErrors ,
11
+ 'v6-convert-as-to-render' : v6ConvertAsToRender ,
12
+ 'v6-convert-form-context-to-form-provider' : v6ConvertFormContextToFormProvider ,
13
+ 'v6-convert-trigger-validation-to-trigger' : v6ConvertTriggerValidationToTrigger ,
14
+ 'v5-remove-value-from-control' : v5RemoveValueFromControl ,
15
+ } ;
Load Diff This file was deleted.
Original file line number Diff line number Diff line change 1
- 'use strict' ;
1
+ export const report = ( ) => `Remove 'value property' from 'control' attribute` ;
2
2
3
- module . exports . report = ( ) => `Remove 'value property' from 'control' attribute` ;
4
-
5
- module . exports . match = ( ) => ( {
3
+ export const match = ( ) => ( {
6
4
'({value: __a})' : ( vars , path ) => {
7
5
if ( ! path . parentPath . parentPath . isJSXExpressionContainer ( ) )
8
6
return false ;
@@ -16,6 +14,6 @@ module.exports.match = () => ({
16
14
} ,
17
15
} ) ;
18
16
19
- module . exports . replace = ( ) => ( {
17
+ export const replace = ( ) => ( {
20
18
'({value: __a})' : '__a' ,
21
19
} ) ;
Original file line number Diff line number Diff line change 1
- 'use strict' ;
1
+ import { createTest } from '@putout/test' ;
2
+ import * as removeValueFromControl from './index.js' ;
2
3
3
- const { createTest} = require ( '@putout/test' ) ;
4
- const removeValueFromControl = require ( '.' ) ;
5
-
6
- const test = createTest ( __dirname , {
4
+ const test = createTest ( import . meta. url , {
7
5
plugins : [
8
6
[ 'remove-value-from-control' , removeValueFromControl ] ,
9
7
] ,
Original file line number Diff line number Diff line change 1
- 'use strict ';
1
+ import { operator } from 'putout ';
2
2
3
- const { operator} = require ( 'putout' ) ;
4
3
const { rename} = operator ;
5
4
6
- module . exports . report = ( ) => `Use 'clearErrors' instead of 'clearError'` ;
5
+ export const report = ( ) => `Use 'clearErrors' instead of 'clearError'` ;
7
6
8
- module . exports . fix = ( path ) => {
7
+ export const fix = ( path ) => {
9
8
const program = path . scope . getProgramParent ( ) . path ;
10
9
rename ( program , 'clearError' , 'clearErrors' ) ;
11
10
} ;
12
11
13
- module . exports . include = ( ) => [
12
+ export const include = ( ) => [
14
13
'clearError(__args)' ,
15
14
] ;
Original file line number Diff line number Diff line change 1
- 'use strict' ;
1
+ import { createTest } from '@putout/test' ;
2
+ import * as applyClearErrors from './index.js' ;
2
3
3
- const { createTest} = require ( '@putout/test' ) ;
4
- const applyClearErrors = require ( '.' ) ;
5
-
6
- const test = createTest ( __dirname , {
4
+ const test = createTest ( import . meta. url , {
7
5
plugins : [
8
6
[ 'apply-clear-errors' , applyClearErrors ] ,
9
7
] ,
Original file line number Diff line number Diff line change 1
- 'use strict' ;
2
-
3
- const { types, template} = require ( 'putout' ) ;
1
+ import { types , template } from 'putout' ;
4
2
5
3
const {
6
4
JSXExpressionContainer,
@@ -15,9 +13,9 @@ const ARROW = template(`({field}) => {
15
13
return (%%expression%%);
16
14
}` ) ;
17
15
18
- module . exports . report = ( ) => `Use 'render' instead of 'as' in '<Control/>' elements` ;
16
+ export const report = ( ) => `Use 'render' instead of 'as' in '<Control/>' elements` ;
19
17
20
- module . exports . match = ( ) => ( {
18
+ export const match = ( ) => ( {
21
19
'<Controller __jsx_attributes/>' : ( { __jsx_attributes} ) => {
22
20
for ( const attr of __jsx_attributes ) {
23
21
if ( isJSXSpreadAttribute ( attr ) )
@@ -31,7 +29,7 @@ module.exports.match = () => ({
31
29
} ,
32
30
} ) ;
33
31
34
- module . exports . replace = ( ) => ( {
32
+ export const replace = ( ) => ( {
35
33
[ `
36
34
<Controller
37
35
as={__a}
Original file line number Diff line number Diff line change 1
- 'use strict' ;
1
+ import { createTest } from '@putout/test' ;
2
+ import * as convertAsToRender from './index.js' ;
2
3
3
- const { createTest} = require ( '@putout/test' ) ;
4
- const convertAsToRender = require ( '.' ) ;
5
-
6
- const test = createTest ( __dirname , {
4
+ const test = createTest ( import . meta. url , {
7
5
plugins : [
8
6
[ 'convert-as-to-render' , convertAsToRender ] ,
9
7
] ,
Original file line number Diff line number Diff line change 1
- 'use strict ';
1
+ import { operator } from 'putout ';
2
2
3
- const { operator} = require ( 'putout' ) ;
4
3
const { rename} = operator ;
5
4
6
- module . exports . report = ( ) => `Use '<FormProvider/>' instead of '<FormContext/>'` ;
5
+ export const report = ( ) => `Use '<FormProvider/>' instead of '<FormContext/>'` ;
7
6
8
- module . exports . fix = ( path ) => {
7
+ export const fix = ( path ) => {
9
8
rename ( path , 'FormContext' , 'FormProvider' ) ;
10
9
} ;
11
10
12
- module . exports . include = ( ) => [
11
+ export const include = ( ) => [
13
12
'<FormContext __jsx_attributes>__jsx_children</FormContext>' ,
14
13
] ;
15
14
16
- module . exports . filter = ( path ) => path . scope . getAllBindings ( ) . FormContext ;
15
+ export const filter = ( path ) => path . scope . getAllBindings ( ) . FormContext ;
Original file line number Diff line number Diff line change 1
- 'use strict' ;
1
+ import { createTest } from '@putout/test' ;
2
+ import * as convert from './index.js' ;
2
3
3
- const { createTest} = require ( '@putout/test' ) ;
4
- const convert = require ( '.' ) ;
5
-
6
- const test = createTest ( __dirname , {
4
+ const test = createTest ( import . meta. url , {
7
5
plugins : [
8
6
[ 'v6-convert-form-context-to-form-provider' , convert ] ,
9
7
] ,
Original file line number Diff line number Diff line change 1
- 'use strict ';
1
+ import { operator } from 'putout ';
2
2
3
- const { operator} = require ( 'putout' ) ;
4
3
const { rename} = operator ;
5
4
6
- module . exports . report = ( ) => `Use 'trigger()' instead of 'triggerValidation()'` ;
5
+ export const report = ( ) => `Use 'trigger()' instead of 'triggerValidation()'` ;
7
6
8
- module . exports . fix = ( path ) => {
7
+ export const fix = ( path ) => {
9
8
rename ( path , 'triggerValidation' , 'trigger' ) ;
10
9
} ;
11
10
12
- module . exports . include = ( ) => [
11
+ export const include = ( ) => [
13
12
'triggerValidation(__args)' ,
14
13
] ;
15
14
16
- module . exports . filter = ( { scope} ) => {
15
+ export const filter = ( { scope} ) => {
17
16
const bindings = scope . getAllBindings ( ) ;
18
17
return bindings . triggerValidation ;
19
18
} ;
Original file line number Diff line number Diff line change 1
- 'use strict' ;
1
+ import { createTest } from '@putout/test' ;
2
+ import * as convertAsToRender from './index.js' ;
2
3
3
- const { createTest} = require ( '@putout/test' ) ;
4
- const convertAsToRender = require ( '.' ) ;
5
-
6
- const test = createTest ( __dirname , {
4
+ const test = createTest ( import . meta. url , {
7
5
plugins : [
8
6
[ 'convert-trigger-validation-to-trigger' , convertAsToRender ] ,
9
7
] ,
Original file line number Diff line number Diff line change 1
- 'use strict ';
1
+ import { types } from 'putout ';
2
2
3
- const { types} = require ( 'putout' ) ;
4
3
const {
5
4
objectProperty,
6
5
isRestElement,
7
6
objectPattern,
8
7
} = types ;
9
8
10
- module . exports . report = ( ) => `Use 'formState.errors' instead of 'errors'` ;
9
+ export const report = ( ) => `Use 'formState.errors' instead of 'errors'` ;
11
10
12
11
const COMPUTED = false ;
13
12
const SHORTHAND = true ;
14
13
15
- module . exports . exclude = ( ) => [
14
+ export const exclude = ( ) => [
16
15
'const __object = formState' ,
17
16
] ;
18
17
19
- module . exports . match = ( ) => ( {
18
+ export const match = ( ) => ( {
20
19
'const __object = __a' : ( { __object} , path ) => {
21
20
const bindings = path . scope . getAllBindings ( ) ;
22
21
@@ -35,7 +34,7 @@ module.exports.match = () => ({
35
34
} ,
36
35
} ) ;
37
36
38
- module . exports . replace = ( ) => ( {
37
+ export const replace = ( ) => ( {
39
38
'const __object = __a' : ( { __object} , path ) => {
40
39
for ( const property of __object . properties ) {
41
40
if ( isRestElement ( property ) )
Original file line number Diff line number Diff line change 1
- 'use strict' ;
1
+ import { createTest } from '@putout/test' ;
2
+ import * as apply from './index.js' ;
2
3
3
- const { createTest} = require ( '@putout/test' ) ;
4
- const apply = require ( '.' ) ;
5
-
6
- const test = createTest ( __dirname , {
4
+ const test = createTest ( import . meta. url , {
7
5
plugins : [
8
6
[ 'apply-form-state' , apply ] ,
9
7
] ,
Original file line number Diff line number Diff line change 1
1
{
2
2
"name" : " @putout/plugin-react-hook-form" ,
3
3
"version" : " 5.0.0" ,
4
- "type" : " commonjs " ,
4
+ "type" : " module " ,
5
5
"author" : " coderaiser <mnemonic.enemy@gmail.com> (https://github.com/coderaiser)" ,
6
6
"description" : " 🐊Putout plugin adds ability to migrate to latest version of React Hook Form" ,
7
7
"homepage" : " https://github.com/coderaiser/putout/tree/master/packages/plugin-react-hook-form#readme" ,
8
- "main" : " lib/react-hook-form .js" ,
8
+ "main" : " lib/index .js" ,
9
9
"release" : false ,
10
10
"tag" : false ,
11
11
"changelog" : false ,
47
47
},
48
48
"license" : " MIT" ,
49
49
"engines" : {
50
- "node" : " >=18 "
50
+ "node" : " >=20 "
51
51
},
52
52
"publishConfig" : {
53
53
"access" : " public"
Original file line number Diff line number Diff line change 1
- 'use strict' ;
1
+ import { createTest } from '@putout/test' ;
2
+ import * as reactHookForm from '../lib/index.js' ;
2
3
3
- const { createTest} = require ( '@putout/test' ) ;
4
- const reactHookForm = require ( '..' ) ;
5
-
6
- const test = createTest ( __dirname , {
4
+ const test = createTest ( import . meta. url , {
7
5
plugins : [
8
6
[ 'react-hook-form' , reactHookForm ] ,
9
7
] ,
You can’t perform that action at this time.
0 commit comments