Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/keep-network/prettier-config-keep
https://github.com/keep-network/prettier-config-keep
Last synced: 18 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/keep-network/prettier-config-keep
- Owner: keep-network
- License: mit
- Created: 2021-05-10T12:58:02.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2021-07-20T09:30:14.000Z (over 3 years ago)
- Last Synced: 2024-04-13T00:15:14.748Z (9 months ago)
- Size: 12.7 KB
- Stars: 0
- Watchers: 12
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.adoc
- License: LICENSE
Awesome Lists containing this project
README
# prettier-config-keep
https://prettier.io/[Prettier] code formatter configuration shared across Keep
Network projects.## Usage
### Setting up a project
1. Install dependencies:
+
```sh
npm install --save-dev github:keep-network/prettier-config-keep 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": "@keep-network/prettier-config-keep"
```
+
For more sophisticated configuration instead of adding this entry add a configuration
file (see: <> section).3. Define `scripts` property in `package.json`:
+
```json
"scripts": {
"format": "prettier --check .",
"format:fix": "prettier --write ."
}
```4. Run `npm run format` or `npm run format:fix`
### Plugins
To handle `*.sh` or `*.toml` files you need to install dedicated plugins:
- for `sh`: `npm install --save-dev prettier-plugin-sh`
- for `toml`: `npm install --save-dev prettier-plugin-toml`And configure the plugins usage in `.prettierrc.js`, e.g.:
```js
module.exports = {
...require("@keep-network/prettier-config-keep"),
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 formatting"
entry: /usr/bin/env bash -c "npm run format"
exclude: '^staker-rewards\/|^solidity\/'
language: script
description: "Checks files formatting with prettier"
```