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. |
| }); | ||
|
|
||
| if (Boolean(namespaceImport) && namespaceImport.text() === options.old) { | ||
| if (namespaceImport && namespaceImport.text() === options.old) { |
There was a problem hiding this comment.
This was automatically applied by the Biome linter during the pre-commit check — Boolean(namespaceImport) and namespaceImport are functionally equivalent in a conditional and Biome flags the explicit coercion as unnecessary. Happy to revert if you'd prefer to keep the original.
ansi-colors-to-styletext): introduce
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.