Pretter svelte-mode (#178)

Adds support for `svelte-mode` using prettier.

Co-authored-by: Radon Rosborough <radon@intuitiveexplanations.com>
This commit is contained in:
Jay Barra 2023-03-23 17:00:51 -04:00 committed by GitHub
parent 782db66457
commit 43ffed7890
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 34 additions and 0 deletions

View file

@ -4,6 +4,8 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog].
## Unreleased
### Enhancements
* Prettier is now enabled in `svelte-mode`.
### Bugs fixed
* `ktlint` would emit log messages into its stdout when formatting,
and these would get spliced into the source file. This has been fixed

View file

@ -54,6 +54,8 @@
. (npx "prettier" "--stdin-filepath" filepath "--parser=ruby"))
(prettier-scss
. (npx "prettier" "--stdin-filepath" filepath "--parser=scss"))
(prettier-svelte
. (npx "prettier" "--stdin-filepath" filepath "--parser=svelte"))
(prettier-typescript
. (npx "prettier" "--stdin-filepath" filepath "--parser=typescript"))
(prettier-yaml
@ -178,6 +180,7 @@ rather than using this system."
(rust-mode . rustfmt)
(rust-ts-mode . rustfmt)
(scss-mode . prettier-scss)
(svelte-mode . prettier-svelte)
(terraform-mode . terraform)
(TeX-latex-mode . latexindent)
(TeX-mode . latexindent)

View file

@ -0,0 +1 @@
npm install -g prettier-plugin-svelte prettier

View file

@ -0,0 +1,9 @@
<script> let attrName = "myattr"; let title = "title"; const myFunc = () => {title = "updated title";}; </script>
<div class="foo">
<ul class={myattr}>
<li><a href="/">Home</a></li>
</ul>
</div>
<style>
.foo { background: #ababab; }
</style>

View file

@ -0,0 +1,19 @@
<script>
let attrName = "myattr";
let title = "title";
const myFunc = () => {
title = "updated title";
};
</script>
<div class="foo">
<ul class={myattr}>
<li><a href="/">Home</a></li>
</ul>
</div>
<style>
.foo {
background: #ababab;
}
</style>