Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

prettier-plugin-svelte

Package Overview
Dependencies
Maintainers
2
Versions
60
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

  • 2.1.1
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
403K
increased by0.48%
Maintainers
2
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

FAQs

Package last updated on 21 Jan 2021

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc