You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 4-6.RSVP
Socket
Book a DemoInstallSign in
Socket

prettier-plugin-svelte

Package Overview
Dependencies
Maintainers
3
Versions
66
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

prettier-plugin-svelte

Svelte plugin for prettier

3.4.0
latest
Source
npmnpm
Version published
Weekly downloads
484K
-21.32%
Maintainers
3
Weekly downloads
 
Created

What is prettier-plugin-svelte?

The prettier-plugin-svelte npm package is a plugin for Prettier that adds support for formatting Svelte files. It ensures that your Svelte code is consistently styled according to Prettier's rules, making it easier to maintain and read.

What are prettier-plugin-svelte's main functionalities?

Format Svelte Files

This feature allows you to format Svelte files using Prettier. By including the plugin in your Prettier configuration, you can ensure that your Svelte code is consistently styled.

/* .prettierrc */
{
  "plugins": ["prettier-plugin-svelte"]
}

/* Example Svelte file before formatting */
<script>
  let count = 0;
  function increment() {
    count += 1;
  }
</script>

<style>
  h1 {
    color: red;
  }
</style>

<h1 on:click={increment}>Count: {count}</h1>

/* Example Svelte file after formatting */
<script>
  let count = 0;
  function increment() {
    count += 1;
  }
</script>

<style>
  h1 {
    color: red;
  }
</style>

<h1 on:click={increment}>Count: {count}</h1>

Integration with Prettier CLI

You can use the Prettier CLI to format all Svelte files in your project. This command will recursively find and format all .svelte files in the src directory.

/* Command to format Svelte files using Prettier CLI */
npx prettier --write "src/**/*.svelte"

Support for Svelte-specific Syntax

The plugin supports Svelte-specific syntax such as reactive statements, bindings, and event handlers, ensuring that these are also formatted correctly.

/* Example Svelte file with Svelte-specific syntax */
<script>
  export let name = 'world';
</script>

<style>
  p {
    font-size: 1.5em;
  }
</style>

<p>Hello {name}!</p>

Other packages similar to prettier-plugin-svelte

Keywords

prettier

FAQs

Package last updated on 14 May 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts