Skip to content

Commit 3344f79

Browse files
committed
Add Prettier to CI and apply formatting across all markdown + JSON
Why this exists --------------- The previous commit (80ec6b3) disabled markdownlint's MD060 (table-column-style) rule with a stated condition for re-enabling it: "If we add a markdown formatter to the lint pipeline later, re-enable this rule." This commit satisfies that condition. The 28 MD060 violations across AGENTS.md and ORG_SETTINGS.md were all the same shape: a single cell length changing on a single row broke the whole table's alignment. That's exactly the failure mode auto-formatters exist to eliminate. Prettier's markdown printer reformats every table to a consistent aligned style, so MD060 can be enforced as a check against drift rather than as a manual maintenance burden. What's in this commit --------------------- 1. `.prettierrc` at the repo root pinning the formatter behaviour that matters: - printWidth: 80 (fits standard terminal/diff views). - proseWrap: preserve - critical. Without this, Prettier would reflow every paragraph on every save and produce huge cross-cutting diffs that destroy git blame. Our prose is wrapped intentionally for readability. - tabWidth: 2, useTabs: false, endOfLine: lf, trailingComma: all - house style that matches the rest of our ecosystem. - embeddedLanguageFormatting: off for *.md / *.mdx so that fenced code blocks (especially YAML and bash inside our workflow examples) aren't reformatted by Prettier and put into conflict with the original source. 2. `.prettierignore` at the repo root that excludes: - YAML files. yamllint and actionlint enforce stricter semantics on those (the `on:` truthy quirk in particular) that Prettier doesn't understand. Letting both touch the same files would produce conflicting expectations. - LICENSE (verbatim text, must not be reformatted). - CODEOWNERS files (have their own structural meaning that Prettier doesn't model). - Lockfiles and node_modules. 3. New `prettier --check` job in .github/workflows/lint.yml. Pinned to prettier 3.3.3, installed globally on Node 20, runs against `**/*.{md,mdx,json,jsonc}`. Should be a required status check on main alongside the other four lint jobs. 4. Re-enabled `MD060: true` in `.markdownlint.jsonc`. Verified locally that Prettier's table output satisfies markdownlint's "aligned" style - 0 errors after `prettier --write` followed by `markdownlint-cli2`. 5. The 11 files Prettier reformatted on this first run: - AGENTS.md, CONTRIBUTING.md, ORG_SETTINGS.md, README.md, SECURITY.md, SUPPORT.md, profile/README.md - tables re-aligned, italics normalised from `*x*` to `_x_`. - .markdownlint.jsonc - trailing comma per JSONC convention. - workflow-templates/ci-docs-mdx.properties.json, codeql.properties.json, dependency-review.properties.json - arrays expanded to multi-line where they exceeded printWidth. None of the changes alter rendered output. Notable decisions ----------------- - `--check` not `--write` in CI. Auto-fixing in CI would require pushing a commit, which is its own surface (token scope, signed commits, DCO trailer). `--check` fails fast and tells the contributor to run `prettier --write` locally. - Prettier scope is markdown + JSON only. NOT YAML. yamllint's `truthy: { check-keys: false }` config and Prettier's YAML printer disagree about how to render the GitHub Actions `on:` key, and resolving that means picking one tool. yamllint wins because actionlint depends on the same indentation conventions. - Prettier 3.3.3 pinned. Dependabot (44dfac9) will track it via GitHub Actions ecosystem updates triggered by changes to the workflow file. - Italics use `_underscores_` after this commit. That's Prettier's default and not worth fighting. GitHub renders both identically. What this deliberately does NOT do ---------------------------------- - Does NOT add a pre-commit hook to auto-format on commit. That's a per-developer-machine concern; an org-wide default repo isn't the place to mandate it. Anyone who wants one can add husky or lefthook to their own repo. - Does NOT format YAML. See above. - Does NOT add Prettier as a reusable workflow. The same pattern (a few lines of CI calling `npm install -g [email protected] && prettier --check`) is shorter than the reusable-workflow invocation would be. Cross-references ---------------- - README.md "Repo basics": new rows for `.prettierrc` and `.prettierignore`. - ORG_SETTINGS.md § required status checks should add `prettier --check` to the list for this repo's main branch alongside the existing four lint job names. Closes the MD060 / "no markdown formatter" gap from the merge-readiness review.
1 parent 80ec6b3 commit 3344f79

14 files changed

Lines changed: 259 additions & 179 deletions

.github/workflows/lint.yml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,3 +80,19 @@ jobs:
8080
fi
8181
done < <(find . -name '*.json' -not -path './node_modules/*' -print0)
8282
exit "$status"
83+
84+
prettier:
85+
name: prettier --check
86+
runs-on: ubuntu-latest
87+
steps:
88+
- uses: actions/checkout@v4
89+
90+
- uses: actions/setup-node@v4
91+
with:
92+
node-version: '20'
93+
94+
- name: Install Prettier
95+
run: npm install --global [email protected]
96+
97+
- name: Check formatting
98+
run: prettier --check "**/*.{md,mdx,json,jsonc}"

.markdownlint.jsonc

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,8 @@
3232
// Unordered list indentation — 2 spaces, matching our house style.
3333
"MD007": { "indent": 2 },
3434

35-
// Table-column-style — disabled. Cosmetic rule that fails the moment a
36-
// single cell length changes, requiring all sibling rows to be
37-
// re-padded by hand. This is the kind of thing auto-fixed by prettier
38-
// or mdformat; without one of those formatters wired up, requiring it
39-
// by hand is high-friction for zero rendered-output difference. If we
40-
// add a markdown formatter to CI later, re-enable this rule.
41-
"MD060": false
35+
// Table-column-style — re-enabled now that Prettier is in CI and
36+
// auto-formats tables. Prettier's table output should satisfy
37+
// MD060's "aligned" style.
38+
"MD060": true,
4239
}

.prettierignore

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# Prettier ignore for nyuchitech/.github.
2+
3+
# Standard ignores
4+
node_modules/
5+
.git/
6+
7+
# Files with structural meaning that Prettier would harm
8+
LICENSE
9+
CODEOWNERS
10+
CODEOWNERS.example
11+
.github/CODEOWNERS
12+
13+
# YAML is handled by yamllint and actionlint, not Prettier — they have
14+
# stronger guarantees about GitHub Actions semantics that Prettier does
15+
# not understand (e.g. the `on:` truthy quirk).
16+
*.yml
17+
*.yaml
18+
19+
# Lockfiles, generated output
20+
*-lock.json
21+
*-lock.yaml
22+
package-lock.json
23+
pnpm-lock.yaml

.prettierrc

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{
2+
"printWidth": 80,
3+
"proseWrap": "preserve",
4+
"tabWidth": 2,
5+
"useTabs": false,
6+
"endOfLine": "lf",
7+
"trailingComma": "all",
8+
"overrides": [
9+
{
10+
"files": ["*.md", "*.mdx"],
11+
"options": {
12+
"embeddedLanguageFormatting": "off"
13+
}
14+
}
15+
]
16+
}

AGENTS.md

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ GitHub Copilot Workspace, Aider, Devin, Codex CLI, and anything
77
similar — are expected to behave when making changes in any repo
88
under [`nyuchitech`](https://github.com/nyuchitech).
99

10-
This file is *advisory for humans* and *authoritative for agents*.
10+
This file is _advisory for humans_ and _authoritative for agents_.
1111
If you are a human reviewing an agent's PR, use this as the checklist
1212
for what the agent should have done.
1313

@@ -44,7 +44,7 @@ contributions without exception. In particular:
4444
- **Signed commits** on every commit that will land on `main`
4545
(GPG or SSH, verified by GitHub).
4646
- **DCO sign-off** on every commit via `git commit -s`. The agent
47-
must use the *human operator's* identity for the sign-off — the
47+
must use the _human operator's_ identity for the sign-off — the
4848
human is the legal contributor of record. Agents must **not**
4949
invent or use fake `Signed-off-by` trailers.
5050

@@ -53,15 +53,15 @@ contributions without exception. In particular:
5353
Use the prefix that matches the agent, so reviewers can see at a
5454
glance what opened the PR:
5555

56-
| Prefix | Agent |
57-
| --------- | ----------------------------------------- |
58-
| `claude/` | Claude Code (Anthropic) |
59-
| `cursor/` | Cursor background agent |
60-
| `copilot/`| GitHub Copilot Workspace / Copilot coding |
61-
| `aider/` | Aider |
62-
| `devin/` | Devin |
63-
| `codex/` | OpenAI Codex CLI |
64-
| `agent/` | Any other agent not listed above |
56+
| Prefix | Agent |
57+
| ---------- | ----------------------------------------- |
58+
| `claude/` | Claude Code (Anthropic) |
59+
| `cursor/` | Cursor background agent |
60+
| `copilot/` | GitHub Copilot Workspace / Copilot coding |
61+
| `aider/` | Aider |
62+
| `devin/` | Devin |
63+
| `codex/` | OpenAI Codex CLI |
64+
| `agent/` | Any other agent not listed above |
6565

6666
Everything else in [`CONTRIBUTING.md` § Branch naming](./CONTRIBUTING.md#branch-naming)
6767
still applies (lowercase, kebab-case, under 50 characters).
@@ -101,12 +101,12 @@ explicitly. Humans reviewing an agent's PR should check each.
101101

102102
- **Don't disable checks silently.** `eslint-disable`, `# type: ignore`,
103103
`#[allow(...)]`, `// @ts-expect-error`, and friends require a
104-
same-line comment explaining *why*.
104+
same-line comment explaining _why_.
105105
- **Don't weaken tests to make them pass.** If a test fails, fix
106106
the code, change the test's behaviour deliberately, or escalate.
107107
- **Don't delete tests in a refactor.** Port them.
108108
- **Don't trust your own tests alone.** When you write a test,
109-
verify it *fails* first on the bug, then passes with the fix.
109+
verify it _fails_ first on the bug, then passes with the fix.
110110
- **Coverage is not correctness.** An agent that writes a test which
111111
asserts `assert True` has gamed the gate, not passed it.
112112

@@ -131,7 +131,7 @@ explicitly. Humans reviewing an agent's PR should check each.
131131
### Data and blast radius
132132

133133
- **Confirm before destructive actions.** `rm -rf`, `git reset
134-
--hard`, dropping database tables, killing processes, deleting
134+
--hard`, dropping database tables, killing processes, deleting
135135
branches, force-pushing, overwriting uncommitted changes. Ask a
136136
human first.
137137
- **Do not push to shared branches without approval.** Even on
@@ -164,12 +164,12 @@ Stop and ask the human operator when:
164164
Repos declare their own local check commands — honour what's there
165165
before guessing. Common patterns across the org:
166166

167-
| Stack | Install | Check |
168-
| --------------------- | ----------------- | -------------------------------------------------------- |
169-
| TypeScript / Next.js | `pnpm install` | `pnpm lint && pnpm typecheck && pnpm test && pnpm build` |
170-
| Rust | (cargo vendored) | `cargo fmt --check && cargo clippy -- -D warnings && cargo nextest run` |
171-
| Python (uv) | `uv sync` | `uv run ruff check && uv run mypy . && uv run pytest` |
172-
| MDX / docs | `pnpm install` | `pnpm cspell && pnpm build` |
167+
| Stack | Install | Check |
168+
| -------------------- | ---------------- | ----------------------------------------------------------------------- |
169+
| TypeScript / Next.js | `pnpm install` | `pnpm lint && pnpm typecheck && pnpm test && pnpm build` |
170+
| Rust | (cargo vendored) | `cargo fmt --check && cargo clippy -- -D warnings && cargo nextest run` |
171+
| Python (uv) | `uv sync` | `uv run ruff check && uv run mypy . && uv run pytest` |
172+
| MDX / docs | `pnpm install` | `pnpm cspell && pnpm build` |
173173

174174
If a repo disagrees with this table, the repo wins.
175175

@@ -188,4 +188,4 @@ these org rules are your ground truth.
188188

189189
---
190190

191-
*Last reviewed by a human: every PR that changes this file.*
191+
_Last reviewed by a human: every PR that changes this file._

CONTRIBUTING.md

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -44,19 +44,19 @@ Every commit and every PR title on every repo in the org must follow
4444

4545
### Allowed types
4646

47-
| Type | Use for |
48-
| ---------- | ----------------------------------------------------- |
49-
| `feat` | A user-visible new feature. |
50-
| `fix` | A user-visible bug fix. |
51-
| `perf` | A change that improves performance. |
52-
| `refactor` | A code change that is neither a fix nor a feature. |
53-
| `docs` | Documentation only. |
54-
| `test` | Adding or correcting tests. |
55-
| `build` | Build system, packaging, bundlers, dependencies. |
56-
| `ci` | CI configuration, workflows, GitHub Actions. |
57-
| `chore` | Maintenance that doesn't fit above. |
58-
| `revert` | Reverting a previous commit. |
59-
| `style` | Formatting only; no logic change. |
47+
| Type | Use for |
48+
| ---------- | -------------------------------------------------- |
49+
| `feat` | A user-visible new feature. |
50+
| `fix` | A user-visible bug fix. |
51+
| `perf` | A change that improves performance. |
52+
| `refactor` | A code change that is neither a fix nor a feature. |
53+
| `docs` | Documentation only. |
54+
| `test` | Adding or correcting tests. |
55+
| `build` | Build system, packaging, bundlers, dependencies. |
56+
| `ci` | CI configuration, workflows, GitHub Actions. |
57+
| `chore` | Maintenance that doesn't fit above. |
58+
| `revert` | Reverting a previous commit. |
59+
| `style` | Formatting only; no logic change. |
6060

6161
### Breaking changes
6262

@@ -169,15 +169,15 @@ No personal names, no ticket-number-only branches.
169169
- Rebase onto the latest default branch; do not merge the default
170170
branch into your feature branch.
171171
- Run the repo's local checks (`pnpm test`, `cargo test`, `uv run
172-
pytest`, etc.) and make sure they pass.
172+
pytest`, etc.) and make sure they pass.
173173
- If your change is user-visible, update the relevant docs in the
174174
same PR.
175175

176176
### When opening
177177

178178
- **Title**: Conventional Commits format. The PR title is what
179179
becomes the commit message on `main` for squash-merges.
180-
- **Description**: explain the *why*, not just the *what*. Link to
180+
- **Description**: explain the _why_, not just the _what_. Link to
181181
the issue it resolves (`Closes #123`) or to any related discussion.
182182
- **Checklist**: the repo's PR template will prompt you through it —
183183
fill it honestly.
@@ -215,7 +215,7 @@ style rules here — the config files in each repo are the source of
215215
truth.
216216

217217
- **Do not disable checks** (`eslint-disable`, `# type: ignore`,
218-
`#[allow(...)]`) without a comment explaining *why* on the same
218+
`#[allow(...)]`) without a comment explaining _why_ on the same
219219
line.
220220
- **Do not commit generated or secret files.** `.env`, build
221221
artifacts, lockfiles for libraries, etc.
@@ -274,7 +274,7 @@ When you contribute:
274274
- **Who reviews PRs?** → The CODEOWNERS file in each repo.
275275

276276
Thanks for contributing. The Ubuntu philosophy we build around —
277-
*I am because we are* — applies to the code too. Everyone's work
277+
_I am because we are_ — applies to the code too. Everyone's work
278278
here is possible because someone else contributed first.
279279

280280
[org]: https://github.com/nyuchitech

0 commit comments

Comments
 (0)