
Product
Introducing Pull Request Stories to Help Security Teams Track Supply Chain Risks
Socket’s new Pull Request Stories give security teams clear visibility into dependency risks and outcomes across scanned pull requests.
lesshint
is a tool to aid you in writing clean and consistent Less.
Node.js 0.10 (or later) or io.js 1.0 (or later).
Run the following command from the command line (add -g to install globally):
npm install lesshint
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 specified by it's own JSON object, for example:
"fileExtensions": [".less", ".css"],
"excludedFiles": ["vendor.less"],
"spaceAfterPropertyColon": {
"enabled": true,
"style": "one_space" // Comments are allowed
}
Array of file extensions to check. Either an array of extensions or "*"
to allow all files. For example:
"fileExtensions": [".less", ".css"] // Allow ".less" and ".css" files. Can be passed with or without a dot.
"fileExtensions": "*" // Allow all files
Array of minimatch glob patterns or a file to exclude. For example:
"excludedFiles": ["vendor/*.less"] // Ignore all files in "vendor/"
"excludedFiles": ["vendor.less"] // Ignore a file named "vendor.less"
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. |
-r /--reporter | The reporter to use. See "Reporters" below for possible values. |
-V /--version | Show version. |
Depending on the linter results and options supplied, the exit status code returned by the CLI will differ.
Exit status code | Description |
---|---|
0 | Everything is alright, no linting errors found. |
1 | One or more linting errors with a severity of warning was found. |
2 | One or more linting errors with a severity of error was found (since 1.3.0 ). |
66 | No files to lint were supplied. |
70 | An unknown error occurred within lesshint , possibly a bug. Please file an issue! |
78 | Something is wrong with the config file, most likely invalid JSON. |
These codes were chosen with regards to the preferable exit codes.
As of 0.8.0
the ability to specify custom reporters has been added. These can do anything from just printing something to the terminal to generate custom reports.
There are three ways to load a reporter.
lesshint
is installed globally only globally installed reporters are available (the normal Node module loading rules apply).process.cwd()
.stylish
- Colored print of all errors to the console.In it's simplest form, a reporter is just a function accepting some input. The most basic reporter possible:
module.exports = {
report: function (errors) {
console.log(errors.length ? 'Errors found' : 'No errors');
}
};
// Old usage, deprecated as of 1.2.0:
module.exports = function (errors) {
console.log(errors.length ? 'Errors found' : 'No errors');
};
The reporter will be passed an array of objects representing each error:
{
column: 5,
file: 'test.less',
line: 1,
linter: 'spaceBeforeBrace',
message: 'Opening curly brace should be preceded by one space.',
severity: 'warning',
source: '.foo{'
}
It's then up to the reporter to do something with the errors. No return
s or anything is needed. lesshint
will handle everything like exit codes etc.
Take a look at the default reporter for more information.
1.3.0 (2016-02-12)
spaceAroundOperator
(ac689c7)severity
and added a new exit status code for it. See linter docs for more info. (0bc95e1, 062950f, e1d6831)4.x
. (ac52619)singleLinePerProperty
. (072664d, bc439e7)FAQs
A tool to aid you in writing clean and consistent Less.
We found that lesshint demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Product
Socket’s new Pull Request Stories give security teams clear visibility into dependency risks and outcomes across scanned pull requests.
Research
/Security News
npm author Qix’s account was compromised, with malicious versions of popular packages like chalk-template, color-convert, and strip-ansi published.
Research
Four npm packages disguised as cryptographic tools steal developer credentials and send them to attacker-controlled Telegram infrastructure.