chore: configurations and update deps
This commit is contained in:
parent
dd70626fa7
commit
0e12431622
@ -29,6 +29,7 @@
|
|||||||
"react/jsx-handler-names": 0,
|
"react/jsx-handler-names": 0,
|
||||||
"react/jsx-fragments": 0,
|
"react/jsx-fragments": 0,
|
||||||
"react/no-unused-prop-types": 0,
|
"react/no-unused-prop-types": 0,
|
||||||
"import/export": 0
|
"import/export": 0,
|
||||||
|
"no-use-before-define": [0]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
76
.github/CODE_OF_CONDUCT.md
vendored
Normal file
76
.github/CODE_OF_CONDUCT.md
vendored
Normal file
@ -0,0 +1,76 @@
|
|||||||
|
# Contributor Covenant Code of Conduct
|
||||||
|
|
||||||
|
## Our Pledge
|
||||||
|
|
||||||
|
In the interest of fostering an open and welcoming environment, we as
|
||||||
|
contributors and maintainers pledge to make participation in our project and
|
||||||
|
our community a harassment-free experience for everyone, regardless of age, body
|
||||||
|
size, disability, ethnicity, sex characteristics, gender identity and expression,
|
||||||
|
level of experience, education, socio-economic status, nationality, personal
|
||||||
|
appearance, race, religion, or sexual identity and orientation.
|
||||||
|
|
||||||
|
## Our Standards
|
||||||
|
|
||||||
|
Examples of behavior that contributes to creating a positive environment
|
||||||
|
include:
|
||||||
|
|
||||||
|
- Using welcoming and inclusive language
|
||||||
|
- Being respectful of differing viewpoints and experiences
|
||||||
|
- Gracefully accepting constructive criticism
|
||||||
|
- Focusing on what is best for the community
|
||||||
|
- Showing empathy towards other community members
|
||||||
|
|
||||||
|
Examples of unacceptable behavior by participants include:
|
||||||
|
|
||||||
|
- The use of sexualized language or imagery and unwelcome sexual attention or
|
||||||
|
advances
|
||||||
|
- Trolling, insulting/derogatory comments, and personal or political attacks
|
||||||
|
- Public or private harassment
|
||||||
|
- Publishing others' private information, such as a physical or electronic
|
||||||
|
address, without explicit permission
|
||||||
|
- Other conduct which could reasonably be considered inappropriate in a
|
||||||
|
professional setting
|
||||||
|
|
||||||
|
## Our Responsibilities
|
||||||
|
|
||||||
|
Project maintainers are responsible for clarifying the standards of acceptable
|
||||||
|
behavior and are expected to take appropriate and fair corrective action in
|
||||||
|
response to any instances of unacceptable behavior.
|
||||||
|
|
||||||
|
Project maintainers have the right and responsibility to remove, edit, or
|
||||||
|
reject comments, commits, code, wiki edits, issues, and other contributions
|
||||||
|
that are not aligned to this Code of Conduct, or to ban temporarily or
|
||||||
|
permanently any contributor for other behaviors that they deem inappropriate,
|
||||||
|
threatening, offensive, or harmful.
|
||||||
|
|
||||||
|
## Scope
|
||||||
|
|
||||||
|
This Code of Conduct applies within all project spaces, and it also applies when
|
||||||
|
an individual is representing the project or its community in public spaces.
|
||||||
|
Examples of representing a project or community include using an official
|
||||||
|
project e-mail address, posting via an official social media account, or acting
|
||||||
|
as an appointed representative at an online or offline event. Representation of
|
||||||
|
a project may be further defined and clarified by project maintainers.
|
||||||
|
|
||||||
|
## Enforcement
|
||||||
|
|
||||||
|
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
||||||
|
reported by contacting the project team at <contact@divlo.fr>. All
|
||||||
|
complaints will be reviewed and investigated and will result in a response that
|
||||||
|
is deemed necessary and appropriate to the circumstances. The project team is
|
||||||
|
obligated to maintain confidentiality with regard to the reporter of an incident.
|
||||||
|
Further details of specific enforcement policies may be posted separately.
|
||||||
|
|
||||||
|
Project maintainers who do not follow or enforce the Code of Conduct in good
|
||||||
|
faith may face temporary or permanent repercussions as determined by other
|
||||||
|
members of the project's leadership.
|
||||||
|
|
||||||
|
## Attribution
|
||||||
|
|
||||||
|
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
|
||||||
|
available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.html
|
||||||
|
|
||||||
|
[homepage]: https://www.contributor-covenant.org
|
||||||
|
|
||||||
|
For answers to common questions about this code of conduct, see
|
||||||
|
https://www.contributor-covenant.org/faq
|
59
.github/CONTRIBUTING.md
vendored
Normal file
59
.github/CONTRIBUTING.md
vendored
Normal file
@ -0,0 +1,59 @@
|
|||||||
|
# Contributing
|
||||||
|
|
||||||
|
Thanks a lot for your interest in contributing to **react-component-form**! 🎉
|
||||||
|
|
||||||
|
## Types of contributions :
|
||||||
|
|
||||||
|
- Reporting a bug.
|
||||||
|
- Suggest a new feature idea.
|
||||||
|
- Correct spelling errors, improvements or additions to documentation files (README, CONTRIBUTING...).
|
||||||
|
- Improve structure/format/performance/refactor/tests of the code.
|
||||||
|
|
||||||
|
## Pull Requests :
|
||||||
|
|
||||||
|
- **Please first discuss** the change you wish to make via [issue](https://github.com/Divlo/react-component-form/issues) before making a change. It might avoid a waste of your time.
|
||||||
|
|
||||||
|
- Ensure your code respect [JavaScript Standard Style](https://standardjs.com/).
|
||||||
|
|
||||||
|
- Make sure your code passes the tests.
|
||||||
|
|
||||||
|
If you're adding new features to **react-component-form**, please include tests.
|
||||||
|
|
||||||
|
## Commits
|
||||||
|
|
||||||
|
The commit message guidelines respect [@commitlint/config-conventional](https://github.com/conventional-changelog/commitlint/tree/master/%40commitlint/config-conventional) and [Semantic Versioning](https://semver.org/) for releases.
|
||||||
|
|
||||||
|
### Types
|
||||||
|
|
||||||
|
Types define which kind of changes you made to the project.
|
||||||
|
|
||||||
|
| Types | Description |
|
||||||
|
| -------- | ------------------------------------------------------------------------------------------------------------ |
|
||||||
|
| feat | A new feature. |
|
||||||
|
| fix | A bug fix. |
|
||||||
|
| docs | Documentation only changes. |
|
||||||
|
| style | Changes that do not affect the meaning of the code (white-space, formatting, missing semi-colons, etc). |
|
||||||
|
| refactor | A code change that neither fixes a bug nor adds a feature. |
|
||||||
|
| perf | A code change that improves performance. |
|
||||||
|
| test | Adding missing tests or correcting existing tests. |
|
||||||
|
| build | Changes that affect the build system or external dependencies (example scopes: gulp, broccoli, npm). |
|
||||||
|
| ci | Changes to our CI configuration files and scripts (example scopes: Travis, Circle, BrowserStack, SauceLabs). |
|
||||||
|
| chore | Other changes that don't modify src or test files. |
|
||||||
|
| revert | Reverts a previous commit. |
|
||||||
|
|
||||||
|
### Scopes
|
||||||
|
|
||||||
|
Scopes define what part of the code changed.
|
||||||
|
|
||||||
|
There are 2 principal scopes in the project :
|
||||||
|
|
||||||
|
- lib
|
||||||
|
- example
|
||||||
|
|
||||||
|
### Examples
|
||||||
|
|
||||||
|
```sh
|
||||||
|
git commit -m "feat(lib): add Form component"
|
||||||
|
git commit -m "docs(readme): update installation process"
|
||||||
|
git commit -m "fix(example): remove bugs"
|
||||||
|
```
|
19
.github/ISSUE_TEMPLATE/BUG.md
vendored
Normal file
19
.github/ISSUE_TEMPLATE/BUG.md
vendored
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
---
|
||||||
|
name: '🐛 Bug Report'
|
||||||
|
about: 'Report an unexpected problem or unintended behavior.'
|
||||||
|
labels: 'bug'
|
||||||
|
---
|
||||||
|
|
||||||
|
<!--
|
||||||
|
Please provide a clear and concise description of what the bug is. Include
|
||||||
|
screenshots if needed. Please make sure your issue has not already been fixed.
|
||||||
|
-->
|
||||||
|
|
||||||
|
## Steps To Reproduce
|
||||||
|
|
||||||
|
1. Step 1
|
||||||
|
2. Step 2
|
||||||
|
|
||||||
|
## The current behavior
|
||||||
|
|
||||||
|
## The expected behavior
|
20
.github/ISSUE_TEMPLATE/DOCUMENTATION.md
vendored
Normal file
20
.github/ISSUE_TEMPLATE/DOCUMENTATION.md
vendored
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
---
|
||||||
|
name: '📜 Documentation'
|
||||||
|
about: 'Correct spelling errors, improvements or additions to documentation files (README, CONTRIBUTING...).'
|
||||||
|
labels: 'documentation'
|
||||||
|
---
|
||||||
|
|
||||||
|
<!--
|
||||||
|
Please make sure your issue has not already been fixed.
|
||||||
|
|
||||||
|
Please place an x (no spaces - [x]) in all [ ] that apply.
|
||||||
|
-->
|
||||||
|
|
||||||
|
### Documentation :
|
||||||
|
|
||||||
|
- [ ] Is Missing
|
||||||
|
- [ ] Is Confusing
|
||||||
|
- [ ] Has Typo errors
|
||||||
|
- [ ] Not Sure?
|
||||||
|
|
||||||
|
### Proposal
|
19
.github/ISSUE_TEMPLATE/FEATURE_REQUEST.md
vendored
Normal file
19
.github/ISSUE_TEMPLATE/FEATURE_REQUEST.md
vendored
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
---
|
||||||
|
name: '✨ Feature Request'
|
||||||
|
about: 'Suggest a new feature idea.'
|
||||||
|
labels: 'feature request'
|
||||||
|
---
|
||||||
|
|
||||||
|
<!-- Please make sure your issue has not already been fixed. -->
|
||||||
|
|
||||||
|
### Description
|
||||||
|
|
||||||
|
<!-- A clear and concise description of the problem or missing capability... -->
|
||||||
|
|
||||||
|
### Describe the solution you'd like
|
||||||
|
|
||||||
|
<!-- If you have a solution in mind, please describe it. -->
|
||||||
|
|
||||||
|
### Describe alternatives you've considered
|
||||||
|
|
||||||
|
<!-- Have you considered any alternative solutions or workarounds? -->
|
21
.github/ISSUE_TEMPLATE/IMPROVEMENT.md
vendored
Normal file
21
.github/ISSUE_TEMPLATE/IMPROVEMENT.md
vendored
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
---
|
||||||
|
name: '🔧 Improvement'
|
||||||
|
about: 'Improve structure/format/performance/refactor/tests of the code.'
|
||||||
|
labels: 'improvement'
|
||||||
|
---
|
||||||
|
|
||||||
|
<!--.
|
||||||
|
Please make sure your issue has not already been fixed.
|
||||||
|
|
||||||
|
Please place an x (no spaces - [x]) in all [ ] that apply.
|
||||||
|
-->
|
||||||
|
|
||||||
|
### Type of Improvement :
|
||||||
|
|
||||||
|
- [ ] Files and Folders Structure
|
||||||
|
- [ ] Performance
|
||||||
|
- [ ] Refactoring code
|
||||||
|
- [ ] Tests
|
||||||
|
- [ ] Not Sure?
|
||||||
|
|
||||||
|
### Proposal
|
7
.github/ISSUE_TEMPLATE/QUESTION.md
vendored
Normal file
7
.github/ISSUE_TEMPLATE/QUESTION.md
vendored
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
---
|
||||||
|
name: '🙋 Question'
|
||||||
|
about: 'Further information is requested.'
|
||||||
|
labels: 'question'
|
||||||
|
---
|
||||||
|
|
||||||
|
### Question
|
29
.github/PULL_REQUEST_TEMPLATE.md
vendored
Normal file
29
.github/PULL_REQUEST_TEMPLATE.md
vendored
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
<!--
|
||||||
|
|
||||||
|
Thanks a lot for your interest in contributing to react-component-form! 🎉
|
||||||
|
|
||||||
|
Please first discuss the change you wish to make via issue before making a change. It might avoid a waste of your time.
|
||||||
|
|
||||||
|
Before submitting your contribution, please take a moment to review this document:
|
||||||
|
https://github.com/Divlo/react-component-form/blob/master/.github/CONTRIBUTING.md
|
||||||
|
|
||||||
|
Please place an x (no spaces - [x]) in all [ ] that apply.
|
||||||
|
|
||||||
|
-->
|
||||||
|
|
||||||
|
### What type of change does this PR introduce?
|
||||||
|
|
||||||
|
- [ ] Bugfix
|
||||||
|
- [ ] Feature
|
||||||
|
- [ ] Refactor
|
||||||
|
- [ ] Documentation
|
||||||
|
- [ ] Not Sure?
|
||||||
|
|
||||||
|
### Does this PR introduce breaking changes?
|
||||||
|
|
||||||
|
- [ ] Yes
|
||||||
|
- [ ] No
|
||||||
|
|
||||||
|
### List any relevant issue numbers:
|
||||||
|
|
||||||
|
### Description:
|
15
.github/dependabot.yml
vendored
Normal file
15
.github/dependabot.yml
vendored
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
# For more information see: https://docs.github.com/en/github/administering-a-repository/configuration-options-for-dependency-updates
|
||||||
|
|
||||||
|
version: 2
|
||||||
|
updates:
|
||||||
|
- package-ecosystem: 'github-actions'
|
||||||
|
directory: '/'
|
||||||
|
schedule:
|
||||||
|
interval: 'monthly'
|
||||||
|
|
||||||
|
- package-ecosystem: 'npm'
|
||||||
|
versioning-strategy: 'auto'
|
||||||
|
directory: '/'
|
||||||
|
open-pull-requests-limit: 10
|
||||||
|
schedule:
|
||||||
|
interval: 'monthly'
|
16
.github/workflows/commitlint.yml
vendored
Normal file
16
.github/workflows/commitlint.yml
vendored
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
name: 'Lint Commit Messages'
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches: [master]
|
||||||
|
pull_request:
|
||||||
|
branches: [master]
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
commitlint:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v2
|
||||||
|
with:
|
||||||
|
fetch-depth: 0
|
||||||
|
- uses: wagoid/commitlint-github-action@v2
|
1
.github/workflows/node.js.yml
vendored
1
.github/workflows/node.js.yml
vendored
@ -23,3 +23,4 @@ jobs:
|
|||||||
- run: npm ci
|
- run: npm ci
|
||||||
- run: npm run test:build
|
- run: npm run test:build
|
||||||
- run: npm run test:lint
|
- run: npm run test:lint
|
||||||
|
- run: npm run test:unit
|
||||||
|
2
LICENSE
2
LICENSE
@ -1,5 +1,5 @@
|
|||||||
The MIT License (MIT)
|
The MIT License (MIT)
|
||||||
Copyright © 2020 Divlo
|
Copyright © 2020
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
@ -5,8 +5,8 @@
|
|||||||
</p>
|
</p>
|
||||||
|
|
||||||
<p align="center">
|
<p align="center">
|
||||||
<a href="https://gitmoji.carloscuesta.me/"><img src="https://camo.githubusercontent.com/2a4924a23bd9ef18afe793f4999b1b9ec474e48f/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6769746d6f6a692d253230f09f989c253230f09f988d2d4646444436372e7376673f7374796c653d666c61742d737175617265" alt="Gitmoji"/></a>
|
|
||||||
<a href="https://standardjs.com"><img src="https://img.shields.io/badge/code_style-standard-brightgreen.svg" alt="JavaScript Style Guide"/></a>
|
<a href="https://standardjs.com"><img src="https://img.shields.io/badge/code_style-standard-brightgreen.svg" alt="JavaScript Style Guide"/></a>
|
||||||
|
<a href="https://conventionalcommits.org"><img src="https://img.shields.io/badge/Conventional%20Commits-1.0.0-yellow.svg" alt="Conventional Commits" /></a>
|
||||||
<a href="./LICENSE"><img src="https://img.shields.io/badge/licence-MIT-blue.svg" alt="Licence MIT"/></a>
|
<a href="./LICENSE"><img src="https://img.shields.io/badge/licence-MIT-blue.svg" alt="Licence MIT"/></a>
|
||||||
<a href="https://www.npmjs.com/package/react-component-form"><img src="https://img.shields.io/npm/v/react-component-form.svg" alt="npm version"></a>
|
<a href="https://www.npmjs.com/package/react-component-form"><img src="https://img.shields.io/npm/v/react-component-form.svg" alt="npm version"></a>
|
||||||
<img src="https://github.com/Divlo/react-component-form/workflows/Node.js%20CI/badge.svg" alt="Node.js CI" />
|
<img src="https://github.com/Divlo/react-component-form/workflows/Node.js%20CI/badge.svg" alt="Node.js CI" />
|
||||||
@ -18,9 +18,11 @@
|
|||||||
|
|
||||||
Demo : [https://divlo.github.io/react-component-form/](https://divlo.github.io/react-component-form/).
|
Demo : [https://divlo.github.io/react-component-form/](https://divlo.github.io/react-component-form/).
|
||||||
|
|
||||||
|
This project was bootstrapped with [create-react-library](https://www.npmjs.com/package/create-react-library).
|
||||||
|
|
||||||
## 💾 Install
|
## 💾 Install
|
||||||
|
|
||||||
```bash
|
```sh
|
||||||
npm install --save react-component-form
|
npm install --save react-component-form
|
||||||
```
|
```
|
||||||
|
|
||||||
|
1
commitlint.config.js
Normal file
1
commitlint.config.js
Normal file
@ -0,0 +1 @@
|
|||||||
|
module.exports = { extends: ['@commitlint/config-conventional'] }
|
9751
example/package-lock.json
generated
9751
example/package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@ -3,6 +3,21 @@
|
|||||||
"homepage": ".",
|
"homepage": ".",
|
||||||
"version": "0.0.0",
|
"version": "0.0.0",
|
||||||
"private": true,
|
"private": true,
|
||||||
|
"eslintConfig": {
|
||||||
|
"extends": "react-app"
|
||||||
|
},
|
||||||
|
"browserslist": {
|
||||||
|
"production": [
|
||||||
|
">0.2%",
|
||||||
|
"not dead",
|
||||||
|
"not op_mini all"
|
||||||
|
],
|
||||||
|
"development": [
|
||||||
|
"last 1 chrome version",
|
||||||
|
"last 1 firefox version",
|
||||||
|
"last 1 safari version"
|
||||||
|
]
|
||||||
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"start": "node ../node_modules/react-scripts/bin/react-scripts.js start",
|
"start": "node ../node_modules/react-scripts/bin/react-scripts.js start",
|
||||||
"build": "node ../node_modules/react-scripts/bin/react-scripts.js build",
|
"build": "node ../node_modules/react-scripts/bin/react-scripts.js build",
|
||||||
@ -25,20 +40,5 @@
|
|||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@babel/plugin-syntax-object-rest-spread": "^7.8.3"
|
"@babel/plugin-syntax-object-rest-spread": "^7.8.3"
|
||||||
},
|
|
||||||
"eslintConfig": {
|
|
||||||
"extends": "react-app"
|
|
||||||
},
|
|
||||||
"browserslist": {
|
|
||||||
"production": [
|
|
||||||
">0.2%",
|
|
||||||
"not dead",
|
|
||||||
"not op_mini all"
|
|
||||||
],
|
|
||||||
"development": [
|
|
||||||
"last 1 chrome version",
|
|
||||||
"last 1 firefox version",
|
|
||||||
"last 1 safari version"
|
|
||||||
]
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
7338
package-lock.json
generated
7338
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
54
package.json
54
package.json
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "react-component-form",
|
"name": "react-component-form",
|
||||||
"version": "1.0.1",
|
"version": "1.1.0",
|
||||||
"description": "Manage React Forms with ease.",
|
"description": "Manage React Forms with ease.",
|
||||||
"author": "Divlo <contact@divlo.fr>",
|
"author": "Divlo <contact@divlo.fr>",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
@ -25,6 +25,11 @@
|
|||||||
"url": "https://github.com/Divlo/react-component-form/issues"
|
"url": "https://github.com/Divlo/react-component-form/issues"
|
||||||
},
|
},
|
||||||
"homepage": "https://github.com/Divlo/react-component-form#readme",
|
"homepage": "https://github.com/Divlo/react-component-form#readme",
|
||||||
|
"husky": {
|
||||||
|
"hooks": {
|
||||||
|
"commit-msg": "commitlint -E HUSKY_GIT_PARAMS"
|
||||||
|
}
|
||||||
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"build": "microbundle-crl --no-compress --format modern,cjs",
|
"build": "microbundle-crl --no-compress --format modern,cjs",
|
||||||
"start": "microbundle-crl watch --no-compress --format modern,cjs",
|
"start": "microbundle-crl watch --no-compress --format modern,cjs",
|
||||||
@ -41,34 +46,37 @@
|
|||||||
"react": "^16.0.0"
|
"react": "^16.0.0"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@testing-library/jest-dom": "^4.2.4",
|
"@commitlint/cli": "^11.0.0",
|
||||||
"@testing-library/react": "^9.5.0",
|
"@commitlint/config-conventional": "^11.0.0",
|
||||||
"@testing-library/user-event": "^7.2.1",
|
"@testing-library/jest-dom": "^5.11.4",
|
||||||
"@types/jest": "^25.1.4",
|
"@testing-library/react": "^11.0.4",
|
||||||
"@types/node": "^12.12.38",
|
"@testing-library/user-event": "^12.1.7",
|
||||||
"@types/react": "^16.9.27",
|
"@types/jest": "^26.0.14",
|
||||||
"@types/react-dom": "^16.9.7",
|
"@types/node": "^14.11.2",
|
||||||
"@typescript-eslint/eslint-plugin": "^2.26.0",
|
"@types/react": "^16.9.50",
|
||||||
"@typescript-eslint/parser": "^2.26.0",
|
"@types/react-dom": "^16.9.8",
|
||||||
"microbundle-crl": "^0.13.10",
|
"@typescript-eslint/eslint-plugin": "^4.0.1",
|
||||||
"babel-eslint": "^10.0.3",
|
"@typescript-eslint/parser": "^4.0.1",
|
||||||
|
"babel-eslint": "^10.1.0",
|
||||||
"cross-env": "^7.0.2",
|
"cross-env": "^7.0.2",
|
||||||
"eslint": "^6.8.0",
|
"eslint": "^6.6.0",
|
||||||
"eslint-config-prettier": "^6.7.0",
|
"eslint-config-prettier": "^6.12.0",
|
||||||
"eslint-config-standard": "^14.1.0",
|
"eslint-config-standard": "^14.1.1",
|
||||||
"eslint-config-standard-react": "^9.2.0",
|
"eslint-config-standard-react": "^9.2.0",
|
||||||
"eslint-plugin-import": "^2.18.2",
|
"eslint-plugin-import": "^2.22.1",
|
||||||
"eslint-plugin-node": "^11.0.0",
|
"eslint-plugin-node": "^11.1.0",
|
||||||
"eslint-plugin-prettier": "^3.1.1",
|
"eslint-plugin-prettier": "^3.1.4",
|
||||||
"eslint-plugin-promise": "^4.2.1",
|
"eslint-plugin-promise": "^4.2.1",
|
||||||
"eslint-plugin-react": "^7.17.0",
|
"eslint-plugin-react": "^7.21.3",
|
||||||
"eslint-plugin-standard": "^4.0.1",
|
"eslint-plugin-standard": "^4.0.1",
|
||||||
"gh-pages": "^2.2.0",
|
"gh-pages": "^3.1.0",
|
||||||
|
"husky": "^4.3.0",
|
||||||
|
"microbundle-crl": "^0.13.11",
|
||||||
"npm-run-all": "^4.1.5",
|
"npm-run-all": "^4.1.5",
|
||||||
"prettier": "^2.0.4",
|
"prettier": "^2.1.2",
|
||||||
"react": "^16.13.1",
|
"react": "^16.13.1",
|
||||||
"react-dom": "^16.13.1",
|
"react-dom": "^16.13.1",
|
||||||
"react-scripts": "^3.4.1",
|
"react-scripts": "^3.4.3",
|
||||||
"typescript": "^3.7.5"
|
"typescript": "^4.0.3"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
40
src/index.test.tsx
Normal file
40
src/index.test.tsx
Normal file
@ -0,0 +1,40 @@
|
|||||||
|
import React from 'react'
|
||||||
|
import Form, { HandleForm } from '.'
|
||||||
|
import { render, cleanup, fireEvent } from '@testing-library/react'
|
||||||
|
|
||||||
|
afterEach(cleanup)
|
||||||
|
|
||||||
|
describe('Form component', () => {
|
||||||
|
it('should get the formData and formElement onSubmit and onChange', () => {
|
||||||
|
let formData: { [k: string]: any } = {}
|
||||||
|
let formElement: any = null
|
||||||
|
const handleSubmitChange: HandleForm = (data, element) => {
|
||||||
|
formData = data
|
||||||
|
formElement = element
|
||||||
|
}
|
||||||
|
const formComponent = render(
|
||||||
|
<Form onSubmit={handleSubmitChange} onChange={handleSubmitChange}>
|
||||||
|
<input data-testid='input-form' type='text' name='inputName' />
|
||||||
|
<button data-testid='button-submit' type='submit'>
|
||||||
|
Submit
|
||||||
|
</button>
|
||||||
|
</Form>
|
||||||
|
)
|
||||||
|
const inputForm = formComponent.getByTestId(
|
||||||
|
'input-form'
|
||||||
|
) as HTMLInputElement
|
||||||
|
const buttonSubmit = formComponent.getByTestId('button-submit')
|
||||||
|
const text = 'some random text'
|
||||||
|
|
||||||
|
fireEvent.change(inputForm, { target: { value: text } })
|
||||||
|
expect(formData.inputName).toEqual(text)
|
||||||
|
expect(formElement instanceof HTMLFormElement).toBeTruthy()
|
||||||
|
formData = {}
|
||||||
|
formElement = null
|
||||||
|
|
||||||
|
fireEvent.click(buttonSubmit)
|
||||||
|
expect(Object.keys(formData).length).toEqual(1)
|
||||||
|
expect(formData.inputName).toEqual(text)
|
||||||
|
expect(formElement instanceof HTMLFormElement).toBeTruthy()
|
||||||
|
})
|
||||||
|
})
|
1
src/react-app-env.d.ts
vendored
Normal file
1
src/react-app-env.d.ts
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
/// <reference types="react-scripts" />
|
@ -3,7 +3,11 @@
|
|||||||
"outDir": "dist",
|
"outDir": "dist",
|
||||||
"module": "esnext",
|
"module": "esnext",
|
||||||
"target": "ES3",
|
"target": "ES3",
|
||||||
"lib": ["dom", "esnext", "DOM.Iterable"],
|
"lib": [
|
||||||
|
"dom",
|
||||||
|
"esnext",
|
||||||
|
"DOM.Iterable"
|
||||||
|
],
|
||||||
"moduleResolution": "node",
|
"moduleResolution": "node",
|
||||||
"jsx": "react",
|
"jsx": "react",
|
||||||
"sourceMap": true,
|
"sourceMap": true,
|
||||||
@ -17,8 +21,21 @@
|
|||||||
"noUnusedLocals": true,
|
"noUnusedLocals": true,
|
||||||
"noUnusedParameters": true,
|
"noUnusedParameters": true,
|
||||||
"allowSyntheticDefaultImports": true,
|
"allowSyntheticDefaultImports": true,
|
||||||
"downlevelIteration": true
|
"downlevelIteration": true,
|
||||||
|
"allowJs": true,
|
||||||
|
"skipLibCheck": true,
|
||||||
|
"strict": true,
|
||||||
|
"forceConsistentCasingInFileNames": true,
|
||||||
|
"resolveJsonModule": true,
|
||||||
|
"isolatedModules": true,
|
||||||
|
"noEmit": true
|
||||||
},
|
},
|
||||||
"include": ["src"],
|
"include": [
|
||||||
"exclude": ["node_modules", "dist", "example"]
|
"src"
|
||||||
|
],
|
||||||
|
"exclude": [
|
||||||
|
"node_modules",
|
||||||
|
"dist",
|
||||||
|
"example"
|
||||||
|
]
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user