scss-lint is a tool to help keep your SCSS files
clean and readable. You can run it manually from the command-line, or integrate
it into your SCM hooks. It uses rules established by the team at
- Ruby 1.9+
- Sass 3 (files you wish to lint must be written in Sass 3 syntax)
gem install scss-lint
scss-lint from the command-line by passing in a directory (or multiple
directories) to recursively scan:
You can also specify a list of files explicitly:
scss-lint will output any problems with your SCSS, including the offending
filename and line number (if available).
What gets linted
scss-lint is an opinionated tool that helps you enforce a consistent style in
your SCSS. As an opinionated tool, we've had to make calls about what we think
are the "best" style conventions, even when there are often reasonable arguments
for more than one possible style. While all of our choices have a rational
basis, we think that the opinions themselves are less important than the fact
scss-lint provides us with an automated and low-cost means of enforcing
To get a sense of what lints exist, check out the spec suite.
The lints include:
- use unit-less dimensions for 0-length quantities; ie.
margin: 0, not
- keep your rules in order, with mix-ins at the top
- use one selector per line
- use the shortest shorthand possible; ie.
padding: 0, not
padding: 0 0
- use consistent spacing between property names and property values
- use short-form lowercase hex codes when possible; ie.
- exclude empty rules
We love getting feedback with or without pull requests. If you do add a new feature, please add tests so that we can avoid breaking it in the future.
Speaking of tests, we use
rspec, which can be run like so:
bundle exec rspec
If you'd like to integrate
scss-lint with Git, check out our Git hook gem,
This project is released under the MIT license.