├── .eslintrc.js
├── .github
├── ISSUE_TEMPLATE
│ ├── bug_report.md
│ ├── config.yml
│ ├── feature_request.md
│ └── pull_request_template.md
└── workflows
│ └── main.yml
├── .gitignore
├── .husky
├── .gitignore
└── pre-commit
├── .prettierignore
├── .prettierrc.json
├── CODE_OF_CONDUCT.md
├── CONTRIBUTING.md
├── LICENCE.md
├── README.md
├── bin
├── cli.ts
└── hookform-codemod.ts
├── jest.config.js
├── package.json
├── transforms
├── __testfixtures__
│ └── v7
│ │ ├── move-errors-to-formState
│ │ ├── already-migrated-context.input.js
│ │ ├── already-migrated-context.output.js
│ │ ├── already-migrated.input.js
│ │ ├── already-migrated.output.js
│ │ ├── function-component-context.input.js
│ │ ├── function-component-context.output.js
│ │ ├── function-component.input.js
│ │ ├── function-component.output.js
│ │ ├── with-custom-errors-context.input.js
│ │ ├── with-custom-errors-context.output.js
│ │ ├── with-custom-errors.input.js
│ │ ├── with-custom-errors.output.js
│ │ ├── with-formState-1-context.input.js
│ │ ├── with-formState-1-context.output.js
│ │ ├── with-formState-1.input.js
│ │ ├── with-formState-1.output.js
│ │ ├── with-formState-2-context.input.js
│ │ ├── with-formState-2-context.output.js
│ │ ├── with-formState-2.input.js
│ │ ├── with-formState-2.output.js
│ │ ├── with-formState-3-context.input.js
│ │ ├── with-formState-3-context.output.js
│ │ ├── with-formState-3.input.js
│ │ └── with-formState-3.output.js
│ │ └── update-register
│ │ ├── already-migrated-context.input.js
│ │ ├── already-migrated-context.output.js
│ │ ├── already-migrated.input.js
│ │ ├── already-migrated.output.js
│ │ ├── custom-register-context.input.js
│ │ ├── custom-register-context.output.js
│ │ ├── custom-register.input.js
│ │ ├── custom-register.output.js
│ │ ├── function-component-2-context.input.js
│ │ ├── function-component-2-context.output.js
│ │ ├── function-component-2.input.js
│ │ ├── function-component-2.output.js
│ │ ├── function-component-context.input.js
│ │ ├── function-component-context.output.js
│ │ ├── function-component.input.js
│ │ ├── function-component.output.js
│ │ ├── function-components-context.input.js
│ │ ├── function-components-context.output.js
│ │ ├── function-components.input.js
│ │ ├── function-components.output.js
│ │ ├── no-transform-context.input.js
│ │ ├── no-transform-context.output.js
│ │ ├── no-transform.input.js
│ │ ├── no-transform.output.js
│ │ ├── template-string-register.input.js
│ │ └── template-string-register.output.js
├── __tests__
│ └── v7
│ │ ├── move-errors-to-formState.test.ts
│ │ └── update-register.test.ts
└── v7
│ ├── move-errors-to-formState.ts
│ └── update-register.ts
├── tsconfig.json
├── utils
├── defineTest.ts
├── getUseFormDeclarators.ts
└── keys.ts
└── yarn.lock
/.eslintrc.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | env: {
3 | browser: true,
4 | es2021: true
5 | },
6 | extends: ['standard'],
7 | parser: '@typescript-eslint/parser',
8 | parserOptions: {
9 | ecmaVersion: 12,
10 | sourceType: 'module'
11 | },
12 | ignorePatterns: ['**/__testfixtures__/**/*.js'],
13 | plugins: ['@typescript-eslint'],
14 | rules: {
15 | semi: ['error', 'always'],
16 | 'comma-dangle': ['error', 'never'],
17 | 'space-before-function-paren': ['error', 'never']
18 | },
19 | overrides: [
20 | {
21 | files: 'transforms/__testfixtures__/**',
22 | rules: {
23 | 'no-undef': 'off'
24 | }
25 | }
26 | ]
27 | };
28 |
--------------------------------------------------------------------------------
/.github/ISSUE_TEMPLATE/bug_report.md:
--------------------------------------------------------------------------------
1 | ---
2 | name: Bug report
3 | about: Create a report to help us improve
4 | title: ''
5 | labels: ''
6 | assignees: ''
7 | ---
8 |
9 | **Describe the bug**
10 | A clear and concise description of what the bug is.
11 |
12 | **To Reproduce**
13 | Steps to reproduce the behavior
14 |
15 | **Expected behavior**
16 | A clear and concise description of what you expected to happen.
17 |
18 | **Screenshots**
19 | If applicable, add screenshots to help explain your problem.
20 |
21 | **Desktop (please complete the following information):**
22 |
23 | - OS: [e.g. MacOs, Linux]
24 | - Node.js [e.g. 12, 14]
25 |
26 | **Additional context**
27 | Add any other context about the problem here.
28 |
--------------------------------------------------------------------------------
/.github/ISSUE_TEMPLATE/config.yml:
--------------------------------------------------------------------------------
1 | blank_issues_enabled: false
2 | contact_links:
3 | - name: Ask a question
4 | url: https://github.com/react-hook-form/react-hook-form/discussions
5 | about: Ask questions and discuss with other community members
6 |
--------------------------------------------------------------------------------
/.github/ISSUE_TEMPLATE/feature_request.md:
--------------------------------------------------------------------------------
1 | ---
2 | name: Feature request
3 | about: Suggest an idea for this project
4 | title: ''
5 | labels: ''
6 | assignees: ''
7 | ---
8 |
9 | **Is your feature request related to a problem? Please describe.**
10 | A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
11 |
12 | **Describe the solution you'd like**
13 | A clear and concise description of what you want to happen.
14 |
15 | **Describe alternatives you've considered**
16 | A clear and concise description of any alternative solutions or features you've considered.
17 |
18 | **Additional context**
19 | Add any other context or screenshots about the feature request here.
20 |
--------------------------------------------------------------------------------
/.github/ISSUE_TEMPLATE/pull_request_template.md:
--------------------------------------------------------------------------------
1 | Fixes #
2 |
3 | ## Proposed Changes
4 |
5 | -
6 | -
7 | -
8 |
--------------------------------------------------------------------------------
/.github/workflows/main.yml:
--------------------------------------------------------------------------------
1 | name: CI
2 | on:
3 | push:
4 | branches:
5 | - master
6 | - beta
7 | pull_request:
8 | paths-ignore:
9 | - '.gitignore'
10 | - '.npmignore'
11 | - '*.md'
12 |
13 | jobs:
14 | build:
15 | name: Lint, and test on Node ${{ matrix.node }} and ${{ matrix.os }}
16 | runs-on: ubuntu-latest
17 |
18 | steps:
19 | - name: Checkout repo
20 | uses: actions/checkout@v2
21 |
22 | - name: Use Node ${{ matrix.node }}
23 | uses: actions/setup-node@v1
24 | with:
25 | node-version: ${{ matrix.node }}
26 |
27 | - name: Install deps and build (with cache)
28 | uses: bahmutov/npm-install@v1
29 |
30 | - name: Lint
31 | run: |
32 | yarn lint
33 | yarn lint:types
34 | - name: Test
35 | run: yarn test --ci
36 |
37 | publish-module:
38 | name: 'Publish Module to NPM on Node ${{ matrix.node }} and ${{ matrix.os }}'
39 | needs: build
40 | if: github.repository == 'react-hook-form/codemod' && (github.ref =='refs/heads/master')
41 | runs-on: ubuntu-latest
42 | steps:
43 | - name: Checkout repo
44 | uses: actions/checkout@v2
45 | - name: 'Use Node ${{ matrix.node }}'
46 | uses: actions/setup-node@v1
47 | with:
48 | node-version: '${{ matrix.node }}'
49 | registry-url: 'https://registry.npmjs.org/'
50 | - name: Install dependencies
51 | uses: bahmutov/npm-install@v1
52 | - name: Build
53 | run: yarn build
54 | - name: Publish
55 | run: npx semantic-release
56 | env:
57 | NODE_AUTH_TOKEN: '${{secrets.NPM_TOKEN}}'
58 | GITHUB_TOKEN: '${{secrets.GITHUB_TOKEN}}'
59 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # Logs
2 | logs
3 | *.log
4 | npm-debug.log*
5 | yarn-debug.log*
6 | yarn-error.log*
7 |
8 | # Coverage directory used by tools like istanbul
9 | coverage
10 |
11 | # Dependency directories
12 | node_modules/
13 |
14 | # Optional npm cache directory
15 | .npm
16 |
17 | # Optional eslint cache
18 | .eslintcache
19 |
20 | # Output of 'npm pack'
21 | *.tgz
22 |
23 | # Yarn Integrity file
24 | .yarn-integrity
25 |
26 | .DS_Store
27 | dist
28 | .idea/
29 | package-lock.json
--------------------------------------------------------------------------------
/.husky/.gitignore:
--------------------------------------------------------------------------------
1 | _
--------------------------------------------------------------------------------
/.husky/pre-commit:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | . "$(dirname "$0")/_/husky.sh"
3 |
4 | yarn lint:types && yarn lint-staged
--------------------------------------------------------------------------------
/.prettierignore:
--------------------------------------------------------------------------------
1 | transforms/__testfixtures__
--------------------------------------------------------------------------------
/.prettierrc.json:
--------------------------------------------------------------------------------
1 | {
2 | "singleQuote": true,
3 | "trailingComma": "none"
4 | }
5 |
--------------------------------------------------------------------------------
/CODE_OF_CONDUCT.md:
--------------------------------------------------------------------------------
1 | # Contributor Covenant Code of Conduct
2 |
3 | ## Our Pledge
4 |
5 | In the interest of fostering an open and welcoming environment, we as
6 | contributors and maintainers pledge to making participation in our project and
7 | our community a harassment-free experience for everyone, regardless of age, body
8 | size, disability, ethnicity, sex characteristics, gender identity and expression,
9 | level of experience, education, socio-economic status, nationality, personal
10 | appearance, race, religion, or sexual identity and orientation.
11 |
12 | ## Our Standards
13 |
14 | Examples of behavior that contributes to creating a positive environment
15 | include:
16 |
17 | - Using welcoming and inclusive language
18 | - Being respectful of differing viewpoints and experiences
19 | - Gracefully accepting constructive criticism
20 | - Focusing on what is best for the community
21 | - Showing empathy towards other community members
22 |
23 | Examples of unacceptable behavior by participants include:
24 |
25 | - The use of sexualized language or imagery and unwelcome sexual attention or
26 | advances
27 | - Trolling, insulting/derogatory comments, and personal or political attacks
28 | - Public or private harassment
29 | - Publishing others' private information, such as a physical or electronic
30 | address, without explicit permission
31 | - Other conduct which could reasonably be considered inappropriate in a
32 | professional setting
33 |
34 | ## Our Responsibilities
35 |
36 | Project maintainers are responsible for clarifying the standards of acceptable
37 | behavior and are expected to take appropriate and fair corrective action in
38 | response to any instances of unacceptable behavior.
39 |
40 | Project maintainers have the right and responsibility to remove, edit, or
41 | reject comments, commits, code, wiki edits, issues, and other contributions
42 | that are not aligned to this Code of Conduct, or to ban temporarily or
43 | permanently any contributor for other behaviors that they deem inappropriate,
44 | threatening, offensive, or harmful.
45 |
46 | ## Scope
47 |
48 | This Code of Conduct applies both within project spaces and in public spaces
49 | when an individual is representing the project or its community. Examples of
50 | representing a project or community include using an official project e-mail
51 | address, posting via an official social media account, or acting as an appointed
52 | representative at an online or offline event. Representation of a project may be
53 | further defined and clarified by project maintainers.
54 |
55 | ## Enforcement
56 |
57 | Instances of abusive, harassing, or otherwise unacceptable behavior may be
58 | reported by contacting the project team at bluebill1049@hotmail.com. All
59 | complaints will be reviewed and investigated and will result in a response that
60 | is deemed necessary and appropriate to the circumstances. The project team is
61 | obligated to maintain confidentiality with regard to the reporter of an incident.
62 | Further details of specific enforcement policies may be posted separately.
63 |
64 | Project maintainers who do not follow or enforce the Code of Conduct in good
65 | faith may face temporary or permanent repercussions as determined by other
66 | members of the project's leadership.
67 |
68 | ## Attribution
69 |
70 | This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
71 | available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.html
72 |
73 | [homepage]: https://www.contributor-covenant.org
74 |
75 | For answers to common questions about this code of conduct, see
76 | https://www.contributor-covenant.org/faq
77 |
--------------------------------------------------------------------------------
/CONTRIBUTING.md:
--------------------------------------------------------------------------------
1 | # Contributing to `React Hook Form`
2 |
3 | As the creators and maintainers of this project, we want to ensure that `codemod` lives and continues to grow and evolve. We would like to encourage everyone to help and support this library by contributing.
4 |
5 | ## Code contributions
6 |
7 | Here is a quick guide to doing code contributions to the library.
8 |
9 | 1. Fork and clone the repo to your local machine `git clone https://github.com/YOUR_GITHUB_USERNAME/codemod.git`
10 |
11 | 2. Create a new branch from `master` with a meaningful name for a new feature or an issue you want to work on: `git checkout -b your-meaningful-branch-name`
12 |
13 | 3. Install packages by running:
14 |
15 | > yarn
16 |
17 | 4. If you've added a code that should be tested, ensure the test suite still passes.
18 |
19 | > yarn test
20 |
21 | 5. Try to write some unit tests to cover as much of your code as possible.
22 |
23 | 6. Ensure your code lints without errors.
24 |
25 | > yarn lint
26 |
27 | 7. Ensure build passes.
28 |
29 | > yarn build
30 |
31 | 8. Push your branch: `git push -u origin your-meaningful-branch-name`
32 |
33 | 9. Submit a pull request to the upstream codemod repository.
34 |
35 | 10. Choose a descriptive title and describe your changes briefly.
36 |
37 | ## Coding style
38 |
39 | Please follow the coding style of the project. React Hook Form uses eslint and prettier. If possible, enable their respective plugins in your editor to get real-time feedback. The linting can be run manually with the following command: `yarn lint`
40 |
41 | ## License
42 |
43 | By contributing your code to the codemod GitHub repository, you agree to license your contribution under the MIT license.
44 |
45 | ### Contributors
46 |
47 | Thank you to all the people who have already contributed to React Hook Form!
48 |
49 |
50 |
--------------------------------------------------------------------------------
/LICENCE.md:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2019-present Beier(Bill) Luo
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 |