Skip to content

Commit b247c5f

Browse files
committed
Minor style tweaks.
1 parent d62278f commit b247c5f

File tree

94 files changed

+747
-745
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

94 files changed

+747
-745
lines changed

src/cli/common.js

Lines changed: 42 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -6,20 +6,20 @@
66
/* global JSON */
77
/* exported cli */
88

9-
function cli(api){
9+
function cli(api) {
1010
"use strict";
1111

1212
var globalOptions = {
13-
"help" : { "format" : "", "description" : "Displays this information."},
14-
"format" : { "format" : "<format>", "description" : "Indicate which format to use for output."},
15-
"list-rules" : { "format" : "", "description" : "Outputs all of the rules available."},
16-
"quiet" : { "format" : "", "description" : "Only output when errors are present."},
17-
"errors" : { "format" : "<rule[,rule]+>", "description" : "Indicate which rules to include as errors."},
18-
"warnings" : { "format" : "<rule[,rule]+>", "description" : "Indicate which rules to include as warnings."},
19-
"ignore" : { "format" : "<rule[,rule]+>", "description" : "Indicate which rules to ignore completely."},
20-
"exclude-list": { "format" : "<file|dir[,file|dir]+>", "description" : "Indicate which files/directories to exclude from being linted."},
21-
"config" : { "format" : "<file>", "description" : "Reads csslint options from specified file."},
22-
"version" : { "format" : "", "description" : "Outputs the current version number."}
13+
"help" : { "format" : "", "description" : "Displays this information." },
14+
"format" : { "format" : "<format>", "description" : "Indicate which format to use for output." },
15+
"list-rules" : { "format" : "", "description" : "Outputs all of the rules available." },
16+
"quiet" : { "format" : "", "description" : "Only output when errors are present." },
17+
"errors" : { "format" : "<rule[,rule]+>", "description" : "Indicate which rules to include as errors." },
18+
"warnings" : { "format" : "<rule[,rule]+>", "description" : "Indicate which rules to include as warnings." },
19+
"ignore" : { "format" : "<rule[,rule]+>", "description" : "Indicate which rules to ignore completely." },
20+
"exclude-list": { "format" : "<file|dir[,file|dir]+>", "description" : "Indicate which files/directories to exclude from being linted." },
21+
"config" : { "format" : "<file>", "description" : "Reads csslint options from specified file." },
22+
"version" : { "format" : "", "description" : "Outputs the current version number." }
2323
};
2424

2525
//-------------------------------------------------------------------------
@@ -32,7 +32,7 @@ function cli(api){
3232
* @param type {String} The type of message to filter on.
3333
* @return {Array} An array of matching messages.
3434
*/
35-
function pluckByType(messages, type){
35+
function pluckByType(messages, type) {
3636
return messages.filter(function(message) {
3737
return message.type === type;
3838
});
@@ -43,20 +43,20 @@ function cli(api){
4343
* @param options {Object} The CLI options.
4444
* @return {Object} A ruleset object.
4545
*/
46-
function gatherRules(options, ruleset){
46+
function gatherRules(options, ruleset) {
4747
var warnings = options.rules || options.warnings,
4848
errors = options.errors;
4949

50-
if (warnings){
50+
if (warnings) {
5151
ruleset = ruleset || {};
52-
warnings.split(",").forEach(function(value){
52+
warnings.split(",").forEach(function(value) {
5353
ruleset[value] = 1;
5454
});
5555
}
5656

57-
if (errors){
57+
if (errors) {
5858
ruleset = ruleset || {};
59-
errors.split(",").forEach(function(value){
59+
errors.split(",").forEach(function(value) {
6060
ruleset[value] = 2;
6161
});
6262
}
@@ -75,7 +75,7 @@ function cli(api){
7575

7676
if (ignore) {
7777
ruleset = CSSLint.getRuleset();
78-
ignore.split(",").forEach(function(value){
78+
ignore.split(",").forEach(function(value) {
7979
ruleset[value] = 0;
8080
});
8181
}
@@ -99,7 +99,7 @@ function cli(api){
9999

100100
if (excludeList) {
101101
// Build up the exclude list, expanding any directory exclusions that were passed in
102-
excludeList.split(",").forEach(function(value){
102+
excludeList.split(",").forEach(function(value) {
103103
if (api.isDirectory(value)) {
104104
excludeFiles = excludeFiles.concat(api.getFiles(value));
105105
} else {
@@ -108,10 +108,10 @@ function cli(api){
108108
});
109109

110110
// Remove the excluded files from the list of files to lint
111-
excludeFiles.forEach(function(value){
111+
excludeFiles.forEach(function(value) {
112112
fullPath = api.getFullPath(value);
113113
if (filesToLint.indexOf(fullPath) > -1) {
114-
filesToLint.splice(filesToLint.indexOf(fullPath),1);
114+
filesToLint.splice(filesToLint.indexOf(fullPath), 1);
115115
}
116116
});
117117
}
@@ -123,10 +123,10 @@ function cli(api){
123123
* Outputs all available rules to the CLI.
124124
* @return {void}
125125
*/
126-
function printRules(){
126+
function printRules() {
127127
api.print("");
128128
var rules = CSSLint.getRules();
129-
rules.forEach(function(rule){
129+
rules.forEach(function(rule) {
130130
api.print(rule.id + "\n " + rule.desc + "\n");
131131
});
132132
}
@@ -157,7 +157,7 @@ function cli(api){
157157
//var relativeFilePath = getRelativePath(api.getWorkingDirectory(), fullFilePath);
158158
options.fullPath = api.getFullPath(relativeFilePath);
159159
output = formatter.formatResults(result, relativeFilePath, options);
160-
if (output){
160+
if (output) {
161161
api.print(output);
162162
}
163163

@@ -174,7 +174,7 @@ function cli(api){
174174
* Outputs the help screen to the CLI.
175175
* @return {void}
176176
*/
177-
function outputHelp(){
177+
function outputHelp() {
178178
var lenToPad = 40,
179179
toPrint = "",
180180
formatString = "";
@@ -212,39 +212,39 @@ function cli(api){
212212
* @param options {Object} options object
213213
* @return {Number} exit code
214214
*/
215-
function processFiles(fileArray, options){
215+
function processFiles(fileArray, options) {
216216
var exitCode = 0,
217217
formatId = options.format || "text",
218218
formatter,
219-
files = filterFiles(fileArray,options),
219+
files = filterFiles(fileArray, options),
220220
output;
221221

222222
if (!files.length) {
223223
api.print("csslint: No files specified.");
224224
exitCode = 1;
225225
} else {
226-
if (!CSSLint.hasFormat(formatId)){
226+
if (!CSSLint.hasFormat(formatId)) {
227227
api.print("csslint: Unknown format '" + formatId + "'. Cannot proceed.");
228228
exitCode = 1;
229229
} else {
230230
formatter = CSSLint.getFormatter(formatId);
231231

232232
output = formatter.startFormat();
233-
if (output){
233+
if (output) {
234234
api.print(output);
235235
}
236236

237237

238-
files.forEach(function(file){
238+
files.forEach(function(file) {
239239
if (exitCode === 0) {
240-
exitCode = processFile(file,options);
240+
exitCode = processFile(file, options);
241241
} else {
242-
processFile(file,options);
242+
processFile(file, options);
243243
}
244244
});
245245

246246
output = formatter.endFormat();
247-
if (output){
247+
if (output) {
248248
api.print(output);
249249
}
250250
}
@@ -260,11 +260,11 @@ function cli(api){
260260
parts,
261261
files = [];
262262

263-
while(arg){
264-
if (arg.indexOf("--") === 0){
263+
while (arg) {
264+
if (arg.indexOf("--") === 0) {
265265
argName = arg.substring(2);
266266

267-
if (argName.indexOf("=") > -1){
267+
if (argName.indexOf("=") > -1) {
268268
parts = argName.split("=");
269269
options[parts[0]] = parts[1];
270270
} else {
@@ -274,7 +274,7 @@ function cli(api){
274274
} else {
275275

276276
//see if it's a directory or a file
277-
if (api.isDirectory(arg)){
277+
if (api.isDirectory(arg)) {
278278
files = files.concat(api.getFiles(arg));
279279
} else {
280280
files.push(arg);
@@ -317,7 +317,7 @@ function cli(api){
317317
data += "--" + optionName + "=" + json[optionName].join();
318318
}
319319
}
320-
} catch(e) {}
320+
} catch (e) {}
321321
}
322322
options = processArguments(data.split(/[\s\n\r]+/m));
323323
}
@@ -338,17 +338,17 @@ function cli(api){
338338
// Preprocess command line arguments
339339
cliOptions = processArguments(args);
340340

341-
if (cliOptions.help || argCount === 0){
341+
if (cliOptions.help || argCount === 0) {
342342
outputHelp();
343343
api.quit(0);
344344
}
345345

346-
if (cliOptions.version){
346+
if (cliOptions.version) {
347347
api.print("v" + CSSLint.version);
348348
api.quit(0);
349349
}
350350

351-
if (cliOptions["list-rules"]){
351+
if (cliOptions["list-rules"]) {
352352
printRules();
353353
api.quit(0);
354354
}
@@ -366,5 +366,5 @@ function cli(api){
366366
// Validate options
367367
validateOptions(options);
368368

369-
api.quit(processFiles(options.files,options));
369+
api.quit(processFiles(options.files, options));
370370
}

src/cli/node.js

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -14,42 +14,42 @@ var fs = require("fs"),
1414
cli({
1515
args: process.argv.slice(2),
1616

17-
print: function(message){
17+
print: function(message) {
1818
fs.writeSync(1, message + "\n");
1919
},
2020

21-
quit: function(code){
21+
quit: function(code) {
2222
process.exit(code || 0);
2323
},
2424

25-
isDirectory: function(name){
25+
isDirectory: function(name) {
2626
try {
2727
return fs.statSync(name).isDirectory();
2828
} catch (ex) {
2929
return false;
3030
}
3131
},
3232

33-
getFiles: function(dir){
33+
getFiles: function(dir) {
3434
var files = [];
3535

3636
try {
3737
fs.statSync(dir);
38-
} catch (ex){
38+
} catch (ex) {
3939
return [];
4040
}
4141

42-
function traverse(dir, stack){
42+
function traverse(dir, stack) {
4343
stack.push(dir);
44-
fs.readdirSync(stack.join("/")).forEach(function(file){
44+
fs.readdirSync(stack.join("/")).forEach(function(file) {
4545
var path = stack.concat([file]).join("/"),
4646
stat = fs.statSync(path);
4747

4848
if (file[0] === ".") {
4949
return;
50-
} else if (stat.isFile() && /\.css$/.test(file)){
50+
} else if (stat.isFile() && /\.css$/.test(file)) {
5151
files.push(path);
52-
} else if (stat.isDirectory()){
52+
} else if (stat.isDirectory()) {
5353
traverse(file, stack);
5454
}
5555
});
@@ -65,11 +65,11 @@ cli({
6565
return process.cwd();
6666
},
6767

68-
getFullPath: function(filename){
68+
getFullPath: function(filename) {
6969
return path.resolve(process.cwd(), filename);
7070
},
7171

72-
readFile: function(filename){
72+
readFile: function(filename) {
7373
try {
7474
return fs.readFileSync(filename, "utf-8");
7575
} catch (ex) {

src/cli/rhino.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,13 @@ cli({
1313
print: print,
1414
quit: quit,
1515

16-
isDirectory: function(name){
16+
isDirectory: function(name) {
1717
"use strict";
1818
var dir = new File(name);
1919
return dir.isDirectory();
2020
},
2121

22-
getFiles: function(dir){
22+
getFiles: function(dir) {
2323
"use strict";
2424
var files = [];
2525

@@ -44,7 +44,7 @@ cli({
4444
return (new File(".")).getCanonicalPath();
4545
},
4646

47-
getFullPath: function(filename){
47+
getFullPath: function(filename) {
4848
"use strict";
4949
return (new File(filename)).getCanonicalPath();
5050
},
@@ -57,4 +57,4 @@ cli({
5757
return "";
5858
}
5959
}
60-
});
60+
});

0 commit comments

Comments
 (0)