Skip to content

Latest commit

 

History

History
112 lines (88 loc) · 2.3 KB

README.zh-CN.md

File metadata and controls

112 lines (88 loc) · 2.3 KB
logo

@configurajs/prettier

一个简单易用的 prettier 预设

中文 | English

version stars license


特性

  • 📦   提供最基本的 prettier 配置
  • 📦   支持 import 语句排序
  • 📦   支持原子化 css 类名排序
  • 📦   支持 package.json 字段排序

快速开始

Tip

支持的prettier最低版本是 3.0.0

安装

# npm
npm i @configurajs/prettier -D
# yarn
yarn add @configurajs/prettier -D
# pnpm
pnpm add @configurajs/prettier -D

使用

// prettier.config.js
import { defineConfig } from '@configurajs/prettier'

export default defineConfig()

OR

// prettier.config.js
const { defineConfig } = require('@configurajs/prettier')

module.exports = defineConfig()

选项

// prettier.config.js
import { defineConfig } from '@configurajs/prettier'

export default defineConfig({ ... })
import { Config } from 'prettier'

export type DefineConfigOptions = Config & {
  /**
   * 是否启用 import 语句排序
   * @default true
   */
  sortImports?: boolean
  /**
   * 是否启用原子化 css 类名排序
   * @default true
   */
  sortAtomicClass?: boolean
  /**
   * 是否启用 package.json 字段排序
   * @default true
   */
  sortPackageJson?: boolean
  /**
   * import 语句的排序顺序
   * @default ['<BUILTIN_MODULES>', '^vue$', '^react$', '<THIRD_PARTY_MODULES>', '^@/(.*)$', '^~/(.*)$', '^[.]']
   */
  importsOrder?: string[]
  /**
   * package.json 属性的排序顺序
   * @default []
   */
  packageJsonOrder?: string[]
}

贡献者

日志

日志

许可证

MIT