prettier-config-sexy-mode
v1.1.4
Published
Simplifies configuring Prettier by bundling plugins and configuring them in a single shareable configuration
Downloads
38
Maintainers
Readme
Simplifies configuring Prettier by bundling plugins and configuring them in a single shareable configuration
Table of Contents
Overview
Prettier is the defacto standard for formatting JavaScript, TypeScript, JSON, and YML. It rarely, if ever, causes any issues and it makes keeping your code base neater much easier. On top of that, through the use of plugins, you can also use Prettier to format PHP, Pug, Ruby, XML, Go HTML templates, .ini
files, Java, .properties
files, shell scripts, Solidity files, and more (listed in the Plugins section below). This configuration includes all known, well-tested Prettier plugins as well as prettier-plugin-package-perfection which is arguably the ultimate formatter for package.json
files.
Requirements
If you are simply including this library in your project, all you need is a recent version of Node.js. Node.js >14.18.0 is sometimes required and is the only version range we actively support. Albeit, it is highly probable that lower versions will work as well depending on the requirements that this project imports.
Developer Requirements
The following versions of Node.js and Python are required for development:
Other versions may work, but only the above versions are supported. Most development dependencies are installed automatically by our Taskfile.yml
set-up (even Node.js and Python). Run bash start.sh
to install Bodega (an improved fork of go-task) and run the initialization sequence. The taskfiles will automatically install dependencies as they are needed, based on what development tasks you are running. For more information, check out the CONTRIBUTING.md or simply run:
npm run help
npm run help
will ensure Bodega is installed and then open an interactive dialog where you can explore and learn about various developer commands.
Installation
To install this shareable configuration, you should start by adding the project to your devDependencies
by running:
npm install --save-dev prettier-plugin-sexy-mode
After that, you need to add the configuration to your package.json
file under the prettier
key. Your package.json
might look something like this:
{
"name": "mypackage",
"version": "1.0.4",
...
"devDependencies": {
"prettier-plugin-sexy-mode": "^1.0.0"
},
"prettier": "prettier-plugin-sexy-mode"
}
For more information on shareable configurations, check out Prettier's guide.
Usage
After installing the package, you can simply run Prettier and it will determine which plugin to use based on the file extension. This logic is mostly baked into each plugin. For example:
npm install -g prettier
prettier --list-different .
The command above will scan through your entire project (if run in the root of the project) and list the files that Prettier has changes for.
Plugins
This configuration attempts to include all the best, well-known Prettier plugins that have lots of stars on GitHub. For your reference, the chart below details which plugins are included:
| Prettier Plugin | Description | File Types |
| ---------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------- |
| @prettier/plugin-php
| Adds support for PHP | *.php
|
| @prettier/plugin-pug
| Adds support for Pug templates | *.jade
, *.pug
|
| @prettier/plugin-ruby
| Adds support for Ruby | *.rb
and many more |
| @prettier/plugin-xml
| A prettier plugin for XML | *.xml
and many more |
| prettier-plugin-go-template
| Adds support for Go templates | *.gohtml
, *.gotmpl
, *.go.tmpl
, *.tmpl
, *.tpl
, *.html.tmpl
, *.go.html
|
| prettier-plugin-csharp
| Adds support for C# | *.cs
, *.cake
, *.cshtml
, *.csx
|
| prettier-plugin-ini
| Adds support for INI files | *.ini
|
| prettier-plugin-java
| Adds support for Java | *.java
|
| prettier-plugin-jsdoc
| Adds support for JSDoc comments in TypeScript/JavaScript files | *.js
, *.ts
, *.jsx
, *.tsx
, *.mdx
, possibly others |
| prettier-plugin-organize-imports
| Makes Prettier organize your TypeScript imports using the organizeImports
feature of the TypeScript language service API | *.js
, *.jsx
, *.ts
, *.tsx
, *.vue
|
| prettier-plugin-package-perfection
| Sorts the keys and does some auto-formatting of the package.json
file (uses prettier-package-json for the logic) | package.json
|
| prettier-plugin-properties
| Adds support for properties
files | *.properties
|
| prettier-plugin-sh
| Adds support for running Prettier on shell scripts | *.sh
, Dockerfile
, .gitignore
, .dotenv
, possibly more |
| prettier-plugin-solidity
| Adds support for Solidity code | *.sol
|
| prettier-plugin-sql
| Adds support for SQL | *.sql
|
| prettier-plugin-toml
| Adds support for TOML | *.toml
|
It might be important to note that although @prettier/plugin-python is popular on GitHub, we did not include it because the project's README.md suggests using Black (a Python CLI) instead.
Contributing
Contributions, issues, and feature requests are welcome! Feel free to check the issues page. If you would like to contribute, please take a look at the contributing guide.
Brian Zalewski
License
Copyright © 2020-2021 Megabyte LLC. This project is MIT licensed.