diff options
| author | Munif Tanjim <hello@muniftanjim.dev> | 2022-01-21 18:44:30 +0600 |
|---|---|---|
| committer | Christian Clason <christian.clason@uni-due.de> | 2022-01-21 16:40:36 +0100 |
| commit | 7a6d93ca5b95b4485dd70c1a1d813bb5a80fcc07 (patch) | |
| tree | a3ee6950f76938ccc8e85b9d78f9da92b097e1dd /tests/indent/ecma | |
| parent | fix(indent): c/cpp - support newline after closing brace (diff) | |
| download | nvim-treesitter-7a6d93ca5b95b4485dd70c1a1d813bb5a80fcc07.tar nvim-treesitter-7a6d93ca5b95b4485dd70c1a1d813bb5a80fcc07.tar.gz nvim-treesitter-7a6d93ca5b95b4485dd70c1a1d813bb5a80fcc07.tar.bz2 nvim-treesitter-7a6d93ca5b95b4485dd70c1a1d813bb5a80fcc07.tar.lz nvim-treesitter-7a6d93ca5b95b4485dd70c1a1d813bb5a80fcc07.tar.xz nvim-treesitter-7a6d93ca5b95b4485dd70c1a1d813bb5a80fcc07.tar.zst nvim-treesitter-7a6d93ca5b95b4485dd70c1a1d813bb5a80fcc07.zip | |
feat(indent): ecma - support common use-cases
Diffstat (limited to 'tests/indent/ecma')
| -rw-r--r-- | tests/indent/ecma/binary_expression.js | 4 | ||||
| -rw-r--r-- | tests/indent/ecma/callback.js | 6 | ||||
| -rw-r--r-- | tests/indent/ecma/func.js | 37 | ||||
| -rw-r--r-- | tests/indent/ecma/object.js | 5 | ||||
| -rw-r--r-- | tests/indent/ecma/ternary.js | 6 | ||||
| -rw-r--r-- | tests/indent/ecma/variable.js | 6 |
6 files changed, 64 insertions, 0 deletions
diff --git a/tests/indent/ecma/binary_expression.js b/tests/indent/ecma/binary_expression.js new file mode 100644 index 000000000..132fee9cf --- /dev/null +++ b/tests/indent/ecma/binary_expression.js @@ -0,0 +1,4 @@ +if_this_is_correct && + run_this_thing() + .filter() + .map() diff --git a/tests/indent/ecma/callback.js b/tests/indent/ecma/callback.js new file mode 100644 index 000000000..a4e1e533e --- /dev/null +++ b/tests/indent/ecma/callback.js @@ -0,0 +1,6 @@ +const itemById = Array.from( + new Set() +).reduce((byId, item) => { + byId[item.id] = item + return result; +}, {}) diff --git a/tests/indent/ecma/func.js b/tests/indent/ecma/func.js new file mode 100644 index 000000000..5bbfa1e31 --- /dev/null +++ b/tests/indent/ecma/func.js @@ -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() +) diff --git a/tests/indent/ecma/object.js b/tests/indent/ecma/object.js new file mode 100644 index 000000000..ca09d238a --- /dev/null +++ b/tests/indent/ecma/object.js @@ -0,0 +1,5 @@ +const obj = { + a: 1, + b: "2", + ["c"]: `three` +} diff --git a/tests/indent/ecma/ternary.js b/tests/indent/ecma/ternary.js new file mode 100644 index 000000000..479e411c9 --- /dev/null +++ b/tests/indent/ecma/ternary.js @@ -0,0 +1,6 @@ +const value = + condition + ? typeof number === 'string' + ? Number(number) + : number + : null; diff --git a/tests/indent/ecma/variable.js b/tests/indent/ecma/variable.js new file mode 100644 index 000000000..80d34beea --- /dev/null +++ b/tests/indent/ecma/variable.js @@ -0,0 +1,6 @@ +let a = + if_this_is_right() && then_this() + +a = func_call() + .map() + .filter() |
