-
Notifications
You must be signed in to change notification settings - Fork 1
chore: add figma code connect coverage guard to lint pipeline #751
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
QuintonJason
merged 4 commits into
ci/component-status-guard
from
ci/figma-coverage-guard
Jun 5, 2026
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
090ac09
chore: add figma code connect coverage guard to lint pipeline
QuintonJason 9e19d55
Merge branch 'ci/component-status-guard' into ci/figma-coverage-guard
QuintonJason 85ef4b7
fix: harden figma-coverage waiver and shared component-dir helper
QuintonJason ba14f2d
fix: wire figma paths into nx affected and lint cache inputs
QuintonJason File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,109 @@ | ||
| /** | ||
| * Figma Code Connect coverage check. | ||
| * | ||
| * Guards that every top-level `pds-*` component is either: | ||
| * - mapped: has a `libs/figma/components/<name>.figma.ts`, or | ||
| * - explicitly waived: listed in `libs/figma/code-connect-waivers.json`. | ||
| * | ||
| * This stops a new component from silently shipping with no Code Connect | ||
| * mapping and no deliberate decision. It also flags stale waivers (a waived | ||
| * component that has since been mapped, or that no longer exists) so the | ||
| * waiver list cannot rot. | ||
| * | ||
| * Runs as `lint.figma` via `run-p lint.*`, gated through the existing | ||
| * `nx affected --target=lint` CI job. `@pine-ds/core` declares an implicit | ||
| * dependency on `@pine-ds/figma` so figma-only PRs still schedule core lint, | ||
| * and the core `lint` target inputs include waiver/mapping paths so Nx cache | ||
| * invalidates when those files change. | ||
| * | ||
| * Exits 0 when coverage is accounted for, 1 (with an actionable report) otherwise. | ||
| */ | ||
| import fs from 'node:fs'; | ||
| import path from 'node:path'; | ||
| import { CORE_ROOT, topLevelComponents } from './lib/components.mjs'; | ||
|
|
||
| const FIGMA_ROOT = path.resolve(CORE_ROOT, '..', 'figma'); | ||
| const FIGMA_COMPONENTS_DIR = path.join(FIGMA_ROOT, 'components'); | ||
| const WAIVERS_PATH = path.join(FIGMA_ROOT, 'code-connect-waivers.json'); | ||
| const WAIVERS_REL = path.relative(path.resolve(CORE_ROOT, '..', '..'), WAIVERS_PATH); | ||
|
|
||
| /** Component names with a `<name>.figma.ts` under libs/figma/components. */ | ||
| function mappedComponents() { | ||
| if (!fs.existsSync(FIGMA_COMPONENTS_DIR)) return new Set(); | ||
| const names = fs | ||
| .readdirSync(FIGMA_COMPONENTS_DIR, { withFileTypes: true }) | ||
| .filter((entry) => entry.isFile() && entry.name.endsWith('.figma.ts')) | ||
| .map((entry) => entry.name.replace(/\.figma\.ts$/, '')); | ||
| return new Set(names); | ||
| } | ||
|
|
||
| function readWaivers() { | ||
| let raw; | ||
| try { | ||
| raw = fs.readFileSync(WAIVERS_PATH, 'utf8'); | ||
| } catch { | ||
| throw new Error(`Could not read waivers at ${WAIVERS_REL}`); | ||
| } | ||
| let parsed; | ||
| try { | ||
| parsed = JSON.parse(raw); | ||
| } catch (err) { | ||
| throw new Error(`Waivers file ${WAIVERS_REL} is not valid JSON: ${err.message}`); | ||
| } | ||
| if (!parsed.waived || typeof parsed.waived !== 'object' || Array.isArray(parsed.waived)) { | ||
| throw new Error(`Waivers file ${WAIVERS_REL} is missing a "waived" object`); | ||
| } | ||
| return new Set(Object.keys(parsed.waived)); | ||
| } | ||
|
|
||
| function main() { | ||
| let waived; | ||
| try { | ||
| waived = readWaivers(); | ||
| } catch (err) { | ||
| console.error(`✖ figma-coverage check failed: ${err.message}`); | ||
| process.exit(1); | ||
| } | ||
|
|
||
| const components = topLevelComponents(); | ||
| const mapped = mappedComponents(); | ||
| const componentSet = new Set(components); | ||
|
|
||
| // A component with neither a mapping nor a waiver is an unaccounted gap. | ||
| const uncovered = components.filter((name) => !mapped.has(name) && !waived.has(name)); | ||
| // A waiver for a component that is now mapped should be removed. | ||
| const redundant = [...waived].filter((name) => mapped.has(name)).sort(); | ||
| // A waiver for a component that no longer exists is stale. | ||
| const orphaned = [...waived].filter((name) => !componentSet.has(name)).sort(); | ||
|
|
||
| if (uncovered.length === 0 && redundant.length === 0 && orphaned.length === 0) { | ||
| console.log( | ||
| `✔ figma code connect coverage accounted for ` + | ||
| `(${mapped.size} mapped, ${waived.size} waived, ${components.length} components).`, | ||
| ); | ||
| return; | ||
| } | ||
|
|
||
| console.error(`✖ figma code connect coverage is unaccounted for.\n`); | ||
| if (uncovered.length > 0) { | ||
| console.error(`Components with no .figma.ts and no waiver:`); | ||
| uncovered.forEach((name) => console.error(` - ${name}`)); | ||
| console.error( | ||
| ` → add libs/figma/components/<name>.figma.ts, ` + | ||
| `or add an entry to ${WAIVERS_REL} with a reason.\n`, | ||
| ); | ||
| } | ||
| if (redundant.length > 0) { | ||
| console.error(`Waivers for components that are already mapped (remove the waiver):`); | ||
| redundant.forEach((name) => console.error(` - ${name}`)); | ||
| console.error(''); | ||
| } | ||
| if (orphaned.length > 0) { | ||
| console.error(`Waivers for components that no longer exist (remove or rename):`); | ||
| orphaned.forEach((name) => console.error(` - ${name}`)); | ||
| console.error(''); | ||
| } | ||
| process.exit(1); | ||
| } | ||
|
|
||
| main(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,50 @@ | ||
| /** | ||
| * Shared component-enumeration helpers for the maturity lint checks | ||
| * (`check-component-status.mjs`, `check-figma-coverage.mjs`). | ||
| * | ||
| * Single source for "what are the components" so the guards cannot diverge on | ||
| * their globbing logic. | ||
| */ | ||
| import fs from 'node:fs'; | ||
| import path from 'node:path'; | ||
| import { fileURLToPath } from 'node:url'; | ||
|
|
||
| /** Repo `libs/core` root (this file lives at `libs/core/scripts/lib/`). */ | ||
| export const CORE_ROOT = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '..', '..'); | ||
| export const COMPONENTS_DIR = path.join(CORE_ROOT, 'src', 'components'); | ||
|
|
||
| /** Directory names directly under `dir` matching `pds-*`. */ | ||
| function pdsDirs(dir) { | ||
| return fs | ||
| .readdirSync(dir, { withFileTypes: true }) | ||
| .filter((entry) => entry.isDirectory() && entry.name.startsWith('pds-')) | ||
| .map((entry) => entry.name); | ||
| } | ||
|
|
||
| /** Top-level components — the public surface that needs status + Figma coverage. */ | ||
| export function topLevelComponents() { | ||
| return pdsDirs(COMPONENTS_DIR).sort(); | ||
| } | ||
|
|
||
| /** | ||
| * Every `pds-*` directory, including nested subcomponents (e.g. `pds-filter`, | ||
| * `pds-table-cell`). Used to accept deliberate subcomponent references while | ||
| * rejecting typos or removed components. | ||
| */ | ||
| export function allComponentDirs() { | ||
| const names = new Set(); | ||
| // Top-level pds-* components. | ||
| for (const top of topLevelComponents()) { | ||
| names.add(top); | ||
| } | ||
| // Nested pds-* subcomponents under ANY top-level directory — including | ||
| // non-pds-* parents like `_internal/` (e.g. `_internal/pds-label`) — so a | ||
| // deliberate subcomponent reference is not falsely rejected. | ||
| for (const entry of fs.readdirSync(COMPONENTS_DIR, { withFileTypes: true })) { | ||
| if (!entry.isDirectory()) continue; | ||
| for (const nested of pdsDirs(path.join(COMPONENTS_DIR, entry.name))) { | ||
| names.add(nested); | ||
| } | ||
| } | ||
| return names; | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| { | ||
| "$comment": "Machine-readable source of truth for INTENTIONALLY unmapped Pine components. A top-level pds-* component passes the Figma Code Connect coverage guard (libs/core/scripts/check-figma-coverage.mjs) when it has a matching libs/figma/components/<name>.figma.ts OR an entry here. Remove a component's entry once it is mapped. Keep CODE_CONNECT_COVERAGE.md in sync (a future change can render that doc from this file).", | ||
| "waived": { | ||
| "pds-accordion": "No Figma Code Connect mapping yet; add components/pds-accordion.figma.ts when the Figma node is ready.", | ||
| "pds-box": "Layout primitive; may map to layout frames rather than a single component node.", | ||
| "pds-combobox": "No Figma Code Connect mapping yet; add components/pds-combobox.figma.ts when the Figma node is ready.", | ||
| "pds-container": "No Figma Code Connect mapping yet; add components/pds-container.figma.ts when the Figma node is ready.", | ||
| "pds-copytext": "No Figma Code Connect mapping yet; add components/pds-copytext.figma.ts when the Figma node is ready.", | ||
| "pds-dropdown-menu": "No Figma Code Connect mapping yet; add components/pds-dropdown-menu.figma.ts when the Figma node is ready.", | ||
| "pds-icon": "Icon set lives in @pine-ds/icons; map if Figma documents a dedicated icon wrapper.", | ||
| "pds-image": "No Figma Code Connect mapping yet; add components/pds-image.figma.ts when the Figma node is ready.", | ||
| "pds-multiselect": "No Figma Code Connect mapping yet; add components/pds-multiselect.figma.ts when the Figma node is ready.", | ||
| "pds-popover": "No Figma Code Connect mapping yet; add components/pds-popover.figma.ts when the Figma node is ready.", | ||
| "pds-row": "Often used with pds-box; may share layout documentation.", | ||
| "pds-sortable": "Figma substitutions exist for sortable list patterns; wire components/pds-sortable.figma.ts when aligned.", | ||
| "pds-table": "Composite; consider per-subcomponent mappings (row, cell, head) if needed.", | ||
| "pds-text": "No Figma Code Connect mapping yet; add components/pds-text.figma.ts when the Figma node is ready.", | ||
| "pds-tooltip": "No Figma Code Connect mapping yet; add components/pds-tooltip.figma.ts when the Figma node is ready." | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| { | ||
| "name": "@pine-ds/figma", | ||
| "version": "0.0.0", | ||
| "private": true, | ||
| "description": "Figma Code Connect sources for Pine (not published)" | ||
| } |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.