-
-
Save marciobarrios/1798852 to your computer and use it in GitHub Desktop.
CSS Lint API
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//include | |
var CSSLint = require("csslint").CSSLint; | |
/* | |
* Basic usage | |
* First argument is the CSS text. | |
* Second argument is the options object. Name is the ID of the rule (see wiki) set to | |
* either 1 for a warning or 2 for an error. | |
*/ | |
var result = CSSLint.verify(".foo { }", { "compatible-vendor-prefixes": 1 }), | |
messages = result.messages; | |
/* | |
* Each object in the messages array has: | |
* - message - the actual warning text | |
* - evidence - the line of code that triggered the message | |
* - line - the line number | |
* - col - the column number | |
* - type - the type of message ("error" or "warning") | |
*/ | |
messages.forEach(function (message, i) { | |
output = output + "\n\n" + shortFilename; | |
if (message.rollup) { | |
output += "\n" + (i+1) + ": " + message.type; | |
output += "\n" + message.message; | |
} else { | |
output += "\n" + (i+1) + ": " + message.type + " at line " + message.line + ", col " + message.col; | |
output += "\n" + message.message; | |
output += "\n" + message.evidence; | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment