intial
This commit is contained in:
21
node_modules/prettier-plugin-svelte/LICENSE
generated
vendored
Normal file
21
node_modules/prettier-plugin-svelte/LICENSE
generated
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2019 [Contributors](https://github.com/sveltejs/prettier-plugin-svelte/graphs/contributors)
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
192
node_modules/prettier-plugin-svelte/README.md
generated
vendored
Normal file
192
node_modules/prettier-plugin-svelte/README.md
generated
vendored
Normal file
@@ -0,0 +1,192 @@
|
||||
> This documentation is for `prettier-plugin-svelte` version 4 which only works with Svelte 5. See [this branch](https://github.com/sveltejs/prettier-plugin-svelte/tree/version-3) for documentation of version 3 which is compatible with Svelte 4.
|
||||
|
||||
# Prettier for Svelte components
|
||||
|
||||
Format your Svelte components using Prettier.
|
||||
|
||||
## Features
|
||||
|
||||
- Format your HTML, CSS, and JavaScript using prettier
|
||||
- Format Svelte syntax, e.g. each loops, if statements, await blocks, etc.
|
||||
- Format the JavaScript expressions embedded in the Svelte syntax
|
||||
- e.g. expressions inside of `{}`, event bindings `onclick={...}`, and more
|
||||
|
||||
## VS Code Extension
|
||||
|
||||
This plugin is bundled in the [Svelte for VS Code](https://marketplace.visualstudio.com/items?itemName=svelte.svelte-vscode) extension. If you only format through the editor, you therefore don't need to do anything in addition.
|
||||
|
||||
The extension lets you define options through extension-specific configuration. These settings are ignored however if there's any configuration file (`.prettierrc` for example) present.
|
||||
|
||||
## Prettier Plugin
|
||||
|
||||
Installing the plugin as a package allows:
|
||||
|
||||
- customizing the formatting behavior
|
||||
- using the command line to format
|
||||
- using a different IDE
|
||||
- using the official VS Code [Prettier](https://marketplace.visualstudio.com/items?itemName=esbenp.prettier-vscode) extension to format Svelte files
|
||||
|
||||
### Compatibility
|
||||
|
||||
- `prettier-plugin-svelte@4` only works with `prettier@3` and Svelte 5+
|
||||
- `prettier-plugin-svelte@3` only works with `prettier@3`
|
||||
- `prettier-plugin-svelte@2` only works with `prettier@2`
|
||||
|
||||
### Setup
|
||||
|
||||
Install Prettier and the plugin as a dev dependency:
|
||||
|
||||
```bash
|
||||
npm i --save-dev prettier-plugin-svelte prettier
|
||||
```
|
||||
|
||||
Then create a `.prettierrc` [configuration file](https://prettier.io/docs/en/configuration.html):
|
||||
|
||||
```jsonc
|
||||
// .prettierrc
|
||||
{
|
||||
// ..
|
||||
"plugins": ["prettier-plugin-svelte"],
|
||||
"overrides": [{ "files": "*.svelte", "options": { "parser": "svelte" } }],
|
||||
}
|
||||
```
|
||||
|
||||
If you want to customize some formatting behavior, see section [Options](#options).
|
||||
|
||||
### CLI Usage
|
||||
|
||||
Format your code using the Prettier CLI.
|
||||
|
||||
```bash
|
||||
npx prettier --write .
|
||||
```
|
||||
|
||||
As part of your scripts in `package.json`:
|
||||
|
||||
```jsonc
|
||||
// package.json
|
||||
{
|
||||
// ..
|
||||
"scripts": {
|
||||
"format": "prettier --write .",
|
||||
},
|
||||
}
|
||||
```
|
||||
|
||||
If you want to customize some formatting behavior, see section [Options](#options).
|
||||
|
||||
## Options
|
||||
|
||||
`Configurations are optional`
|
||||
|
||||
Make a `.prettierrc` file in your project directory and add your preferred [options](https://prettier.io/docs/en/options.html) to [configure Prettier](https://prettier.io/docs/en/configuration.html). When using Prettier through the CLI, you can also pass options through CLI flags, but a `.prettierrc` file is recommended.
|
||||
|
||||
### Svelte Sort Order
|
||||
|
||||
Sort order for `svelte:options`, scripts, markup, and styles.
|
||||
|
||||
Format: join the keywords `options`, `scripts`, `markup`, `styles` with a `-` in the order you want; or `none` if you don't want Prettier to reorder anything.
|
||||
|
||||
| Default | CLI Override | API Override |
|
||||
| ------------------------------- | ------------------------------ | --------------------------- |
|
||||
| `options-scripts-markup-styles` | `--svelte-sort-order <string>` | `svelteSortOrder: <string>` |
|
||||
|
||||
> The `options` order option only exists since version 2. If you use version 1 of `prettier-plugin-svelte`, omit that option (so for example only write `scripts-markup-styles`).
|
||||
|
||||
### Svelte Allow Shorthand
|
||||
|
||||
Option to enable/disable component attribute shorthand if attribute name and expression are same.
|
||||
|
||||
Example:
|
||||
|
||||
<!-- prettier-ignore -->
|
||||
```html
|
||||
<!-- allowShorthand: true -->
|
||||
<input type="text" {value} />
|
||||
|
||||
<!-- allowShorthand: false -->
|
||||
<input type="text" value={value} />
|
||||
```
|
||||
|
||||
| Default | CLI Override | API Override |
|
||||
| ------- | --------------------------------- | ------------------------------ |
|
||||
| `true` | `--svelte-allow-shorthand <bool>` | `svelteAllowShorthand: <bool>` |
|
||||
|
||||
### Svelte Indent Script And Style
|
||||
|
||||
Whether or not to indent the code inside `<script>` and `<style>` tags in Svelte files. This saves an indentation level, but might break code folding in your editor.
|
||||
|
||||
| Default | CLI Override | API Override |
|
||||
| ------- | ----------------------------------------- | ------------------------------------ |
|
||||
| `true` | `--svelte-indent-script-and-style <bool>` | `svelteIndentScriptAndStyle: <bool>` |
|
||||
|
||||
### `.prettierrc` example
|
||||
|
||||
```json
|
||||
{
|
||||
"svelteSortOrder": "options-styles-scripts-markup",
|
||||
"svelteAllowShorthand": false,
|
||||
"svelteIndentScriptAndStyle": false
|
||||
}
|
||||
```
|
||||
|
||||
## Usage with Tailwind Prettier Plugin
|
||||
|
||||
- VS Code Extension: Use it as the default formatter for Svelte files
|
||||
- Prettier Plugin: Load the Tailwind plugin in the end - [Tailwind docs](https://github.com/tailwindlabs/prettier-plugin-tailwindcss#compatibility-with-other-prettier-plugins)
|
||||
|
||||
```jsonc
|
||||
// .prettierrc
|
||||
{
|
||||
// ..
|
||||
"plugins": [
|
||||
"prettier-plugin-svelte",
|
||||
"prettier-plugin-tailwindcss", // MUST come last
|
||||
],
|
||||
}
|
||||
```
|
||||
|
||||
Since we are using configuration overrides to handle svelte files, you might also have to configure the [prettier.documentselectors](https://github.com/prettier/prettier-vscode#prettierdocumentselectors) in your VS Code `settings.json`, to tell Prettier extension to handle svelte files, like this:
|
||||
|
||||
```jsonc
|
||||
// settings.json
|
||||
{
|
||||
// ..
|
||||
"prettier.documentSelectors": ["**/*.svelte"],
|
||||
}
|
||||
```
|
||||
|
||||
## Usage in the browser
|
||||
|
||||
Usage in the browser is semi-supported. You can import the plugin from `prettier-plugin-svelte/browser` to get a version that depends on `prettier/standalone` and therefore doesn't use any node APIs. What isn't supported in a good way yet is using this without a build step - you still need a bundler like Vite to build everything together as one self-contained package in advance.
|
||||
|
||||
## Migration
|
||||
|
||||
> For migration to `prettier-plugin-svelte@3` [see here](https://github.com/sveltejs/prettier-plugin-svelte/tree/version-3?tab=readme-ov-file#migration).
|
||||
|
||||
- Upgrade to Svelte 5 before upgrading to `prettier-plugin-svelte@4`, as it doesn't support older Svelte versions.
|
||||
- `svelteStrictMode` option has been removed. Attributes are now never quoted, because this will mean "stringify this attribute value" in a future Svelte version.
|
||||
- `svelteBracketNewLine` option has been removed. Use Prettier's [bracketSameLine](https://prettier.io/docs/en/options.html#bracket-line) option instead.
|
||||
|
||||
## FAQ
|
||||
|
||||
### Why is the closing or opening tag (`>` or `<`) hugging the inner tag or text?
|
||||
|
||||
If you are wondering why this code
|
||||
|
||||
<!-- prettier-ignore -->
|
||||
```html
|
||||
<span><span>assume very long text</span></span>
|
||||
```
|
||||
|
||||
becomes this
|
||||
|
||||
<!-- prettier-ignore -->
|
||||
```html
|
||||
<span
|
||||
><span>assume very long text</span
|
||||
></span
|
||||
>
|
||||
```
|
||||
|
||||
it's because of whitespace sensitivity. For inline elements (`span`, `a`, etc) it makes a difference when rendered if there's a space (or newline) between them. Since we don't know if your slot inside your Svelte component is surrounded by inline elements, Svelte components are treated as such, too. You can adjust this whitespace sensitivity through [this setting](https://prettier.io/docs/en/options.html#html-whitespace-sensitivity). You can read more about HTML whitespace sensitivity [here](https://prettier.io/blog/2018/11/07/1.15.0.html#whitespace-sensitive-formatting).
|
||||
2643
node_modules/prettier-plugin-svelte/browser.js
generated
vendored
Normal file
2643
node_modules/prettier-plugin-svelte/browser.js
generated
vendored
Normal file
File diff suppressed because it is too large
Load Diff
37
node_modules/prettier-plugin-svelte/index.d.ts
generated
vendored
Normal file
37
node_modules/prettier-plugin-svelte/index.d.ts
generated
vendored
Normal file
@@ -0,0 +1,37 @@
|
||||
import { Config } from 'prettier';
|
||||
|
||||
export interface PluginConfig {
|
||||
svelteSortOrder?: SortOrder;
|
||||
svelteAllowShorthand?: boolean;
|
||||
svelteIndentScriptAndStyle?: boolean;
|
||||
svelte5CompilerPath?: string;
|
||||
}
|
||||
|
||||
export type PrettierConfig = PluginConfig & Config;
|
||||
|
||||
type SortOrder =
|
||||
| 'options-scripts-markup-styles'
|
||||
| 'options-scripts-styles-markup'
|
||||
| 'options-markup-styles-scripts'
|
||||
| 'options-markup-scripts-styles'
|
||||
| 'options-styles-markup-scripts'
|
||||
| 'options-styles-scripts-markup'
|
||||
| 'scripts-options-markup-styles'
|
||||
| 'scripts-options-styles-markup'
|
||||
| 'markup-options-styles-scripts'
|
||||
| 'markup-options-scripts-styles'
|
||||
| 'styles-options-markup-scripts'
|
||||
| 'styles-options-scripts-markup'
|
||||
| 'scripts-markup-options-styles'
|
||||
| 'scripts-styles-options-markup'
|
||||
| 'markup-styles-options-scripts'
|
||||
| 'markup-scripts-options-styles'
|
||||
| 'styles-markup-options-scripts'
|
||||
| 'styles-scripts-options-markup'
|
||||
| 'scripts-markup-styles-options'
|
||||
| 'scripts-styles-markup-options'
|
||||
| 'markup-styles-scripts-options'
|
||||
| 'markup-scripts-styles-options'
|
||||
| 'styles-markup-scripts-options'
|
||||
| 'styles-scripts-markup-options'
|
||||
| 'none';
|
||||
68
node_modules/prettier-plugin-svelte/package.json
generated
vendored
Normal file
68
node_modules/prettier-plugin-svelte/package.json
generated
vendored
Normal file
@@ -0,0 +1,68 @@
|
||||
{
|
||||
"name": "prettier-plugin-svelte",
|
||||
"version": "4.1.1",
|
||||
"description": "Svelte plugin for prettier",
|
||||
"main": "plugin.js",
|
||||
"files": [
|
||||
"plugin.js",
|
||||
"plugin.js.map",
|
||||
"browser.js",
|
||||
"index.d.ts"
|
||||
],
|
||||
"types": "./index.d.ts",
|
||||
"exports": {
|
||||
".": {
|
||||
"types": "./index.d.ts",
|
||||
"default": "./plugin.js"
|
||||
},
|
||||
"./browser": "./browser.js",
|
||||
"./package.json": "./package.json"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/sveltejs/prettier-plugin-svelte.git"
|
||||
},
|
||||
"keywords": [
|
||||
"prettier",
|
||||
"svelte"
|
||||
],
|
||||
"author": "James Birtles <jameshbirtles@gmail.com>",
|
||||
"license": "MIT",
|
||||
"bugs": {
|
||||
"url": "https://github.com/sveltejs/prettier-plugin-svelte/issues"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=20"
|
||||
},
|
||||
"homepage": "https://github.com/sveltejs/prettier-plugin-svelte#readme",
|
||||
"devDependencies": {
|
||||
"@changesets/cli": "^2.29.8",
|
||||
"@svitejs/changesets-changelog-github-compact": "^1.1.0",
|
||||
"@rollup/plugin-alias": "^5.1.0",
|
||||
"@rollup/plugin-commonjs": "14.0.0",
|
||||
"@rollup/plugin-node-resolve": "11.0.1",
|
||||
"@types/node": "^20",
|
||||
"ava": "3.15.0",
|
||||
"prettier": "^3.8.0",
|
||||
"rollup": "2.36.0",
|
||||
"rollup-plugin-typescript": "1.0.1",
|
||||
"svelte": "^5.56.0",
|
||||
"ts-node": "^10.1.1",
|
||||
"tslib": "^2.6.0",
|
||||
"typescript": "5.1.3"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"prettier": "^3.0.0",
|
||||
"svelte": "^5.0.0"
|
||||
},
|
||||
"scripts": {
|
||||
"build": "rollup -c",
|
||||
"check": "tsc --noEmit",
|
||||
"check:watch": "tsc --noEmit --watch",
|
||||
"lint": "prettier --check .",
|
||||
"format": "prettier --write .",
|
||||
"test": "ava",
|
||||
"changeset:version": "changeset version && git add --all",
|
||||
"changeset:publish": "changeset publish"
|
||||
}
|
||||
}
|
||||
2671
node_modules/prettier-plugin-svelte/plugin.js
generated
vendored
Normal file
2671
node_modules/prettier-plugin-svelte/plugin.js
generated
vendored
Normal file
File diff suppressed because it is too large
Load Diff
1
node_modules/prettier-plugin-svelte/plugin.js.map
generated
vendored
Normal file
1
node_modules/prettier-plugin-svelte/plugin.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user