Prettier — format UXML and USS
When to use
- User wants
*.uxmlor*.ussfiles formatted, or a directory run through Prettier. - Before handoff or before commit when UXML/USS is in scope (
format-before-handoff-and-commit.mdc).
Preconditions
- Prettier +
@prettier/plugin-xmlinstalled vianpm installat repo root (package.json). - Cursor extension:
esbenp.prettier-vscode— Format Document / format on save (.vscode/settings.jsonmaps*.uss→ CSS). - Run from griddungeon-game root (folder with
Assets/andpackage.json).
Commands
From repo root:
npm install
npx prettier --write path/to/File.uxml
npx prettier --write path/to/File.uss
npx prettier --write "Assets/UI/**/*.{uxml,uss}"
npm run format:uitk
npm run format:uitk:check
Config: .prettierrc — UXML: parser: xml, 4-space indent; USS: parser: css, 4-space indent.
Agent workflow
- Confirm root:
griddungeon-game(parent ofAssets/). - If
node_modules/is missing:npm installonce. - Format changed paths only unless the user asked for the whole tree:
npx prettier --write path/to/Changed.uxml path/to/Changed.uss - Re-run
git diffafter formatting. - If
npm installornpx prettierfails, report it; do not substitute another formatter.
Notes
- Prettier formats
.uxmland.ussonly in this repo — not.csor YAML. - USS uses Unity-specific properties (
-unity-*); Prettier treats files as CSS — valid USS should still parse. - CLI output should match Format Document with the Prettier extension on the same files.
- Windows PowerShell: use
;instead of&&when chaining commands.