Search code examples
cssangularsasssonarqubeangular-schematics

Empty style (.css/.scss) files


When I create Angular application, I am using CLI for generating components. After certain time of developing app I have style file for every component but major part of them are empty.

When I check sonar I have Code smells in empty style files:

  • Remove this empty stylesheet.
  • Add an empty new line at the end of this file.

Should I remove sonar rules or I must delete all empty style files in project and recreating them in next versions of project when I need them for component styling? What are best practices?


Solution

  • For me, you can let the CSS / SCSS files empty. Just because after the build everything around styling will be minified and contained the "styles.js" file. So, even if it's a bit ugly to see all these empty files in dev mode, the compiler will solve your probelm by itself

    this is a screen of your project after build :

    enter image description here