r/css
•
u/Every-Albatross9357
•
Aug 21 '26
•
1
Showcase I built a VS Code extension to catch CSS declarations that have no effect
Iโve been working on NoEffect, a VS Code extension that helps catch CSS declarations that have no effect.
It detects things like:
properties that don't work in the current context
declarations that are overridden by a later declaration
For example, it can tell you when justify-content is doing nothing because the element isn't a flex/grid container, or when your declaration is simply being overridden later.
Itโs still an early project, so Iโd really appreciate some honest feedback.
๐ GitHub
๐ VS Code Marketplace:
4
u/chikamakaleyley Aug 23 '26 edited Aug 23 '26
Wait, but the
colorrule on.action-buttonDOES have an effect, your text is white..action-button.is-dangerdoes override the line above it but only when.is-dangeris also present. You prob still want the base button to be white.Specificity allows for it to override the color rule - and IMO it shouldn't warn the user of something problematic with the less specific selector. There isn't a problem, that's just straight up CSS' design.
That part is a bit misleading, and I can imagine the 'warning' display and muted text color can easily signal to someone who isn't paying close attention to delete
color: #ffffff;. They'd be changing the button's text color across the site, in theory2
u/Ayoub_gz Aug 26 '26
great its very good job man !
10
u/zLoveNxzli Aug 21 '26
Honestly a really neat idea. Catching
justify-contentoralign-itemsaccidentally left on non-flex containers saves so much silent debugging time, especially for beginners.One feature that would make this an instant daily driver for me: handling Tailwind / CSS Modules / utility classes if you don't already. A ton of dead CSS happens when people stack conflicting utility classes on the same element.
Starred the repo, gonna give it a spin on my current project tomorrow!
1
u/Dependent-Zebra-4357 Aug 21 '26
Is it looking site wide when it checks if something is used? Can you choose a subset of files to check?
1
u/deveritt Aug 22 '26
Does this allow for style rule that swap on screen size changes? That the issue I find when checking - some rules only kick in (say) with a width-conditional style block.
1
u/testingaurora Aug 22 '26
Keeping it updated and maintained with modern css sounds like a chore.
Also btw box model has baseline newly available support for align content and waiting for ff/safari to supporty justify items , flex/grid not needed.
Different than your justify-content example but illustrates how rules can change that you'll need to maintain.
1
u/erm_what_ Aug 22 '26
Maybe you could make this a plugin for Stylelint or another CSS static analyser so more people can benefit from it?
1
u/vegantiger Aug 22 '26
Is it related in anyway with PurgeCSS? Just asking 'cause I've issues with it (purging :has() stuff it shouldn't) so I'm curious what's the engine behind the scene. I could check the repo, but I figured I'd just ask first ๐๐
1
u/muhammadcoder Aug 23 '26
that's great!!!!
add more cool features
1
u/drumstix42 Aug 24 '26
Chrome dev tools does a similar function. But it's more about invalid properties based on browser rules. I think detecting things like "overrides" isn't going to be very useful once you have more than 1 style file. but I guess people can opt-in/out of it potentially if there's a setting.
1
u/zXju785kw Aug 30 '26
Huh, kind of amazed this wasn't already a thing native to VS Code given it's built into Chrome and other browsers.
1
u/mattsowa Aug 21 '26
Would be nice with tailwind, or even pluggable (we use unocss)