Skip to content

Commit

Permalink
fix(javascript): class property (#20)
Browse files Browse the repository at this point in the history
  • Loading branch information
Goose97 committed Dec 22, 2024
1 parent f45a27c commit 518c6a5
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 0 deletions.
2 changes: 2 additions & 0 deletions queries/javascript/timber-log-target.scm
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
(member_expression
object: [
(identifier)
(this)
(member_expression)
(subscript_expression)
]
Expand All @@ -26,6 +27,7 @@
(subscript_expression
object: [
(identifier)
(this)
(member_expression)
(subscript_expression)
]
Expand Down
2 changes: 2 additions & 0 deletions queries/tsx/timber-log-target.scm
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,15 @@
(member_expression
object: [
(identifier)
(this)
(member_expression)
(subscript_expression)
]
)
(subscript_expression
object: [
(identifier)
(this)
(member_expression)
(subscript_expression)
]
Expand Down
30 changes: 30 additions & 0 deletions tests/timber/actions/lang/javascript_base.lua
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,36 @@ local run = function(language)
})
end)

it("supports class property", function()
helper.assert_scenario({
input = [[
class Foo {
foo = 1;
bar() {
this.fo|o = 2;
}
}
]],
filetype = language,
action = function()
actions.insert_log({ position = "above" })
actions.insert_log({ position = "below" })
end,
expected = [[
class Foo {
foo = 1;
bar() {
console.log("this.foo", this.foo)
this.foo = 2;
console.log("this.foo", this.foo)
}
}
]],
})
end)

it("supports array destructuring assignment", function()
local input = [[
const [fo|o] = ["bar"]
Expand Down

0 comments on commit 518c6a5

Please sign in to comment.