test(typia-validator): use `unplugin-typia` (#1000)
* test(typia-validator): use `unplugin-typia` Fixes #999 * chore: cleanup ignored test-generatedpull/1004/head
parent
7007f19734
commit
cc26ddcae3
|
@ -3,6 +3,6 @@ import baseConfig from './packages/eslint-config/index.js'
|
||||||
export default [
|
export default [
|
||||||
...baseConfig,
|
...baseConfig,
|
||||||
{
|
{
|
||||||
ignores: ['**/dist/*', '**/test-generated/*'],
|
ignores: ['**/dist/*'],
|
||||||
},
|
},
|
||||||
]
|
]
|
||||||
|
|
|
@ -1 +0,0 @@
|
||||||
/test-generated
|
|
|
@ -23,8 +23,7 @@
|
||||||
"dist"
|
"dist"
|
||||||
],
|
],
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"generate-test": "rimraf test-generated && typia generate --input test --output test-generated --project tsconfig.json && node scripts/add-ts-ignore.cjs",
|
"test": "vitest",
|
||||||
"test": "npm run generate-test && vitest",
|
|
||||||
"build:cjs": "tsc -p tsconfig.cjs.json",
|
"build:cjs": "tsc -p tsconfig.cjs.json",
|
||||||
"build:esm": "tsc -p tsconfig.esm.json",
|
"build:esm": "tsc -p tsconfig.esm.json",
|
||||||
"build": "rimraf dist && yarn build:cjs && yarn build:esm",
|
"build": "rimraf dist && yarn build:cjs && yarn build:esm",
|
||||||
|
@ -46,6 +45,7 @@
|
||||||
"typia": "^7.0.0"
|
"typia": "^7.0.0"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
|
"@ryoppippi/unplugin-typia": "^1.2.0",
|
||||||
"hono": "^3.11.7",
|
"hono": "^3.11.7",
|
||||||
"rimraf": "^5.0.5",
|
"rimraf": "^5.0.5",
|
||||||
"typescript": "^5.4.0",
|
"typescript": "^5.4.0",
|
||||||
|
|
|
@ -1,27 +0,0 @@
|
||||||
// @ts-check
|
|
||||||
const fs = require('node:fs')
|
|
||||||
const path = require('node:path')
|
|
||||||
|
|
||||||
// https://github.com/samchon/typia/issues/1432
|
|
||||||
// typia generated files have some type errors
|
|
||||||
|
|
||||||
const generatedFiles = fs
|
|
||||||
.readdirSync(path.resolve(__dirname, '../test-generated'))
|
|
||||||
.map((file) => path.resolve(__dirname, '../test-generated', file))
|
|
||||||
|
|
||||||
for (const file of generatedFiles) {
|
|
||||||
const content = fs.readFileSync(file, 'utf8')
|
|
||||||
const lines = content.split('\n')
|
|
||||||
const distLines = []
|
|
||||||
for (const line of lines) {
|
|
||||||
if (
|
|
||||||
line.includes('._httpHeaderReadNumber(') ||
|
|
||||||
line.includes('._httpHeaderReadBigint(') ||
|
|
||||||
line.includes('._httpHeaderReadBoolean(')
|
|
||||||
)
|
|
||||||
distLines.push(`// @ts-ignore`)
|
|
||||||
distLines.push(line)
|
|
||||||
}
|
|
||||||
|
|
||||||
fs.writeFileSync(file, distLines.join('\n'))
|
|
||||||
}
|
|
|
@ -2,7 +2,7 @@ import { Hono } from 'hono'
|
||||||
import type { Equal, Expect } from 'hono/utils/types'
|
import type { Equal, Expect } from 'hono/utils/types'
|
||||||
import type { tags } from 'typia'
|
import type { tags } from 'typia'
|
||||||
import typia from 'typia'
|
import typia from 'typia'
|
||||||
import { typiaValidator } from '../src/http'
|
import { typiaValidator } from './http'
|
||||||
|
|
||||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||||
type ExtractSchema<T> = T extends Hono<infer _, infer S> ? S : never
|
type ExtractSchema<T> = T extends Hono<infer _, infer S> ? S : never
|
|
@ -2,7 +2,7 @@ import { Hono } from 'hono'
|
||||||
import type { Equal, Expect } from 'hono/utils/types'
|
import type { Equal, Expect } from 'hono/utils/types'
|
||||||
import type { tags } from 'typia'
|
import type { tags } from 'typia'
|
||||||
import typia from 'typia'
|
import typia from 'typia'
|
||||||
import { typiaValidator } from '../src'
|
import { typiaValidator } from '.'
|
||||||
|
|
||||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||||
type ExtractSchema<T> = T extends Hono<infer _, infer S> ? S : never
|
type ExtractSchema<T> = T extends Hono<infer _, infer S> ? S : never
|
|
@ -0,0 +1,13 @@
|
||||||
|
import UnpluginTypia from '@ryoppippi/unplugin-typia/vite'
|
||||||
|
import { defineConfig } from 'vitest/config'
|
||||||
|
|
||||||
|
export default defineConfig({
|
||||||
|
plugins: [
|
||||||
|
UnpluginTypia({
|
||||||
|
tsconfig: './tsconfig.json',
|
||||||
|
}),
|
||||||
|
],
|
||||||
|
test: {
|
||||||
|
globals: true,
|
||||||
|
},
|
||||||
|
})
|
|
@ -1,8 +0,0 @@
|
||||||
import { defineConfig, defaultExclude } from 'vitest/config'
|
|
||||||
|
|
||||||
export default defineConfig({
|
|
||||||
test: {
|
|
||||||
globals: true,
|
|
||||||
exclude: [...defaultExclude, 'test'],
|
|
||||||
},
|
|
||||||
})
|
|
Loading…
Reference in New Issue