How to find CSS/SCSS classes that contains single property

182 Views Asked by At

I have bunch of SCSS files. I'd like to find blocks which contains only single property, like:

&__input {
  width: 100%;
}

What tools may be helpful here (for example some NodeJS library etc.) ?

I've created repository to better show what I want to achieve: https://github.com/lusarz/singular-scss-block-finder

1

There are 1 best solutions below

4
On BEST ANSWER

You'll have to create an Abstract Syntax Tree (AST) for each SCSS file, which will allow you to traverse and analyze your code.

The library scss-parser looks pretty robust for creating ASTs for SCSS, though I have never used it.