From 051318c6dbaf8696844799810bd817d5f6a35ca9 Mon Sep 17 00:00:00 2001 From: Andrew Seguin Date: Thu, 31 Jul 2025 10:33:23 -0600 Subject: [PATCH 1/2] fix(material/core): add key validation to m2-theme --- src/material/core/tokens/_system.scss | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/material/core/tokens/_system.scss b/src/material/core/tokens/_system.scss index 6f7aeb3fec84..a281d372931b 100644 --- a/src/material/core/tokens/_system.scss +++ b/src/material/core/tokens/_system.scss @@ -24,6 +24,7 @@ @use '../style/sass-utils'; @use './m2'; @use './m3'; +@use 'sass:list'; @use 'sass:map'; @use 'sass:meta'; @@ -328,6 +329,19 @@ 'configs created with define-light-theme or define-dark-theme'; } + // Check whether any override keys do not match keys in the theme + // config system map. + $invalid-keys: (); + $config-system: map.get($theme-config, _mat-system); + @each $key, $value in $overrides { + @if (not map.has-key($config-system, $key)) { + $invalid-keys: list.append($invalid-keys, $key); + } + } + @if (list.length($invalid-keys) > 0) { + @error 'The following overrides are not valid system variables: #{$invalid-keys}. Valid keys are: #{map.keys($config-system)}'; + } + $config: m2-inspection.get-m2-config($theme-config); $color: map.get($config, color); From 9358a4b7751996912327da315c910d070a342466 Mon Sep 17 00:00:00 2001 From: Andrew Seguin Date: Thu, 31 Jul 2025 14:54:36 -0600 Subject: [PATCH 2/2] refactor: lint --- src/material/core/tokens/_system.scss | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/material/core/tokens/_system.scss b/src/material/core/tokens/_system.scss index a281d372931b..3d4e72af14f5 100644 --- a/src/material/core/tokens/_system.scss +++ b/src/material/core/tokens/_system.scss @@ -339,7 +339,8 @@ } } @if (list.length($invalid-keys) > 0) { - @error 'The following overrides are not valid system variables: #{$invalid-keys}. Valid keys are: #{map.keys($config-system)}'; + @error 'The following overrides are not valid system variables: #{$invalid-keys}. ' + + 'Valid keys are: #{map.keys($config-system)}'; } $config: m2-inspection.get-m2-config($theme-config);