Skip to content

Commit ad81e67

Browse files
committed
Merge remote-tracking branch 'refs/remotes/CSSLint/master'
2 parents 6beedfd + 5436a1e commit ad81e67

File tree

8 files changed

+1918
-1874
lines changed

8 files changed

+1918
-1874
lines changed

dist/cli.js

Lines changed: 53 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -30,20 +30,20 @@ THE SOFTWARE.
3030
/* global JSON */
3131
/* exported cli */
3232

33-
function cli(api){
33+
function cli(api) {
3434
"use strict";
3535

3636
var globalOptions = {
37-
"help" : { "format" : "", "description" : "Displays this information."},
38-
"format" : { "format" : "<format>", "description" : "Indicate which format to use for output."},
39-
"list-rules" : { "format" : "", "description" : "Outputs all of the rules available."},
40-
"quiet" : { "format" : "", "description" : "Only output when errors are present."},
41-
"errors" : { "format" : "<rule[,rule]+>", "description" : "Indicate which rules to include as errors."},
42-
"warnings" : { "format" : "<rule[,rule]+>", "description" : "Indicate which rules to include as warnings."},
43-
"ignore" : { "format" : "<rule[,rule]+>", "description" : "Indicate which rules to ignore completely."},
44-
"exclude-list": { "format" : "<file|dir[,file|dir]+>", "description" : "Indicate which files/directories to exclude from being linted."},
45-
"config" : { "format" : "<file>", "description" : "Reads csslint options from specified file."},
46-
"version" : { "format" : "", "description" : "Outputs the current version number."}
37+
"help" : { "format" : "", "description" : "Displays this information." },
38+
"format" : { "format" : "<format>", "description" : "Indicate which format to use for output." },
39+
"list-rules" : { "format" : "", "description" : "Outputs all of the rules available." },
40+
"quiet" : { "format" : "", "description" : "Only output when errors are present." },
41+
"errors" : { "format" : "<rule[,rule]+>", "description" : "Indicate which rules to include as errors." },
42+
"warnings" : { "format" : "<rule[,rule]+>", "description" : "Indicate which rules to include as warnings." },
43+
"ignore" : { "format" : "<rule[,rule]+>", "description" : "Indicate which rules to ignore completely." },
44+
"exclude-list": { "format" : "<file|dir[,file|dir]+>", "description" : "Indicate which files/directories to exclude from being linted." },
45+
"config" : { "format" : "<file>", "description" : "Reads csslint options from specified file." },
46+
"version" : { "format" : "", "description" : "Outputs the current version number." }
4747
};
4848

4949
//-------------------------------------------------------------------------
@@ -56,7 +56,7 @@ function cli(api){
5656
* @param type {String} The type of message to filter on.
5757
* @return {Array} An array of matching messages.
5858
*/
59-
function pluckByType(messages, type){
59+
function pluckByType(messages, type) {
6060
return messages.filter(function(message) {
6161
return message.type === type;
6262
});
@@ -67,20 +67,20 @@ function cli(api){
6767
* @param options {Object} The CLI options.
6868
* @return {Object} A ruleset object.
6969
*/
70-
function gatherRules(options, ruleset){
70+
function gatherRules(options, ruleset) {
7171
var warnings = options.rules || options.warnings,
7272
errors = options.errors;
7373

74-
if (warnings){
74+
if (warnings) {
7575
ruleset = ruleset || {};
76-
warnings.split(",").forEach(function(value){
76+
warnings.split(",").forEach(function(value) {
7777
ruleset[value] = 1;
7878
});
7979
}
8080

81-
if (errors){
81+
if (errors) {
8282
ruleset = ruleset || {};
83-
errors.split(",").forEach(function(value){
83+
errors.split(",").forEach(function(value) {
8484
ruleset[value] = 2;
8585
});
8686
}
@@ -99,7 +99,7 @@ function cli(api){
9999

100100
if (ignore) {
101101
ruleset = CSSLint.getRuleset();
102-
ignore.split(",").forEach(function(value){
102+
ignore.split(",").forEach(function(value) {
103103
ruleset[value] = 0;
104104
});
105105
}
@@ -123,7 +123,7 @@ function cli(api){
123123

124124
if (excludeList) {
125125
// Build up the exclude list, expanding any directory exclusions that were passed in
126-
excludeList.split(",").forEach(function(value){
126+
excludeList.split(",").forEach(function(value) {
127127
if (api.isDirectory(value)) {
128128
excludeFiles = excludeFiles.concat(api.getFiles(value));
129129
} else {
@@ -132,10 +132,10 @@ function cli(api){
132132
});
133133

134134
// Remove the excluded files from the list of files to lint
135-
excludeFiles.forEach(function(value){
135+
excludeFiles.forEach(function(value) {
136136
fullPath = api.getFullPath(value);
137137
if (filesToLint.indexOf(fullPath) > -1) {
138-
filesToLint.splice(filesToLint.indexOf(fullPath),1);
138+
filesToLint.splice(filesToLint.indexOf(fullPath), 1);
139139
}
140140
});
141141
}
@@ -147,10 +147,10 @@ function cli(api){
147147
* Outputs all available rules to the CLI.
148148
* @return {void}
149149
*/
150-
function printRules(){
150+
function printRules() {
151151
api.print("");
152152
var rules = CSSLint.getRules();
153-
rules.forEach(function(rule){
153+
rules.forEach(function(rule) {
154154
api.print(rule.id + "\n " + rule.desc + "\n");
155155
});
156156
}
@@ -181,7 +181,7 @@ function cli(api){
181181
//var relativeFilePath = getRelativePath(api.getWorkingDirectory(), fullFilePath);
182182
options.fullPath = api.getFullPath(relativeFilePath);
183183
output = formatter.formatResults(result, relativeFilePath, options);
184-
if (output){
184+
if (output) {
185185
api.print(output);
186186
}
187187

@@ -198,7 +198,7 @@ function cli(api){
198198
* Outputs the help screen to the CLI.
199199
* @return {void}
200200
*/
201-
function outputHelp(){
201+
function outputHelp() {
202202
var lenToPad = 40,
203203
toPrint = "",
204204
formatString = "";
@@ -236,39 +236,39 @@ function cli(api){
236236
* @param options {Object} options object
237237
* @return {Number} exit code
238238
*/
239-
function processFiles(fileArray, options){
239+
function processFiles(fileArray, options) {
240240
var exitCode = 0,
241241
formatId = options.format || "text",
242242
formatter,
243-
files = filterFiles(fileArray,options),
243+
files = filterFiles(fileArray, options),
244244
output;
245245

246246
if (!files.length) {
247247
api.print("csslint: No files specified.");
248248
exitCode = 1;
249249
} else {
250-
if (!CSSLint.hasFormat(formatId)){
250+
if (!CSSLint.hasFormat(formatId)) {
251251
api.print("csslint: Unknown format '" + formatId + "'. Cannot proceed.");
252252
exitCode = 1;
253253
} else {
254254
formatter = CSSLint.getFormatter(formatId);
255255

256256
output = formatter.startFormat();
257-
if (output){
257+
if (output) {
258258
api.print(output);
259259
}
260260

261261

262-
files.forEach(function(file){
262+
files.forEach(function(file) {
263263
if (exitCode === 0) {
264-
exitCode = processFile(file,options);
264+
exitCode = processFile(file, options);
265265
} else {
266-
processFile(file,options);
266+
processFile(file, options);
267267
}
268268
});
269269

270270
output = formatter.endFormat();
271-
if (output){
271+
if (output) {
272272
api.print(output);
273273
}
274274
}
@@ -284,11 +284,11 @@ function cli(api){
284284
parts,
285285
files = [];
286286

287-
while(arg){
288-
if (arg.indexOf("--") === 0){
287+
while (arg) {
288+
if (arg.indexOf("--") === 0) {
289289
argName = arg.substring(2);
290290

291-
if (argName.indexOf("=") > -1){
291+
if (argName.indexOf("=") > -1) {
292292
parts = argName.split("=");
293293
options[parts[0]] = parts[1];
294294
} else {
@@ -298,7 +298,7 @@ function cli(api){
298298
} else {
299299

300300
//see if it's a directory or a file
301-
if (api.isDirectory(arg)){
301+
if (api.isDirectory(arg)) {
302302
files = files.concat(api.getFiles(arg));
303303
} else {
304304
files.push(arg);
@@ -341,7 +341,7 @@ function cli(api){
341341
data += "--" + optionName + "=" + json[optionName].join();
342342
}
343343
}
344-
} catch(e) {}
344+
} catch (e) {}
345345
}
346346
options = processArguments(data.split(/[\s\n\r]+/m));
347347
}
@@ -362,17 +362,17 @@ function cli(api){
362362
// Preprocess command line arguments
363363
cliOptions = processArguments(args);
364364

365-
if (cliOptions.help || argCount === 0){
365+
if (cliOptions.help || argCount === 0) {
366366
outputHelp();
367367
api.quit(0);
368368
}
369369

370-
if (cliOptions.version){
370+
if (cliOptions.version) {
371371
api.print("v" + CSSLint.version);
372372
api.quit(0);
373373
}
374374

375-
if (cliOptions["list-rules"]){
375+
if (cliOptions["list-rules"]) {
376376
printRules();
377377
api.quit(0);
378378
}
@@ -390,7 +390,7 @@ function cli(api){
390390
// Validate options
391391
validateOptions(options);
392392

393-
api.quit(processFiles(options.files,options));
393+
api.quit(processFiles(options.files, options));
394394
}
395395

396396
/*
@@ -409,42 +409,42 @@ var fs = require("fs"),
409409
cli({
410410
args: process.argv.slice(2),
411411

412-
print: function(message){
412+
print: function(message) {
413413
fs.writeSync(1, message + "\n");
414414
},
415415

416-
quit: function(code){
416+
quit: function(code) {
417417
process.exit(code || 0);
418418
},
419419

420-
isDirectory: function(name){
420+
isDirectory: function(name) {
421421
try {
422422
return fs.statSync(name).isDirectory();
423423
} catch (ex) {
424424
return false;
425425
}
426426
},
427427

428-
getFiles: function(dir){
428+
getFiles: function(dir) {
429429
var files = [];
430430

431431
try {
432432
fs.statSync(dir);
433-
} catch (ex){
433+
} catch (ex) {
434434
return [];
435435
}
436436

437-
function traverse(dir, stack){
437+
function traverse(dir, stack) {
438438
stack.push(dir);
439-
fs.readdirSync(stack.join("/")).forEach(function(file){
439+
fs.readdirSync(stack.join("/")).forEach(function(file) {
440440
var path = stack.concat([file]).join("/"),
441441
stat = fs.statSync(path);
442442

443443
if (file[0] === ".") {
444444
return;
445-
} else if (stat.isFile() && /\.css$/.test(file)){
445+
} else if (stat.isFile() && /\.css$/.test(file)) {
446446
files.push(path);
447-
} else if (stat.isDirectory()){
447+
} else if (stat.isDirectory()) {
448448
traverse(file, stack);
449449
}
450450
});
@@ -460,11 +460,11 @@ cli({
460460
return process.cwd();
461461
},
462462

463-
getFullPath: function(filename){
463+
getFullPath: function(filename) {
464464
return path.resolve(process.cwd(), filename);
465465
},
466466

467-
readFile: function(filename){
467+
readFile: function(filename) {
468468
try {
469469
return fs.readFileSync(filename, "utf-8");
470470
} catch (ex) {

0 commit comments

Comments
 (0)