arco-design / arco-cli

CLI tool for Arco Design
https://arco.design/docs/material/guide
MIT License
203 stars 76 forks source link

fix: 替换ExpressionStatement为JSXElement #48

Closed zzfn closed 1 year ago

zzfn commented 1 year ago

Types of changes

Background and context

背景

现在是替换%%content%%,当尝试自动在生成的PROPS前插入时,会出现“;”分号。

出现问题

现有情况下,replaceWith的是ExpressionStatement,当改为insertBefore ExpressionStatement。生成的code中会出现“;” 分号 insertBefore JSXElement则表现正确 image

Solution

How is the change tested?

Changelog

Changelog(CN) Changelog(EN) Related issues

Checklist:

Other information

MisterLuffy commented 1 year ago

Hi,你说的生成的 Code 中会出现分号指的是?

headwindz commented 1 year ago

Hi, 我用 PR 里的修改在本地跑了下,观察到最后的产物 markdownAst 转换后的代码还是带「分号」的。

zzfn commented 1 year ago

Hi, 我用 PR 里的修改在本地跑了下,观察到最后的产物 markdownAst 转换后的代码还是带「分号」的。

image

分号指?这个分号吗 观察生成的代码 image

headwindz commented 1 year ago

分号指?这个分号吗 观察生成的代码 image

我是跑的单元测试 yarn run test 。你截图里的「生成的代码」是在哪一行生成的。最终产物里 %%Content%% 应该是会被替换掉的呀。 image

zzfn commented 1 year ago

image

背景是这样的 ,我参考arco-cli代码 在 ## API前插入ast,把replaceWith替换成insertBefore发现的这个问题,本仓库使用replaceWith是不会出现分号问题,觉得pr方案严谨些(笑(逃