@lcbase/prettier-config

2.0.1 • Public • Published

Prettier Config

This package provides Prettier's Config.

Usage

1. Install package

pnpm add -D prettier @lcbase/prettier-config

2. Add "prettier": "@lcbase/prettier-config" to your package.json.

{
  "prettier": "@lcbase/prettier-config"
}

3. Add script to your package.json.

{
  "scripts": {
    "prettify": "prettier src --check",
    "prettify:fix": "pnpm prettify --write"
  }
}

4. Combine with @lcbase/eslint-config-* packages

pnpm add -D eslint @lcbase/eslint-config-*
{
  "scripts": {
    "lint": "eslint src",
    "lint:fix": "pnpm lint --fix",
    "prettify": "prettier src --check",
    "prettify:fix": "prettier src --write",
    "format": "pnpm prettify:fix && pnpm lint:fix"
  }
}

5. Configuration your VScode.

In root your project's folder. Create .vscode folder with structure:

.vscode
  - settings.json
{
  "editor.defaultFormatter": "esbenp.prettier-vscode",
  "editor.formatOnSave": true
}

6. Setup git hooks

  • Install packages and global setup husky, lint-staged.
pnpm add -D husky lint-staged
npx husky install
npm pkg set scripts.prepare="husky install"
npx husky add .husky/pre-commit "npx lint-staged"
  • Add the following to your package.json:
{
  "scripts": {
    "prepare": "husky install"
  },
  "lint-staged": {
    "*.{js,cjs,mjs,jsx,cjsx,mjsx,ts,mts,cts,tsx,mtsx,ctsx}": ["pnpm format"],
    "*.{json,css,md,html}": ["pnpm prettify:fix"]
  }
}

Readme

Keywords

none

Package Sidebar

Install

npm i @lcbase/prettier-config

Weekly Downloads

0

Version

2.0.1

License

MIT

Unpacked Size

4.82 kB

Total Files

5

Last publish

Collaborators

  • thienlinh
  • linh2t