@sc-way
: The way SC (@saxoncameron) likes to do things.
Prettier config
An importable, installable Prettier config based on the author's personal preferences.
.editorconfig
under the hood as well.
TOC
Install
- First install the config package:
#npm
npm install --save-dev @sc-way/config-prettier
#yarn
yarn --dev @sc-way/config-prettier
- and then reference it, in one of the following ways:
- in
package.json
:- Add this line:
"prettier": "@sc-way/config-prettier"
- Add this line:
- or if you prefer to keep it in a separate config file:
.prettierrc.js
module.exports = require("@sc-way/config-prettier");
Extending the config
To extend/override this config, import it into .prettierrc.js
like so:
module.exports = {
...require("@sc-way/config-prettier"),
// your overrides/additions here
};
.editorconfig
On differences between Prettier and EditorConfig's role is to configure your editor so that the code you write is already formatted while Prettier will format your already written code. This allows EditorConfig to be used in many more languages and projects than Prettier.
Using EditorConfig will also avoid Prettier of uselessly formatting your file on save as your editor will already have done the formatting based on EditorConfig's rules. The tricky part though is to make sure Prettier and EditorConfig have the same rules without repeating your configuration in two separate files.