From fbea03cb977b5294143fad5b388415f7d0a95ad2 Mon Sep 17 00:00:00 2001 From: Robert King Date: Tue, 4 Apr 2017 10:21:58 -0700 Subject: [PATCH 1/2] Adding ability to pass cli options to rules --- src/cli/common.js | 2 +- src/core/CSSLint.js | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/cli/common.js b/src/cli/common.js index 4533ad78..502c2a80 100644 --- a/src/cli/common.js +++ b/src/cli/common.js @@ -140,7 +140,7 @@ function cli(api) { function processFile(relativeFilePath, options) { var input = api.readFile(relativeFilePath), ruleset = filterRules(options), - result = CSSLint.verify(input, gatherRules(options, ruleset)), + result = CSSLint.verify(input, gatherRules(options, ruleset), options), formatter = CSSLint.getFormatter(options.format || "text"), messages = result.messages || [], output, diff --git a/src/core/CSSLint.js b/src/core/CSSLint.js index 4ebbfa15..b6c5b7b0 100644 --- a/src/core/CSSLint.js +++ b/src/core/CSSLint.js @@ -169,10 +169,11 @@ var CSSLint = (function() { * @param {Object} ruleset (Optional) List of rules to apply. If null, then * all rules are used. If a rule has a value of 1 then it's a warning, * a value of 2 means it's an error. + * @param {Object} options (Optional) options for processing * @return {Object} Results of the verification. * @method verify */ - api.verify = function(text, ruleset) { + api.verify = function(text, ruleset, options) { var i = 0, reporter, @@ -245,7 +246,7 @@ var CSSLint = (function() { for (i in ruleset) { if (ruleset.hasOwnProperty(i) && ruleset[i]) { if (rules[i]) { - rules[i].init(parser, reporter); + rules[i].init(parser, reporter, options); } } } From b80894f3e34c80cb8ceb2355e3e9993458d36e4a Mon Sep 17 00:00:00 2001 From: Robert King Date: Thu, 6 Apr 2017 10:40:18 -0700 Subject: [PATCH 2/2] Defaulting 'evidence' property to empty string --- src/core/Reporter.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/core/Reporter.js b/src/core/Reporter.js index cdaf73dc..9362c402 100644 --- a/src/core/Reporter.js +++ b/src/core/Reporter.js @@ -133,7 +133,7 @@ Reporter.prototype = { line : line, col : col, message : message, - evidence: this.lines[line-1], + evidence: this.lines[line-1] || "", rule : rule }); },