csslint
Lint CSS code for errors and style
TLDR
Lint a single CSS file
Lint multiple CSS files
List all possible style rules
Treat certain rules as errors (which results in a non-zero exit code)
Treat certain rules as warnings
Ignore specific rules
SYNOPSIS
csslint [options] file.css [file2.css ...]
PARAMETERS
--errors
Show only errors, hiding warnings.
--warnings
Show only warnings, hiding errors.
--quiet
Suppress all output except for the final report.
--version
Display the version number and exit.
--config file
Specify a configuration file to use.
--list-rules
List all available rules.
--format format
Specify the output format (e.g., text, compact, json).
DESCRIPTION
csslint is a command-line tool and library designed to identify potential problems in CSS code.
It helps developers write more maintainable and efficient stylesheets by enforcing a set of coding conventions and best practices. csslint parses CSS files and analyzes them for issues related to syntax, performance, accessibility, and compatibility. It's a valuable asset for any front-end developer striving for high-quality CSS code. Using csslint, developers can catch errors early in the development process, reduce the likelihood of browser compatibility issues, and improve the overall performance of their web applications. The tool is highly customizable, allowing users to configure which rules are enforced and the severity of the reported errors.
This customization makes it adaptable to various project requirements and coding style preferences.
CAVEATS
csslint relies on parsing CSS code and may not always accurately identify all potential issues. Results should be reviewed in context.
CONFIGURATION FILES
csslint can be configured using a .csslintrc
file. This file allows you to specify which rules to enable or disable and configure their severity levels. The config file should be a JSON file. It allows to override global settings and define project specific linting rules. It's commonly placed in the project's root directory.
RULE SEVERITIES
csslint supports different severity levels for rules: error
and warning
. Errors indicate more serious problems that should be addressed, while warnings suggest potential issues that may or may not be problematic.
HISTORY
csslint was initially developed to address the need for a dedicated tool to check the quality of CSS code. It has evolved over time with contributions from the open-source community. Usage has increased with the growing complexity of CSS and the adoption of best practices in web development.
SEE ALSO
eslint(1), stylelint(1)