UNPKG

2.21 kBMarkdownView Raw
1<p align="center">
2 <img src="https://raw.githubusercontent.com/rx-ts/prettier/master/assets/sh.png" height="100" />
3</p>
4
5# prettier-plugin-sh ![npm bundle size](https://img.shields.io/bundlephobia/min/prettier-plugin-sh) ![npm bundle size](https://img.shields.io/bundlephobia/minzip/prettier-plugin-sh)
6
7> An opinionated `shellscript、Dockerfile、properties、gitignore、dotenv、hosts、jvmoptions...` formatter plugin for [Prettier][]
8
9Prettier is an opinionated code formatter. It enforces a consistent style by parsing your code and re-printing, taking various rules into account.
10
11This plugin adds support for a lot of files through [mvdan-sh][].
12
13## Notice
14
15This plugin is still under development, its printer just wraps [mvdan-sh][]'s default printer.
16Of course it should just work, but may not match [prettier][]'s format sometimes.
17
18## Requirements
19
20`prettier-plugin-sh` is an evergreen module. 🌲 This module requires an [LTS](https://github.com/nodejs/Release) Node version (v12.0.0+).
21
22## Install
23
24Using npm:
25
26```sh
27# npm
28npm i -D prettier prettier-plugin-sh
29
30# yarn
31yarn add -D prettier prettier-plugin-sh
32```
33
34## Usage
35
36Once installed, [Prettier plugins](https://prettier.io/docs/en/plugins.html) should be automatically recognized by Prettier. To use this plugin, confirm that it's installed and run Prettier using your preferred method. For example:
37
38```sh
39# npx
40npx prettier --write script.sh
41
42# yarn
43yarn prettier --write script.sh
44```
45
46## Parser Options
47
48```ts
49interface ShOptions {
50 // parser
51 keepComments: boolean // default `true`
52 stopAt: string
53 variant: LangVariant
54
55 // printer
56 indent: number
57 binaryNextLine: boolean // default `true`
58 switchCaseIndent: boolean
59 spaceRedirects: boolean
60 keepPadding: boolean
61 minify: boolean
62 functionNextLine: boolean
63}
64```
65
66More details on [godoc](https://godoc.org/mvdan.cc/sh/syntax#NewParser)
67
68## Changelog
69
70Detailed changes for each release are documented in [CHANGELOG.md](./CHANGELOG.md).
71
72## License
73
74[MIT][] © [JounQin][]@[1stG.me][]
75
76[1stg.me]: https://www.1stg.me
77[jounqin]: https://GitHub.com/JounQin
78[mit]: http://opensource.org/licenses/MIT
79[mvdan-sh]: https://github.com/mvdan/sh
80[prettier]: https://prettier.io