Skip to content

Commit 28948ec

Browse files
improve build setting (#11)
* improve build setting * update settings * improve workflow * update workflow * update README.md * upgrade packages * fix peerDeps * improve types * fix superstruct * run lint * fix prepublishOnly script * 0.0.4 * fix types * update README.md * separate prettier setting * chage umd name from HookFormResolvers to ReactHookFormResolvers
1 parent f940be4 commit 28948ec

File tree

17 files changed

+1724
-1207
lines changed

17 files changed

+1724
-1207
lines changed

.eslintignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
/node_modules
2+
/dist
3+
/esm
4+
/coverage
5+
!.*.js

.eslintrc.js

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,14 @@
11
module.exports = {
22
parser: '@typescript-eslint/parser',
3-
extends: ['plugin:@typescript-eslint/recommended'],
3+
plugins: ['@typescript-eslint'],
4+
extends: [
5+
'plugin:@typescript-eslint/recommended',
6+
'prettier/@typescript-eslint',
7+
'plugin:prettier/recommended',
8+
],
9+
parser: '@typescript-eslint/parser',
410
parserOptions: {
5-
ecmaVersion: 2018,
11+
ecmaVersion: 2020,
612
sourceType: 'module',
713
},
814
rules: {

.github/workflows/blank.yml

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

.github/workflows/main.yml

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
name: CI
2+
on:
3+
push:
4+
branches:
5+
- master
6+
pull_request:
7+
branches:
8+
- master
9+
paths-ignore:
10+
- ".gitignore"
11+
- ".npmignore"
12+
- "*.md"
13+
jobs:
14+
build:
15+
runs-on: ubuntu-latest
16+
strategy:
17+
matrix:
18+
node-version: [12.x]
19+
steps:
20+
- uses: actions/checkout@v2
21+
- name: Use Node.js ${{ matrix.node-version }}
22+
uses: actions/setup-node@v1
23+
with:
24+
node-version: ${{ matrix.node-version }}
25+
- name: Install dependencies
26+
run: yarn install --frozen-lockfile
27+
- name: Lint
28+
run: |
29+
npm run lint:types
30+
npm run lint
31+
- name: Test
32+
run: npm test
33+
env:
34+
CI: true
35+
- name: Build
36+
run: npm run build

.npmignore

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

.prettierrc

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

.prettierrc.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
module.exports = {
2+
singleQuote: true,
3+
trailingComma: 'all',
4+
};

README.md

Lines changed: 24 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,6 @@
1414
[![npm](https://img.shields.io/npm/dt/@hookform/resolvers.svg?style=for-the-badge)](https://www.npmjs.com/package/@hookform/resolvers)
1515
[![npm](https://img.shields.io/bundlephobia/minzip/@hookform/resolvers?style=for-the-badge)](https://bundlephobia.com/result?p=@hookform/resolvers)
1616

17-
[![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/@hookform/resolvers) [![Join the community on Spectrum](https://withspectrum.github.io/badge/badge.svg)](https://spectrum.chat/react-hook-form)
18-
1917
</div>
2018

2119
## Goal
@@ -25,26 +23,24 @@ We are moving away from native support for Yup validation and begin to support o
2523
## Install
2624

2725
$ npm install @hookform/resolvers
28-
29-
## API
3026

31-
`resolver(schema: object, config?: object)`
27+
## API
3228

33-
| | type | Required | Description|
34-
|--|--|--|--|
35-
| schema | `object` || validation schema |
36-
| config | `object` | | validation schema configuration object |
29+
`resolver(schema: object, config?: object)`
3730

31+
| | type | Required | Description |
32+
| ------ | -------- | -------- | -------------------------------------- |
33+
| schema | `object` || validation schema |
34+
| config | `object` | | validation schema configuration object |
3835

3936
## Quickstart
4037

41-
### [Yup](https://github.com/jquense/yup)
38+
### [Yup](https://github.com/jquense/yup)
4239

4340
Dead simple Object schema validation.
4441

4542
[![npm](https://img.shields.io/bundlephobia/minzip/yup?style=for-the-badge)](https://bundlephobia.com/result?p=yup)
4643

47-
4844
```typescript jsx
4945
import React from 'react';
5046
import { useForm } from 'react-hook-form';
@@ -65,7 +61,7 @@ const App = () => {
6561
<form onSubmit={handleSubmit(d => console.log(d))}>
6662
<input name="name" ref={register} />
6763
<input name="age" type="number" ref={register} />
68-
64+
6965
<input type="submit" />
7066
</form>
7167
);
@@ -77,16 +73,16 @@ const App = () => {
7773
A simple and composable way to validate data in JavaScript (or TypeScript).
7874

7975
[![npm](https://img.shields.io/bundlephobia/minzip/superstruct?style=for-the-badge)](https://bundlephobia.com/result?p=superstruct)
80-
76+
8177
```typescript jsx
82-
import React from 'react';
83-
import { useForm } from 'react-hook-form';
84-
import { superstructResolver } from '@hookform/resolvers';
85-
import { struct } from 'superstruct';
78+
import React from "react";
79+
import { useForm } from "react-hook-form";
80+
import { superstructResolver } from "@hookform/resolvers";
81+
import { struct } from "superstruct";
8682

8783
const schema = struct({
88-
name: 'string',
89-
age: 'number',
84+
name: "string",
85+
age: "number",
9086
});
9187

9288
const App = () => {
@@ -95,10 +91,10 @@ const App = () => {
9591
});
9692

9793
return (
98-
<form onSubmit={handleSubmit(d => console.log(d))}>
94+
<form onSubmit={handleSubmit((d) => console.log(d))}>
9995
<input name="name" ref={register} />
10096
<input name="age" type="number" ref={register} />
101-
97+
10298
<input type="submit" />
10399
</form>
104100
);
@@ -110,15 +106,15 @@ const App = () => {
110106
The most powerful data validation library for JS.
111107

112108
[![npm](https://img.shields.io/bundlephobia/minzip/@hapi/joi?style=for-the-badge)](https://bundlephobia.com/result?p=@hapi/joi)
113-
109+
114110
```typescript jsx
115-
import React from 'react';
116-
import { useForm } from 'react-hook-form';
117-
import { joiResolver } from '@hookform/resolvers';
111+
import React from "react";
112+
import { useForm } from "react-hook-form";
113+
import { joiResolver } from "@hookform/resolvers";
118114
import Joi from "@hapi/joi";
119115

120116
const schema = Joi.object({
121-
username: Joi.string().required()
117+
username: Joi.string().required(),
122118
});
123119

124120
const App = () => {
@@ -127,10 +123,10 @@ const App = () => {
127123
});
128124

129125
return (
130-
<form onSubmit={handleSubmit(d => console.log(d))}>
126+
<form onSubmit={handleSubmit((d) => console.log(d))}>
131127
<input name="name" ref={register} />
132128
<input name="age" type="number" ref={register} />
133-
129+
134130
<input type="submit" />
135131
</form>
136132
);

package.json

Lines changed: 77 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,52 +1,97 @@
11
{
22
"name": "@hookform/resolvers",
3-
"version": "0.0.3",
3+
"version": "0.0.4",
44
"description": "React Hook Form validation resolvers: Yup, Joi, Superstruct and etc.",
5-
"main": "dist/resolvers.js",
6-
"module": "dist/resolvers.es.js",
5+
"main": "dist/index.js",
6+
"module": "dist/index.esm.js",
7+
"umd:main": "dist/index.umd.min.js",
8+
"unpkg": "dist/index.umd.min.js",
9+
"jsdelivr": "dist/index.umd.min.js",
10+
"jsnext:main": "index.esm.js",
711
"types": "dist/index.d.ts",
8-
"repository": {
9-
"type": "git",
10-
"url": "git+ssh://[email protected]/react-hook-form/resolvers.git"
11-
},
12+
"sideEffects": false,
13+
"files": [
14+
"dist"
15+
],
1216
"publishConfig": {
1317
"access": "public"
1418
},
15-
"author": "bluebill1049 <[email protected]>",
16-
"license": "MIT",
1719
"scripts": {
18-
"clean": "rm -rf dist",
19-
"build": "rollup -c",
20-
"prepublishOnly": "yarn lint && yarn test && yarn run clean && yarn build",
20+
"clean": "rimraf dist",
21+
"build": "npm run clean && rollup -c",
22+
"lint": "eslint '**/*.{js,ts}'",
23+
"lint:fix": "npm run lint -- --fix",
24+
"lint:types": "tsc --noEmit",
2125
"test": "jest --runInBand",
22-
"lint": "yarn lint:check --fix && yarn prettier",
23-
"prettier": "prettier --write './src/**/*.ts' './src/**/*.tsx' --config ./.prettierrc",
24-
"lint:check": "eslint ./src --ext .jsx,.ts --ignore-pattern *.test.ts --report-unused-disable-directives",
25-
"test:watch": "yarn test -- --watchAll --coverage"
26+
"test:watch": "npm run test -- --watchAll --coverage",
27+
"prepublishOnly": "npm run lint && npm run lint:types && npm test && npm run build"
28+
},
29+
"keywords": [
30+
"scheme",
31+
"validation",
32+
"scheme-validation",
33+
"hookform",
34+
"react-hook-form",
35+
"yup",
36+
"joi",
37+
"sperstruct",
38+
"typescript"
39+
],
40+
"repository": {
41+
"type": "git",
42+
"url": "git+https://github.com/react-hook-form/resolvers.git"
2643
},
44+
"author": "bluebill1049 <[email protected]>",
45+
"license": "MIT",
46+
"bugs": {
47+
"url": "https://github.com/react-hook-form/resolvers/issues"
48+
},
49+
"homepage": "https://github.com/react-hook-form/resolvers#readme",
2750
"devDependencies": {
2851
"@hapi/joi": "^17.1.1",
52+
"@rollup/plugin-commonjs": "^13.0.0",
53+
"@rollup/plugin-json": "^4.1.0",
54+
"@rollup/plugin-node-resolve": "^8.0.1",
2955
"@types/hapi__joi": "^17.1.0",
30-
"@types/jest": "^25.1.2",
31-
"@types/yup": "^0.28.0",
32-
"@typescript-eslint/eslint-plugin": "^2.18.0",
33-
"@typescript-eslint/parser": "^2.18.0",
34-
"eslint": "^6.8.0",
35-
"jest": "^25.1.0",
36-
"prettier": "^1.19.1",
56+
"@types/jest": "^26.0.0",
57+
"@types/yup": "^0.29.3",
58+
"@typescript-eslint/eslint-plugin": "^3.2.0",
59+
"@typescript-eslint/parser": "^3.2.0",
60+
"eslint": "^7.2.0",
61+
"eslint-config-prettier": "^6.11.0",
62+
"eslint-plugin-prettier": "^3.1.4",
63+
"husky": "^4.2.5",
64+
"jest": "^26.0.1",
65+
"lint-staged": "^10.2.10",
66+
"prettier": "^2.0.5",
3767
"react": "^16.13.1",
38-
"rollup": "^1.31.0",
39-
"rollup-plugin-typescript2": "^0.25.3",
68+
"react-hook-form": "^6.0.0-rc.4",
69+
"rimraf": "^3.0.2",
70+
"rollup": "^2.16.1",
71+
"rollup-plugin-peer-deps-external": "^2.2.2",
72+
"rollup-plugin-sourcemaps": "^0.6.2",
73+
"rollup-plugin-terser": "^6.1.0",
74+
"rollup-plugin-typescript2": "^0.27.1",
4075
"superstruct": "^0.8.3",
41-
"ts-jest": "^25.2.0",
76+
"ts-jest": "^26.1.0",
4277
"typescript": "^3.7.5",
43-
"yup": "^0.28.5"
78+
"yup": "^0.29.1"
4479
},
45-
"dependencies": {
46-
"react-hook-form": "6.0.0-beta.2"
80+
"peerDependencies": {
81+
"react-hook-form": ">=6.0.0"
4782
},
48-
"bugs": {
49-
"url": "https://github.com/react-hook-form/resolvers/issues"
83+
"husky": {
84+
"hooks": {
85+
"pre-commit": "npm run lint:types && lint-staged"
86+
}
5087
},
51-
"homepage": "https://github.com/react-hook-form/resolvers#readme"
88+
"lint-staged": {
89+
"*.{js,ts}": [
90+
"npm run lint:fix"
91+
],
92+
"*.{md,json}": [
93+
"prettier --write",
94+
"git add"
95+
]
96+
}
5297
}

0 commit comments

Comments
 (0)