feat(ansi-colors-to-styletext): introduce#481
Conversation
|
hello thanks for the effort here but you aren't shipping any codemod here just codes stored on utils package. So please read the CONTRIBUTING.MD |
|
Hi @AugustinMauroy, I've reworked the full implementation. The codemod is now properly structured under recipes/ansi-colors-to-styletext/ with all required files. |
AugustinMauroy
left a comment
There was a problem hiding this comment.
add test case:
- dynamic import with await
- dynamic import with then methode
- mixed syntax like chained and imported
- imported with commonJS
const { red, blue } = require('ansi-colors');
ansi-colors-to-styletext): introduce
|
also you have to |
|
Hi @AugustinMauroy, all feedback addressed. |
ansi-colors-to-styletext): introduce
JakobJingleheimer
left a comment
There was a problem hiding this comment.
Thanks for this! Mostly nits and code health improvements; but I do have a concern about the handling of unsupported APIs.
There was a problem hiding this comment.
This isn't really doing anything—it seems just bloat.
There was a problem hiding this comment.
I what we do for all ecosystem codemod
There was a problem hiding this comment.
I think this is a problem, no? The rest is migrated, but it leaves dead code that I think now broken.
There was a problem hiding this comment.
since it's specify on the readme as not migratable api we can leave that as it but add test to be sure it's not modified
…lls, replace Set with array
|
Um, what the heck happened with these commits—did you cherry-pick them from |
… COMPATIBILITY_MAP access
4af94d1 to
2f1eb46
Compare
|
These came in accidentally during a git pull origin feat/ansi-colors-to-styletext --rebase which pulled in commits from my remote fork that had already gotten upstream changes mixed in. I've cleaned it up with a force push — the branch now only contains my commits. |
Closes #480
Implements the ansi-colors to util.styleText codemod as specified in the issue. The transform handles the following cases:
CommonJS require('ansi-colors') and ES module import ac from 'ansi-colors' — both replaced with the appropriate styleText destructured import from node:util
Simple single style calls — ac.red('text') becomes styleText('red', 'text')
Chained style calls — ac.bold.red('text') becomes styleText(['bold', 'red'], 'text')
Unsupported APIs — detects enabled, visible, unstyle, alias, theme, and create, skips transformation for the enclosing scope, and emits a warning pointing to the line for manual remediation
190 tests passing, 0 failures. Coverage on the new file is 96.94% line and 100% function.