Skip to content
This repository has been archived by the owner on Jul 5, 2022. It is now read-only.

feat: add objects and arrays in javascript #107

Merged
merged 1 commit into from
Jun 9, 2022

Conversation

dylanbyars
Copy link
Contributor

@dylanbyars dylanbyars commented May 31, 2022

#93

Add queries for a few common shapes of arrays and objects.

const foo = {
  bar: {
    baz: {
      bip: 'bop' // cursor on this line
    }
  }
}

{} foo > {} bar > {} baz > {} bip
foo = {
  yabba: {
    dabba: {
      doo: 'wilma' // cursor on this line
    }
  }
}

{} foo > {} yabba > {} dabba > {} doo
foo.zip = {
  zop: 'wow' // cursor on this line
}

{} foo.zip > {} zop
const yo = [1,2,3] // cursor after `=`

[] yo

Some of these queries look very similar. I feel like there's probably some way to make these a bit more clever. For example, the object literal and array queries are identical besides the selector on object or array.

@SmiteshP
Copy link
Owner

SmiteshP commented Jun 9, 2022

Some of these queries look very similar. I feel like there's probably some way to make these a bit more clever. For example, the object literal and array queries are identical besides the selector on object or array.

Yeah, we can use the same query for both captures using [object array] syntax, which mean object or array node. But its more readable to keep them separate so its fine 😄

Copy link
Owner

@SmiteshP SmiteshP left a comment

Choose a reason for hiding this comment

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

Thanks for the PR! LGTM 😄

@SmiteshP SmiteshP merged commit c1e561d into SmiteshP:master Jun 9, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants