Skip to content

feat(rules): [[ignore]] selectors over the element path a rule reports #1440 - #1475

Closed
nc9 wants to merge 1 commit into
mainfrom
feat/ignore-selectors-1440
Closed

nc9 wants to merge 1 commit into
mainfrom
feat/ignore-selectors-1440

Conversation

@nc9

@nc9 nc9 commented Oct 31, 2026 •

Copy link
Copy Markdown
Contributor

Closes #1440.

[[ignore]] entries now take selectors: a waiver names an element by where it sits, so a rule keeps reporting the merchant's own elements while it waives the one a platform renders.

[[ignore]]
rule      = "a11y/label-content-name-mismatch"
selectors = ["localization-form select"]
reason    = "The country selector is rendered by the platform"
  • CheckItem.selector (new, optional): the element's ancestry as html > body > form#f > select#s.c, built by elementSelector(el) (packages/rules/src/element-path.ts: tag, #id, .class tokens of letters, digits, _, -; nearest 24 ancestors; at most 8 classes). RuleMeta.itemSelectors marks rules that set it. a11y/label-content-name-mismatch, a11y/form-labels and a11y/select-name do (and now set messageCountsItems, so the message count follows the waiver).
  • Selector language (ignore-selector.ts): tag or *, #id, .class, descendant and >; up to 12 parts and 300 characters; matched right to left with memoisation (parts x segments). Attribute selectors, pseudo-classes, +, ~, lists are refused with a message by squirrel config validate and the entry is not applied.
  • Engine (ignore.ts): selector matchers compile per entry; an item is waived when its selector matches, ANDed with items and urls; waived items are counted and listed in meta.ignored like items; an entry that matched nothing is reported as before; selectors are in the entry's cache signature; an entry with only selectors is not a page waiver.
  • The runner strips selector from every item after the ignore filter (waivers or not), so no output carries it and a run with no selector entry is byte-identical. A test compares the check list with no entry against one whose entry matched nothing.
  • Schema: selectors accepted (1 to 100 entries of 1 to 300 chars); an entry needs items, urls or selectors. checkIgnoreEntries: an entry with only selectors for rules that report no element path is a validate problem naming the rule.
  • Tests: ignore-selectors-1440.test.ts (12: the issue's two country selects, one inside <localization-form> and one outside, only the first waived; both waived; unmatched; items AND selectors; the language; refusal messages; deep-path bound; validate problems), config schema, config validate CLI, plus the two existing tests that asserted the old refusal/shape.
  • Docs: docs/configuration/ignore.mdx (field table, Selectors section, rule authors), CHANGELOG under Unreleased / Added. make validate passes.

Limits stated in the docs: a waiver applies to the items a rule lists (these three list the first ten); the recorded place covers 24 ancestors and omits a name with other characters.

Review round 3 (tests, docs): the path is computed only for a rule an entry with selectors names (a runner-level spy on elementSelector sees 0 calls with no entry, with another rule's entry and with an items-only entry; each of the three rules builds no path when the flag is unset); the class slice, the per-element cache and the segments-squared charge are each pinned by a test that fails without them; the hostile "409 KB class and 5,000 controls" test now asserts the outcome (all 5,000 waived, check passes, meta.ignored items 5,000). Docs: an ancestor with a tag name like o:p or svg:x makes the path unparseable so selectors never match it (fails closed); selector matching shares the audit-wide 50M step pool with regex and glob entries; about 100 MB per 100,000 reported elements at the 1,000-character path cap while an entry names the rule.

Skill: needs a change (the config reference gains selectors): the maintainer files the private skills issue.

nik

@nc9
nc9 force-pushed the feat/ignore-selectors-1440 branch 2 times, most recently from ada6f23 to 5ee4b62 Compare November 1, 2026 05:35
…s, for label-content-name-mismatch, form-labels and select-name #1440

Signed-off-by: Nik Cubrilovic <[email protected]>
@nc9
nc9 force-pushed the feat/ignore-selectors-1440 branch from 5ee4b62 to 46bd1a1 Compare November 1, 2026 05:54
@nc9 nc9 mentioned this pull request Nov 1, 2026
@nc9

nc9 commented Nov 1, 2026

Copy link
Copy Markdown
Contributor Author

Landed in v0.0.155 as ab4c091b via #1503.

nik

@nc9 nc9 closed this Nov 1, 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.

rule_options ignore: support selectors in [[ignore]] entries (#1262 follow-up)

1 participant