fix(core): warn when composeSimple receives modifiers from different …#633
Merged
veged merged 1 commit intobem:masterfrom Feb 18, 2026
Merged
Conversation
…blocks Co-authored-by: Cursor <cursoragent@cursor.com>
veged
approved these changes
Feb 18, 2026
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Проблема
Функция
composeSimpleвнутриcompose— оптимизация, которая объединяет несколько «простых» модификаторов (без кастомногоenhance) в один компонент-обёртку вместо цепочки HOC-ов.При этом она молча предполагает, что все переданные модификаторы принадлежат одному и тому же блоку:
__blockNameберётся только из первого элемента массива, и на его основе создаётся единственныйentity. Названия блоков у остальных модификаторов игнорируются.Если передать в
composeпростые модификаторы от разных блоков, все они применяются к первому блоку — результирующие CSS-классы генерируются неверно, и никакого предупреждения при этом не выводится:Решение
В начало
composeSimpleдобавлена проверка: если хотя бы один из модификаторов принадлежит блоку, отличному от первого, в консоль выводитсяconsole.errorс объектомError. ИспользованиеError(а не строки) гарантирует, что в консоли отображается полный стектрейс — разработчик сразу видит, где именно был вызван некорректныйcompose.Проверка работает в любом окружении (не ограничена
__DEV__), поскольку подобная ошибка конфигурации может проявиться и в продакшене.