From 30b19fa7b3841bb9b811e2ecdcd3782248052ae8 Mon Sep 17 00:00:00 2001 From: Radon Rosborough Date: Sun, 12 Jan 2025 22:50:10 -0800 Subject: [PATCH 1/2] [#336] Fix broken link (#340) Close https://github.com/radian-software/apheleia/issues/336 --- Makefile | 2 ++ README.md | 2 +- apheleia-rcs.el | 6 +++++- 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 8560a77..9bc2998 100644 --- a/Makefile +++ b/Makefile @@ -49,6 +49,8 @@ checkdoc: ## Check for missing or poorly formatted docstrings --eval "(or (fboundp 'checkdoc-file) (kill-emacs))" \ --eval "(setq sentence-end-double-space nil)" \ --eval "(checkdoc-file \"$$file\")" 2>&1 \ + | (grep -v "Warning (emacs): \\?$$" ||:) \ + | (grep -v "Some lines are over 80 columns wide" ||:) \ | grep . && exit 1 || true ;\ done diff --git a/README.md b/README.md index 7610325..d3aeae1 100644 --- a/README.md +++ b/README.md @@ -28,7 +28,7 @@ The approach is as follows: has finished running, check if the buffer has been modified since it started; only apply the changes if not. 2. After running the code formatter, generate an [RCS - patch](https://tools.ietf.org/doc/tcllib/html/rcs.html#section4) + patch](https://web.archive.org/web/20220527003730/https://tools.ietf.org/doc/tcllib/html/rcs.html#section4) showing the changes and then apply it to the buffer. This prevents changes elsewhere in the buffer from moving point. If a patch region happens to include point, then use a [dynamic programming diff --git a/apheleia-rcs.el b/apheleia-rcs.el index e462921..2fcf79f 100644 --- a/apheleia-rcs.el +++ b/apheleia-rcs.el @@ -25,7 +25,7 @@ the following keys: - `lines': number of lines to be inserted or removed - `text': the string to be inserted, only for `addition' -See +See for documentation on the RCS patch format." (save-excursion (goto-char (point-min)) @@ -206,3 +206,7 @@ contains the patch." (provide 'apheleia-rcs) ;;; apheleia-rcs.el ends here + +;; Local Variables: +;; byte-compile-docstring-max-column: 160 +;; End: From fa50cb3a3c7cb8f2b4216760c05f8a885a3ce906 Mon Sep 17 00:00:00 2001 From: Daniel Perez Alvarez Date: Sat, 18 Jan 2025 11:08:20 -0800 Subject: [PATCH 2/2] feat: add biome formatter (#339) See https://biomejs.dev/ Alternative formatter to `prettier` closes https://github.com/radian-software/apheleia/issues/323 --- CHANGELOG.md | 6 ++++++ apheleia-formatters.el | 3 ++- test/formatters/installers/biome.bash | 1 + test/formatters/samplecode/biome/in.css | 13 +++++++++++++ test/formatters/samplecode/biome/in.graphql | 1 + test/formatters/samplecode/biome/in.js | 4 ++++ test/formatters/samplecode/biome/in.json | 1 + test/formatters/samplecode/biome/in.ts | 1 + test/formatters/samplecode/biome/out.css | 6 ++++++ test/formatters/samplecode/biome/out.graphql | 6 ++++++ test/formatters/samplecode/biome/out.js | 10 ++++++++++ test/formatters/samplecode/biome/out.json | 19 +++++++++++++++++++ test/formatters/samplecode/biome/out.ts | 6 ++++++ 13 files changed, 76 insertions(+), 1 deletion(-) create mode 100644 test/formatters/installers/biome.bash create mode 100644 test/formatters/samplecode/biome/in.css create mode 100644 test/formatters/samplecode/biome/in.graphql create mode 100644 test/formatters/samplecode/biome/in.js create mode 100644 test/formatters/samplecode/biome/in.json create mode 100644 test/formatters/samplecode/biome/in.ts create mode 100644 test/formatters/samplecode/biome/out.css create mode 100644 test/formatters/samplecode/biome/out.graphql create mode 100644 test/formatters/samplecode/biome/out.js create mode 100644 test/formatters/samplecode/biome/out.json create mode 100644 test/formatters/samplecode/biome/out.ts diff --git a/CHANGELOG.md b/CHANGELOG.md index cb03f72..3297592 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,12 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog]. +## Unreleased +### Formatters +* `biome` ([#339]). + +[#339]: https://github.com/radian-software/apheleia/pull/339 + ## 4.3 (released 2024-11-12) ### Features * New user option `apheleia-skip-functions`, like diff --git a/apheleia-formatters.el b/apheleia-formatters.el index bef7aa0..ba3aad1 100644 --- a/apheleia-formatters.el +++ b/apheleia-formatters.el @@ -35,6 +35,7 @@ "-")) (brittany . ("brittany")) (buildifier . ("buildifier")) + (biome . ("apheleia-npx" "biome" "format" "--stdin-file-path" filepath)) (caddyfmt . ("caddy" "fmt" "-")) (clang-format . ("clang-format" "-assume-filename" @@ -1177,7 +1178,7 @@ For more implementation detail, see (setq-local indent-line-function (buffer-local-value 'indent-line-function buffer)) (setq-local lisp-indent-function - (buffer-local-value 'lisp-indent-function buffer)) + (buffer-local-value 'lisp-indent-function buffer)) (setq-local indent-tabs-mode (buffer-local-value 'indent-tabs-mode buffer)) (goto-char (point-min)) diff --git a/test/formatters/installers/biome.bash b/test/formatters/installers/biome.bash new file mode 100644 index 0000000..56b6e1b --- /dev/null +++ b/test/formatters/installers/biome.bash @@ -0,0 +1 @@ +npm install -g @biomejs/biome diff --git a/test/formatters/samplecode/biome/in.css b/test/formatters/samplecode/biome/in.css new file mode 100644 index 0000000..55d5d36 --- /dev/null +++ b/test/formatters/samplecode/biome/in.css @@ -0,0 +1,13 @@ + body + +{ + padding-left : 11em; +font-family + : Georgia, + + "Times New Roman", + Times, serif; + color: purple; + background-color: + #d8da3d + } diff --git a/test/formatters/samplecode/biome/in.graphql b/test/formatters/samplecode/biome/in.graphql new file mode 100644 index 0000000..72fc73e --- /dev/null +++ b/test/formatters/samplecode/biome/in.graphql @@ -0,0 +1 @@ +{human(id: "1000") {name height(unit: FOOT)}} diff --git a/test/formatters/samplecode/biome/in.js b/test/formatters/samplecode/biome/in.js new file mode 100644 index 0000000..fd56713 --- /dev/null +++ b/test/formatters/samplecode/biome/in.js @@ -0,0 +1,4 @@ +function HelloWorld({greeting = "hello", greeted = '"World"', silent = false, onMouseOver,}) { + + if(!greeting){return null}; + } diff --git a/test/formatters/samplecode/biome/in.json b/test/formatters/samplecode/biome/in.json new file mode 100644 index 0000000..28dc75f --- /dev/null +++ b/test/formatters/samplecode/biome/in.json @@ -0,0 +1 @@ +{"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/biome/in.ts b/test/formatters/samplecode/biome/in.ts new file mode 100644 index 0000000..c75d40f --- /dev/null +++ b/test/formatters/samplecode/biome/in.ts @@ -0,0 +1 @@ +interface GreetingSettings{greeting: string; duration?: number; color?: string;}declare function greet(setting: GreetingSettings): void; diff --git a/test/formatters/samplecode/biome/out.css b/test/formatters/samplecode/biome/out.css new file mode 100644 index 0000000..87717b9 --- /dev/null +++ b/test/formatters/samplecode/biome/out.css @@ -0,0 +1,6 @@ +body { + padding-left: 11em; + font-family: Georgia, "Times New Roman", Times, serif; + color: purple; + background-color: #d8da3d; +} diff --git a/test/formatters/samplecode/biome/out.graphql b/test/formatters/samplecode/biome/out.graphql new file mode 100644 index 0000000..89828da --- /dev/null +++ b/test/formatters/samplecode/biome/out.graphql @@ -0,0 +1,6 @@ +{ + human(id: "1000") { + name + height(unit: FOOT) + } +} diff --git a/test/formatters/samplecode/biome/out.js b/test/formatters/samplecode/biome/out.js new file mode 100644 index 0000000..1486b51 --- /dev/null +++ b/test/formatters/samplecode/biome/out.js @@ -0,0 +1,10 @@ +function HelloWorld({ + greeting = "hello", + greeted = '"World"', + silent = false, + onMouseOver, +}) { + if (!greeting) { + return null; + } +} diff --git a/test/formatters/samplecode/biome/out.json b/test/formatters/samplecode/biome/out.json new file mode 100644 index 0000000..86787f9 --- /dev/null +++ b/test/formatters/samplecode/biome/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/biome/out.ts b/test/formatters/samplecode/biome/out.ts new file mode 100644 index 0000000..b97c21b --- /dev/null +++ b/test/formatters/samplecode/biome/out.ts @@ -0,0 +1,6 @@ +interface GreetingSettings { + greeting: string; + duration?: number; + color?: string; +} +declare function greet(setting: GreetingSettings): void;