mirror of
https://github.com/acamarata/prettier-config.git
synced 2026-06-30 19:04:27 +00:00
chore: scaffold @acamarata/prettier-config 0.1.0
This commit is contained in:
commit
e6a7e09ed6
10 changed files with 409 additions and 0 deletions
57
.github/workflows/ci.yml
vendored
Normal file
57
.github/workflows/ci.yml
vendored
Normal file
|
|
@ -0,0 +1,57 @@
|
|||
name: CI
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [main]
|
||||
pull_request:
|
||||
branches: [main]
|
||||
|
||||
jobs:
|
||||
test:
|
||||
name: Test (Node ${{ matrix.node-version }})
|
||||
runs-on: ubuntu-latest
|
||||
strategy:
|
||||
matrix:
|
||||
node-version: [20, 22, 24]
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- name: Setup Node ${{ matrix.node-version }}
|
||||
uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: ${{ matrix.node-version }}
|
||||
|
||||
- name: Enable corepack
|
||||
run: corepack enable
|
||||
|
||||
- name: Install dependencies
|
||||
run: pnpm install
|
||||
|
||||
- name: Test
|
||||
run: pnpm test
|
||||
|
||||
pack-check:
|
||||
name: Pack Check
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- name: Setup Node 24
|
||||
uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: 24
|
||||
|
||||
- name: Enable corepack
|
||||
run: corepack enable
|
||||
|
||||
- name: Install dependencies
|
||||
run: pnpm install
|
||||
|
||||
- name: Verify pack contents
|
||||
run: |
|
||||
npm pack --dry-run 2>&1 | tee pack-output.txt
|
||||
grep "index.js" pack-output.txt
|
||||
grep "README.md" pack-output.txt
|
||||
grep "CHANGELOG.md" pack-output.txt
|
||||
grep "LICENSE" pack-output.txt
|
||||
echo "Pack check passed"
|
||||
14
.gitignore
vendored
Normal file
14
.gitignore
vendored
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
node_modules/
|
||||
*.tgz
|
||||
.DS_Store
|
||||
.vscode/*
|
||||
.idea/
|
||||
.claude/
|
||||
.codex/
|
||||
.cursor/
|
||||
.aider/
|
||||
.aider.chat.history.md
|
||||
.continue/
|
||||
.windsurf/
|
||||
.gemini/
|
||||
.codeium/
|
||||
0
.npmrc
Normal file
0
.npmrc
Normal file
22
CHANGELOG.md
Normal file
22
CHANGELOG.md
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
# Changelog
|
||||
|
||||
All notable changes to `@acamarata/prettier-config` are documented here.
|
||||
|
||||
Format follows [Keep a Changelog](https://keepachangelog.com/en/1.1.0/).
|
||||
Version numbers follow [Semantic Versioning](https://semver.org/).
|
||||
|
||||
## [Unreleased]
|
||||
|
||||
## [0.1.0] - 2026-05-28
|
||||
|
||||
### Added
|
||||
|
||||
- Initial release.
|
||||
- Base Prettier config: `printWidth: 100`, `tabWidth: 2`, `singleQuote: false`,
|
||||
`trailingComma: "all"`, `semi: true`, `endOfLine: "lf"`.
|
||||
- Per-file-type overrides for Markdown, JSON, and YAML.
|
||||
- ESM-only distribution (`"type": "module"`).
|
||||
- Node test suite verifying config shape and override structure.
|
||||
|
||||
[Unreleased]: https://github.com/acamarata/prettier-config/compare/v0.1.0...HEAD
|
||||
[0.1.0]: https://github.com/acamarata/prettier-config/releases/tag/v0.1.0
|
||||
21
LICENSE
Normal file
21
LICENSE
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
MIT License
|
||||
|
||||
Copyright (c) 2026 Aric Camarata
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
76
README.md
Normal file
76
README.md
Normal file
|
|
@ -0,0 +1,76 @@
|
|||
# @acamarata/prettier-config
|
||||
|
||||
[](https://www.npmjs.com/package/@acamarata/prettier-config)
|
||||
[](https://github.com/acamarata/prettier-config/actions/workflows/ci.yml)
|
||||
|
||||
Shared [Prettier](https://prettier.io) configuration for acamarata JavaScript and TypeScript packages.
|
||||
|
||||
## Install
|
||||
|
||||
```bash
|
||||
npm install --save-dev @acamarata/prettier-config prettier
|
||||
```
|
||||
|
||||
Or with pnpm:
|
||||
|
||||
```bash
|
||||
pnpm add -D @acamarata/prettier-config prettier
|
||||
```
|
||||
|
||||
Prettier 3.x is required as a peer dependency.
|
||||
|
||||
## Usage
|
||||
|
||||
Reference the package in your `package.json`:
|
||||
|
||||
```json
|
||||
{
|
||||
"prettier": "@acamarata/prettier-config"
|
||||
}
|
||||
```
|
||||
|
||||
That is all you need for the defaults. Prettier reads the `prettier` field and loads the config automatically.
|
||||
|
||||
## Defaults
|
||||
|
||||
| Option | Value |
|
||||
|---|---|
|
||||
| `printWidth` | `100` |
|
||||
| `tabWidth` | `2` |
|
||||
| `useTabs` | `false` |
|
||||
| `singleQuote` | `false` |
|
||||
| `trailingComma` | `"all"` |
|
||||
| `semi` | `true` |
|
||||
| `bracketSpacing` | `true` |
|
||||
| `arrowParens` | `"always"` |
|
||||
| `endOfLine` | `"lf"` |
|
||||
|
||||
### File-type overrides
|
||||
|
||||
| File pattern | Override |
|
||||
|---|---|
|
||||
| `*.md`, `*.mdx` | `printWidth: 80`, `proseWrap: "always"`, `trailingComma: "none"` |
|
||||
| `*.json`, `*.jsonc` | `trailingComma: "none"` |
|
||||
| `*.yaml`, `*.yml` | `singleQuote: true`, `trailingComma: "none"` |
|
||||
|
||||
## Extending
|
||||
|
||||
If you need to override specific options, use a `prettier.config.mjs` file in your project:
|
||||
|
||||
```js
|
||||
import acamarataConfig from "@acamarata/prettier-config";
|
||||
|
||||
/** @type {import("prettier").Config} */
|
||||
export default {
|
||||
...acamarataConfig,
|
||||
// Your overrides here
|
||||
printWidth: 120,
|
||||
};
|
||||
```
|
||||
|
||||
Note: the `prettier` field in `package.json` does not support extending. Use a config file
|
||||
when you need project-specific overrides.
|
||||
|
||||
## License
|
||||
|
||||
MIT
|
||||
54
index.js
Normal file
54
index.js
Normal file
|
|
@ -0,0 +1,54 @@
|
|||
/**
|
||||
* Purpose: Shared Prettier configuration for all acamarata JS/TS packages.
|
||||
* Inputs: none — this file is consumed via the "prettier" field in package.json.
|
||||
* Outputs: a Prettier config object with base settings and per-file-type overrides.
|
||||
* Constraints: Prettier 3.x required (see peerDependencies). The overrides array
|
||||
* is evaluated in order; later entries win on conflict.
|
||||
* SPORT: packages.md — @acamarata/prettier-config
|
||||
*/
|
||||
|
||||
/** @type {import("prettier").Config} */
|
||||
const config = {
|
||||
// Base formatting rules
|
||||
printWidth: 100,
|
||||
tabWidth: 2,
|
||||
useTabs: false,
|
||||
singleQuote: false,
|
||||
quoteProps: "as-needed",
|
||||
trailingComma: "all",
|
||||
semi: true,
|
||||
bracketSpacing: true,
|
||||
bracketSameLine: false,
|
||||
arrowParens: "always",
|
||||
endOfLine: "lf",
|
||||
|
||||
// Per-file-type overrides
|
||||
overrides: [
|
||||
{
|
||||
// Markdown: narrower width, no trailing comma, preserve prose wrapping
|
||||
files: ["*.md", "*.mdx"],
|
||||
options: {
|
||||
printWidth: 80,
|
||||
proseWrap: "always",
|
||||
trailingComma: "none",
|
||||
},
|
||||
},
|
||||
{
|
||||
// JSON: no trailing comma (JSON spec disallows it)
|
||||
files: ["*.json", "*.jsonc"],
|
||||
options: {
|
||||
trailingComma: "none",
|
||||
},
|
||||
},
|
||||
{
|
||||
// YAML: single quotes match most YAML authoring conventions
|
||||
files: ["*.yaml", "*.yml"],
|
||||
options: {
|
||||
singleQuote: true,
|
||||
trailingComma: "none",
|
||||
},
|
||||
},
|
||||
],
|
||||
};
|
||||
|
||||
export default config;
|
||||
58
package.json
Normal file
58
package.json
Normal file
|
|
@ -0,0 +1,58 @@
|
|||
{
|
||||
"name": "@acamarata/prettier-config",
|
||||
"version": "0.1.0",
|
||||
"description": "Shared Prettier configuration for acamarata packages.",
|
||||
"author": "Aric Camarata",
|
||||
"license": "MIT",
|
||||
"type": "module",
|
||||
"main": "./index.js",
|
||||
"exports": {
|
||||
".": "./index.js",
|
||||
"./package.json": "./package.json"
|
||||
},
|
||||
"files": [
|
||||
"index.js",
|
||||
"README.md",
|
||||
"CHANGELOG.md",
|
||||
"LICENSE"
|
||||
],
|
||||
"sideEffects": false,
|
||||
"engines": {
|
||||
"node": ">=20"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "node --test test.mjs",
|
||||
"typecheck": "echo 'No TypeScript source \u2014 skipped'"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"prettier": ">=3.0.0"
|
||||
},
|
||||
"peerDependenciesMeta": {
|
||||
"prettier": {
|
||||
"optional": false
|
||||
}
|
||||
},
|
||||
"devDependencies": {
|
||||
"prettier": "^3.5.3"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/acamarata/prettier-config.git"
|
||||
},
|
||||
"homepage": "https://github.com/acamarata/prettier-config#readme",
|
||||
"bugs": {
|
||||
"url": "https://github.com/acamarata/prettier-config/issues"
|
||||
},
|
||||
"keywords": [
|
||||
"prettier",
|
||||
"prettier-config",
|
||||
"config",
|
||||
"formatting",
|
||||
"acamarata"
|
||||
],
|
||||
"publishConfig": {
|
||||
"access": "public",
|
||||
"registry": "https://registry.npmjs.org/"
|
||||
},
|
||||
"packageManager": "pnpm@10.11.1"
|
||||
}
|
||||
24
pnpm-lock.yaml
Normal file
24
pnpm-lock.yaml
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
lockfileVersion: '9.0'
|
||||
|
||||
settings:
|
||||
autoInstallPeers: true
|
||||
excludeLinksFromLockfile: false
|
||||
|
||||
importers:
|
||||
|
||||
.:
|
||||
devDependencies:
|
||||
prettier:
|
||||
specifier: ^3.5.3
|
||||
version: 3.8.3
|
||||
|
||||
packages:
|
||||
|
||||
prettier@3.8.3:
|
||||
resolution: {integrity: sha512-7igPTM53cGHMW8xWuVTydi2KO233VFiTNyF5hLJqpilHfmn8C8gPf+PS7dUT64YcXFbiMGZxS9pCSxL/Dxm/Jw==}
|
||||
engines: {node: '>=14'}
|
||||
hasBin: true
|
||||
|
||||
snapshots:
|
||||
|
||||
prettier@3.8.3: {}
|
||||
83
test.mjs
Normal file
83
test.mjs
Normal file
|
|
@ -0,0 +1,83 @@
|
|||
/**
|
||||
* Tests for @acamarata/prettier-config.
|
||||
*
|
||||
* Verifies that the config object exports the expected keys and that
|
||||
* per-file-type overrides are structured correctly.
|
||||
*/
|
||||
|
||||
import { strict as assert } from "node:assert";
|
||||
import { describe, it } from "node:test";
|
||||
import config from "./index.js";
|
||||
|
||||
describe("@acamarata/prettier-config — base config", () => {
|
||||
it("exports an object", () => {
|
||||
assert.strictEqual(typeof config, "object");
|
||||
assert.notStrictEqual(config, null);
|
||||
});
|
||||
|
||||
it("has printWidth", () => {
|
||||
assert.strictEqual(typeof config.printWidth, "number");
|
||||
assert.strictEqual(config.printWidth, 100);
|
||||
});
|
||||
|
||||
it("has tabWidth", () => {
|
||||
assert.strictEqual(typeof config.tabWidth, "number");
|
||||
assert.strictEqual(config.tabWidth, 2);
|
||||
});
|
||||
|
||||
it("has singleQuote", () => {
|
||||
assert.strictEqual(typeof config.singleQuote, "boolean");
|
||||
assert.strictEqual(config.singleQuote, false);
|
||||
});
|
||||
|
||||
it("has trailingComma", () => {
|
||||
assert.strictEqual(typeof config.trailingComma, "string");
|
||||
assert.strictEqual(config.trailingComma, "all");
|
||||
});
|
||||
|
||||
it("has semi", () => {
|
||||
assert.strictEqual(typeof config.semi, "boolean");
|
||||
assert.strictEqual(config.semi, true);
|
||||
});
|
||||
|
||||
it("has endOfLine lf", () => {
|
||||
assert.strictEqual(config.endOfLine, "lf");
|
||||
});
|
||||
});
|
||||
|
||||
describe("@acamarata/prettier-config — overrides", () => {
|
||||
it("exports an overrides array", () => {
|
||||
assert.ok(Array.isArray(config.overrides));
|
||||
assert.ok(config.overrides.length >= 3);
|
||||
});
|
||||
|
||||
it("has markdown override with proseWrap always", () => {
|
||||
const md = config.overrides.find((o) =>
|
||||
(Array.isArray(o.files) ? o.files : [o.files]).some((f) =>
|
||||
f.includes("*.md"),
|
||||
),
|
||||
);
|
||||
assert.ok(md, "markdown override not found");
|
||||
assert.strictEqual(md.options.proseWrap, "always");
|
||||
});
|
||||
|
||||
it("has JSON override with no trailing comma", () => {
|
||||
const json = config.overrides.find((o) =>
|
||||
(Array.isArray(o.files) ? o.files : [o.files]).some((f) =>
|
||||
f.includes("*.json"),
|
||||
),
|
||||
);
|
||||
assert.ok(json, "JSON override not found");
|
||||
assert.strictEqual(json.options.trailingComma, "none");
|
||||
});
|
||||
|
||||
it("has YAML override with no trailing comma", () => {
|
||||
const yaml = config.overrides.find((o) =>
|
||||
(Array.isArray(o.files) ? o.files : [o.files]).some((f) =>
|
||||
f.includes("*.yaml"),
|
||||
),
|
||||
);
|
||||
assert.ok(yaml, "YAML override not found");
|
||||
assert.strictEqual(yaml.options.trailingComma, "none");
|
||||
});
|
||||
});
|
||||
Loading…
Reference in a new issue