Skip to content

Commit

Permalink
chore: restructure (#13)
Browse files Browse the repository at this point in the history
BREAKING CHANGE: v1.0.0 release
  • Loading branch information
sahinvardar committed Nov 23, 2023
1 parent f746636 commit 7cb6bbc
Show file tree
Hide file tree
Showing 35 changed files with 1,766 additions and 690 deletions.
52 changes: 52 additions & 0 deletions .eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
module.exports = {
extends: [
'eslint:recommended',
'plugin:@typescript-eslint/recommended',
'prettier',
'plugin:typescript-sort-keys/recommended'
],
plugins: ['@typescript-eslint', 'unused-imports', 'typescript-sort-keys'],
ignorePatterns: [
'*.cjs',
'jest.*.ts',
'/dist',
'**/cdk.out/*',
'**/build/*',
'pnpm-*.yaml',
'*.sql',
'*.sh',
'*.png',
'*.svg',
'*.jpg',
'*.jpeg',
'*.csv',
'*.ttf',
'*.postcss',
'*.html',
'*.md',
'*.css'
],
overrides: [],
parserOptions: {
sourceType: 'module',
ecmaVersion: 2021
},
rules: {
'@typescript-eslint/no-explicit-any': 'off',
'@typescript-eslint/no-non-null-assertion': 'off',
'turbo/no-undeclared-env-vars': 'off',
'unused-imports/no-unused-imports-ts': 'error',
'@typescript-eslint/no-unused-vars': [
'warn',
{ vars: 'all', varsIgnorePattern: '^_', args: 'after-used', argsIgnorePattern: '^_' }
]
},
env: {
browser: true,
es2022: true,
node: true
},
globals: {
$$Generic: 'readonly'
}
};
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
name: Publish to NPM
on:
release:
types: [created]
name: build-test
on: push
jobs:
publish:
build-and-test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
Expand All @@ -13,8 +11,5 @@ jobs:
registry-url: https://registry.npmjs.org/
- uses: pnpm/action-setup@v2
- run: pnpm install
- run: pnpm test
- run: pnpm build
- run: pnpm --filter @vardario/zod-form-validation publish --access public --no-git-checks
env:
NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}}
- run: pnpm test
29 changes: 29 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: release
on:
push:
branches: [release]
jobs:
publish:
runs-on: ubuntu-latest
permissions:
contents: write
id-token: write
pull-requests: write
steps:
- uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 18
registry-url: https://registry.npmjs.org/
- uses: pnpm/action-setup@v2
- run: pnpm install
- run: pnpm build
- run: pnpm test
- run: pnpm semantic-release
env:
GITHUB_TOKEN: ${{ github.TOKEN }}
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ dist
.yarn/build-state.yml
.yarn/install-state.gz
.pnp.*
./lib

lib

.DS_Store
2 changes: 1 addition & 1 deletion .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"

npm test
pnpm lint-staged
13 changes: 2 additions & 11 deletions .prettierrc
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,6 @@
"semi": true,
"singleQuote": true,
"printWidth": 120,
"arrowParens": "always",
"plugins": ["prettier-plugin-svelte", "prettier-plugin-tailwindcss"],
"trailingComma": "all",
"overrides": [
{
"files": ["**/*.js", "**/*.ts"],
"options": {
"plugins": ["prettier-plugin-organize-imports"]
}
}
]
"arrowParens": "avoid",
"trailingComma": "none"
}
118 changes: 0 additions & 118 deletions eslint.config.js

This file was deleted.

22 changes: 11 additions & 11 deletions examples/html/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -313,24 +313,24 @@
observerValidationErrors,
validateFormData,
setValidationErrorsToForm,
clearFormValidationErrors,
clearFormValidationErrors
} from '@vardario/zod-form-validation';
import { z } from 'zod';
const form = document.querySelector('form');
const inputs = form.querySelectorAll('input,select,textarea,fieldset');

inputs.forEach((input) => {
observerValidationErrors(input, (errors) => {
inputs.forEach(input => {
observerValidationErrors(input, errors => {
const errorMessages = input.parentElement.nextElementSibling;

errorMessages &&
errorMessages.replaceChildren(
...errors.map((error) => {
...errors.map(error => {
const span = document.createElement('span');
span.innerText = error;
span.className = 'text-sm text-red-600';
return span;
}),
})
);
});
});
Expand All @@ -350,24 +350,24 @@
email: z
.object({
email: z.string().email(),
confirmEmail: z.string().email(),
confirmEmail: z.string().email()
})
.superRefine(({ email, confirmEmail }, context) => {
if (email !== confirmEmail) {
context.addIssue({
code: z.ZodIssueCode.custom,
message: 'E-Mail does not match',
path: ['confirmEmail'],
path: ['confirmEmail']
});
}
}),
})
}),
amount: z.number(),
range: z.number(),
pet: petsSchema,
fruits: z.array(fruits),
description: z.string(),
monster: monsterSchema,
monster: monsterSchema
});

function fromValidation() {
Expand All @@ -384,15 +384,15 @@
setRequiresToForm(form, schema);
clearFormValidationErrors(form);

form.addEventListener('submit', (event) => {
form.addEventListener('submit', event => {
doValidateOnInput = true;
if (!fromValidation()) {
event.preventDefault();
event.stopImmediatePropagation();
}
});

form.addEventListener('input', (event) => {
form.addEventListener('input', event => {
doValidateOnInput && fromValidation();
});
</script>
Expand Down
3 changes: 0 additions & 3 deletions examples/next/.eslintrc.json

This file was deleted.

4 changes: 2 additions & 2 deletions examples/next/postcss.config.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module.exports = {
plugins: {
tailwindcss: {},
autoprefixer: {},
},
autoprefixer: {}
}
};
2 changes: 1 addition & 1 deletion examples/next/src/app/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const inter = Inter({ subsets: ['latin'] });

export const metadata: Metadata = {
title: 'Create Next App',
description: 'Generated by create next app',
description: 'Generated by create next app'
};

export default function RootLayout({ children }: { children: React.ReactNode }) {
Expand Down
10 changes: 5 additions & 5 deletions examples/next/src/app/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,24 +22,24 @@ const schema = z.object({
email: z
.object({
email: z.string().email(),
confirmEmail: z.string().email(),
confirmEmail: z.string().email()
})
.superRefine(({ email, confirmEmail }, context) => {
if (email !== confirmEmail) {
context.addIssue({
code: z.ZodIssueCode.custom,
message: 'E-Mail does not match',
path: ['confirmEmail'],
path: ['confirmEmail']
});
}
}),
})
}),
amount: z.number(),
range: z.number(),
pet: petsSchema,
fruits: z.array(fruits),
description: z.string(),
monster: monsterSchema,
monster: monsterSchema
});

export default function Home() {
Expand All @@ -50,7 +50,7 @@ export default function Home() {
data={{}}
schema={schema}
className="m-auto flex w-1/3 flex-col gap-2 rounded border p-4"
onSubmit={(event) => {
onSubmit={event => {
alert(JSON.stringify(formDataToObject(new FormData(event.target as HTMLFormElement), schema), null, 2));
event.preventDefault();
}}
Expand Down
Loading

0 comments on commit 7cb6bbc

Please sign in to comment.