Skip to content

Commit

Permalink
Improve precommit hooks
Browse files Browse the repository at this point in the history
  • Loading branch information
Colin McDonnell committed Mar 19, 2022
1 parent 43b258b commit 66f044b
Show file tree
Hide file tree
Showing 9 changed files with 181 additions and 248 deletions.
17 changes: 3 additions & 14 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,8 @@ on:
push:
branches:
- "master"
# - "ci"
# paths:
# - package.json
paths:
- package.json

jobs:
build_and_publish:
Expand All @@ -27,21 +26,11 @@ jobs:
run: |
yarn install
- name: Build, lint, format
- name: Build
run: |
yarn clean
yarn lint:fix
yarn prettier:fix
yarn build
- name: Commit and push
run: |
git add .
git config --global user.name 'ZodBot'
git config --global user.email 'bot@zodlabs.com'
git commit -am "chore: Format, lint, build Deno"
git push
- id: publish
name: Publish to NPM
uses: JS-DevTools/npm-publish@v1
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@ coverage
*.log
src/playground.ts
deno/lib/playground.ts
.eslintcache
1 change: 1 addition & 0 deletions .husky/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
_
6 changes: 6 additions & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

yarn build:deno
git add deno
npx eslint --fix --cache src
4 changes: 4 additions & 0 deletions .husky/pre-push
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

npx lint-staged
9 changes: 2 additions & 7 deletions deno/lib/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -265,12 +265,6 @@ export abstract class ZodType<
/** Alias of safeParseAsync */
spa = this.safeParseAsync;

/** The .is method has been removed in Zod 3. For details see https://github.com/colinhacks/zod/tree/v3. */
is!: never;

/** The .check method has been removed in Zod 3. For details see https://github.com/colinhacks/zod/tree/v3. */
check!: never;

refine<RefinedOutput extends Output>(
check: (arg: Output) => arg is RefinedOutput,
message?: string | CustomErrorParams | ((arg: Output) => CustomErrorParams)
Expand Down Expand Up @@ -375,8 +369,9 @@ export abstract class ZodType<
this.transform = this.transform.bind(this);
this.default = this.default.bind(this);
this.describe = this.describe.bind(this);
this.isOptional = this.isOptional.bind(this);

this.isNullable = this.isNullable.bind(this);
this.isOptional = this.isOptional.bind(this);
}

optional(): ZodOptional<this> {
Expand Down
19 changes: 7 additions & 12 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,8 @@
"prepublishOnly": "npm run test && npm run build && npm run build:deno",
"play": "nodemon -e ts -w . -x ts-node src/playground.ts --project tsconfig.json --trace-warnings",
"depcruise": "depcruise -c .dependency-cruiser.js src",
"benchmark": "ts-node src/benchmarks/index.ts"
"benchmark": "ts-node src/benchmarks/index.ts",
"prepare": "husky install"
},
"devDependencies": {
"@rollup/plugin-typescript": "^8.2.0",
Expand All @@ -78,9 +79,9 @@
"eslint-plugin-import": "^2.22.1",
"eslint-plugin-simple-import-sort": "^7.0.0",
"eslint-plugin-unused-imports": "^1.1.0",
"husky": "^4.3.4",
"husky": "^7.0.4",
"jest": "^26.6.3",
"lint-staged": "^10.5.3",
"lint-staged": "^12.3.7",
"make-coverage-badge": "^1.2.0",
"nodemon": "^2.0.2",
"prettier": "^2.2.1",
Expand All @@ -92,16 +93,10 @@
"tslib": "^2.3.1",
"typescript": "^4.6.2"
},
"husky": {
"hooks": {
"pre-commit": "lint-staged",
"pre-push": "lint-staged"
}
},
"lint-staged": {
"*.ts": [
"yarn lint:fix",
"yarn prettier:fix"
"src/*.ts": [
"eslint --cache --fix",
"prettier --ignore-unknown --write"
]
}
}
9 changes: 2 additions & 7 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -265,12 +265,6 @@ export abstract class ZodType<
/** Alias of safeParseAsync */
spa = this.safeParseAsync;

/** The .is method has been removed in Zod 3. For details see https://github.com/colinhacks/zod/tree/v3. */
is!: never;

/** The .check method has been removed in Zod 3. For details see https://github.com/colinhacks/zod/tree/v3. */
check!: never;

refine<RefinedOutput extends Output>(
check: (arg: Output) => arg is RefinedOutput,
message?: string | CustomErrorParams | ((arg: Output) => CustomErrorParams)
Expand Down Expand Up @@ -375,8 +369,9 @@ export abstract class ZodType<
this.transform = this.transform.bind(this);
this.default = this.default.bind(this);
this.describe = this.describe.bind(this);
this.isOptional = this.isOptional.bind(this);

this.isNullable = this.isNullable.bind(this);
this.isOptional = this.isOptional.bind(this);
}

optional(): ZodOptional<this> {
Expand Down

0 comments on commit 66f044b

Please sign in to comment.