arco-cli icon indicating copy to clipboard operation
arco-cli copied to clipboard

fix: 替换ExpressionStatement为JSXElement

Open zzfn opened this issue 2 years ago • 5 comments

Types of changes

  • [ ] New feature
  • [x] Bug fix
  • [ ] Documentation change
  • [ ] Coding style change
  • [ ] Refactoring
  • [ ] Performance improvement
  • [ ] Test cases
  • [ ] Continuous integration
  • [ ] Typescript definition change
  • [ ] Breaking change

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:

  • [ ] Provide changelog for relevant changes (e.g. bug fixes and new features) if applicable.
  • [ ] Changes are submitted to the appropriate branch (e.g. features should be submitted to feature branch and others should be submitted to master branch)

Other information

zzfn avatar Aug 07 '22 02:08 zzfn

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

Helium-Z avatar Aug 19 '22 08:08 Helium-Z

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

headwindz avatar Aug 19 '22 08:08 headwindz

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

image

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

zzfn avatar Aug 19 '22 09:08 zzfn

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

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

headwindz avatar Aug 26 '22 02:08 headwindz

image

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

zzfn avatar Aug 26 '22 07:08 zzfn