Skip to content

benhammondmusic/find-dead-classes

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

41 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Find Dead Classes 😵

Simple tool that compares a directory's .scss and .tsx files, and reports the "dead" code, meaning a class declaration like .CoolText {} that is never called in a component, or a class call like className={styles.AwesomeText} that is not declared in any style file.

To Use

In your terminal, navigate to the directory that contains the existing project you want to check:

cd code/MySweetProject

Run the script:

npx @benhammondmusic/find-dead-classes

The results will be logged to the console; showing each .scss file grouped with any related .tsx files

Example

fdc.mov

TODO

  • make script return {deadClasses: [...], deadDeclarations: [...]}
  • add tests to ensure expected passes/failures for /test-project
  • add more scss/tsx test files to /test-project
  • allow config options (.css, .scss, .ts, .js, .jsx)
  • allow fo @uses and not just @import
  • test on some more real projects
  • use in Health Equity Tracker as an automated test

https://benhammond.tech

About

Find unused .ClassDeclarations in .scss files, and find undeclared styles.ClassCalls in .tsx files

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published