Skip to content

Commit 98acaf8

Browse files
committed
feature: @putout/plugin-react-hook-form: drop support of node < 20
1 parent 4718b72 commit 98acaf8

File tree

16 files changed

+65
-89
lines changed

16 files changed

+65
-89
lines changed
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
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+
};

packages/plugin-react-hook-form/lib/react-hook-form.js

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

packages/plugin-react-hook-form/lib/v5-remove-value-from-control/index.js

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
1-
'use strict';
1+
export const report = () => `Remove 'value property' from 'control' attribute`;
22

3-
module.exports.report = () => `Remove 'value property' from 'control' attribute`;
4-
5-
module.exports.match = () => ({
3+
export const match = () => ({
64
'({value: __a})': (vars, path) => {
75
if (!path.parentPath.parentPath.isJSXExpressionContainer())
86
return false;
@@ -16,6 +14,6 @@ module.exports.match = () => ({
1614
},
1715
});
1816

19-
module.exports.replace = () => ({
17+
export const replace = () => ({
2018
'({value: __a})': '__a',
2119
});

packages/plugin-react-hook-form/lib/v5-remove-value-from-control/index.spec.js

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
1-
'use strict';
1+
import {createTest} from '@putout/test';
2+
import * as removeValueFromControl from './index.js';
23

3-
const {createTest} = require('@putout/test');
4-
const removeValueFromControl = require('.');
5-
6-
const test = createTest(__dirname, {
4+
const test = createTest(import.meta.url, {
75
plugins: [
86
['remove-value-from-control', removeValueFromControl],
97
],
Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,14 @@
1-
'use strict';
1+
import {operator} from 'putout';
22

3-
const {operator} = require('putout');
43
const {rename} = operator;
54

6-
module.exports.report = () => `Use 'clearErrors' instead of 'clearError'`;
5+
export const report = () => `Use 'clearErrors' instead of 'clearError'`;
76

8-
module.exports.fix = (path) => {
7+
export const fix = (path) => {
98
const program = path.scope.getProgramParent().path;
109
rename(program, 'clearError', 'clearErrors');
1110
};
1211

13-
module.exports.include = () => [
12+
export const include = () => [
1413
'clearError(__args)',
1514
];

packages/plugin-react-hook-form/lib/v6-apply-clear-errors/index.spec.js

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
1-
'use strict';
1+
import {createTest} from '@putout/test';
2+
import * as applyClearErrors from './index.js';
23

3-
const {createTest} = require('@putout/test');
4-
const applyClearErrors = require('.');
5-
6-
const test = createTest(__dirname, {
4+
const test = createTest(import.meta.url, {
75
plugins: [
86
['apply-clear-errors', applyClearErrors],
97
],

packages/plugin-react-hook-form/lib/v6-convert-as-to-render/index.js

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
'use strict';
2-
3-
const {types, template} = require('putout');
1+
import {types, template} from 'putout';
42

53
const {
64
JSXExpressionContainer,
@@ -15,9 +13,9 @@ const ARROW = template(`({field}) => {
1513
return (%%expression%%);
1614
}`);
1715

18-
module.exports.report = () => `Use 'render' instead of 'as' in '<Control/>' elements`;
16+
export const report = () => `Use 'render' instead of 'as' in '<Control/>' elements`;
1917

20-
module.exports.match = () => ({
18+
export const match = () => ({
2119
'<Controller __jsx_attributes/>': ({__jsx_attributes}) => {
2220
for (const attr of __jsx_attributes) {
2321
if (isJSXSpreadAttribute(attr))
@@ -31,7 +29,7 @@ module.exports.match = () => ({
3129
},
3230
});
3331

34-
module.exports.replace = () => ({
32+
export const replace = () => ({
3533
[`
3634
<Controller
3735
as={__a}

packages/plugin-react-hook-form/lib/v6-convert-as-to-render/index.spec.js

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
1-
'use strict';
1+
import {createTest} from '@putout/test';
2+
import * as convertAsToRender from './index.js';
23

3-
const {createTest} = require('@putout/test');
4-
const convertAsToRender = require('.');
5-
6-
const test = createTest(__dirname, {
4+
const test = createTest(import.meta.url, {
75
plugins: [
86
['convert-as-to-render', convertAsToRender],
97
],
Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,15 @@
1-
'use strict';
1+
import {operator} from 'putout';
22

3-
const {operator} = require('putout');
43
const {rename} = operator;
54

6-
module.exports.report = () => `Use '<FormProvider/>' instead of '<FormContext/>'`;
5+
export const report = () => `Use '<FormProvider/>' instead of '<FormContext/>'`;
76

8-
module.exports.fix = (path) => {
7+
export const fix = (path) => {
98
rename(path, 'FormContext', 'FormProvider');
109
};
1110

12-
module.exports.include = () => [
11+
export const include = () => [
1312
'<FormContext __jsx_attributes>__jsx_children</FormContext>',
1413
];
1514

16-
module.exports.filter = (path) => path.scope.getAllBindings().FormContext;
15+
export const filter = (path) => path.scope.getAllBindings().FormContext;

packages/plugin-react-hook-form/lib/v6-convert-form-context-to-form-provider/index.spec.js

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
1-
'use strict';
1+
import {createTest} from '@putout/test';
2+
import * as convert from './index.js';
23

3-
const {createTest} = require('@putout/test');
4-
const convert = require('.');
5-
6-
const test = createTest(__dirname, {
4+
const test = createTest(import.meta.url, {
75
plugins: [
86
['v6-convert-form-context-to-form-provider', convert],
97
],

0 commit comments

Comments
 (0)