Test husky

This commit is contained in:
Colin McDonnell 2022-03-19 15:15:27 -07:00
parent 361c789d84
commit 2348c00719
16 changed files with 177 additions and 202 deletions

View File

@ -2,68 +2,64 @@ module.exports = {
forbidden: [
/* rules from the 'recommended' preset: */
{
name: 'no-circular',
severity: 'warn',
name: "no-circular",
severity: "warn",
comment:
'This dependency is part of a circular relationship. You might want to revise ' +
'your solution (i.e. use dependency inversion, make sure the modules have a single responsibility) ',
"This dependency is part of a circular relationship. You might want to revise " +
"your solution (i.e. use dependency inversion, make sure the modules have a single responsibility) ",
from: {},
to: {
circular: true
}
circular: true,
},
},
{
name: 'no-deprecated-core',
name: "no-deprecated-core",
comment:
'A module depends on a node core module that has been deprecated. Find an alternative - these are ' +
"A module depends on a node core module that has been deprecated. Find an alternative - these are " +
"bound to exist - node doesn't deprecate lightly.",
severity: 'warn',
severity: "warn",
from: {},
to: {
dependencyTypes: [
'core'
],
dependencyTypes: ["core"],
path: [
'^(v8\/tools\/codemap)$',
'^(v8\/tools\/consarray)$',
'^(v8\/tools\/csvparser)$',
'^(v8\/tools\/logreader)$',
'^(v8\/tools\/profile_view)$',
'^(v8\/tools\/profile)$',
'^(v8\/tools\/SourceMap)$',
'^(v8\/tools\/splaytree)$',
'^(v8\/tools\/tickprocessor-driver)$',
'^(v8\/tools\/tickprocessor)$',
'^(node-inspect\/lib\/_inspect)$',
'^(node-inspect\/lib\/internal\/inspect_client)$',
'^(node-inspect\/lib\/internal\/inspect_repl)$',
'^(async_hooks)$',
'^(assert)$',
'^(punycode)$',
'^(domain)$',
'^(constants)$',
'^(sys)$',
'^(_linklist)$',
'^(_stream_wrap)$'
"^(v8/tools/codemap)$",
"^(v8/tools/consarray)$",
"^(v8/tools/csvparser)$",
"^(v8/tools/logreader)$",
"^(v8/tools/profile_view)$",
"^(v8/tools/profile)$",
"^(v8/tools/SourceMap)$",
"^(v8/tools/splaytree)$",
"^(v8/tools/tickprocessor-driver)$",
"^(v8/tools/tickprocessor)$",
"^(node-inspect/lib/_inspect)$",
"^(node-inspect/lib/internal/inspect_client)$",
"^(node-inspect/lib/internal/inspect_repl)$",
"^(async_hooks)$",
"^(assert)$",
"^(punycode)$",
"^(domain)$",
"^(constants)$",
"^(sys)$",
"^(_linklist)$",
"^(_stream_wrap)$",
],
}
},
},
{
name: 'not-to-deprecated',
name: "not-to-deprecated",
comment:
'This module uses a (version of an) npm module that has been deprecated. Either upgrade to a later ' +
'version of that module, or find an alternative. Deprecated modules are a security risk.',
severity: 'warn',
"This module uses a (version of an) npm module that has been deprecated. Either upgrade to a later " +
"version of that module, or find an alternative. Deprecated modules are a security risk.",
severity: "warn",
from: {},
to: {
dependencyTypes: [
'deprecated'
]
}
dependencyTypes: ["deprecated"],
},
},
{
name: 'no-non-package-json',
severity: 'error',
name: "no-non-package-json",
severity: "error",
comment:
"This module depends on an npm package that isn't in the 'dependencies' section of your package.json. " +
"That's problematic as the package either (1) won't be available on live (2 - worse) will be " +
@ -71,71 +67,67 @@ module.exports = {
"in your package.json.",
from: {},
to: {
dependencyTypes: [
'npm-no-pkg',
'npm-unknown'
]
}
dependencyTypes: ["npm-no-pkg", "npm-unknown"],
},
},
{
name: 'not-to-unresolvable',
name: "not-to-unresolvable",
comment:
"This module depends on a module that cannot be found ('resolved to disk'). If it's an npm " +
'module: add it to your package.json. In all other cases you likely already know what to do.',
severity: 'error',
"module: add it to your package.json. In all other cases you likely already know what to do.",
severity: "error",
from: {},
to: {
couldNotResolve: true
}
couldNotResolve: true,
},
},
{
name: 'no-duplicate-dep-types',
name: "no-duplicate-dep-types",
comment:
"Likely this module depends on an external ('npm') package that occurs more than once " +
"in your package.json i.e. bot as a devDependencies and in dependencies. This will cause " +
"maintenance problems later on.",
severity: 'warn',
severity: "warn",
from: {},
to: {
moreThanOneDependencyType: true
}
moreThanOneDependencyType: true,
},
},
/* rules you might want to tweak for your specific situation: */
{
name: 'not-to-spec',
name: "not-to-spec",
comment:
'This module depends on a spec (test) file. The sole responsibility of a spec file is to test code. ' +
"This module depends on a spec (test) file. The sole responsibility of a spec file is to test code. " +
"If there's something in a spec that's of use to other modules, it doesn't have that single " +
'responsibility anymore. Factor it out into (e.g.) a separate utility/ helper or a mock.',
severity: 'error',
"responsibility anymore. Factor it out into (e.g.) a separate utility/ helper or a mock.",
severity: "error",
from: {},
to: {
path: '\\.(spec|test)\\.(js|mjs|cjs|ts|ls|coffee|litcoffee|coffee\\.md)$'
}
path: "\\.(spec|test)\\.(js|mjs|cjs|ts|ls|coffee|litcoffee|coffee\\.md)$",
},
},
{
name: 'not-to-dev-dep',
severity: 'error',
name: "not-to-dev-dep",
severity: "error",
comment:
"This module depends on an npm package from the 'devDependencies' section of your " +
'package.json. It looks like something that ships to production, though. To prevent problems ' +
"package.json. It looks like something that ships to production, though. To prevent problems " +
"with npm packages that aren't there on production declare it (only!) in the 'dependencies'" +
'section of your package.json. If this module is development only - add it to the ' +
'from.pathNot re of the not-to-dev-dep rule in the dependency-cruiser configuration',
"section of your package.json. If this module is development only - add it to the " +
"from.pathNot re of the not-to-dev-dep rule in the dependency-cruiser configuration",
from: {
path: '^(src)',
pathNot: '\\.(spec|test)\\.(js|mjs|cjs|ts|ls|coffee|litcoffee|coffee\\.md)$'
path: "^(src)",
pathNot:
"\\.(spec|test)\\.(js|mjs|cjs|ts|ls|coffee|litcoffee|coffee\\.md)$",
},
to: {
dependencyTypes: [
'npm-dev'
]
}
dependencyTypes: ["npm-dev"],
},
},
{
name: 'optional-deps-used',
severity: 'info',
name: "optional-deps-used",
severity: "info",
comment:
"This module depends on an npm package that is declared as an optional dependency " +
"in your package.json. As this makes sense in limited situations only, it's flagged here. " +
@ -143,44 +135,39 @@ module.exports = {
"dependency-cruiser configuration.",
from: {},
to: {
dependencyTypes: [
'npm-optional'
]
}
dependencyTypes: ["npm-optional"],
},
},
{
name: 'peer-deps-used',
name: "peer-deps-used",
comment:
"This module depends on an npm package that is declared as a peer dependency " +
"in your package.json. This makes sense if your package is e.g. a plugin, but in " +
"other cases - maybe not so much. If the use of a peer dependency is intentional " +
"add an exception to your dependency-cruiser configuration.",
severity: 'warn',
severity: "warn",
from: {},
to: {
dependencyTypes: [
'npm-peer'
]
}
}
dependencyTypes: ["npm-peer"],
},
},
],
options: {
/* conditions specifying which files not to follow further when encountered:
- path: a regular expression to match
- dependencyTypes: see https://github.com/sverweij/dependency-cruiser/blob/master/doc/rules-reference.md#dependencytypes
for a complete list
*/
doNotFollow: {
path: 'node_modules',
path: "node_modules",
dependencyTypes: [
'npm',
'npm-dev',
'npm-optional',
'npm-peer',
'npm-bundled',
'npm-no-pkg'
]
"npm",
"npm-dev",
"npm-optional",
"npm-peer",
"npm-bundled",
"npm-no-pkg",
],
},
/* conditions specifying which dependencies to exclude
@ -237,7 +224,7 @@ module.exports = {
defaults to './tsconfig.json'.
*/
tsConfig: {
fileName: 'tsconfig.json'
fileName: "tsconfig.json",
},
/* Webpack configuration to use to get resolve options from.
@ -265,7 +252,6 @@ module.exports = {
// babelConfig: {
// fileName: './.babelrc'
// },
/* How to resolve external modules - use "yarn-pnp" if you're using yarn's Plug'n'Play.
otherwise leave it out (or set to the default, which is 'node_modules')
@ -284,7 +270,7 @@ module.exports = {
collapses everything in node_modules to one folder deep so you see
the external modules, but not the innards your app depends upon.
*/
collapsePattern: 'node_modules/[^/]+',
collapsePattern: "node_modules/[^/]+",
/* Options to tweak the appearance of your graph.See
https://github.com/sverweij/dependency-cruiser/blob/master/doc/options-reference.md#reporteroptions
@ -339,7 +325,8 @@ module.exports = {
dependency graph reporter (`archi`) you probably want to tweak
this collapsePattern to your situation.
*/
collapsePattern: '^(node_modules|packages|src|lib|app|bin|test(s?)|spec(s?))/[^/]+',
collapsePattern:
"^(node_modules|packages|src|lib|app|bin|test(s?)|spec(s?))/[^/]+",
/* Options to tweak the appearance of your graph.See
https://github.com/sverweij/dependency-cruiser/blob/master/doc/options-reference.md#reporteroptions
@ -349,8 +336,8 @@ module.exports = {
*/
// theme: {
// },
}
}
}
},
},
},
};
// generated: dependency-cruiser@9.19.0 on 2020-12-12T06:59:50.855Z

View File

@ -21,12 +21,12 @@ jobs:
uses: actions/setup-node@v1
with:
node-version: 16
- name: Install dependencies
run: |
yarn install
- name: Build
- name: Build
run: |
yarn clean
yarn build

View File

@ -13,8 +13,8 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
node: [ '14' ]
typescript: [ '4.1', '4.2', '4.3', '4.4', '4.5', '4.6' ]
node: ["14"]
typescript: ["4.1", "4.2", "4.3", "4.4", "4.5", "4.6"]
name: Test with TypeScript ${{ matrix.typescript }} on Node ${{ matrix.node }}
steps:
- uses: actions/checkout@v2
@ -30,7 +30,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
deno: [ "v1.x" ]
deno: ["v1.x"]
name: Test with Deno ${{ matrix.deno }}
steps:
- uses: actions/checkout@v2
@ -58,7 +58,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
node: [ '14' ]
node: ["14"]
name: Lint on Node ${{ matrix.node }}
steps:
- uses: actions/checkout@v2

View File

@ -1,6 +1,6 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"
npx lint-staged
yarn build:deno
git add deno
npx eslint --fix --cache src

View File

@ -51,7 +51,7 @@ _Every_ ZodIssue has these fields:
| ZodIssueCode.invalid_date | _no additional properties_ |
| ZodIssueCode.invalid_string | `validation: "url" \| "email" \| "uuid"`<br> Which built-in string validator failed |
| ZodIssueCode.too_small | `type: "string" \| "number" \| "array"` <br>The type of the data failing validation<br><br> `minimum: number` <br>The expected length/value.<br><br>`inclusive: boolean`<br>Whether the minimum is included in the range of acceptable values.<br> |
| ZodIssueCode.too_big | `type: "string" \| "number" \| "array"` <br>The type of the data failing validation<br><br> `maximum: number` <br>The expected length/value.<br><br>`inclusive: boolean`<br>Whether the maximum is included in the range of acceptable values.<br> |
| ZodIssueCode.too_big | `type: "string" \| "number" \| "array"` <br>The type of the data failing validation<br><br> `maximum: number` <br>The expected length/value.<br><br>`inclusive: boolean`<br>Whether the maximum is included in the range of acceptable values.<br> |
| ZodIssueCode.not_multiple_of | `multipleOf: number` <br>The value the number should be a multiple of.<br> |
| ZodIssueCode.custom | `params: { [k: string]: any }` <br> This is the error code throw by refinements (unless you are using `superRefine` in which case it's possible to throw issues of any `code`). You are able to pass in a `params` object here that is available in your custom error maps (see [ZodErrorMap](#Customizing-errors-with-ZodErrorMap) below for details on error maps) |
@ -392,7 +392,10 @@ type FormDataErrors = z.inferFlattenedErrors<typeof FormData>;
By default all error types are assumed to be `string`. If you're using a mapping function to transform `ZodIssue`s, you can provide the error type to `z.inferFlattenedErrors`.
```ts
type FormDataErrors = z.inferFlattenedErrors<typeof FormData, { message: string, errorCode: string }>;
type FormDataErrors = z.inferFlattenedErrors<
typeof FormData,
{ message: string; errorCode: string }
>;
/*
formErrors: { message: string, errorCode: string }[],
@ -407,21 +410,24 @@ const result = FormData.safeParse({
email: "not email",
password: "tooshort",
confirm: "nomatch",
})
});
if (!result.success) {
let bad: FormDataErrors = err.flatten(); // Type error: Type 'string' is not assignable to type '{ message: string; }'.
let good: FormDataErrors = err.flatten(i => ({
let good: FormDataErrors = err.flatten((i) => ({
message: i.message,
errorCode: i.code
}))
errorCode: i.code,
}));
}
```
Additionally, you can use `z.inferFormErrors` as a convienience for `z.inferFlattenedErrors<T, string>` in combination with `formErrors`.
```ts
type FormDataErrors = z.inferFormErrors<typeof FormData, { message: string, errorCode: string }>;
type FormDataErrors = z.inferFormErrors<
typeof FormData,
{ message: string; errorCode: string }
>;
let formErrors: FormDataErrors = result.error.formErrors;
```

View File

@ -1 +1 @@
github: colinhacks
github: colinhacks

View File

@ -369,11 +369,12 @@ 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> {
("");
return ZodOptional.create(this) as any;
}
nullable(): ZodNullable<this> {

View File

@ -1,37 +1,46 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
<meta name="description" content="Description">
<meta name="viewport"
content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
<link rel="stylesheet" href="//cdn.jsdelivr.net/npm/docsify/lib/themes/vue.css">
</head>
<body>
<nav style="display:flex;flex-direction:row;align-items:center;justify-content:space-between;">
<a href="https://twitter.com/colinhacks"><span style="color:#888888;">created by @colinhacks</span></a>
<a href="#/">Docs</a>
<a href="#/screencasts">Screencasts</a>
</nav>
<div id="app"></div>
<script>
window.$docsify = {
// repo: 'docsifyjs/docsify',
subMaxLevel: 1,
coverpage: true,
onlyCover: true
};
</script>
<script src="//cdn.jsdelivr.net/npm/docsify/lib/docsify.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/prismjs@1.21.0/components/prism-typescript.min.js"></script>
</body>
</html>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<title>Document</title>
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
<meta name="description" content="Description" />
<meta
name="viewport"
content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0"
/>
<link
rel="stylesheet"
href="//cdn.jsdelivr.net/npm/docsify/lib/themes/vue.css"
/>
</head>
<body>
<nav
style="
display: flex;
flex-direction: row;
align-items: center;
justify-content: space-between;
"
>
<a href="https://twitter.com/colinhacks"
><span style="color: #888888">created by @colinhacks</span></a
>
<a href="#/">Docs</a>
<a href="#/screencasts">Screencasts</a>
</nav>
<div id="app"></div>
<script>
window.$docsify = {
// repo: 'docsifyjs/docsify',
subMaxLevel: 1,
coverpage: true,
onlyCover: true,
};
</script>
<script src="//cdn.jsdelivr.net/npm/docsify/lib/docsify.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/prismjs@1.21.0/components/prism-typescript.min.js"></script>
</body>
</html>

View File

@ -4,22 +4,11 @@
"^.+\\.tsx?$": "ts-jest"
},
"testRegex": "src/.*\\.test\\.ts$",
"moduleFileExtensions": [
"ts",
"tsx",
"js",
"jsx",
"json",
"node"
],
"coverageReporters": [
"json-summary",
"text",
"lcov"
],
"moduleFileExtensions": ["ts", "tsx", "js", "jsx", "json", "node"],
"coverageReporters": ["json-summary", "text", "lcov"],
"globals": {
"ts-jest": {
"tsconfig": "tsconfig.json"
}
}
}
}

View File

@ -43,7 +43,7 @@
],
"scripts": {
"prettier:check": "prettier --check src/**/*.ts deno/lib/**/*.ts --no-error-on-unmatched-pattern",
"prettier:fix": "prettier --write src/**/*.ts deno/lib/**/*.ts --no-error-on-unmatched-pattern",
"prettier:fix": "prettier --write src/**/*.ts deno/lib/**/*.ts --ignore-unknown --no-error-on-unmatched-pattern",
"lint:check": "eslint --ext .ts ./src",
"lint:fix": "eslint --fix --ext .ts ./src",
"check": "yarn lint:check && yarn prettier:check",
@ -96,7 +96,7 @@
"lint-staged": {
"src/*.ts": [
"eslint --cache --fix",
"prettier --ignore-unknown --write"
"prettier --ignore-unknown --debug --loglevel debug --write"
]
}
}

View File

@ -369,11 +369,12 @@ 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> {
("");
return ZodOptional.create(this) as any;
}
nullable(): ZodNullable<this> {

View File

@ -1,12 +1,6 @@
{
"compilerOptions": {
"lib": [
"es5",
"es6",
"es7",
"esnext",
"dom"
],
"lib": ["es5", "es6", "es7", "esnext", "dom"],
"target": "es2018",
"removeComments": false,
"esModuleInterop": true,
@ -22,8 +16,5 @@
"downlevelIteration": true,
"isolatedModules": true
},
"include": [
"./src/**/*",
"./.eslintrc.js"
]
"include": ["./src/**/*", "./.eslintrc.js"]
}

View File

@ -5,10 +5,7 @@
"outDir": "lib",
"declaration": true,
"declarationMap": false,
"sourceMap": false,
"sourceMap": false
},
"exclude": [
"./src/**/__tests__",
"./src/playground.ts"
]
"exclude": ["./src/**/__tests__", "./src/playground.ts"]
}

View File

@ -5,10 +5,7 @@
// "outDir": "./lib/esm",
"declaration": false,
"declarationMap": false,
"sourceMap": false,
"sourceMap": false
},
"exclude": [
"./src/**/__tests__",
"./src/playground.ts"
]
"exclude": ["./src/**/__tests__", "./src/playground.ts"]
}

View File

@ -1,3 +1,3 @@
{
"extends": "./tsconfig.base.json"
}
}

View File

@ -6,8 +6,5 @@
"declarationMap": true,
"emitDeclarationOnly": true
},
"exclude": [
"./src/**/__tests__",
"./src/playground.ts"
]
}
"exclude": ["./src/**/__tests__", "./src/playground.ts"]
}