Skip to content

Commit

Permalink
Merge branch 'develop' into v1-dev
Browse files Browse the repository at this point in the history
  • Loading branch information
DanPurdy authored Oct 3, 2017
2 parents 50e21f5 + 241e5a0 commit 07d41df
Show file tree
Hide file tree
Showing 14 changed files with 234 additions and 96 deletions.
42 changes: 23 additions & 19 deletions bin/sass-lint.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,20 +16,13 @@ var tooManyWarnings = function (detects, userConfig) {
return warningCount > 0 && warningCount > userConfig.options['max-warnings'];
};

var detectPattern = function (pattern, userConfig) {
var detectPattern = function (pattern) {
var detects = lint.lintFiles(pattern, configOptions, configPath);

if (program.verbose) {
lint.outputResults(detects, configOptions, configPath);
}

if (lint.errorCount(detects).count || tooManyWarnings(detects, userConfig)) {
exitCode = 1;
}

if (program.exit) {
lint.failOnError(detects, configOptions, configPath);
}
return detects;
};

program
Expand Down Expand Up @@ -72,17 +65,28 @@ if (program.maxWarnings && program.maxWarnings !== true) {
configOptions.options['max-warnings'] = program.maxWarnings;
}

// load our config here so we only load it once for each file
config = lint.getConfig(configOptions, configPath);
(function () {
// load our config here so we only load it once for each file
config = lint.getConfig(configOptions, configPath);
var results = [];

if (program.args.length === 0) {
detectPattern(null, config);
}
else {
program.args.forEach(function (path) {
detectPattern(path, config);
});
}
if (program.args.length === 0) {
results = results.concat(detectPattern(null));
}
else {
program.args.forEach(function (path) {
results = results.concat(detectPattern(path));
});
}

if (program.verbose) {
lint.outputResults(results, configOptions, configPath);
}

if (lint.errorCount(results).count || tooManyWarnings(results, config)) {
exitCode = 1;
}
}());

process.on('exit', function () {
process.exit(exitCode); // eslint-disable-line no-process-exit
Expand Down
18 changes: 9 additions & 9 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ sassLint.getConfig = function (config, configPath) {
* Parses our results object to count errors and return
* paths to files with detected errors.
*
* @param {object} results our results object
* @param {Array} results our results Array
* @returns {object} errors object containing the error count and paths for files incl. errors
*/
sassLint.errorCount = function (results) {
Expand All @@ -58,7 +58,7 @@ sassLint.errorCount = function (results) {
* Parses our results object to count warnings and return
* paths to files with detected warnings.
*
* @param {object} results our results object
* @param {Array} results our results array
* @returns {object} warnings object containing the error count and paths for files incl. warnings
*/
sassLint.warningCount = function (results) {
Expand All @@ -81,7 +81,7 @@ sassLint.warningCount = function (results) {
* Parses our results object to count warnings and errors and return
* a cumulative count of both
*
* @param {object} results our results object
* @param {Array} results our results array
* @returns {int} the cumulative count of errors and warnings detected
*/
sassLint.resultCount = function (results) {
Expand Down Expand Up @@ -188,7 +188,7 @@ sassLint.lintFileText = function (file, options, configPath) {
* @param {string} files a glob pattern or single file path as a lint target
* @param {object} options user specified rules/options passed in
* @param {string} configPath path to a config file
* @returns {object} results object containing all results
* @returns {Array} results object containing all results
*/
sassLint.lintFiles = function (files, options, configPath) {
var that = this,
Expand Down Expand Up @@ -245,10 +245,10 @@ sassLint.lintFiles = function (files, options, configPath) {
/**
* Handles formatting of results using EsLint formatters
*
* @param {object} results our results object
* @param {Array} results our results array
* @param {object} options user specified rules/options passed in
* @param {string} configPath path to a config file
* @returns {object} results our results object in the user specified format
* @returns {string} results our results object in the user specified format
*/
sassLint.format = function (results, options, configPath) {
var config = this.getConfig(options, configPath),
Expand All @@ -263,10 +263,10 @@ sassLint.format = function (results, options, configPath) {
* Handles outputting results whether this be straight to the console/stdout or to a file.
* Passes results to the format function to ensure results are output in the chosen format
*
* @param {object} results our results object
* @param {Array} results our results array
* @param {object} options user specified rules/options passed in
* @param {string} configPath path to a config file
* @returns {object} results our results object
* @returns {string} the formatted results string
*/
sassLint.outputResults = function (results, options, configPath) {
var config = this.getConfig(options, configPath);
Expand Down Expand Up @@ -295,7 +295,7 @@ sassLint.outputResults = function (results, options, configPath) {
* Throws an error if there are any errors detected. The error includes a count of all errors
* and a list of all files that include errors.
*
* @param {object} results - our results object
* @param {Array} results - our results array
* @param {object} [options] - extra options to use when running failOnError, e.g. max-warnings
* @param {string} [configPath] - path to the config file
* @returns {void}
Expand Down
Loading

0 comments on commit 07d41df

Please sign in to comment.