@coxy/react-validator 2.0.2 → 2.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/.eslintignore CHANGED
@@ -1,3 +1,2 @@
1
1
  dist
2
2
  node_modules
3
- example/dist
package/.eslintrc.js CHANGED
@@ -1,28 +1,7 @@
1
1
  module.exports = {
2
2
  root: true,
3
3
  parser: '@typescript-eslint/parser',
4
- plugins: [
5
- 'react',
6
- 'import',
7
- '@typescript-eslint'
8
- ],
9
- rules: {
10
- 'no-void': [0],
11
- 'react/jsx-tag-spacing': ['error', {
12
- closingSlash: 'never',
13
- beforeSelfClosing: 'always',
14
- afterOpening: 'never',
15
- beforeClosing: 'never'
16
- }],
17
- 'import/order': ['error', {
18
- groups: ['type', 'external', 'internal', 'builtin', 'object', 'index', 'parent', 'sibling'],
19
- 'newlines-between': 'always'
20
- }]
21
- },
22
4
  extends: [
23
- 'standard',
24
- 'eslint:recommended',
25
- 'plugin:@typescript-eslint/eslint-recommended',
26
- 'plugin:@typescript-eslint/recommended'
5
+ '@coxy/eslint-config/react'
27
6
  ]
28
7
  }
package/README.md CHANGED
@@ -20,7 +20,7 @@ Need react **>=16.3**
20
20
 
21
21
  # Example
22
22
 
23
- See more examples [here](example/example.jsx)
23
+ See more examples [here](example/example.tsx)
24
24
 
25
25
  ```jsx
26
26
  import React, { useState } from 'react';
@@ -68,7 +68,7 @@ export default () => {
68
68
  };
69
69
  ```
70
70
 
71
- See more examples [here](example/example.jsx)
71
+ See more examples [here](example/example.tsx)
72
72
   
73
73
  # Rules
74
74
 
@@ -6,7 +6,7 @@ import { ValidatorWrapper, rules, ValidatorField, Validator } from '../dist/inde
6
6
 
7
7
  function App () {
8
8
  const [email, setEmail] = useState('')
9
- const jsxValidator = createRef()
9
+ const jsxValidator = createRef<ValidatorWrapper>()
10
10
 
11
11
  function handleValidateEmail () {
12
12
  const { isValid, message, errors } = jsxValidator.current.validate()
@@ -0,0 +1,15 @@
1
+ {
2
+ "extends": "../tsconfig.json",
3
+ "compilerOptions": {
4
+ "outDir": "./dist",
5
+ "rootDir": ".",
6
+ "baseUrl": "./",
7
+ },
8
+ "include": [
9
+ "example.tsx"
10
+ ],
11
+ "exclude": [
12
+ "node_modules",
13
+ "dist"
14
+ ]
15
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@coxy/react-validator",
3
- "version": "2.0.2",
3
+ "version": "2.0.3",
4
4
  "description": "🚀 Simple validation form for React or NodeJS apps. useValidator are included ;)",
5
5
  "main": "./dist/index.js",
6
6
  "repository": {
@@ -21,7 +21,7 @@
21
21
  "scripts": {
22
22
  "start": "ts-node . --watch",
23
23
  "build": "NODE_ENV=production tsc --project tsconfig.build.json",
24
- "example": "webpack-cli -w --config ./example/webpack.config.js",
24
+ "example": "tsc --project ./example/tsconfig.json",
25
25
  "coverage": "codecov",
26
26
  "coveralls": "coveralls .",
27
27
  "test": "jest"
@@ -34,32 +34,28 @@
34
34
  "react": ">=18.x.x"
35
35
  },
36
36
  "devDependencies": {
37
- "@babel/core": "^7.18.6",
38
- "@babel/preset-env": "^7.18.6",
39
- "@babel/preset-react": "^7.18.6",
40
- "@testing-library/react": "^13.3.0",
41
- "@types/jest": "^28.1.4",
42
- "@types/react": "^18.0.15",
43
- "@typescript-eslint/eslint-plugin": "^5.30.6",
44
- "@typescript-eslint/parser": "^5.30.6",
45
- "babel-loader": "^8.2.5",
46
- "codecov": "^3.8.3",
47
- "coveralls": "^3.1.1",
48
- "eslint": "7.32.0",
49
- "eslint-config-standard": "^16.0.3",
50
- "eslint-plugin-import": "^2.26.0",
51
- "eslint-plugin-jsx-a11y": "^6.6.0",
52
- "eslint-plugin-node": "^11.1.0",
53
- "eslint-plugin-promise": "^6.0.0",
54
- "eslint-plugin-react": "^7.30.1",
55
- "jest": "^28.1.2",
56
- "jest-environment-jsdom": "^28.1.2",
57
- "react-dom": "^18.2.0",
58
- "react-test-renderer": "^18.2.0",
59
- "ts-jest": "^28.0.5",
60
- "ts-node": "^10.8.2",
61
- "typescript": "^4.7.4",
62
- "webpack": "^5.73.0",
63
- "webpack-cli": "^4.10.0"
37
+ "@coxy/eslint-config": "1.0.5",
38
+ "@testing-library/react": "13.4.0",
39
+ "@types/jest": "29.1.2",
40
+ "@types/react": "18.0.21",
41
+ "@typescript-eslint/eslint-plugin": "5.*",
42
+ "@typescript-eslint/parser": "5.*",
43
+ "codecov": "3.8.3",
44
+ "coveralls": "3.1.1",
45
+ "eslint": "8.25.0",
46
+ "eslint-config-standard": "17.0.0",
47
+ "eslint-plugin-import": "2.26.0",
48
+ "eslint-plugin-jsx-a11y": "6.6.1",
49
+ "eslint-plugin-n": "15.3.0",
50
+ "eslint-plugin-promise": "6.0.1",
51
+ "eslint-plugin-filename-rules": "1.2.0",
52
+ "eslint-plugin-react": "7.31.8",
53
+ "jest": "29.1.2",
54
+ "jest-environment-jsdom": "29.1.2",
55
+ "react-dom": "18.2.0",
56
+ "react-test-renderer": "18.2.0",
57
+ "ts-jest": "29.0.3",
58
+ "ts-node": "10.9.1",
59
+ "typescript": "4.8.4"
64
60
  }
65
61
  }
@@ -8,3 +8,4 @@ export function useValidator (value: Value, rules: ValidatorRules): [boolean, Pi
8
8
  const { isValid, ...validateObject } = validator.validate()
9
9
  return [isValid, validateObject]
10
10
  }
11
+
@@ -1,4 +1,3 @@
1
- /* eslint react/sort-comp: [0], camelcase: [0] */
2
1
  import { Component, ReactNode, RefObject } from 'react'
3
2
 
4
3
  import { Context } from './context'
@@ -11,7 +10,7 @@ interface ComponentProps {
11
10
  }
12
11
 
13
12
  export class ValidatorWrapper extends Component<ComponentProps> {
14
- fields = [];
13
+ fields = []
15
14
 
16
15
  constructor (props, ctx) {
17
16
  super(props, ctx)
package/src/validator.ts CHANGED
@@ -5,14 +5,15 @@ export interface FieldParams {
5
5
  value: Value
6
6
  rules: ValidatorRules,
7
7
  required?: boolean
8
- id?: string | number
8
+ id?: string|number
9
9
  }
10
10
 
11
11
  export class Field {
12
- private rules: ValidatorRules;
13
- private required: boolean;
14
- private value: Value;
15
- public id: string | number;
12
+ private rules: ValidatorRules
13
+ private required: boolean
14
+ private value: Value
15
+ public id: string|number
16
+
16
17
  constructor ({
17
18
  rules,
18
19
  required,
@@ -61,8 +62,8 @@ export interface ValidatorParams {
61
62
  }
62
63
 
63
64
  export class Validator {
64
- private fields: Field[];
65
- private params: ValidatorParams;
65
+ private fields: Field[]
66
+ private params: ValidatorParams
66
67
 
67
68
  constructor (params?: ValidatorParams) {
68
69
  this.params = params || null
package/babel.config.js DELETED
@@ -1,3 +0,0 @@
1
- module.exports = {
2
- presets: ['@babel/preset-env', '@babel/preset-react']
3
- }
@@ -1,29 +0,0 @@
1
- // eslint-disable-next-line @typescript-eslint/no-var-requires
2
- const path = require('path')
3
-
4
- module.exports = {
5
- target: 'web',
6
- entry: [
7
- path.resolve('./example/example.jsx')
8
- ],
9
- mode: 'development',
10
- output: {
11
- path: path.resolve('./example'),
12
- filename: './dist/example.js'
13
- },
14
- devtool: 'source-map',
15
- module: {
16
- rules: [{
17
- test: /\.jsx?$/,
18
- exclude: /node_modules/,
19
- loader: 'babel-loader'
20
- }]
21
- },
22
- resolve: {
23
- extensions: ['.js', '.jsx']
24
- },
25
- externals: {
26
- react: 'React',
27
- 'react-dom': 'ReactDOM'
28
- }
29
- }