Skip to content

Use file-format layer names for silkscreen rules, and lint for it - #36

Closed
Cimos wants to merge 2 commits into
mainfrom
fix/silkscreen-layer-names
Closed

Use file-format layer names for silkscreen rules, and lint for it#36
Cimos wants to merge 2 commits into
mainfrom
fix/silkscreen-layer-names

Conversation

@Cimos

@Cimos Cimos commented Aug 2, 2026

Copy link
Copy Markdown
Owner

Two users hit ERROR: Unrecognized layer '?.Silkscreen' when adding these rules to their projects (#33, and the same report upstream). They were right, and the problem is bigger than the error suggests.

What was wrong

The silkscreen rules used ?.Silkscreen and F./B.Silkscreen. Those are Board Setup display names. A layer name in a .kicad_dru resolves against the file-format name (F.SilkS, always present) plus the board's current layer name — and the current name only equals F.Silkscreen while the board keeps KiCad's default.

Two ways a board carries a different name with no user action:

  • Board importers — Altium, Eagle, EasyEDA, CADSTAR, Fabmaster, legacy — write the source tool's layer names in. Altium boards arrive as Top Overlay.
  • Any .kicad_pcb older than file version 20200922 (KiCad 5.1 and earlier) loads with the layer named F.SilkS, and looks untouched in Board Setup.

On those boards the name does not resolve, and KiCad rejects the entire rule file — every JLCPCB or PCBWay rule silently reverts to KiCad defaults.

What changed

Rule files. Both surfaces, in both fabs. The (layer ...) clauses that produce the visible error, and the Pad to Silkscreen conditions that fail with no message at all (#34) — fixing only the first would have left that rule dead.

Linter. It had no layer vocabulary and passed both files despite this bug (#35). It now checks every layer name in a (layer ...) clause, a .Layer comparison and an existsOnLayer() call, handling the ?/* wildcards and the outer/inner keywords. Display-name spellings get a message naming the file-format form to use; anything matching no layer is reported as unknown.

README. Short section on why the file-format names matter, plus the warning that kicad-cli pcb drc reports a rejected rule file as a clean run with exit code 0 — so green CI does not prove the rules ran.

Evidence

Run against the paired test boards on KiCad 9.0.6 and 10.0.5. Thresholds exaggerated so a live rule must fire; baseline with no custom rules is 30 violations.

Board Spelling 9.0.6 10.0.5
stock ?.Silkscreen 51 51 fires
stock ?.SilkS 51 51 fires
silk layers renamed ?.Silkscreen + a good rule 30 30 whole file discarded
silk layers renamed ?.SilkS + a good rule 72 72 both fire
silk layers renamed condition == 'F.Silkscreen' 0 0 silently inert
silk layers renamed condition == 'F.SilkS' 26 26 fires

Linter checked both ways: it passes the fixed files, and flags all four occurrences in the pre-fix content with the right suggestion.

Not a version regression — the layer names are identical in KiCad 7, 8, 9, 10 and master, and 9.0.4 and 9.0.6 are byte-identical in the files that matter. The README claim about tokens being unchanged across 8/9/10 still holds and is left alone.

#32 carries the same spelling in its generator and emits it into all eight generated files; that needs the same change on its branch.

Refs #33
Refs #34
Refs #35

Cimos added 2 commits August 2, 2026 12:41
The silkscreen rules referenced ?.Silkscreen and F./B.Silkscreen, which are
Board Setup display names. That name is editable, board importers overwrite
it with the source tool's naming, and boards written before KiCad 6 load
with the file-format name showing instead. On any of those boards it does
not resolve.

In a (layer ...) clause that makes KiCad reject the whole rule file, so
every rule in it silently stops being enforced. In the Pad to Silkscreen
condition it fails with no message anywhere. Both now use F.SilkS/B.SilkS,
which the board file format fixes and nothing can rename.

Checked by running DRC on the paired test boards under KiCad 9.0.6 and
10.0.5.

Refs #33
The linter had no layer vocabulary, so it passed both rule files despite the
silkscreen bug. It now checks every layer name in a (layer ...) clause, a
.Layer comparison and an existsOnLayer() call against the file-format names,
handling the ? and * wildcards and the outer/inner keywords.

Display-name spellings get a targeted message naming the file-format form to
use; anything matching no layer is reported as unknown.

README gains a short section on why the file-format names matter, and the
warning that kicad-cli pcb drc reports a rejected rule file as a clean run
with exit code 0 - so green CI does not prove the rules ran.

Refs #33
@Cimos

Cimos commented Aug 2, 2026

Copy link
Copy Markdown
Owner Author

Superseded by the move. This fix shipped in kicad-druid as part of the migration — the new repo's main launched with it rather than carrying the bug over. Closing; nothing to merge here.

@Cimos Cimos closed this Aug 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant