npm package: @obinexusltd/obix-config-prettier
Description: OBIX Prettier configuration for OBIX CLI and SDK packages
Author: Nnamdi Michael Okpala
Latest version: 0.1.0

# @obinexusltd/obix-config-prettier

> Prettier 3 configuration for OBIX SDK packages — part of the `@obinexusltd/obix-monorepo`.

Provides typed factory functions, a ready-to-use `prettier.config.js`, and profile-based configuration presets for formatting OBIX SDK source code with Prettier 3.

---

## Installation

Registered automatically as an npm workspace package:

```bash
# From monorepo root
npm install
```

To add it as a dependency in a consumer package:

```json
{
  "devDependencies": {
    "@obinexusltd/obix-config-prettier": "workspace:*"
  }
}
```

---

## Package Structure

```
packages/config/prettier/
├── prettier.config.js    ← Base config (./base export)
└── src/
    └── index.ts          ← TypeScript programmatic API (compiled to dist/)
```

---

## Programmatic API

```ts
import {
  createBaseConfig,
  createLibraryConfig,
  createAppConfig,
  resolveConfig,
} from '@obinexusltd/obix-config-prettier';

// Base — OBIX SDK defaults (printWidth: 100, singleQuote, trailingComma: 'all')
export default createBaseConfig();

// Library — wider line length for verbose type signatures (printWidth: 120)
export default createLibraryConfig({ trailingComma: 'all' });

// App — narrower line length for readable application code (printWidth: 80)
export default createAppConfig();

// Resolve by profile name
export default resolveConfig('library', { semi: false });
```

### Factory Functions

| Function | Description |
|----------|-------------|
| `createBaseConfig(opts?)` | Standard OBIX defaults — `printWidth: 100`, `singleQuote`, `trailingComma: 'all'` |
| `createLibraryConfig(opts?)` | SDK/library packages — `printWidth: 120` for long type signatures |
| `createAppConfig(opts?)` | Browser/CLI apps — `printWidth: 80` for readable application code |
| `resolveConfig(profile, opts?)` | Delegates by `'base' \| 'library' \| 'app'` |

### `ObixPrettierOptions`

```ts
interface ObixPrettierOptions {
  printWidth?:                  number;                          // default: 100
  tabWidth?:                    number;                          // default: 2
  useTabs?:                     boolean;                         // default: false
  semi?:                        boolean;                         // default: true
  singleQuote?:                 boolean;                         // default: true
  jsxSingleQuote?:              boolean;                         // default: false
  trailingComma?:               'all' | 'es5' | 'none';         // default: 'all'
  bracketSpacing?:              boolean;                         // default: true
  bracketSameLine?:             boolean;                         // default: false
  arrowParens?:                 'always' | 'avoid';              // default: 'always'
  endOfLine?:                   'lf' | 'crlf' | 'cr' | 'auto'; // default: 'lf'
  proseWrap?:                   'always' | 'never' | 'preserve';// default: 'preserve'
  htmlWhitespaceSensitivity?:   'css' | 'strict' | 'ignore';   // default: 'css'
  embeddedLanguageFormatting?:  'auto' | 'off';                 // default: 'auto'
  overrides?:                   Array<Record<string, unknown>>; // default: []
}
```

### Static Descriptors

```ts
import {
  baseConfig,
  libraryConfig,
  appConfig,
} from '@obinexusltd/obix-config-prettier';
```

---

## Using the Config File Directly

### Reference from your project's `prettier.config.js`

```js
// prettier.config.js — use OBIX base config directly
export { default } from '@obinexusltd/obix-config-prettier/base';
```

### Extend with project-specific overrides

```js
// prettier.config.js
import base from '@obinexusltd/obix-config-prettier/base';

export default {
  ...base,
  printWidth: 80,        // narrower for this project
  semi: false,           // no semicolons
};
```

### Reference via `package.json`

```json
{
  "prettier": "@obinexusltd/obix-config-prettier/base"
}
```

> **Note:** The `package.json` `"prettier"` key does not support the `./base` subpath export directly in all tooling versions. Use the `prettier.config.js` file reference form for guaranteed compatibility.

---

## Profile Reference

| Profile | `printWidth` | `singleQuote` | `trailingComma` | Best for |
|---------|-------------|---------------|-----------------|----------|
| `base` | 100 | `true` | `'all'` | General SDK packages |
| `library` | 120 | `true` | `'all'` | Packages with verbose generic/type signatures |
| `app` | 80 | `true` | `'all'` | Browser apps, CLI tools |

---

## File-Specific Overrides (built-in)

All factory functions include sensible per-file-type overrides automatically:

| File pattern | Parser | `printWidth` | Notes |
|---|---|---|---|
| `*.ts`, `*.tsx` | `typescript` | same as profile | Explicit TypeScript parser |
| `*.json`, `*.jsonc` | `json` | 80 | No trailing commas |
| `*.md`, `*.mdx` | `markdown` | 80 | `proseWrap: 'always'` |
| `*.yml`, `*.yaml` | `yaml` | — | `singleQuote: false` |

---

## Peer Dependencies

Required:

```json
{
  "devDependencies": {
    "prettier": ">=3.0.0"
  }
}
```

Optional plugins:

```json
{
  "devDependencies": {
    "@prettier/plugin-xml": "*",
    "prettier-plugin-organize-imports": "*"
  }
}
```

---

## Author

**Nnamdi Michael Okpala** — OBINexus &lt;okpalan@protonmail.com&gt;

Part of the [OBIX Heart/Soul UI/UX SDK](https://github.com/OBINexusComputing/obix-sdk) monorepo.