fabian-hiller / valibot

The modular and type safe schema library for validating structural data 🤖
https://valibot.dev
MIT License
5.88k stars 181 forks source link

Codemod with `toTrimmed` fails #717

Closed hyunbinseo closed 1 month ago

hyunbinseo commented 1 month ago

This code does not work with codemod:

// Original
import { minLength, object, string, toTrimmed } from 'valibot';
const FormSchema = object({ 'given-name': string([toTrimmed(), minLength(1)]) });
// Modified
import { minLength, object, string, trim, pipe } from "valibot"bot';
const FormSchema = object({ 'given-napipe(string(), trim() , minLength(1))ength(1)]) });

Notes

Received the following error in another repository. Cannot reproduce in this MRE.

Error: Cannot split a chunk that has already been edited (31:26 – "toTrimmed")

I might be using an outdated codemod? It automatically used the cached version.

pnpm dlx codemod valibot/migrate-to-v0.31.0
✔ Successfully fetched "valibot/migrate-to-v0.31.0" from local cache.
╭───────────────────────────────────────────────────────╮
│                                                       │
│                                                       │
│      Codemod: valibot/migrate-to-v0.31.0@0.2.2        │
fabian-hiller commented 1 month ago

Thank you for reporting this. I am not sure we can fix this. This looks like a bug in the libraries our codemod is based on.

hyunbinseo commented 1 month ago

You can close this issue as closed as not planned.

I am fine as long as people can search this issue and reference it.

I personally still have Valibot v0.29 projects to migrate from :)