Skip to content

Commit 4248a6c

Browse files
committed
set up template
1 parent 28b0390 commit 4248a6c

16 files changed

+5874
-7
lines changed

.eslintrc.js

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
module.exports = {
2+
parser: '@typescript-eslint/parser',
3+
extends: [
4+
'plugin:@typescript-eslint/recommended',
5+
'plugin:react/recommended',
6+
],
7+
parserOptions: {
8+
ecmaVersion: 2018,
9+
sourceType: 'module',
10+
},
11+
plugins: ['react-hooks'],
12+
rules: {
13+
curly: 'error',
14+
'@typescript-eslint/indent': 'off',
15+
'@typescript-eslint/no-non-null-assertion': 'off',
16+
'@typescript-eslint/no-explicit-any': 'off',
17+
'@typescript-eslint/explicit-function-return-type': 'off',
18+
'@typescript-eslint/no-object-literal-type-assertion': 'off',
19+
'react-hooks/rules-of-hooks': 'error',
20+
'react-hooks/exhaustive-deps': 'error',
21+
},
22+
settings: {
23+
react: {
24+
pragma: 'React',
25+
version: '16.9',
26+
},
27+
},
28+
};

.github/workflows/blank.yml

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
name: CI
2+
3+
on: [push]
4+
5+
jobs:
6+
build:
7+
8+
runs-on: ubuntu-latest
9+
10+
steps:
11+
- uses: actions/checkout@v1
12+
- name: Run build
13+
run: npm install && npm run build
14+
- name: Run test
15+
run: npm run test

.gitignore

+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
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+
app/node_modules/
14+
example/node_modules/
15+
example/build/
16+
17+
# Optional npm cache directory
18+
.npm
19+
20+
# Optional eslint cache
21+
.eslintcache
22+
23+
# Output of 'npm pack'
24+
*.tgz
25+
26+
# Yarn Integrity file
27+
.yarn-integrity
28+
29+
.DS_Store
30+
/lib
31+
/dist
32+
.idea/
33+
.rpt2_cache
34+
.coveralls.yml
35+
package-lock.json
36+
/cypress/videos
37+
/cypress/screenshots

.npmignore

+38
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
example/
2+
.circleci/
3+
.DS_Store
4+
src/
5+
test/
6+
.babelrc
7+
.flowconfig
8+
.npmignore
9+
yarn-error.log
10+
yarn.lock
11+
CONTRIBUTING.md
12+
.eslintrc
13+
jestConfig.json
14+
.idea/
15+
.rpt2_cache/
16+
/lib
17+
.coveralls.yml
18+
jest.config.js
19+
rollup.config.js
20+
setup.ts
21+
tsconfig.json
22+
tsconfig.jest.json
23+
/coverage
24+
/website
25+
.github
26+
/docs
27+
/examples
28+
.eslintrc.js
29+
/app
30+
/cypress
31+
cypress.json
32+
CODE_OF_CONDUCT.md
33+
.vscode
34+
.prettierrc
35+
README.zh-CN.md
36+
rollup.ie11.config.js
37+
rollup.min.config.js
38+
tsconfig.ie11.json

.npmrc

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
package-lock=false

.prettierrc

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"trailingComma": "all",
3+
"singleQuote": true
4+
}

CODE_OF_CONDUCT.md

+76
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
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 [email protected]. 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

README.md

+47-5
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,50 @@
1-
# react-hook-form-error
2-
React Hook Form error message component
1+
<div align="center">
2+
<p align="center">
3+
<a href="https://react-hook-form.com" title="React Hook Form - Simple React forms validation">
4+
<img src="https://raw.githubusercontent.com/bluebill1049/react-hook-form/master/website/logo.png" alt="React Hook Form Logo - React hook custom hook for form validation" width="300px" />
5+
</a>
6+
</p>
7+
</div>
38

4-
```
5-
import { RHFError } from 'react-hook-form-error';
9+
<p align="center">Performant, flexible and extensible forms with easy to use validation.</p>
10+
11+
<div align="center">
12+
13+
[![npm downloads](https://img.shields.io/npm/dm/react-hook-form-error.svg?style=flat-square)](https://www.npmjs.com/package/react-hook-form)
14+
[![npm](https://img.shields.io/npm/dt/react-hook-form-error.svg?style=flat-square)](https://www.npmjs.com/package/react-hook-form)
15+
[![npm](https://badgen.net/bundlephobia/minzip/react-hook-form-error)](https://badgen.net/bundlephobia/minzip/react-hook-form)
16+
[![Tweet](https://img.shields.io/twitter/url/http/shields.io.svg?style=social)](https://twitter.com/intent/tweet?text=React+hooks+for+form+validation+without+the+hassle&url=https://github.com/bluebill1049/react-hook-form)&nbsp;[![Join the community on Spectrum](https://withspectrum.github.io/badge/badge.svg)](https://spectrum.chat/react-hook-form)
17+
18+
</div>
19+
20+
## Install
21+
22+
$ npm install react-hook-form-error
23+
24+
## Demo
25+
26+
Check out this <a href="https://codesandbox.io/s/react-hook-form-hookforminput-rzu9s">demo</a>.
627

7-
<RHFError name="test" errors={errors} as={<span />} />
28+
## Quickstart
29+
30+
```jsx
831
```
32+
33+
## API
34+
|
35+
36+
## Contributors
37+
38+
Thanks goes to these wonderful people. [[Become a contributor](CONTRIBUTING.md)].
39+
40+
<a href="https://github.com/react-hook-form/react-hook-form/graphs/contributors">
41+
<img src="https://opencollective.com/react-hook-form/contributors.svg?width=950" />
42+
</a>
43+
44+
## Backers
45+
46+
Thank goes to all our backers! [[Become a backer](https://opencollective.com/react-hook-form#backer)].
47+
48+
<a href="https://opencollective.com/react-hook-form#backers">
49+
<img src="https://opencollective.com/react-hook-form/backers.svg?width=950" />
50+
</a>

jest.config.js

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
module.exports = {
2+
roots: ['<rootDir>/src'],
3+
transform: {
4+
'^.+\\.tsx?$': 'ts-jest',
5+
},
6+
globals: {
7+
'ts-jest': {
8+
tsConfig: 'tsconfig.jest.json',
9+
},
10+
},
11+
testMatch: ['**/?(*.)+(spec|test).ts?(x)'],
12+
transformIgnorePatterns: ['[/\\\\]node_modules[/\\\\].+\\.(js|jsx)$'],
13+
moduleFileExtensions: ['ts', 'tsx', 'js'],
14+
};

package.json

+48-2
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,54 @@
22
"name": "react-hook-form-error",
33
"version": "0.0.1",
44
"description": "React Hook Form error message component",
5-
"main": "src/index.js",
65
"repository": "[email protected]:react-hook-form/react-hook-form-error.git",
76
"author": "bluebill1049 <[email protected]>",
8-
"license": "MIT"
7+
"license": "MIT",
8+
"main": "dist/index.js",
9+
"module": "dist/index.es.js",
10+
"types": "dist/index.d.ts",
11+
"scripts": {
12+
"test": "jest --runInBand",
13+
"test:watch": "yarn test -- --watchAll",
14+
"clean": "rm -rf dist",
15+
"build": "rollup -c",
16+
"prettier": "prettier --write './src/**/*.ts' './src/**/*.tsx' --config ./.prettierrc",
17+
"lint": "yarn lint:check --fix && yarn prettier",
18+
"lint:check": "eslint ./src --ext .tsx,.ts --ignore-pattern *.test.ts --report-unused-disable-directives",
19+
"postrelease": "yarn publish && git push --follow-tags",
20+
"prepublishOnly": "yarn lint && yarn test && yarn run clean && yarn build"
21+
},
22+
"devDependencies": {
23+
"@testing-library/react": "^9.3.2",
24+
"@testing-library/react-hooks": "^3.2.1",
25+
"@types/jest": "^24.0.23",
26+
"@types/react": "^16.9.0",
27+
"@types/react-dom": "^16.9.4",
28+
"@types/react-test-renderer": "^16.9.0",
29+
"@typescript-eslint/eslint-plugin": "^2.7.0",
30+
"@typescript-eslint/parser": "^2.7.0",
31+
"bundlesize": "^0.18.0",
32+
"coveralls": "^3.0.3",
33+
"eslint": "^6.6.0",
34+
"eslint-plugin-react": "^7.13.0",
35+
"eslint-plugin-react-hooks": "^2.2.0",
36+
"husky": ">=1",
37+
"jest": "^24.7.1",
38+
"lint-staged": ">=8",
39+
"mutationobserver-shim": "^0.3.3",
40+
"prettier": "^1.19.1",
41+
"react": "^16.9.0",
42+
"react-dom": "^16.9.0",
43+
"react-test-renderer": "^16.9.0",
44+
"rollup": "^1.20.3",
45+
"rollup-plugin-terser": "^5.1.1",
46+
"rollup-plugin-typescript2": "^0.25.2",
47+
"ts-jest": "^24.0.2",
48+
"typescript": "^3.7.2",
49+
"react-hook-form": "^3.28.0"
50+
},
51+
"peerDependencies": {
52+
"react": "^16.8.0",
53+
"react-hook-form": "^3.28.0"
54+
}
955
}

rollup.config.js

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
import typescript from 'rollup-plugin-typescript2';
2+
3+
export function getConfig({
4+
tsconfig = './tsconfig.json',
5+
output = [
6+
{
7+
file: `dist/index.js`,
8+
format: 'cjs',
9+
},
10+
{
11+
file: `dist/index.es.js`,
12+
format: 'esm',
13+
},
14+
],
15+
} = {}) {
16+
return {
17+
input: 'src/index.tsx',
18+
external: ['react', 'react-dom'],
19+
plugins: [
20+
typescript({
21+
tsconfig,
22+
clean: true,
23+
}),
24+
],
25+
output,
26+
};
27+
}
28+
29+
export default getConfig();

src/index.test.tsx

Whitespace-only changes.

src/index.tsx

Whitespace-only changes.

tsconfig.jest.json

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"extends": "./tsconfig.json",
3+
"compilerOptions": {
4+
"module": "commonjs",
5+
}
6+
}

tsconfig.json

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
{
2+
"compilerOptions": {
3+
"sourceMap": true,
4+
"module": "es2015",
5+
"target": "es2017",
6+
"moduleResolution": "node",
7+
"outDir": "./dist",
8+
"jsx": "react",
9+
"skipLibCheck": true,
10+
"declaration": true,
11+
"noEmit": true,
12+
"allowSyntheticDefaultImports": true,
13+
"lib": ["dom", "dom.iterable", "esnext"],
14+
"strict": true,
15+
"noUnusedLocals": true,
16+
"noUnusedParameters": true,
17+
"noImplicitReturns": true,
18+
"noFallthroughCasesInSwitch": true
19+
},
20+
"include": ["src"],
21+
"exclude": ["node_modules", "app", "examples", "cypress"]
22+
}

0 commit comments

Comments
 (0)