Contributing
git clone https://github.com/mohammadreza-zr/figma-tokens.gitcd figma-tokensnpm installnpm test # builds, then runs every testLayout
Section titled “Layout”src/ index.ts public exports: generate, write, stale and the config helpers cli.ts the figma-tokens command: argument parsing, --check, exit codes config.ts the config type, defaults, resolveConfig, findConfig, loadConfig build.ts reads the input, runs the steps, rejects composite tokens, returns the files; write and stale clean.ts renames collections and $root, rewrites references, flattens Figma colour objects, strips $extensions, merges files deeply css.ts Style Dictionary: names, oklch, units; also kebab() tailwind.ts the Tailwind v4 file: theme registration, light/dark pairingexamples/ basic/ a real input, its config and its committed outputtest/ build.test.mjs the behaviour, with real files and the real Tailwind compiler docs.test.mjs checks the docs against the real filesscripts/test.mjs runs every test/*.test.mjswiki/ these pages-
No project names in
src/. A colour alias, a font variable, a collection spelling belongs in the user’s config. -
The output must not change by accident. The committed files in
examples/basic/generatedmust equal what the tool writes. After a deliberate change, regenerate them:Terminal window npm run buildcd examples/basic && node ../../dist/cli.js -
Tests use real files. No mocks, stubs or fake timers. Each behaviour has a test with a small input written to a temporary folder, or the example project.
-
Docs are checked. A code block directly under
<!-- verbatim: path -->must consist of lines of that file, in order, and every wiki link written in double square brackets must point at a page.npm testfails when they do not. -
A change to behaviour needs the wiki and
CHANGELOG.mdupdated.
Releasing
Section titled “Releasing”- Update
CHANGELOG.md. npm version patch(orminor,major) andgit push --follow-tags.- The
releaseworkflow checks that the tag equals the version inpackage.json, runs the typecheck and the tests on Node 22 and 24, checks the type resolution, publishes to npm with provenance (trusted publishing, no token) and creates the GitHub release.
Trusted publishing is set up once on npmjs.com for the package: Settings → Trusted Publisher → GitHub Actions, user mohammadreza-zr, repository figma-tokens, workflow release.yml.
The wiki
Section titled “The wiki”wiki/ is the source. Publish it to the GitHub Wiki with:
npm run docs:syncGitHub creates the wiki repository only once a first page exists. Enable it in the repository settings (Features → Wikis) and create any page in the browser, then run the command; it replaces the pages.