Skip to content

Commit

Permalink
Merge pull request CSSLint#484 from XhmikosR/quotmark
Browse files Browse the repository at this point in the history
Enable JSHint's `quotmark` rule.
  • Loading branch information
nschonni committed Apr 9, 2014
2 parents 32d93f7 + 4369012 commit 9feb5f6
Show file tree
Hide file tree
Showing 19 changed files with 166 additions and 165 deletions.
1 change: 1 addition & 0 deletions .jshintrc
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
"noarg": true,
"noempty": true,
"nonbsp": true,
"quotmark": "double",
"undef": true,
"globals": {
"CSSLint": true,
Expand Down
244 changes: 122 additions & 122 deletions Gruntfile.js

Large diffs are not rendered by default.

14 changes: 7 additions & 7 deletions src/cli/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -171,8 +171,8 @@ function cli(api){
*/
function outputHelp(){
var lenToPad = 40,
toPrint = '',
formatString = '';
toPrint = "",
formatString = "";

api.print([
"\nUsage: csslint-rhino.js [options]* [file|dir]*",
Expand All @@ -185,14 +185,14 @@ function cli(api){
// Print the option name and the format if present
toPrint += " --" + optionName;
if (globalOptions[optionName].format !== "") {
formatString = '=' + globalOptions[optionName].format;
formatString = "=" + globalOptions[optionName].format;
toPrint += formatString;
} else {
formatString = '';
formatString = "";
}

// Pad out with the appropriate number of spaces
toPrint += new Array(lenToPad - (optionName.length + formatString.length)).join(' ');
toPrint += new Array(lenToPad - (optionName.length + formatString.length)).join(" ");

// Print the description
toPrint += globalOptions[optionName].description + "\n";
Expand Down Expand Up @@ -283,8 +283,8 @@ function cli(api){

function validateOptions(options) {
for (var option_key in options) {
if (!globalOptions.hasOwnProperty(option_key) && option_key !== 'files') {
api.print(option_key + ' is not a valid option. Exiting...');
if (!globalOptions.hasOwnProperty(option_key) && option_key !== "files") {
api.print(option_key + " is not a valid option. Exiting...");
outputHelp();
api.quit(0);
}
Expand Down
2 changes: 1 addition & 1 deletion src/core/CSSLint.js
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ var CSSLint = (function(){
underscoreHack: true, strict: false });

// normalize line endings
lines = text.replace(/\n\r?/g, "$split$").split('$split$');
lines = text.replace(/\n\r?/g, "$split$").split("$split$");

if (!ruleset){
ruleset = this.getRuleset();
Expand Down
4 changes: 2 additions & 2 deletions src/formatters/checkstyle-xml.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,10 +81,10 @@
* @return rule source as {String}
*/
var generateSource = function(rule) {
if (!rule || !('name' in rule)) {
if (!rule || !("name" in rule)) {
return "";
}
return 'net.csslint.' + rule.name.replace(/\s/g,'');
return "net.csslint." + rule.name.replace(/\s/g,"");
};


Expand Down
12 changes: 6 additions & 6 deletions src/formatters/junit-xml.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ CSSLint.addFormatter({
var messages = results.messages,
output = [],
tests = {
'error': 0,
'failure': 0
"error": 0,
"failure": 0
};

/**
Expand All @@ -43,10 +43,10 @@ CSSLint.addFormatter({
* @return rule source as {String}
*/
var generateSource = function(rule) {
if (!rule || !('name' in rule)) {
if (!rule || !("name" in rule)) {
return "";
}
return 'net.csslint.' + rule.name.replace(/\s/g,'');
return "net.csslint." + rule.name.replace(/\s/g,"");
};

/**
Expand Down Expand Up @@ -76,15 +76,15 @@ CSSLint.addFormatter({

// since junit has no warning class
// all issues as errors
var type = message.type === 'warning' ? 'error' : message.type;
var type = message.type === "warning" ? "error" : message.type;

//ignore rollups for now
if (!message.rollup) {

// build the test case seperately, once joined
// we'll add it to a custom array filtered by type
output.push("<testcase time=\"0\" name=\"" + generateSource(message.rule) + "\">");
output.push("<" + type + " message=\"" + escapeSpecialCharacters(message.message) + "\"><![CDATA[" + message.line + ':' + message.col + ':' + escapeSpecialCharacters(message.evidence) + "]]></" + type + ">");
output.push("<" + type + " message=\"" + escapeSpecialCharacters(message.message) + "\"><![CDATA[" + message.line + ":" + message.col + ":" + escapeSpecialCharacters(message.evidence) + "]]></" + type + ">");
output.push("</testcase>");

tests[type] += 1;
Expand Down
2 changes: 1 addition & 1 deletion src/rules/bulletproof-font-face.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ CSSLint.addRule({
col = event.col;

// This is the property that we care about, we can ignore the rest
if (propertyName === 'src') {
if (propertyName === "src") {
var regex = /^\s?url\(['"].+\.eot\?.*['"]\)\s*format\(['"]embedded-opentype['"]\).*$/i;

// We need to handle the advanced syntax with two src properties
Expand Down
4 changes: 2 additions & 2 deletions src/rules/compatible-vendor-prefixes.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,9 +90,9 @@ CSSLint.addRule({
for (prop in compatiblePrefixes) {
if (compatiblePrefixes.hasOwnProperty(prop)) {
variations = [];
prefixed = compatiblePrefixes[prop].split(' ');
prefixed = compatiblePrefixes[prop].split(" ");
for (i = 0, len = prefixed.length; i < len; i++) {
variations.push('-' + prefixed[i] + '-' + prop);
variations.push("-" + prefixed[i] + "-" + prop);
}
compatiblePrefixes[prop] = variations;
arrayPush.apply(applyTo, variations);
Expand Down
4 changes: 2 additions & 2 deletions src/rules/duplicate-background-images.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ CSSLint.addRule({

if (name.match(/background/i)) {
for (i=0, len=value.parts.length; i < len; i++) {
if (value.parts[i].type == 'uri') {
if (typeof stack[value.parts[i].uri] === 'undefined') {
if (value.parts[i].type == "uri") {
if (typeof stack[value.parts[i].uri] === "undefined") {
stack[value.parts[i].uri] = event;
}
else {
Expand Down
4 changes: 2 additions & 2 deletions src/rules/order-alphabetical.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ CSSLint.addRule({
});

parser.addListener("endrule", function(event){
var currentProperties = properties.join(','),
expectedProperties = properties.sort().join(',');
var currentProperties = properties.join(","),
expectedProperties = properties.sort().join(",");

if (currentProperties !== expectedProperties){
reporter.report("Rule doesn't have all its properties in alphabetical ordered.", event.line, event.col, rule);
Expand Down
2 changes: 1 addition & 1 deletion src/rules/selector-max-approaching.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ CSSLint.addRule({
init: function(parser, reporter) {
var rule = this, count = 0;

parser.addListener('startrule', function(event) {
parser.addListener("startrule", function(event) {
count += event.selectors.length;
});

Expand Down
2 changes: 1 addition & 1 deletion src/rules/selector-max.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ CSSLint.addRule({
init: function(parser, reporter){
var rule = this, count = 0;

parser.addListener('startrule',function(event) {
parser.addListener("startrule", function(event) {
count += event.selectors.length;
});

Expand Down
10 changes: 5 additions & 5 deletions tests/core/CSSLint.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,13 @@

"Embedded ruleset should be honored": function(){
var result = CSSLint.verify("/*csslint bogus, adjoining-classes:true, box-sizing:false */\n.foo.bar{}", {
'text-indent': 1,
'box-sizing': 1
"text-indent": 1,
"box-sizing": 1
});

Assert.areEqual(2, result.ruleset['adjoining-classes']);
Assert.areEqual(1, result.ruleset['text-indent']);
Assert.areEqual(0, result.ruleset['box-sizing']);
Assert.areEqual(2, result.ruleset["adjoining-classes"]);
Assert.areEqual(1, result.ruleset["text-indent"]);
Assert.areEqual(0, result.ruleset["box-sizing"]);
}

}));
Expand Down
6 changes: 3 additions & 3 deletions tests/formatters/checkstyle-xml.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,14 @@
},

"Formatter should escape special characters": function() {
var specialCharsSting = 'sneaky, "sneaky", <sneaky>, sneak & sneaky',
var specialCharsSting = "sneaky, 'sneaky', <sneaky>, sneak & sneaky",
result = { messages: [
{ type: "warning", line: 1, col: 1, message: specialCharsSting, evidence: "ALSO BOGUS", rule: [] },
{ type: "error", line: 2, col: 1, message: specialCharsSting, evidence: "ALSO BOGUS", rule: [] }
], stats: [] },
file = "<file name=\"FILE\">",
error1 = "<error line=\"1\" column=\"1\" severity=\"warning\" message=\"sneaky, &quot;sneaky&quot;, &lt;sneaky&gt;, sneak &amp; sneaky\" source=\"\"/>",
error2 = "<error line=\"2\" column=\"1\" severity=\"error\" message=\"sneaky, &quot;sneaky&quot;, &lt;sneaky&gt;, sneak &amp; sneaky\" source=\"\"/>",
error1 = "<error line=\"1\" column=\"1\" severity=\"warning\" message=\"sneaky, 'sneaky', &lt;sneaky&gt;, sneak &amp; sneaky\" source=\"\"/>",
error2 = "<error line=\"2\" column=\"1\" severity=\"error\" message=\"sneaky, 'sneaky', &lt;sneaky&gt;, sneak &amp; sneaky\" source=\"\"/>",
expected = "<?xml version=\"1.0\" encoding=\"utf-8\"?><checkstyle>" + file + error1 + error2 + "</file></checkstyle>",
actual = CSSLint.format(result, "FILE", "checkstyle-xml");
Assert.areEqual(expected, actual);
Expand Down
8 changes: 4 additions & 4 deletions tests/formatters/compact.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@

"File with problems should list them": function() {
var result = { messages: [
{ type: 'error', line: 2, col: 1, message: 'BOGUS ERROR', evidence: 'BOGUS', rule: { id: 'BOGUS_RULE_ID' } },
{ type: 'warning', line: 1, col: 1, message: 'BOGUS WARNING', evidence: 'BOGUS', rule: { id: 'BOGUS_RULE_ID' } }
{ type: "error", line: 2, col: 1, message: "BOGUS ERROR", evidence: "BOGUS", rule: { id: "BOGUS_RULE_ID" } },
{ type: "warning", line: 1, col: 1, message: "BOGUS WARNING", evidence: "BOGUS", rule: { id: "BOGUS_RULE_ID" } }
], stats: [] },
err = "path/to/FILE: line 2, col 1, Error - BOGUS ERROR (BOGUS_RULE_ID)\n",
warning = "path/to/FILE: line 1, col 1, Warning - BOGUS WARNING (BOGUS_RULE_ID)\n",
Expand All @@ -32,8 +32,8 @@

"Should output relative file paths": function() {
var result = { messages: [
{ type: 'error', line: 2, col: 1, message: 'BOGUS ERROR', evidence: 'BOGUS', rule: { id: 'BOGUS_RULE_ID' } },
{ type: 'warning', line: 1, col: 1, message: 'BOGUS WARNING', evidence: 'BOGUS', rule: { id: 'BOGUS_RULE_ID' } }
{ type: "error", line: 2, col: 1, message: "BOGUS ERROR", evidence: "BOGUS", rule: { id: "BOGUS_RULE_ID" } },
{ type: "warning", line: 1, col: 1, message: "BOGUS WARNING", evidence: "BOGUS", rule: { id: "BOGUS_RULE_ID" } }
], stats: [] },
err = "path/to/FILE: line 2, col 1, Error - BOGUS ERROR (BOGUS_RULE_ID)\n",
warning = "path/to/FILE: line 1, col 1, Warning - BOGUS WARNING (BOGUS_RULE_ID)\n",
Expand Down
2 changes: 1 addition & 1 deletion tests/formatters/csslint-xml.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
},

"Formatter should escape double quotes": function() {
var doubleQuotedEvidence = 'sneaky, "sneaky", <sneaky>, sneak & sneaky',
var doubleQuotedEvidence = "sneaky, \"sneaky\", <sneaky>, sneak & sneaky",
result = { messages: [
{ type: "warning", line: 1, col: 1, message: "BOGUS", evidence: doubleQuotedEvidence, rule: [] },
{ type: "error", line: 2, col: 1, message: "BOGUS", evidence: doubleQuotedEvidence, rule: [] }
Expand Down
2 changes: 1 addition & 1 deletion tests/formatters/junit-xml.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@

"Formatter should escape special characters": function() {

var specialCharsSting = 'sneaky, "sneaky", <sneaky>',
var specialCharsSting = "sneaky, 'sneaky', <sneaky>",
result = { messages: [
{ type: "warning", line: 1, col: 1, message: specialCharsSting, evidence: "ALSO BOGUS", rule: [] },
{ type: "error", line: 2, col: 1, message: specialCharsSting, evidence: "ALSO BOGUS", rule: [] }
Expand Down
2 changes: 1 addition & 1 deletion tests/formatters/lint-xml.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
},

"Formatter should escape double quotes": function() {
var doubleQuotedEvidence = 'sneaky, "sneaky", <sneaky>, sneak & sneaky',
var doubleQuotedEvidence = "sneaky, \"sneaky\", <sneaky>, sneak & sneaky",
result = { messages: [
{ type: "warning", line: 1, col: 1, message: "BOGUS", evidence: doubleQuotedEvidence, rule: [] },
{ type: "error", line: 2, col: 1, message: "BOGUS", evidence: doubleQuotedEvidence, rule: [] }
Expand Down
6 changes: 3 additions & 3 deletions tests/formatters/text.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

"File with one problem should use proper grammar": function() {
var result = { messages: [
{ type: 'warning', line: 1, col: 1, message: 'BOGUS', evidence: 'ALSO BOGUS', rule: [] }
{ type: "warning", line: 1, col: 1, message: "BOGUS", evidence: "ALSO BOGUS", rule: [] }
], stats: [] },
error1 = "\n1: warning at line 1, col 1\nBOGUS\nALSO BOGUS",
expected = "\n\ncsslint: There is 1 problem in path/to/FILE.\n\nFILE" + error1,
Expand All @@ -31,8 +31,8 @@

"File with problems should list them": function() {
var result = { messages: [
{ type: 'warning', line: 1, col: 1, message: 'BOGUS', evidence: 'ALSO BOGUS', rule: [] },
{ type: 'error', line: 2, col: 1, message: 'BOGUS', evidence: 'ALSO BOGUS', rule: [] }
{ type: "warning", line: 1, col: 1, message: "BOGUS", evidence: "ALSO BOGUS", rule: [] },
{ type: "error", line: 2, col: 1, message: "BOGUS", evidence: "ALSO BOGUS", rule: [] }
], stats: [] },
error1 = "\n1: warning at line 1, col 1\nBOGUS\nALSO BOGUS",
error2 = "\n2: error at line 2, col 1\nBOGUS\nALSO BOGUS",
Expand Down

0 comments on commit 9feb5f6

Please sign in to comment.