Skip to content

Commit 411971c

Browse files
authored
feat(formatter): add deno fmt (#60)
* feat(formatter): add deno fmt * sort deno-fmt alphabetically
1 parent 6bd5ad7 commit 411971c

3 files changed

Lines changed: 35 additions & 0 deletions

File tree

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
- [cljfmt](https://github.com/weavejester/cljfmt)
1616
- [csharpier](https://csharpier.com/)
1717
- [dart](https://github.com/dart-lang)
18+
- [deno_fmt](https://github.com/denoland/deno) as `deno fmt`
1819
- [djhtml](https://github.com/rtts/djhtml)
1920
- [docformatter](https://github.com/PyCQA/docformatter)
2021
- [dprint](https://dprint.dev/)

lua/guard-collection/formatter.lua

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,12 @@ M.dart = {
5353
stdin = true,
5454
}
5555

56+
M.deno_fmt = {
57+
cmd = 'deno',
58+
args = { 'fmt', '-' },
59+
stdin = true,
60+
}
61+
5662
M.djhtml = {
5763
cmd = 'djhtml',
5864
args = { '-' },

test/formatter/deno_fmt_spec.lua

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
describe('deno fmt', function()
2+
it('can format', function()
3+
local ft = require('guard.filetype')
4+
ft('typescript'):fmt('deno_fmt')
5+
6+
local formatted = require('test.formatter.helper').test_with('typescript', {
7+
[[function ]],
8+
[[ fibonacci(num:]],
9+
[[ number):]],
10+
[[number {]],
11+
[[ if ]],
12+
[[ (num <= 1 ]],
13+
[[ )]],
14+
[[ return num ;]],
15+
[[ return fibonacci(num - 1) + fibonacci(num - 2]],
16+
[[ );]],
17+
[[}]],
18+
})
19+
assert.are.same({
20+
[[function fibonacci(num: number): number {]],
21+
[[ if (num <= 1) {]],
22+
[[ return num;]],
23+
[[ }]],
24+
[[ return fibonacci(num - 1) + fibonacci(num - 2);]],
25+
[[}]],
26+
}, formatted)
27+
end)
28+
end)

0 commit comments

Comments
 (0)