2020-06-16 21:46:58 +02:00
|
|
|
# mastermindzh' code conventions
|
2019-06-16 10:30:22 +02:00
|
|
|
|
2020-06-16 21:46:58 +02:00
|
|
|
In this repo you'll find various code convention guideline files (and some .ignore stuff).
|
|
|
|
Most of my projects will use at least one of these but I strive to use as many as I can.
|
|
|
|
|
|
|
|
**note** these are by no means definitive. Every project has different needs, treat these files as a starting point.
|
2019-06-16 10:30:22 +02:00
|
|
|
|
|
|
|
<!-- toc -->
|
|
|
|
|
2020-06-16 21:46:58 +02:00
|
|
|
- [repo outline](#repo-outline)
|
|
|
|
- [@mastermindzh/prettier-config](#mastermindzhprettier-config)
|
|
|
|
- [Installation](#installation)
|
|
|
|
- [Configuration](#configuration)
|
|
|
|
- [package.json](#packagejson)
|
|
|
|
- [.prettierrc.js](#prettierrcjs)
|
2019-06-16 10:30:22 +02:00
|
|
|
|
|
|
|
<!-- tocstop -->
|
|
|
|
|
2020-06-16 21:46:58 +02:00
|
|
|
## repo outline
|
|
|
|
|
|
|
|
```js
|
|
|
|
.
|
|
|
|
├── prettier // prettier config
|
|
|
|
│ ├── index.js
|
|
|
|
│ └── package.json
|
|
|
|
├── .dockerignore // things to ignore when building dockers
|
|
|
|
├── .editorconfig // default editor configuration
|
|
|
|
├── .eslintignore // files to ignore when using eslint
|
|
|
|
├── .eslintrc // default eslint config
|
|
|
|
├── .gitignore // files to ignore when working with git
|
|
|
|
├── LICENSE
|
|
|
|
└── README.md
|
|
|
|
```
|
|
|
|
|
|
|
|
## @mastermindzh/prettier-config
|
|
|
|
|
|
|
|
My preferred prettier configuration.
|
|
|
|
|
|
|
|
### Installation
|
2019-06-16 10:30:22 +02:00
|
|
|
|
|
|
|
Simply install the package with npm:
|
|
|
|
|
|
|
|
`npm install --save-dev @mastermindzh/prettier-config`
|
|
|
|
|
2020-06-16 21:46:58 +02:00
|
|
|
### Configuration
|
2019-06-16 10:30:22 +02:00
|
|
|
|
2020-06-16 21:46:58 +02:00
|
|
|
Configuring your project to use `@mastermindzh/prettier-config` can be done in several ways.
|
2019-06-16 10:30:22 +02:00
|
|
|
The easiest is the [package.json](#packagejson) solution, the most extensible is the [.prettierrc.js](#prettierrcjs) version.
|
|
|
|
|
2020-06-16 21:46:58 +02:00
|
|
|
#### package.json
|
2019-06-16 10:30:22 +02:00
|
|
|
|
|
|
|
Simply add a "prettier" key with the package name:
|
|
|
|
|
|
|
|
```json
|
|
|
|
{
|
|
|
|
"prettier": "@mastermindzh/prettier-config"
|
|
|
|
}
|
|
|
|
```
|
|
|
|
|
2020-06-16 21:46:58 +02:00
|
|
|
#### .prettierrc.js
|
2019-06-16 10:30:22 +02:00
|
|
|
|
|
|
|
This solution requires you to put a `.prettierrc.js` file at the root of your project with the following code:
|
|
|
|
|
|
|
|
```js
|
|
|
|
module.exports = {
|
|
|
|
...require("@mastermindzh/prettier-config"),
|
|
|
|
// optional overrides:
|
2020-06-16 21:46:58 +02:00
|
|
|
jsxBracketSameLine: true,
|
2019-06-16 10:30:22 +02:00
|
|
|
};
|
|
|
|
```
|