0.1.0-alpha.3 • Published 12 months ago

@itaober/prettier-config v0.1.0-alpha.3

Weekly downloads
-
License
MIT
Repository
github
Last release
12 months ago

@itaober/prettier-config

English / 简体中文

Introduction

@itaober/prettier-config provides a set of predefined Prettier configurations to help quickly standardize code formatting, improving code readability and maintainability.

Install

pnpm install @itaober/prettier-config prettier -D

Usage

If you fully agree with the @itaober/prettier-config, it is recommended to use the JSON method.

If you partially agree with the @itaober/prettier-config and need to add custom configurations, it is recommended to use the CJS or ESM method.

For more configurations, refer to the Prettier configuration.

ESM

Set "type": "module" in your package.json.

Configuration files can be one of the following:

  • .prettierrc.js
  • prettier.config.js
  • .prettierrc.mjs
  • prettier.config.mjs
import config from '@itaober/prettier-config';

/** @type {import("prettier").Config} */
export default {
  ...config,
  // Add your custom configurations here
};

CJS

Set "type": "commonjs" in your package.json.

Configuration files can be one of the following:

  • .prettierrc.js
  • prettier.config.js
  • .prettierrc.cjs
  • prettier.config.cjs
/** @type { import("prettier").Config } */
module.exports = {
  ...require('@itaober/prettier-config'),
  // Add your custom configurations here
};

JSON

Configuration files can be one of the following:

  • .prettierrc
  • .prettierrc.json
  • .prettierrc.json5
"@itaober/prettier-config"

package.json

Add the following configuration to your package.json:

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

Add format Script to package.json

Example:

{
  "scripts": {
    "format": "prettier --write \"./**/*.{js,jsx,ts,tsx,json,vue}\""
  }
}

Pre-commit Formatting

If you want prettier to format your code before every git commit, follow these steps:

  1. Install the necessary dependencies
pnpm add simple-git-hooks lint-staged -D
  1. Add the following code to your package.json
{
  "simple-git-hooks": {
    "pre-commit": "pnpm lint-staged"
  },
  "lint-staged": {
    "*": "pnpm format"
  }
}

Changelog

See the CHANGELOG.md.

0.1.0-alpha.3

12 months ago

0.1.0-alpha.2

12 months ago

0.1.0-alpha.1

1 year ago