mirror of
https://github.com/nvim-treesitter/nvim-treesitter.git
synced 2026-07-14 01:10:02 -04:00
feat(indent): ecma - support common use-cases
This commit is contained in:
parent
782e299cd6
commit
7a6d93ca5b
8 changed files with 149 additions and 20 deletions
4
tests/indent/ecma/binary_expression.js
Normal file
4
tests/indent/ecma/binary_expression.js
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
if_this_is_correct &&
|
||||
run_this_thing()
|
||||
.filter()
|
||||
.map()
|
||||
6
tests/indent/ecma/callback.js
Normal file
6
tests/indent/ecma/callback.js
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
const itemById = Array.from(
|
||||
new Set()
|
||||
).reduce((byId, item) => {
|
||||
byId[item.id] = item
|
||||
return result;
|
||||
}, {})
|
||||
37
tests/indent/ecma/func.js
Normal file
37
tests/indent/ecma/func.js
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
const arrow_func = (
|
||||
a,
|
||||
b,
|
||||
c
|
||||
) => {
|
||||
log(a, b, c)
|
||||
}
|
||||
|
||||
const arrow_func_without_brace = (a, b, c) =>
|
||||
log(
|
||||
a,
|
||||
b,
|
||||
c
|
||||
)
|
||||
|
||||
function func_def(
|
||||
a,
|
||||
b,
|
||||
{ c = '' }
|
||||
) {
|
||||
log(a, b, c)
|
||||
}
|
||||
|
||||
func_call(
|
||||
a,
|
||||
(b) => b
|
||||
)
|
||||
|
||||
chained_func_call()
|
||||
.map()
|
||||
.filter()
|
||||
|
||||
func_call(
|
||||
chained_func_call()
|
||||
.map()
|
||||
.filter()
|
||||
)
|
||||
5
tests/indent/ecma/object.js
Normal file
5
tests/indent/ecma/object.js
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
const obj = {
|
||||
a: 1,
|
||||
b: "2",
|
||||
["c"]: `three`
|
||||
}
|
||||
6
tests/indent/ecma/ternary.js
Normal file
6
tests/indent/ecma/ternary.js
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
const value =
|
||||
condition
|
||||
? typeof number === 'string'
|
||||
? Number(number)
|
||||
: number
|
||||
: null;
|
||||
6
tests/indent/ecma/variable.js
Normal file
6
tests/indent/ecma/variable.js
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
let a =
|
||||
if_this_is_right() && then_this()
|
||||
|
||||
a = func_call()
|
||||
.map()
|
||||
.filter()
|
||||
Loading…
Add table
Add a link
Reference in a new issue