An open API service indexing awesome lists of open source software.

https://github.com/thesis/prettier-config


https://github.com/thesis/prettier-config

Last synced: 4 months ago
JSON representation

Awesome Lists containing this project

README

          

# prettier-config

https://prettier.io/[Prettier] code formatter configuration shared across Thesis projects.

## Usage

### Setting up a project

1. Install dependencies:

+
```sh
yarn add --Dev github:thesis/prettier-config prettier
```

2. Configure prettier:
+
The easiest way to configure prettier to use this configuration is to define
`prettier` property in the project's `package.json`:
+
```json
"prettier": "@thesis/prettier-config"
```
+
For more sophisticated configuration instead of adding this entry add a configuration
file (see: <> section).

3. Define `scripts` property in `package.json`, e.g.:
+
```json
"scripts": {
"lint:config": "prettier -c '**/*.@(json|yaml|toml)'",
"lint:config:fix": "prettier -w '**/*.@(json|yaml|toml)'",
}
```
+
For `JavaScript` and `TypeScript` Thesis projects should use prettier-eslint integration in https://github.com/thesis/eslint-config[@thesis/eslint-config].

4. Run `yarn lint:config` or `yarn lint:config:fix`

### Plugins

To handle `*.sh` or `*.toml` files you need to install dedicated plugins:

- for `sh`: `yarn add --Dev prettier-plugin-sh`
- for `toml`: `yarn add --Dev prettier-plugin-toml`

And configure the plugins usage in `.prettierrc.js`, e.g.:

```js
module.exports = {
...require("@thesis/prettier-config"),
plugins: ["prettier-plugin-sh", "prettier-plugin-toml"],
}
```

### Adding a pre-commit hook

This solution is using https://pre-commit.com[pre-commit].

```yaml
- id: format
name: "code config formatting"
entry: /usr/bin/env bash -c "npm run lint:config"
language: script
description: "Checks files formatting with prettier"
```