lesshint
lesshint
is a tool to aid you in writing clean and consistent Less.
Requirements
Node.js 0.10 (or later) or io.js 1.0 (or later).
Installation
Run the following command from the command line (add -g to install globally):
npm install lesshint
Configuration
lesshint
is customizable and we highly recommend you to look at the available options to tailor it to your needs.
Start by creating a .lesshintrc
file in your project root and add your settings to it. It will be automatically loaded and merged with the default values.
Each option is then specifed by it's own JSON object, for example:
"fileExtensions": [".less", ".css"],
"excludedFiles": ["vendor.less"],
"spaceAfterPropertyColon": {
"enabled": true,
"style": "one_space"
}
Options
fileExtensions
Array of file extensions to check. Either an array of extensions or "*"
to allow all files. For example:
"fileExtensions": [".less", ".css"]
"fileExtensions": "*"
excludedFiles
Array of minimatch glob patterns or a file to exclude. For example:
"excludedFiles": ["vendor/*.less"]
"excludedFiles": ["vendor.less"]
CLI usage
Run lesshint
from the command-line by passing one or more files/directories to recursively scan.
lesshint src/less/ lib/style.less
Available Flags | Description |
---|
-c /--config | Specify the configuration file to use (will be merged with defaults). |
-e /--exclude | A minimatch glob pattern or a file to exclude form being linted. |
-V /--version | Show version. |
Known issues
We are aware of some instances where some Less features won't be properly parsed. In those cases the whole file will simply be ignored by lesshint
.
- Using variables in
@media
directives are not supported. Related issue. - Using variables in selectors are not supported. Related issue.
- Using double parentheses around calculations etc. are not supported. Related issue.