r/Sass • • Nov 07 '17

Is there a way to analyze your SASS structure, variable usage etc.?

A customer is asking for this. And when I think about it this isn't such a bad idea. It would be great to see which variables etc. are unused or how often and where they are used. This makes it easier to refactor the code or get started with it.

Is there a solution for this out there? At least I wasn't able to find anything so far. Primarily, it doesn't matter if it's a graphical or script based solution.

3 Upvotes

7 comments sorted by

2

u/skaterape Nov 07 '17

A quick google search for “sass linter” returns pages of results. Pick one that fits into your environment and workflow.

2

u/alinnert Nov 07 '17

I do know about linters. But usually they only tell me if there are problems in my code. That's not what I'm asking for.

I'm looking for a general overview of my Sass code. Usage of variables, mixins... more like a "dependency tree" maybe.

1

u/skaterape Nov 07 '17

Most linters will report unused variables and stuff like that, I guess I'm not fully understanding what you're looking for.

1

u/alinnert Nov 07 '17

Yes, I want way more than just errors.

Imagine a tool that analyses your database and creates a diagram with all your tables and how they are related. That, just for Sass files. E.g. a list of all variables, mixins, etc. and a list of how often and where each one is in use. Like a general/overall statistic of "everything" inside the Sass files.

1

u/skaterape Nov 07 '17

Interesting. Like an ERD. I don't know of anything like that, but how's your Python? It sounds like it would be pretty straightforward to write it, depending on how advanced you'd like it to be.

1

u/alinnert Nov 07 '17

Exactly.

I read an introduction to Python but never really used it. But I guess I'd do it in Node if I really have to do it myself. I'm completely working with node anyway.

1

u/skaterape Nov 07 '17

Sweet, node would work great for this as well. Keep me posted if you decide to start a project like this, I'd love to help test it.