Skip to content

Extend JavaScript ast-grep rules to match functions/methods in pairs and objects#135

Merged
maks-ivanov merged 5 commits intoagentic-labs:mainfrom
jy-tan:main
May 19, 2025
Merged

Extend JavaScript ast-grep rules to match functions/methods in pairs and objects#135
maks-ivanov merged 5 commits intoagentic-labs:mainfrom
jy-tan:main

Conversation

@jy-tan
Copy link
Contributor

@jy-tan jy-tan commented May 16, 2025

Context

Previously, the function rules for JS wouldn't match these functions and methods:

// Property identifier in a 'pair' with a 'function_expression'
const objWithFuncExpr = {
  propFuncExpr: function () {
    console.log("Hello, world!");
  },
};

// Property identifier in a 'method_definition' (object shorthand method)
const objWithShorthand = {
  shorthandObjMethod() {},

  *generatorShorthandMethod() {},

  async asyncShorthandMethod() {},
};

Changes

  • Include matches for function_expression in pair and method_definition in property_identifier
  • Add tests

@maks-ivanov maks-ivanov merged commit 375fd8b into agentic-labs:main May 19, 2025
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.

2 participants