aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordalu <25452934+dalugm@users.noreply.github.com>2023-11-30 03:25:11 +0800
committerGitHub <noreply@github.com>2023-11-29 19:25:11 +0000
commitc8d9ad43ba99bb3b8703e6810fca357cf96c05ad (patch)
treed1997bb52d7187d7e8b4bf1c888eb027089126aa
parent56651724ad22f2769bbdaccf54cbe75c1cb35c91 (diff)
Add denofmt (#264)
-rw-r--r--CHANGELOG.md3
-rw-r--r--apheleia-formatters.el8
l---------test/formatters/installers/denofmt-js.bash1
l---------test/formatters/installers/denofmt-json.bash1
l---------test/formatters/installers/denofmt-jsonc.bash1
l---------test/formatters/installers/denofmt-jsx.bash1
l---------test/formatters/installers/denofmt-md.bash1
l---------test/formatters/installers/denofmt-ts.bash1
l---------test/formatters/installers/denofmt-tsx.bash1
-rw-r--r--test/formatters/installers/denofmt.bash1
l---------test/formatters/samplecode/denofmt-js/in.js1
-rw-r--r--test/formatters/samplecode/denofmt-js/out.js5
l---------test/formatters/samplecode/denofmt-json/in.json1
-rw-r--r--test/formatters/samplecode/denofmt-json/out.json19
-rw-r--r--test/formatters/samplecode/denofmt-jsonc/in.jsonc10
-rw-r--r--test/formatters/samplecode/denofmt-jsonc/out.jsonc19
-rw-r--r--test/formatters/samplecode/denofmt-jsx/in.jsx17
-rw-r--r--test/formatters/samplecode/denofmt-jsx/out.jsx16
l---------test/formatters/samplecode/denofmt-md/in.md1
-rw-r--r--test/formatters/samplecode/denofmt-md/out.md4
l---------test/formatters/samplecode/denofmt-ts/in.ts1
-rw-r--r--test/formatters/samplecode/denofmt-ts/out.ts6
-rw-r--r--test/formatters/samplecode/denofmt-tsx/in.tsx20
-rw-r--r--test/formatters/samplecode/denofmt-tsx/out.tsx19
l---------test/formatters/samplecode/denofmt/in.js1
l---------test/formatters/samplecode/denofmt/in.jsx1
l---------test/formatters/samplecode/denofmt/in.ts1
l---------test/formatters/samplecode/denofmt/in.tsx1
l---------test/formatters/samplecode/denofmt/out.js1
l---------test/formatters/samplecode/denofmt/out.jsx1
l---------test/formatters/samplecode/denofmt/out.ts1
l---------test/formatters/samplecode/denofmt/out.tsx1
32 files changed, 166 insertions, 0 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 8871d12..bdf604f 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -13,9 +13,12 @@ The format is based on [Keep a Changelog].
([#229])
* [`robotidy`](https://robotidy.readthedocs.io) for Robot Framework files
([#263]).
+* [denofmt](https://docs.deno.com/runtime/manual/tools/formatter) for
+ js, jsx, ts, tsx, json, jsonc, md files. ([#264])
[#229]: https://github.com/radian-software/apheleia/pull/229
[#263]: https://github.com/radian-software/apheleia/pull/263
+[#264]: https://github.com/radian-software/apheleia/pull/264
## 4.0 (released 2023-11-23)
### Breaking changes
diff --git a/apheleia-formatters.el b/apheleia-formatters.el
index 780da69..49ffd7d 100644
--- a/apheleia-formatters.el
+++ b/apheleia-formatters.el
@@ -47,6 +47,14 @@
(apheleia-formatters-indent
"--indent-with-tabs" "--indent-size"))
(dart-format . ("dart" "format"))
+ (denofmt . ("deno" "fmt" "-"))
+ (denofmt-js . ("deno" "fmt" "-" "--ext" "js"))
+ (denofmt-json . ("deno" "fmt" "-" "--ext" "json"))
+ (denofmt-jsonc . ("deno" "fmt" "-" "--ext" "jsonc"))
+ (denofmt-jsx . ("deno" "fmt" "-" "--ext" "jsx"))
+ (denofmt-md . ("deno" "fmt" "-" "--ext" "md"))
+ (denofmt-ts . ("deno" "fmt" "-" "--ext" "ts"))
+ (denofmt-tsx . ("deno" "fmt" "-" "--ext" "tsx"))
(elm-format . ("elm-format" "--yes" "--stdin"))
(fish-indent . ("fish_indent"))
(fourmolu . ("fourmolu"))
diff --git a/test/formatters/installers/denofmt-js.bash b/test/formatters/installers/denofmt-js.bash
new file mode 120000
index 0000000..5308b4b
--- /dev/null
+++ b/test/formatters/installers/denofmt-js.bash
@@ -0,0 +1 @@
+denofmt.bash \ No newline at end of file
diff --git a/test/formatters/installers/denofmt-json.bash b/test/formatters/installers/denofmt-json.bash
new file mode 120000
index 0000000..5308b4b
--- /dev/null
+++ b/test/formatters/installers/denofmt-json.bash
@@ -0,0 +1 @@
+denofmt.bash \ No newline at end of file
diff --git a/test/formatters/installers/denofmt-jsonc.bash b/test/formatters/installers/denofmt-jsonc.bash
new file mode 120000
index 0000000..5308b4b
--- /dev/null
+++ b/test/formatters/installers/denofmt-jsonc.bash
@@ -0,0 +1 @@
+denofmt.bash \ No newline at end of file
diff --git a/test/formatters/installers/denofmt-jsx.bash b/test/formatters/installers/denofmt-jsx.bash
new file mode 120000
index 0000000..5308b4b
--- /dev/null
+++ b/test/formatters/installers/denofmt-jsx.bash
@@ -0,0 +1 @@
+denofmt.bash \ No newline at end of file
diff --git a/test/formatters/installers/denofmt-md.bash b/test/formatters/installers/denofmt-md.bash
new file mode 120000
index 0000000..5308b4b
--- /dev/null
+++ b/test/formatters/installers/denofmt-md.bash
@@ -0,0 +1 @@
+denofmt.bash \ No newline at end of file
diff --git a/test/formatters/installers/denofmt-ts.bash b/test/formatters/installers/denofmt-ts.bash
new file mode 120000
index 0000000..5308b4b
--- /dev/null
+++ b/test/formatters/installers/denofmt-ts.bash
@@ -0,0 +1 @@
+denofmt.bash \ No newline at end of file
diff --git a/test/formatters/installers/denofmt-tsx.bash b/test/formatters/installers/denofmt-tsx.bash
new file mode 120000
index 0000000..5308b4b
--- /dev/null
+++ b/test/formatters/installers/denofmt-tsx.bash
@@ -0,0 +1 @@
+denofmt.bash \ No newline at end of file
diff --git a/test/formatters/installers/denofmt.bash b/test/formatters/installers/denofmt.bash
new file mode 100644
index 0000000..e78611b
--- /dev/null
+++ b/test/formatters/installers/denofmt.bash
@@ -0,0 +1 @@
+curl -fsSL https://deno.land/x/install/install.sh | sudo DENO_INSTALL=/usr/local sh
diff --git a/test/formatters/samplecode/denofmt-js/in.js b/test/formatters/samplecode/denofmt-js/in.js
new file mode 120000
index 0000000..da49303
--- /dev/null
+++ b/test/formatters/samplecode/denofmt-js/in.js
@@ -0,0 +1 @@
+../prettier-javascript/in.js \ No newline at end of file
diff --git a/test/formatters/samplecode/denofmt-js/out.js b/test/formatters/samplecode/denofmt-js/out.js
new file mode 100644
index 0000000..bfd7620
--- /dev/null
+++ b/test/formatters/samplecode/denofmt-js/out.js
@@ -0,0 +1,5 @@
+function HelloWorld(
+ { greeting = "hello", greeted = '"World"', silent = false, onMouseOver },
+) {
+ if (!greeting) return null;
+}
diff --git a/test/formatters/samplecode/denofmt-json/in.json b/test/formatters/samplecode/denofmt-json/in.json
new file mode 120000
index 0000000..599a1e2
--- /dev/null
+++ b/test/formatters/samplecode/denofmt-json/in.json
@@ -0,0 +1 @@
+../prettier-json/in.json \ No newline at end of file
diff --git a/test/formatters/samplecode/denofmt-json/out.json b/test/formatters/samplecode/denofmt-json/out.json
new file mode 100644
index 0000000..59bb3b4
--- /dev/null
+++ b/test/formatters/samplecode/denofmt-json/out.json
@@ -0,0 +1,19 @@
+{
+ "arrowParens": "always",
+ "bracketSpacing": true,
+ "embeddedLanguageFormatting": "auto",
+ "htmlWhitespaceSensitivity": "css",
+ "insertPragma": false,
+ "jsxBracketSameLine": false,
+ "jsxSingleQuote": false,
+ "printWidth": 80,
+ "proseWrap": "preserve",
+ "quoteProps": "as-needed",
+ "requirePragma": false,
+ "semi": true,
+ "singleQuote": false,
+ "tabWidth": 2,
+ "trailingComma": "es5",
+ "useTabs": false,
+ "vueIndentScriptAndStyle": false
+}
diff --git a/test/formatters/samplecode/denofmt-jsonc/in.jsonc b/test/formatters/samplecode/denofmt-jsonc/in.jsonc
new file mode 100644
index 0000000..8ce15bd
--- /dev/null
+++ b/test/formatters/samplecode/denofmt-jsonc/in.jsonc
@@ -0,0 +1,10 @@
+{"arrowParens": "always",// top comment
+ "bracketSpacing": true,"embeddedLanguageFormatting": "auto","htmlWhitespaceSensitivity": "css","insertPragma": false,"jsxBracketSameLine": false,"jsxSingleQuote": false,"printWidth": 80,// middle comment
+ "proseWrap": "preserve","quoteProps": "as-needed",
+ "requirePragma": false,
+ "semi": true,
+ "singleQuote": false,
+ "tabWidth": 2,
+ "trailingComma": "es5",
+ "useTabs": false,"vueIndentScriptAndStyle": false // bottom comment
+} \ No newline at end of file
diff --git a/test/formatters/samplecode/denofmt-jsonc/out.jsonc b/test/formatters/samplecode/denofmt-jsonc/out.jsonc
new file mode 100644
index 0000000..879665d
--- /dev/null
+++ b/test/formatters/samplecode/denofmt-jsonc/out.jsonc
@@ -0,0 +1,19 @@
+{
+ "arrowParens": "always", // top comment
+ "bracketSpacing": true,
+ "embeddedLanguageFormatting": "auto",
+ "htmlWhitespaceSensitivity": "css",
+ "insertPragma": false,
+ "jsxBracketSameLine": false,
+ "jsxSingleQuote": false,
+ "printWidth": 80, // middle comment
+ "proseWrap": "preserve",
+ "quoteProps": "as-needed",
+ "requirePragma": false,
+ "semi": true,
+ "singleQuote": false,
+ "tabWidth": 2,
+ "trailingComma": "es5",
+ "useTabs": false,
+ "vueIndentScriptAndStyle": false // bottom comment
+}
diff --git a/test/formatters/samplecode/denofmt-jsx/in.jsx b/test/formatters/samplecode/denofmt-jsx/in.jsx
new file mode 100644
index 0000000..1895e85
--- /dev/null
+++ b/test/formatters/samplecode/denofmt-jsx/in.jsx
@@ -0,0 +1,17 @@
+const Foo = ({name,
+ test}
+ ) => {
+ return <>
+ <h1>hello, {name}</h1>
+ <div>{test}</div>
+ </>
+;
+};
+
+const Bar = () => {
+ return (
+ <>
+ <Foo name="aaa" test="bbb" />
+ </>
+ )
+}
diff --git a/test/formatters/samplecode/denofmt-jsx/out.jsx b/test/formatters/samplecode/denofmt-jsx/out.jsx
new file mode 100644
index 0000000..9ce294f
--- /dev/null
+++ b/test/formatters/samplecode/denofmt-jsx/out.jsx
@@ -0,0 +1,16 @@
+const Foo = ({ name, test }) => {
+ return (
+ <>
+ <h1>hello, {name}</h1>
+ <div>{test}</div>
+ </>
+ );
+};
+
+const Bar = () => {
+ return (
+ <>
+ <Foo name="aaa" test="bbb" />
+ </>
+ );
+};
diff --git a/test/formatters/samplecode/denofmt-md/in.md b/test/formatters/samplecode/denofmt-md/in.md
new file mode 120000
index 0000000..99482b8
--- /dev/null
+++ b/test/formatters/samplecode/denofmt-md/in.md
@@ -0,0 +1 @@
+../prettier-markdown/in.md \ No newline at end of file
diff --git a/test/formatters/samplecode/denofmt-md/out.md b/test/formatters/samplecode/denofmt-md/out.md
new file mode 100644
index 0000000..4d08fcd
--- /dev/null
+++ b/test/formatters/samplecode/denofmt-md/out.md
@@ -0,0 +1,4 @@
+| col1 | col 2 |
+| ------ | ---------- |
+| nice | fits |
+| oh no! | it's ugly! |
diff --git a/test/formatters/samplecode/denofmt-ts/in.ts b/test/formatters/samplecode/denofmt-ts/in.ts
new file mode 120000
index 0000000..1b5f9d6
--- /dev/null
+++ b/test/formatters/samplecode/denofmt-ts/in.ts
@@ -0,0 +1 @@
+../prettier-typescript/in.ts \ No newline at end of file
diff --git a/test/formatters/samplecode/denofmt-ts/out.ts b/test/formatters/samplecode/denofmt-ts/out.ts
new file mode 100644
index 0000000..143b5a7
--- /dev/null
+++ b/test/formatters/samplecode/denofmt-ts/out.ts
@@ -0,0 +1,6 @@
+interface GreetingSettings {
+ greeting: string;
+ duration?: number;
+ color?: string;
+}
+declare function greet(setting: GreetingSettings): void;
diff --git a/test/formatters/samplecode/denofmt-tsx/in.tsx b/test/formatters/samplecode/denofmt-tsx/in.tsx
new file mode 100644
index 0000000..2412779
--- /dev/null
+++ b/test/formatters/samplecode/denofmt-tsx/in.tsx
@@ -0,0 +1,20 @@
+const Foo: FooComponent = ({
+name: string,
+ test: number}
+ ) => {
+ return <>
+ <h1>hello, {name}</h1>
+ <div>{test}</div>
+ </>
+;
+};
+
+const Bar
+: BarComponent = ()=> {
+ return (
+ <>
+ <Foo name="aaa"
+test={1} />
+ </>
+ )
+}
diff --git a/test/formatters/samplecode/denofmt-tsx/out.tsx b/test/formatters/samplecode/denofmt-tsx/out.tsx
new file mode 100644
index 0000000..8825eb5
--- /dev/null
+++ b/test/formatters/samplecode/denofmt-tsx/out.tsx
@@ -0,0 +1,19 @@
+const Foo: FooComponent = ({
+ name: string,
+ test: number,
+}) => {
+ return (
+ <>
+ <h1>hello, {name}</h1>
+ <div>{test}</div>
+ </>
+ );
+};
+
+const Bar: BarComponent = () => {
+ return (
+ <>
+ <Foo name="aaa" test={1} />
+ </>
+ );
+};
diff --git a/test/formatters/samplecode/denofmt/in.js b/test/formatters/samplecode/denofmt/in.js
new file mode 120000
index 0000000..0c434a4
--- /dev/null
+++ b/test/formatters/samplecode/denofmt/in.js
@@ -0,0 +1 @@
+../denofmt-js/in.js \ No newline at end of file
diff --git a/test/formatters/samplecode/denofmt/in.jsx b/test/formatters/samplecode/denofmt/in.jsx
new file mode 120000
index 0000000..cabbf0f
--- /dev/null
+++ b/test/formatters/samplecode/denofmt/in.jsx
@@ -0,0 +1 @@
+../denofmt-jsx/in.jsx \ No newline at end of file
diff --git a/test/formatters/samplecode/denofmt/in.ts b/test/formatters/samplecode/denofmt/in.ts
new file mode 120000
index 0000000..559c4ec
--- /dev/null
+++ b/test/formatters/samplecode/denofmt/in.ts
@@ -0,0 +1 @@
+../denofmt-ts/in.ts \ No newline at end of file
diff --git a/test/formatters/samplecode/denofmt/in.tsx b/test/formatters/samplecode/denofmt/in.tsx
new file mode 120000
index 0000000..ce378b5
--- /dev/null
+++ b/test/formatters/samplecode/denofmt/in.tsx
@@ -0,0 +1 @@
+../denofmt-tsx/in.tsx \ No newline at end of file
diff --git a/test/formatters/samplecode/denofmt/out.js b/test/formatters/samplecode/denofmt/out.js
new file mode 120000
index 0000000..591eac8
--- /dev/null
+++ b/test/formatters/samplecode/denofmt/out.js
@@ -0,0 +1 @@
+../denofmt-js/out.js \ No newline at end of file
diff --git a/test/formatters/samplecode/denofmt/out.jsx b/test/formatters/samplecode/denofmt/out.jsx
new file mode 120000
index 0000000..531e738
--- /dev/null
+++ b/test/formatters/samplecode/denofmt/out.jsx
@@ -0,0 +1 @@
+../denofmt-jsx/out.jsx \ No newline at end of file
diff --git a/test/formatters/samplecode/denofmt/out.ts b/test/formatters/samplecode/denofmt/out.ts
new file mode 120000
index 0000000..82e64da
--- /dev/null
+++ b/test/formatters/samplecode/denofmt/out.ts
@@ -0,0 +1 @@
+../denofmt-ts/out.ts \ No newline at end of file
diff --git a/test/formatters/samplecode/denofmt/out.tsx b/test/formatters/samplecode/denofmt/out.tsx
new file mode 120000
index 0000000..7089154
--- /dev/null
+++ b/test/formatters/samplecode/denofmt/out.tsx
@@ -0,0 +1 @@
+../denofmt-tsx/out.tsx \ No newline at end of file