watermelontools / watermelon

🍉 Open-Source Copilot For Code Review
https://app.watermelontools.com
Apache License 2.0
145 stars 12 forks source link

Make comment detection RegEx legible #416

Open baristaGeek opened 9 months ago

baristaGeek commented 9 months ago

In detectConsoleLogs.ts we have the consoleLogRegex variable. It's a RegEx literal that will keep growing.

We can do something like the following to keep this RegEx more legible:

const consoleLogsByLanguage = [
   "(console\.log"
   "print"
   // Add the syntax of each language 
]

And then concat this into the RegEx literal. This possibly looks similar to this:

const consoleLogRegex = consoleLogsByLanguage.map(element => element).join('');