Prettier code formatter configuration shared across Thesis projects.
-
Install dependencies:
yarn add --Dev github:thesis/prettier-config prettier
-
Configure prettier:
The easiest way to configure prettier to use this configuration is to define
prettier
property in the project’spackage.json
:"prettier": "@thesis/prettier-config"
For more sophisticated configuration instead of adding this entry add a configuration file (see: Plugins section).
-
Define
scripts
property inpackage.json
, e.g.:"scripts": { "lint:config": "prettier -c '**/*.@(json|yaml|toml)'", "lint:config:fix": "prettier -w '**/*.@(json|yaml|toml)'", }
For
JavaScript
andTypeScript
Thesis projects should use prettier-eslint integration in @thesis/eslint-config. -
Run
yarn lint:config
oryarn lint:config:fix
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.:
module.exports = {
...require("@thesis/prettier-config"),
plugins: ["prettier-plugin-sh", "prettier-plugin-toml"],
}
This solution is using pre-commit.
- id: format
name: "code config formatting"
entry: /usr/bin/env bash -c "npm run lint:config"
language: script
description: "Checks files formatting with prettier"