Skip to content

Fix JST PH: support jst_ph_N format and dynamic silkscreen#560

Open
mendarb wants to merge 2 commits intotscircuit:mainfrom
mendarb:fix-jst-ph-pin-count
Open

Fix JST PH: support jst_ph_N format and dynamic silkscreen#560
mendarb wants to merge 2 commits intotscircuit:mainfrom
mendarb:fix-jst-ph-pin-count

Conversation

@mendarb
Copy link

@mendarb mendarb commented Mar 20, 2026

/claim #495

Summary

Fixes two issues with JST PH connectors:

  1. Pin count parsing: Added support for jst_ph_4 format (variant_pincount with underscore separator). Previously only jst4_ph worked. Now both formats are supported for all JST variants (PH, SH, ZH).

  2. Dynamic silkscreen sizing: The PH silkscreen body was hardcoded to a fixed 6x5mm box regardless of pin count. Now it scales dynamically based on the pin span, matching how the ZH variant already worked.

Changes

  • src/fn/jst.ts: Added regex pattern for trailing pin count format (jst_ph_4, jst_sh_6), updated PH silkscreen to use dynamic sizing based on pin span
  • tests/jst.test.ts: Added tests for jst_ph_4 (verifies 4 plated holes), jst4_ph (verifies 4 plated holes), and jst_sh_6 formats
  • Updated jst2_ph snapshot for new dynamic silkscreen dimensions

Test plan

  • All 383 tests pass
  • jst_ph_4 generates 4 plated holes with correctly sized silkscreen
  • jst4_ph still works (backward compatible)
  • jst_sh_6 works via trailing format
  • jst_ph and jst_sh without pin count still throw errors

Comment on lines +34 to 59
test("jst_ph_4 (trailing pin count format)", () => {
const circuitJson = fp.string("jst_ph_4").circuitJson()
const holes = circuitJson.filter(
(e: any) => e.type === "pcb_plated_hole",
)
expect(holes.length).toBe(4)
const svgContent = convertCircuitJsonToPcbSvg(circuitJson)
expect(svgContent).toMatchSvgSnapshot(import.meta.path + "jst_ph_4")
})

test("jst4_ph generates 4 pads", () => {
const circuitJson = fp.string("jst4_ph").circuitJson()
const holes = circuitJson.filter(
(e: any) => e.type === "pcb_plated_hole",
)
expect(holes.length).toBe(4)
const svgContent = convertCircuitJsonToPcbSvg(circuitJson)
expect(svgContent).toMatchSvgSnapshot(import.meta.path + "jst4_ph")
})

test("jst_sh_6 (trailing pin count format)", () => {
const circuitJson = fp.string("jst_sh_6").circuitJson()
const pads = circuitJson.filter((e: any) => e.type === "pcb_smtpad")
// 6 signal pads + 2 mounting pads = 8
expect(pads.length).toBe(8)
})
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The test file contains multiple test() functions, which violates the rule that a *.test.ts file may have AT MOST one test(...). The file has at least 4 test() functions: 'jst_ph_4 (trailing pin count format)', 'jst4_ph generates 4 pads', 'jst_sh_6 (trailing pin count format)', and others. To fix this, split the tests into multiple numbered files such as jst1.test.ts, jst2.test.ts, jst3.test.ts, etc., with each file containing only one test() function.

Spotted by Graphite (based on custom rule: Custom rule)

Fix in Graphite


Is this helpful? React 👍 or 👎 to let us know.

mendarb added 2 commits March 21, 2026 06:06
- Add regex to parse pin count from trailing variant format (jst_ph_4, jst_sh_6)
- Make PH silkscreen scale dynamically with pin count instead of hardcoded 6x5mm
- Add tests for jst_ph_4 (4 plated holes), jst4_ph (4 plated holes), jst_sh_6
- Update jst2_ph snapshot for new dynamic silkscreen dimensions
- All 383 tests pass
@mendarb mendarb force-pushed the fix-jst-ph-pin-count branch from f33ea9d to f51adc4 Compare March 21, 2026 05:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant