Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Javascript #5182

Draft
wants to merge 10 commits into
base: main
Choose a base branch
from
Draft

Add Javascript #5182

wants to merge 10 commits into from

Conversation

jkschneider
Copy link
Member

What's changed?

Bringing Javascript into the core repository. A lot is changing to make openrewrite/rewrite-javascript more idiomatic to JS/TS along the way.

What's your motivation?

Native recipe development of Javascript recipes!

@@ -0,0 +1,5 @@
export type ExecutionContext = Map<string | symbol, any> & { __brand: "ExecutionContext" }
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍🏼 big fan of opaque types

Comment on lines +171 to +175
* @param recipeName A unique name for the recipe consisting of a dot separated sequence of category
* names in which the recipe should appear followed by a name. For example,
* "org.openrewrite.typescript.find-methods-by-pattern".
*/
export function Registered(recipeName: string) {
Copy link
Member

@zieka zieka Mar 27, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like this

I could imagine a @Recipe decorator that accepts an object with recipe meta data and standardized across all languages supporting the decorator pattern to have the authorship experience converge slightly. Would also reduce the code in the recipe down to just method implementations (javascript is already pretty slim but for other languages may reduce some boilerplate)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

examples:

typescript

@Recipe({
  id: 'org.testkitchen.BigAwesome', 
  name: 'Big awesome', 
  description: 'A recipe ensuring big awesome things'
})
class BigAwesome extends Recipe {}

java

@Recipe(
    id = "org.testkitchen.BigAwesome",
    name = "Big awesome",
    description = "A recipe ensuring big awesome things"
)
public class BigAwesome extends Recipe {}

python

@recipe(
    id="org.testkitchen.BigAwesome",
    name="Big awesome",
    description="A recipe ensuring big awesome things"
)
class BigAwesome(Recipe):

c#

[Recipe(
    Id = "org.testkitchen.BigAwesome",
    Name = "Big awesome",
    Description = "A recipe ensuring big awesome things"
)]
public class BigAwesome : Recipe {}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: In Progress
Development

Successfully merging this pull request may close these issues.

2 participants