Skip to content

feat: add syntax replacements using web-features-codemods#207

Open
alieron wants to merge 2 commits intoe18e:mainfrom
alieron:feat/syntax-replacement
Open

feat: add syntax replacements using web-features-codemods#207
alieron wants to merge 2 commits intoe18e:mainfrom
alieron:feat/syntax-replacement

Conversation

@alieron
Copy link
Copy Markdown

@alieron alieron commented Apr 6, 2026

Looking to help close #128 eventually.

For now, this PR adds a fixable-syntax-replacement.ts file and a generator script, similar to how module replacements are handled in the existing project.

I've also added a simple plugin that checks the source files for possible syntax replacements when the analyze command is run, to see if this aligns with what you have planned.

I'll continue working on this PR but I have a couple of things to clarify:

  1. Is my approach good so far? should I continue keeping syntax replacements and module replacements separate or should I put them both under fixable replacements?
  2. Currently, I have it check all .js and .ts in the cwd, but should we only check in the src directory? Are there plans to let the user choose this when running the command?

Any other feedback is appreciated since I'm new to this codebase.

@43081j
Copy link
Copy Markdown
Contributor

43081j commented Apr 6, 2026

once #182 lands, we have a new sources option to let the user specify where their sources live. there's also a default glob in there (which we should move to a shared file).

im not sure we need any code generation here as everything we need is already available from the package itself as far as i can tell. in that all exported codemods of web-features-codemods are applicable, so we can just put them into a usable shape at runtime.

it looks like the fixable replacements script may be wrong and/or broken right now too outside of this as it writes to lib/ rather than src/ (iirc its meant to be a committed thing).

i think keeping this separate from module replacements makes sense as long as it happens as part of the analyze command

@alieron
Copy link
Copy Markdown
Author

alieron commented Apr 6, 2026

Got it, shall I close this PR for now then?

I will be happy to approach this once again once #182 is merged.

@43081j
Copy link
Copy Markdown
Contributor

43081j commented Apr 6, 2026

feel free to leave it open and we can catch up from main once the other PR lands (should be soon).

you could also rebase onto that branch for now so you can resolve the other things meanwhile

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add web-features-codemods

2 participants