analyze-css can be used from the Node.js console or programmatically as any other JS library inside the code.
analyze-css works by parsing an entire CSS file and running its content against a series of metrics and parameters.
It then builds a report in the form of a JSON file, listing each metrics' value, and a list of "offenders" at the bottom with more in-depth details about problematic areas.
In case the file is hard to read, there's also a JSON pretty-printing option available as well.
analyze-css can work with local CSS files stored on disk, or with remote stylesheets used in production environments or hosted on a dev site.
The library also comes with (experimental) SCSS support.
Features:
- analyze-css scanned metrics:
- Number of rules
- Number of selectors
- Number of declarations
- Number of media queries
- Number of empty rules
- Number of @import rules
- Number of @important properties
- Number of properties with vendor prefixes
- Number of complex selectors
- Number of duplicate selectors
- Number of redundant body selectors
- Number of qualified selectors
- Number of rules with CSS expressions
- Number of fixes for old versions of Internet Explorer
- Number of selectors by attribute
- Number of selectors by class
- Number of selectors by ID
- Number of pseudo-selectors
- Number of selectors by tag name
- Number of universal selectors
- Number of CSS comments
- Comment length
- Length of CSS source
- Length of base64-encoded data found embedded in the CSS file
- Average specificity for ID
- Total specificity for ID
- Average specificity for class, pseudo-class or attribute
- Total specificity for class, pseudo-class or attribute
- Average specificity for element
- Total specificity for element
What is new in this release:
- This release brings the detection of duplicated properties (especially useful when using CSS preprocessors) and command line / CommonJS module option to disabled offenders.
What is new in version 0.5.0:
- Added support for analyzing SASS files
- Report CSS @import
- Relax redundant body selector rule
- Code coverage via Istanbul
Requirements:
- Node.js 0.8 or higher
Comments not found