From 1ade2a9c821ac5d2477f293c4ae13f1eb4c634d2 Mon Sep 17 00:00:00 2001 From: Axel Date: Tue, 6 Sep 2022 09:37:14 +0200 Subject: [PATCH] chore: move files and delete useless files --- .eslintrc.json | 1 + makefile | 7 +--- rollup.config.ts | 48 ++++++------------------ src/Error/index.ts | 16 -------- src/{Validator/index.ts => Validator.ts} | 29 +++++++++++++- src/index.ts | 4 -- src/types.ts | 12 ------ src/vite-env.d.ts | 1 - tsconfig.types.json | 4 +- 9 files changed, 43 insertions(+), 79 deletions(-) delete mode 100644 src/Error/index.ts rename src/{Validator/index.ts => Validator.ts} (84%) delete mode 100644 src/index.ts delete mode 100644 src/types.ts delete mode 100644 src/vite-env.d.ts diff --git a/.eslintrc.json b/.eslintrc.json index 9476017..8f849e8 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -24,6 +24,7 @@ "import" ], "rules": { + "max-classes-per-file": 0, "@typescript-eslint/no-shadow": 0, "@typescript-eslint/no-non-null-assertion": 0, "guard-for-in": 0, diff --git a/makefile b/makefile index 36fd147..cf043e3 100644 --- a/makefile +++ b/makefile @@ -16,12 +16,7 @@ lint: .PHONY: publish-npmjs publish-npmjs: - yarn publish --access public --registry https://registry.npmjs.org/ --new-version $(PACKAGE_VERSION) --non-interactive - -.PHONY: github-tag -github-tag: - git tag -a v$(PACKAGE_VERSION) -m "update to v$(PACKAGE_VERSION)" - git push origin v$(PACKAGE_VERSION) + yarn publish --registry https://registry.npmjs.org/ --access public --new-version $(PACKAGE_VERSION) --non-interactive .PHONY: types types: diff --git a/rollup.config.ts b/rollup.config.ts index 2f3df46..02211f3 100644 --- a/rollup.config.ts +++ b/rollup.config.ts @@ -3,41 +3,15 @@ import {resolve} from "node:path"; import {terser} from "rollup-plugin-terser"; import typescript from "@rollup/plugin-typescript"; -export default [ - { - input: resolve("src", "Validator/index.ts"), - plugins: [ - remove({targets: resolve("lib", "*")}), - typescript(), - terser() - ], - output: { - file: resolve("lib", "Validator/index.js"), - format: "cjs" - } - }, - { - input: resolve("src", "Error/index.ts"), - plugins: [ - remove({targets: resolve("lib", "*")}), - typescript(), - terser() - ], - output: { - file: resolve("lib", "Error/index.js.js"), - format: "cjs" - } - }, - { - input: resolve("src", "index.ts"), - plugins: [ - remove({targets: resolve("lib", "*")}), - typescript(), - terser() - ], - output: { - file: resolve("lib", "index.js"), - format: "cjs" - } +export default { + input: resolve("src", "Validator.ts"), + plugins: [ + remove({targets: resolve("lib", "*")}), + typescript(), + terser() + ], + output: { + file: resolve("lib", "Validator.js"), + format: "cjs" } -]; \ No newline at end of file +} \ No newline at end of file diff --git a/src/Error/index.ts b/src/Error/index.ts deleted file mode 100644 index a187992..0000000 --- a/src/Error/index.ts +++ /dev/null @@ -1,16 +0,0 @@ -export class Error { - constructor(private _field: string, private _error: string) { - } - - public get field(): string { - return this._field; - } - - public get error(): string { - return this._error; - } - - public toString(): string { - return `${this.error.replace("{champ}", this.field)}`; - } -} diff --git a/src/Validator/index.ts b/src/Validator.ts similarity index 84% rename from src/Validator/index.ts rename to src/Validator.ts index 9beb66c..b6a24da 100644 --- a/src/Validator/index.ts +++ b/src/Validator.ts @@ -1,5 +1,28 @@ -import { CallableRule, Rules } from "../types"; -import { Error } from "../Error"; +type CallableRule = ((data: string, ...args: unknown[]) => boolean); + +type Rule = { + cb: CallableRule, + optionalParams?: unknown[] +}; + +type Rules = Record; + +class Error { + constructor(private _field: string, private _error: string) { + } + + public get field(): string { + return this._field; + } + + public get error(): string { + return this._error; + } + + public toString(): string { + return `${this.error.replace("{champ}", this.field)}`; + } +} export class Validator { private _rules: Rules = {}; @@ -113,3 +136,5 @@ export class Validator { this._rulesMapping[input] = [rule]; } } + +export default Validator; diff --git a/src/index.ts b/src/index.ts deleted file mode 100644 index 8c55f96..0000000 --- a/src/index.ts +++ /dev/null @@ -1,4 +0,0 @@ -import { Validator } from "./Validator"; - -export * from "./Validator"; -export default Validator; diff --git a/src/types.ts b/src/types.ts deleted file mode 100644 index 473cd74..0000000 --- a/src/types.ts +++ /dev/null @@ -1,12 +0,0 @@ -export type CallableRule = ((data: string, ...args: unknown[]) => boolean); - -export type Rule = { - cb: CallableRule, - optionalParams?: unknown[] -}; - -export type Rules = Record; - -export type DataToValidate = { - [field: string]: keyof Rules[] -}; diff --git a/src/vite-env.d.ts b/src/vite-env.d.ts deleted file mode 100644 index 11f02fe..0000000 --- a/src/vite-env.d.ts +++ /dev/null @@ -1 +0,0 @@ -/// diff --git a/tsconfig.types.json b/tsconfig.types.json index 686bc68..9824d0c 100644 --- a/tsconfig.types.json +++ b/tsconfig.types.json @@ -1,6 +1,8 @@ { "extends": "./tsconfig.json", - "files": ["src/index.ts"], + "files": [ + "src/Validator.ts" + ], "compilerOptions": { "declaration": true, "declarationMap": true,