Skip to content

Commit

Permalink
improve build setting (#11)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
kotarella1110 authored Jun 16, 2020
1 parent f940be4 commit 28948ec
Show file tree
Hide file tree
Showing 17 changed files with 1,724 additions and 1,207 deletions.
5 changes: 5 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
/node_modules
/dist
/esm
/coverage
!.*.js
10 changes: 8 additions & 2 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
module.exports = {
parser: '@typescript-eslint/parser',
extends: ['plugin:@typescript-eslint/recommended'],
plugins: ['@typescript-eslint'],
extends: [
'plugin:@typescript-eslint/recommended',
'prettier/@typescript-eslint',
'plugin:prettier/recommended',
],
parser: '@typescript-eslint/parser',
parserOptions: {
ecmaVersion: 2018,
ecmaVersion: 2020,
sourceType: 'module',
},
rules: {
Expand Down
28 changes: 0 additions & 28 deletions .github/workflows/blank.yml

This file was deleted.

36 changes: 36 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: CI
on:
push:
branches:
- master
pull_request:
branches:
- master
paths-ignore:
- ".gitignore"
- ".npmignore"
- "*.md"
jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [12.x]
steps:
- uses: actions/checkout@v2
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}
- name: Install dependencies
run: yarn install --frozen-lockfile
- name: Lint
run: |
npm run lint:types
npm run lint
- name: Test
run: npm test
env:
CI: true
- name: Build
run: npm run build
39 changes: 0 additions & 39 deletions .npmignore

This file was deleted.

4 changes: 0 additions & 4 deletions .prettierrc

This file was deleted.

4 changes: 4 additions & 0 deletions .prettierrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
module.exports = {
singleQuote: true,
trailingComma: 'all',
};
52 changes: 24 additions & 28 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@
[![npm](https://img.shields.io/npm/dt/@hookform/resolvers.svg?style=for-the-badge)](https://www.npmjs.com/package/@hookform/resolvers)
[![npm](https://img.shields.io/bundlephobia/minzip/@hookform/resolvers?style=for-the-badge)](https://bundlephobia.com/result?p=@hookform/resolvers)

[![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)

</div>

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

$ npm install @hookform/resolvers

## API

`resolver(schema: object, config?: object)`
## API

| | type | Required | Description|
|--|--|--|--|
| schema | `object` || validation schema |
| config | `object` | | validation schema configuration object |
`resolver(schema: object, config?: object)`

| | type | Required | Description |
| ------ | -------- | -------- | -------------------------------------- |
| schema | `object` || validation schema |
| config | `object` | | validation schema configuration object |

## Quickstart

### [Yup](https://github.com/jquense/yup)
### [Yup](https://github.com/jquense/yup)

Dead simple Object schema validation.

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


```typescript jsx
import React from 'react';
import { useForm } from 'react-hook-form';
Expand All @@ -65,7 +61,7 @@ const App = () => {
<form onSubmit={handleSubmit(d => console.log(d))}>
<input name="name" ref={register} />
<input name="age" type="number" ref={register} />

<input type="submit" />
</form>
);
Expand All @@ -77,16 +73,16 @@ const App = () => {
A simple and composable way to validate data in JavaScript (or TypeScript).

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

```typescript jsx
import React from 'react';
import { useForm } from 'react-hook-form';
import { superstructResolver } from '@hookform/resolvers';
import { struct } from 'superstruct';
import React from "react";
import { useForm } from "react-hook-form";
import { superstructResolver } from "@hookform/resolvers";
import { struct } from "superstruct";

const schema = struct({
name: 'string',
age: 'number',
name: "string",
age: "number",
});

const App = () => {
Expand All @@ -95,10 +91,10 @@ const App = () => {
});

return (
<form onSubmit={handleSubmit(d => console.log(d))}>
<form onSubmit={handleSubmit((d) => console.log(d))}>
<input name="name" ref={register} />
<input name="age" type="number" ref={register} />

<input type="submit" />
</form>
);
Expand All @@ -110,15 +106,15 @@ const App = () => {
The most powerful data validation library for JS.

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

```typescript jsx
import React from 'react';
import { useForm } from 'react-hook-form';
import { joiResolver } from '@hookform/resolvers';
import React from "react";
import { useForm } from "react-hook-form";
import { joiResolver } from "@hookform/resolvers";
import Joi from "@hapi/joi";

const schema = Joi.object({
username: Joi.string().required()
username: Joi.string().required(),
});

const App = () => {
Expand All @@ -127,10 +123,10 @@ const App = () => {
});

return (
<form onSubmit={handleSubmit(d => console.log(d))}>
<form onSubmit={handleSubmit((d) => console.log(d))}>
<input name="name" ref={register} />
<input name="age" type="number" ref={register} />

<input type="submit" />
</form>
);
Expand Down
109 changes: 77 additions & 32 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,52 +1,97 @@
{
"name": "@hookform/resolvers",
"version": "0.0.3",
"version": "0.0.4",
"description": "React Hook Form validation resolvers: Yup, Joi, Superstruct and etc.",
"main": "dist/resolvers.js",
"module": "dist/resolvers.es.js",
"main": "dist/index.js",
"module": "dist/index.esm.js",
"umd:main": "dist/index.umd.min.js",
"unpkg": "dist/index.umd.min.js",
"jsdelivr": "dist/index.umd.min.js",
"jsnext:main": "index.esm.js",
"types": "dist/index.d.ts",
"repository": {
"type": "git",
"url": "git+ssh://[email protected]/react-hook-form/resolvers.git"
},
"sideEffects": false,
"files": [
"dist"
],
"publishConfig": {
"access": "public"
},
"author": "bluebill1049 <[email protected]>",
"license": "MIT",
"scripts": {
"clean": "rm -rf dist",
"build": "rollup -c",
"prepublishOnly": "yarn lint && yarn test && yarn run clean && yarn build",
"clean": "rimraf dist",
"build": "npm run clean && rollup -c",
"lint": "eslint '**/*.{js,ts}'",
"lint:fix": "npm run lint -- --fix",
"lint:types": "tsc --noEmit",
"test": "jest --runInBand",
"lint": "yarn lint:check --fix && yarn prettier",
"prettier": "prettier --write './src/**/*.ts' './src/**/*.tsx' --config ./.prettierrc",
"lint:check": "eslint ./src --ext .jsx,.ts --ignore-pattern *.test.ts --report-unused-disable-directives",
"test:watch": "yarn test -- --watchAll --coverage"
"test:watch": "npm run test -- --watchAll --coverage",
"prepublishOnly": "npm run lint && npm run lint:types && npm test && npm run build"
},
"keywords": [
"scheme",
"validation",
"scheme-validation",
"hookform",
"react-hook-form",
"yup",
"joi",
"sperstruct",
"typescript"
],
"repository": {
"type": "git",
"url": "git+https://github.com/react-hook-form/resolvers.git"
},
"author": "bluebill1049 <[email protected]>",
"license": "MIT",
"bugs": {
"url": "https://github.com/react-hook-form/resolvers/issues"
},
"homepage": "https://github.com/react-hook-form/resolvers#readme",
"devDependencies": {
"@hapi/joi": "^17.1.1",
"@rollup/plugin-commonjs": "^13.0.0",
"@rollup/plugin-json": "^4.1.0",
"@rollup/plugin-node-resolve": "^8.0.1",
"@types/hapi__joi": "^17.1.0",
"@types/jest": "^25.1.2",
"@types/yup": "^0.28.0",
"@typescript-eslint/eslint-plugin": "^2.18.0",
"@typescript-eslint/parser": "^2.18.0",
"eslint": "^6.8.0",
"jest": "^25.1.0",
"prettier": "^1.19.1",
"@types/jest": "^26.0.0",
"@types/yup": "^0.29.3",
"@typescript-eslint/eslint-plugin": "^3.2.0",
"@typescript-eslint/parser": "^3.2.0",
"eslint": "^7.2.0",
"eslint-config-prettier": "^6.11.0",
"eslint-plugin-prettier": "^3.1.4",
"husky": "^4.2.5",
"jest": "^26.0.1",
"lint-staged": "^10.2.10",
"prettier": "^2.0.5",
"react": "^16.13.1",
"rollup": "^1.31.0",
"rollup-plugin-typescript2": "^0.25.3",
"react-hook-form": "^6.0.0-rc.4",
"rimraf": "^3.0.2",
"rollup": "^2.16.1",
"rollup-plugin-peer-deps-external": "^2.2.2",
"rollup-plugin-sourcemaps": "^0.6.2",
"rollup-plugin-terser": "^6.1.0",
"rollup-plugin-typescript2": "^0.27.1",
"superstruct": "^0.8.3",
"ts-jest": "^25.2.0",
"ts-jest": "^26.1.0",
"typescript": "^3.7.5",
"yup": "^0.28.5"
"yup": "^0.29.1"
},
"dependencies": {
"react-hook-form": "6.0.0-beta.2"
"peerDependencies": {
"react-hook-form": ">=6.0.0"
},
"bugs": {
"url": "https://github.com/react-hook-form/resolvers/issues"
"husky": {
"hooks": {
"pre-commit": "npm run lint:types && lint-staged"
}
},
"homepage": "https://github.com/react-hook-form/resolvers#readme"
"lint-staged": {
"*.{js,ts}": [
"npm run lint:fix"
],
"*.{md,json}": [
"prettier --write",
"git add"
]
}
}
Loading

0 comments on commit 28948ec

Please sign in to comment.