Report the stylesheets an entry imports that no view needs any more
missingStylesheets() names an import the views need, but nothing named one they had stopped needing: when SealShare's last card left its views, card.css stayed in every page until a reviewer noticed by hand. unusedStylesheets($cssEntry) reads the entry's direct package imports and reports each one no scanned view needs, counting what a needed stylesheet imports itself and foundation.css always; an entry that imports all.css is left alone. Opt-in, beside missingStylesheets() (plan step 46). Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5
parent
ff5349759b
commit
05f115ab36
@@ -420,6 +420,20 @@ it('counts what an imported package stylesheet already brings in, through its ow
|
||||
expect($violations)->toBe([]);
|
||||
});
|
||||
|
||||
it('names each stylesheet the entry imports that no scanned view needs, and leaves all.css alone', function () {
|
||||
// dependencies.blade.php renders <x-button>, <x-menu> and <x-split-button>: menu.css is needed
|
||||
// (and reached through split-button.css too); card.css and stack.css serve nothing on the page.
|
||||
$entry = realpath(GUARD_FIXTURES.'/stylesheets/unused.css');
|
||||
|
||||
expect(fixtureRelative(DesignGuard::scan(realpath(GUARD_FIXTURES.'/stylesheets/views/dependencies.blade.php'))->unusedStylesheets($entry)->violations()))->toBe([
|
||||
"stylesheets/unused.css:4 `components/card.css` is imported, but no scanned view renders a component that needs it — remove `@import '../../../../resources/css/components/card.css';`",
|
||||
"stylesheets/unused.css:5 `layout/stack.css` is imported, but no scanned view renders a component that needs it — remove `@import '../../../../resources/css/layout/stack.css';`",
|
||||
])
|
||||
// missingStylesheets() alone never reports an unused import.
|
||||
->and(DesignGuard::scan(realpath(GUARD_FIXTURES.'/stylesheets/views/dependencies.blade.php'))->missingStylesheets($entry)->violations())->toBe([])
|
||||
->and(DesignGuard::scan(realpath(GUARD_FIXTURES.'/stylesheets/views/dependencies.blade.php'))->unusedStylesheets(realpath(GUARD_FIXTURES.'/stylesheets/all.css'))->violations())->toBe([]);
|
||||
});
|
||||
|
||||
it('needs nothing more once the entry imports all.css', function () {
|
||||
$violations = DesignGuard::scan(realpath(GUARD_FIXTURES.'/stylesheets/views'))
|
||||
->missingStylesheets(realpath(GUARD_FIXTURES.'/stylesheets/all.css'))
|
||||
|
||||
Reference in New Issue
Block a user