Guidance for USWDS repo agents. See README.md and CONTRIBUTING.md for user docs.
- Node: v24 (
.nvmrc). CI:cimg/node:24.16.0-browsers. - Build: Gulp 4 (
gulpfile.js,tasks/*.js). Not direct npm scripts. Vite is only for web-components CDN banner (vite.config.banner.cdn.js); main lib uses Gulp/Browserify/Uglify. Do not assume Vite builds the whole project. - SCSS:
sass-embedded(modern API).@uswds/compileis consumer-side.
- Monorepo:
packages/(not npm workspace). Rootpackage.json. Component pkgs (packages/<component>/):src/,_index.scss,src/index.js,src/*.twig,src/*.stories.js,src/test/*.spec.js. uswds-core:packages/uswds-core/for shared JS (src/js/), Sass (src/styles/), settings, tokens, mixins, fonts, images. JS entry:packages/uswds-core/src/js/start.js. Bundled dist:dist/js/uswds.min.js.- Sass Entry:
packages/uswds/_index.scss(top-level barrel). Component_index.scssfiles importuswds-core. - Root
src/: Onlysrc/stylesheets/uswds.scssfor compiled entry and root specs. Component sources underpackages/. dist/: Generated; do not edit.gulp cleanDistclears.- Project Focus: US federal (GSA/TTS) open source project. Accessibility, performance, and security are critical. All updates must align with these requirements.
- Install:
npm install(CI alsonpx playwright installfor a11y). - Full Test (Local):
npm test(lint,gulp typecheck,gulp test). - CI Equivalent:
npm run test:ci(lint, gulp test, a11y, HTML build). - Lint:
npm run lint(lint:js+lint:sass). - Typecheck:
gulp typecheck(uses./node_modules/.bin/tsc).tsconfig.jsononly checkspackages/uswds-core/src/js/utils/select.js(no repo-wide TS coverage). - Unit Tests:
npm run test:unit(gulp unitTests). Sass tests:npm run test:sass(gulp sassTests, usessass-true). - Single JS Test:
npx mocha --require jsdom-global/register packages/<pkg>/src/test/<name>.spec.js(mocharc inpackages/uswds-core/src/js/utils/test/.mocharc.json). - Build:
npm run build(runsgulp[defaultbuildUSWDS] then Vite web-components bundle). Requires internet. - Dev Server:
npm start(Storybook on:6006).npm run watch(Gulp watch). - Formatting:
npm run prettier(writes) ornpm run prettier:check(CI checks). - Icon SVGO:
npm run fix:icons(before committingpackages/usa-icon/src/img/changes).
- JS Unit Tests: Mocha with
jsdom-global/register(browser-ish env); not Jest/Vitest.sinonavailable. - Test Discovery: Globs
packages/usa-*/**/*.spec.js,packages/uswds-*/**/*.spec.js(excludespackages/uswds-core/src/test/sass.spec.js). - Component Tests: Load sibling
template.htmlinto jsdom. Followpackages/usa-accordion/src/test/pattern. - a11y Tests:
npm run test:a11yrequires built Storybook (_site/) on:6006, Playwright + Axe.test:cihandles E2E; local is slow, needsnpx playwright install.
- Prettier:
{}(defaults),.prettierignore. 2 spaces indent, LF endings (.editorconfig). - ESLint: Bans
var, requires===, forbidsnew Function, enforcesno-unsanitized/*(relaxed in*.spec.js). Preferconst.
- Default Branch:
develop(notmain); PRs targetdevelop.main/library--maintrigger npm publish; do not push. - Commit Signatures: All commits must be verified (GPG/SSH); unsigned rejected by
verify-commit-signatures.yml. Sign before commit. COMMUNITY.md: Do not edit unless requested.
- Sass Exports:
package.jsonexports./scss/*->./packages/*/_index.scss,./functions/*->packages/uswds-core/src/styles/functions/*. New pkgs need_index.scss. - Web Components:
lit-using pkgs bundled byvite.config.banner.cdn.js, additive touswds.min.js.