@nexusui/prettier-config
v1.0.0
Published
nexus prettier config
Downloads
608
Readme
NexusUI Prettier Config
This is a Shareable Configuration for Prettier. This is the configuration used in all NexusUI packages and contains prettier rules that we recommend for all NexusUI applications.
Installation
- First, add necessary prettier dependencies to your project's
devDependencies
:
# With yarn
yarn add --dev prettier onchange
# With npm
npm install --save-dev prettier onchange
- Second, add the NexusUI prettier config library as a
devDependency
to your project:
# With yarn
yarn add --dev @nexusui/prettier-config
# With npm
npm install --save-dev @nexusui/prettier-config
Usage
Configuration supports three ways, please choose one you prefer to.
It's out of box, reference
@nexusui/prettier-config
in yourpackage.json
prettier field as below:{ "name": "Your-App", "version": "0.0.1", "prettier": "@nexusui/prettier-config" }
If you don’t want to use
package.json
, you can use any of the supported extensions to export a string, e.g..prettierrc.json
:"@nexusui/prettier-config"
The above two ways do not provide extended configuration to override some properties in shared configuration. If you need to do that, import the file in a
.prettierrc.js
file and export the modifications, e.g:module.exports = { ...require("@nexusui/prettier-config"), printWidth: 250, };
Migration Guide
0.X.X -> 1.0.0
printWidth
printWidth
was changed from 250
to 120
to make code readable.
trailingComma
trailingComma
was changed from none
to all
to prevent unnecessary line changes in git and makes PRs cleaner.
// Before (0.x.x)
printWidth: 250,
trailingComma: 'none'
// After (1.0.0)
printWidth: 120,
trailingComma: 'all'
Scripts
Update the package.json
file to add prettier
scripts.
// package.json
"scripts": {
"prettier": "prettier \"src/**/*.{js,ts,tsx,jsx}\" --write",
"prettier-check": "prettier \"src/**/*.{js,ts,tsx,jsx}\" --check",
"prettier-watch": "onchange 'src/**/*.{js,ts,tsx,jsx}' -- prettier --write {{changed}}"
}
Related Packages
@nexusui/eslint-config is a complementary package that includes recommended eslint Shareable Configuration for NexusUI projects.