https://github.com/thesis/prettier-config
https://github.com/thesis/prettier-config
Last synced: 4 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/thesis/prettier-config
- Owner: thesis
- License: mit
- Created: 2021-09-30T14:05:24.000Z (over 4 years ago)
- Default Branch: main
- Last Pushed: 2023-08-26T03:55:20.000Z (almost 3 years ago)
- Last Synced: 2025-12-13T14:46:18.293Z (7 months ago)
- Size: 16.6 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.adoc
- License: LICENSE
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"
```