Skip to content

Commit 02c6f3a

Browse files
committed
Tests, CI, improvements
1 parent 1d48b01 commit 02c6f3a

18 files changed

+6227
-2610
lines changed

.eslintrc.json

+3-11
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,7 @@
33
"eslint:recommended",
44
"plugin:@typescript-eslint/recommended",
55
"plugin:react/recommended",
6-
7-
"plugin:prettier/recommended",
8-
"prettier/@typescript-eslint"
6+
"plugin:prettier/recommended"
97
],
108
"plugins": [
119
"react",
@@ -27,17 +25,11 @@
2725
},
2826
"rules": {
2927
"react-hooks/rules-of-hooks": "error",
30-
"simple-import-sort/sort": "error",
3128
"prettier/prettier": ["error"],
3229
"linebreak-style": 0,
3330
"camelcase": "off",
3431
"endOfLine": 0,
35-
"@typescript-eslint/camelcase": [
36-
"error",
37-
{
38-
"ignoreDestructuring": true
39-
}
40-
],
41-
"@typescript-eslint/explicit-function-return-type": 0
32+
"@typescript-eslint/explicit-function-return-type": 0,
33+
"@typescript-eslint/no-explicit-any": 0
4234
}
4335
}

.github/CODEOWNERS

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# These owners will be the default owners for everything in the repo.
2+
3+

.github/workflows/lint-and-test.yaml

+59
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
name: lint-and-test
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
pull_request:
8+
branches:
9+
- master
10+
11+
jobs:
12+
lint:
13+
runs-on: ubuntu-latest
14+
steps:
15+
- name: Checkout repository
16+
uses: actions/checkout@v3
17+
18+
- name: Install pnpm
19+
uses: pnpm/action-setup@v2
20+
with:
21+
version: 8
22+
23+
- name: Install NodeJS
24+
uses: actions/setup-node@v3
25+
with:
26+
node-version: '20.8.0'
27+
cache: 'pnpm'
28+
29+
- name: Install NodeJS dependencies
30+
run: pnpm install
31+
32+
- name: Run linting
33+
run: pnpm lint:ci
34+
35+
- name: Run type check
36+
run: pnpm types:check
37+
test:
38+
runs-on: ubuntu-latest
39+
needs: lint
40+
steps:
41+
- name: Checkout repository
42+
uses: actions/checkout@v3
43+
44+
- name: Install pnpm
45+
uses: pnpm/action-setup@v2
46+
with:
47+
version: 8
48+
49+
- name: Install NodeJS
50+
uses: actions/setup-node@v3
51+
with:
52+
node-version: '18'
53+
cache: 'pnpm'
54+
55+
- name: Install NodeJS dependencies
56+
run: pnpm install
57+
58+
- name: Run tests
59+
run: pnpm test:ci

.husky/.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
_

.husky/pre-commit

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#!/bin/sh
2+
. "$(dirname "$0")/_/husky.sh"
3+
4+
npx lint-staged

.husky/pre-push

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#!/bin/sh
2+
. "$(dirname "$0")/_/husky.sh"
3+
4+
echo "Running Typescript type check"
5+
6+
pnpm types:check

package.json

+58-41
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,43 @@
11
{
2-
"name": "use-ajv-form",
2+
"name": "@programmer_network/use-ajv-form",
33
"version": "1.0.0",
44
"description": "Custom React Hook that integrates with Ajv JSON Schema Validator",
5-
"main": "dist/index.js",
5+
"main": "dist/use-ajv.es.js",
6+
"author": "Aleksandar Grbic",
7+
"publishConfig": {
8+
"access": "public"
9+
},
10+
"types": "dist/index.d.ts",
611
"scripts": {
7-
"build": "rollup -c",
8-
"start": "rollup -c -w",
9-
"test": "jest"
12+
"dev": "vite",
13+
"build": "vite build",
14+
"serve": "vite preview",
15+
"prepare": "husky install",
16+
"format": "prettier --write .",
17+
"test": "vitest run",
18+
"test:watch": "vitest",
19+
"test:ui": "vitest --ui",
20+
"coverage": "vitest run --coverage",
21+
"lint:ci": "eslint --cache .",
22+
"lint:fix": "eslint --cache --fix src",
23+
"lint:quiet": "eslint --cache --quiet src",
24+
"test:ci": "vitest",
25+
"types:check": "tsc",
26+
"publish": "npm publish --auth-type=legacy"
1027
},
11-
"engines": {
12-
"node": ">=8",
13-
"npm": ">=5"
28+
"lint-staged": {
29+
"*.{js,jsx,ts,tsx}": "eslint --cache --fix",
30+
"*": "prettier --write"
1431
},
15-
"jest": {
16-
"transform": {
17-
".(ts|tsx)": "ts-jest"
18-
},
19-
"testRegex": "(/__tests__/.*|\\.(test|spec))\\.(ts|tsx|js)$",
20-
"moduleFileExtensions": [
21-
"ts",
22-
"tsx",
23-
"js"
24-
],
25-
"modulePathIgnorePatterns": [
26-
"<rootDir>/dist/"
27-
]
32+
"vitest": {
33+
"test": {
34+
"include": "/**/*.test.jsx|js|tsx"
35+
}
2836
},
2937
"repository": {
3038
"type": "git",
3139
"url": "git+https://github.com/agjs/use-ajv-form.git"
3240
},
33-
"author": "Aleksandar Grbic",
3441
"license": "ISC",
3542
"bugs": {
3643
"url": "https://github.com/agjs/use-ajv-form/issues"
@@ -41,28 +48,38 @@
4148
"react-dom": ">= 18.2.0"
4249
},
4350
"dependencies": {
44-
"@types/ajv": "^1.0.0",
45-
"ajv": "^8.12.0",
46-
"ajv-errors": "^3.0.0",
47-
"ajv-formats": "^2.1.1",
51+
"ajv": "8.12.0",
52+
"ajv-errors": "3.0.0",
53+
"ajv-formats": "2.1.1",
4854
"programmer-network-ajv": "github:Programmer-Network/Programmer-Network-AJV",
49-
"prop-types": "^15.7.2"
55+
"prop-types": "15.7.2"
5056
},
5157
"devDependencies": {
52-
"@testing-library/react-hooks": "^3.4.1",
53-
"@types/jest": "^26.0.7",
54-
"@types/react": "^18.2.37",
55-
"@types/react-dom": "^18.2.15",
56-
"babel-core": "^6.26.3",
57-
"babel-runtime": "^6.26.0",
58-
"eslint-plugin-react-hooks": "^4.0.8",
59-
"jest": "^26.1.0",
60-
"react-test-renderer": "^16.13.1",
61-
"rollup": "^1.29.0",
62-
"rollup-plugin-typescript2": "^0.25.3",
63-
"rollup-plugin-uglify": "^6.0.4",
64-
"ts-jest": "^26.1.3",
65-
"typescript": "^3.8.3"
58+
"@testing-library/jest-dom": "^6.1.4",
59+
"@testing-library/react": "^14.1.2",
60+
"@testing-library/react-hooks": "^8.0.1",
61+
"@types/ajv": "1.0.0",
62+
"@types/jest": "^29.5.10",
63+
"@types/react": "18.2.37",
64+
"@types/react-dom": "18.2.15",
65+
"@typescript-eslint/eslint-plugin": "^6.12.0",
66+
"@vitejs/plugin-react": "4.2.0",
67+
"d": "github:testing-library/jest-dom",
68+
"eslint-config-prettier": "9.0.0",
69+
"eslint-plugin-prettier": "5.0.1",
70+
"eslint-plugin-react": "7.33.2",
71+
"eslint-plugin-react-hooks": "4.6.0",
72+
"eslint-plugin-simple-import-sort": "^10.0.0",
73+
"husky": "8.0.3",
74+
"jsdom": "22.1.0",
75+
"prettier": "3.0.3",
76+
"react-hooks": "link:@types/@testing-library/react-hooks",
77+
"ts-jest": "29.1.1",
78+
"typescript": "5.2.2",
79+
"vite": "5.0.2",
80+
"vite-plugin-dts": "3.6.3",
81+
"vite-tsconfig-paths": "4.2.1",
82+
"vitest": "0.34.6"
6683
},
6784
"files": [
6885
"dist"

0 commit comments

Comments
 (0)