Rules Hub
Coding Rules Library
← Back to all rules
Rule priority, scope & exceptions
Use this to align rules with the senior-level structure (P0/P1/P2, scope, exceptions/tradeoffs).
frontend ruleP1universalStack: Storybook/testing
testingstorybookisolationcleanup
Restore shared environment state after a story/test changes it
When a story or test mutates shared state (e.g. the viewport, globals), reset it on teardown so later stories/tests aren't affected by leaked state.
PR: hegnar-components · org-mining-hist-2026-06Created: Jun 18, 2026
Bad example
Old codetypescript
| 1 | export const Mobile = { |
| 2 | parameters: { viewport: { defaultViewport: 'mobile' } }, |
| 3 | }; |
| 4 | // leaks the mobile viewport into the next story |
Explanation (EN)
Objašnjenje (HR)
Good example
New codetypescript
| 1 | export const Mobile = { |
| 2 | parameters: { viewport: { defaultViewport: 'mobile' } }, |
| 3 | // ensure the addon restores the previous viewport on leave, |
| 4 | // so other stories render at their intended size |
Explanation (EN)
Objašnjenje (HR)