From 43690120d414dc2113411d604f0427d6b83dcadc Mon Sep 17 00:00:00 2001 From: XhmikosR Date: Tue, 12 Nov 2013 13:34:36 +0200 Subject: [PATCH] Enable JSHint's `quotmark` rule. --- .jshintrc | 1 + Gruntfile.js | 244 +++++++++++------------ src/cli/common.js | 14 +- src/core/CSSLint.js | 2 +- src/formatters/checkstyle-xml.js | 4 +- src/formatters/junit-xml.js | 12 +- src/rules/bulletproof-font-face.js | 2 +- src/rules/compatible-vendor-prefixes.js | 4 +- src/rules/duplicate-background-images.js | 4 +- src/rules/order-alphabetical.js | 4 +- src/rules/selector-max-approaching.js | 2 +- src/rules/selector-max.js | 2 +- tests/core/CSSLint.js | 10 +- tests/formatters/checkstyle-xml.js | 6 +- tests/formatters/compact.js | 8 +- tests/formatters/csslint-xml.js | 2 +- tests/formatters/junit-xml.js | 2 +- tests/formatters/lint-xml.js | 2 +- tests/formatters/text.js | 6 +- 19 files changed, 166 insertions(+), 165 deletions(-) diff --git a/.jshintrc b/.jshintrc index 6720ab6f..b1c36bc6 100644 --- a/.jshintrc +++ b/.jshintrc @@ -9,6 +9,7 @@ "noarg": true, "noempty": true, "nonbsp": true, + "quotmark": "double", "undef": true, "globals": { "CSSLint": true, diff --git a/Gruntfile.js b/Gruntfile.js index b72b7a80..04db7824 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -4,137 +4,137 @@ module.exports = function(grunt) { // Project configuration. grunt.initConfig({ // Metadata. - pkg: grunt.file.readJSON('package.json'), + pkg: grunt.file.readJSON("package.json"), banner: { - compact: '/*! <%= pkg.title || pkg.name %> - v<%= pkg.version %> - ' + - '<%= grunt.template.today("yyyy-mm-dd") %>\n' + - '<%= pkg.homepage ? "* " + pkg.homepage + "\\n" : "" %>' + - '* Copyright (c) <%= grunt.template.today("yyyy") %> Nicole Sullivan and Nicholas C. Zakas;\n' + - '* Licensed <%= _.pluck(pkg.licenses, "type").join(", ") %> <%= _.pluck(pkg.licenses, "url").join(", ") %> */\n', - full: '/*!\n' + - 'CSSLint\n' + - 'Copyright (c) <%= grunt.template.today("yyyy") %> Nicole Sullivan and Nicholas C. Zakas. All rights reserved.\n' + - '\n' + - 'Permission is hereby granted, free of charge, to any person obtaining a copy\n' + - 'of this software and associated documentation files (the "Software"), to deal\n' + - 'in the Software without restriction, including without limitation the rights\n' + - 'to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n' + - 'copies of the Software, and to permit persons to whom the Software is\n' + - 'furnished to do so, subject to the following conditions:\n' + - '\n' + - 'The above copyright notice and this permission notice shall be included in\n' + - 'all copies or substantial portions of the Software.\n' + - '\n' + - 'THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n' + - 'IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n' + - 'FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n' + - 'AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n' + - 'LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n' + - 'OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n' + - 'THE SOFTWARE.\n\n' + - '*/\n' + - '/* Build: v<%= pkg.version %> <%= grunt.template.today("dd-mmmm-yyyy hh:MM:ss") %> */' + compact: "/*! <%= pkg.title || pkg.name %> - v<%= pkg.version %> - " + + "<%= grunt.template.today('yyyy-mm-dd') %>\n" + + "<%= pkg.homepage ? '* ' + pkg.homepage + '\\n' : '' %>" + + "* Copyright (c) <%= grunt.template.today('yyyy') %> Nicole Sullivan and Nicholas C. Zakas;\n" + + "* Licensed <%= _.pluck(pkg.licenses, 'type').join(', ') %> <%= _.pluck(pkg.licenses, 'url').join(', ') %> */\n", + full: "/*!\n" + + "CSSLint\n" + + "Copyright (c) <%= grunt.template.today('yyyy') %> Nicole Sullivan and Nicholas C. Zakas. All rights reserved.\n" + + "\n" + + "Permission is hereby granted, free of charge, to any person obtaining a copy\n" + + "of this software and associated documentation files (the 'Software'), to deal\n" + + "in the Software without restriction, including without limitation the rights\n" + + "to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n" + + "copies of the Software, and to permit persons to whom the Software is\n" + + "furnished to do so, subject to the following conditions:\n" + + "\n" + + "The above copyright notice and this permission notice shall be included in\n" + + "all copies or substantial portions of the Software.\n" + + "\n" + + "THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n" + + "IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n" + + "FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n" + + "AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n" + + "LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n" + + "OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n" + + "THE SOFTWARE.\n\n" + + "*/\n" + + "/* Build: v<%= pkg.version %> <%= grunt.template.today('dd-mmmm-yyyy hh:MM:ss') %> */" }, - build_dir: 'build', - //Parser lib copy for verions that can't user requirejs - parserlib: 'node_modules/parserlib/lib/node-parserlib.js', + build_dir: "build", + //Parser lib copy for versions that can't use requirejs + parserlib: "node_modules/parserlib/lib/node-parserlib.js", //Core CSSLint files used by most versions csslint_files: [ - 'src/core/CSSLint.js', - 'src/core/*.js', - 'src/rules/*.js', - 'src/formatters/*.js' + "src/core/CSSLint.js", + "src/core/*.js", + "src/rules/*.js", + "src/formatters/*.js" ], //Core fileset used by most versions core_files: [ - '<%= parserlib %>', - '<%= csslint_files %>' + "<%= parserlib %>", + "<%= csslint_files %>" ], // Task configuration. clean: { - build: ['<%= build_dir %>'], - release: ['release'] + build: ["<%= build_dir %>"], + release: ["release"] }, changelog: { - dest: 'CHANGELOG' + dest: "CHANGELOG" }, concat: { core: { options: { - banner: '<%= banner.full %>\n' + + banner: "<%= banner.full %>\n" + //Hack for using the node version of parserlib - 'var exports = exports || {};\n' + - 'var CSSLint = (function(){\n', - footer: '\nreturn CSSLint;\n})();' + "var exports = exports || {};\n" + + "var CSSLint = (function(){\n", + footer: "\nreturn CSSLint;\n})();" }, src: [ - '<%= core_files %>' + "<%= core_files %>" ], - dest: '<%= build_dir %>/<%= pkg.name %>.js' + dest: "<%= build_dir %>/<%= pkg.name %>.js" },//Build environment workers rhino: { src: [ - '<%= concat.core.dest %>', - 'src/cli/common.js', - 'src/cli/rhino.js' + "<%= concat.core.dest %>", + "src/cli/common.js", + "src/cli/rhino.js" ], - dest: '<%= build_dir %>/<%= pkg.name %>-rhino.js' + dest: "<%= build_dir %>/<%= pkg.name %>-rhino.js" }, node: { options: { - banner: '<%= banner.full %>\n' + - 'var parserlib = require("parserlib");\n', - footer: '\nexports.CSSLint = CSSLint;' + banner: "<%= banner.full %>\n" + + "var parserlib = require('parserlib');\n", + footer: "\nexports.CSSLint = CSSLint;" }, files: { - '<%= build_dir %>/<%= pkg.name %>-node.js': ['<%= csslint_files %>'], - '<%= build_dir %>/npm/lib/<%= pkg.name %>-node.js': ['<%= csslint_files %>'] + "<%= build_dir %>/<%= pkg.name %>-node.js": ["<%= csslint_files %>"], + "<%= build_dir %>/npm/lib/<%= pkg.name %>-node.js": ["<%= csslint_files %>"] } }, node_cli: { options: { - banner: '#!/usr/bin/env node\n<%= banner.full %>' + banner: "#!/usr/bin/env node\n<%= banner.full %>" }, src: [ - 'src/cli/common.js', - 'src/cli/node.js' + "src/cli/common.js", + "src/cli/node.js" ], - dest: '<%= build_dir %>/npm/cli.js' + dest: "<%= build_dir %>/npm/cli.js" }, tests: { src: [ - 'tests/**/*.js', - '!tests/all-rules.js' + "tests/**/*.js", + "!tests/all-rules.js" ], - dest: '<%= build_dir %>/<%= pkg.name %>-tests.js' + dest: "<%= build_dir %>/<%= pkg.name %>-tests.js" }, worker: { options: { - banner: '<%= banner.full %>\n' + + banner: "<%= banner.full %>\n" + //Hack for using the node version of parserlib - 'var exports = exports || {};\n' + "var exports = exports || {};\n" }, src: [ - '<%= core_files %>', - 'src/worker/*.js' + "<%= core_files %>", + "src/worker/*.js" ], - dest: '<%= build_dir %>/<%= pkg.name %>-worker.js' + dest: "<%= build_dir %>/<%= pkg.name %>-worker.js" }, wsh: { src: [ - '<%= concat.core.dest %>', - 'src/cli/common.js', - 'src/cli/wsh.js' + "<%= concat.core.dest %>", + "src/cli/common.js", + "src/cli/wsh.js" ], - dest: '<%= build_dir %>/<%= pkg.name %>-wsh.js' + dest: "<%= build_dir %>/<%= pkg.name %>-wsh.js" } }, copy: { release: { files: { - '<%= build_dir %>': 'release', - 'release/npm/README.md': 'README.md', - 'release/npm/package.json': 'package.json' + "<%= build_dir %>": "release", + "release/npm/README.md": "README.md", + "release/npm/package.json": "package.json" } } }, @@ -143,15 +143,15 @@ module.exports = function(grunt) { options: { // Global variables available in all files globals: { - VERSION: '<%= pkg.version %>' + VERSION: "<%= pkg.version %>" }, - prefix: '@', - suffix: '@' + prefix: "@", + suffix: "@" }, // Files to perform replacements and includes with - src: '<%= build_dir %>/**/*.*', + src: "<%= build_dir %>/**/*.*", // Destinaion directory to copy files to - dest: 'release/' + dest: "release/" } }, jshint: { @@ -159,73 +159,73 @@ module.exports = function(grunt) { jshintrc: ".jshintrc" }, gruntfile: { - src: 'Gruntfile.js' + src: "Gruntfile.js" }, all: { - src: ['src/**/*.js'] + src: ["src/**/*.js"] }, tests: { - src: ['tests/**/*.js'] + src: ["tests/**/*.js"] } }, watch: { gruntfile: { - files: '<%= jshint.gruntfile.src %>', - tasks: ['jshint'] + files: "<%= jshint.gruntfile.src %>", + tasks: ["jshint"] }, src: { - files: '<%= jshint.all.src %>', - tasks: ['jshint:all'] + files: "<%= jshint.all.src %>", + tasks: ["jshint:all"] }, lib_test: { - files: '<%= jshint.tests.src %>', - tasks: ['jshint:tests'] + files: "<%= jshint.tests.src %>", + tasks: ["jshint:tests"] } }, yuitest: { tests: { src: [ - 'tests/**/*.js' + "tests/**/*.js" ] } }, test_rhino: { tests: { src: [ - '<%= concat.tests.dest %>', - 'tests/all-rules.js' + "<%= concat.tests.dest %>", + "tests/all-rules.js" ] } } }); // These plugins provide necessary tasks. - grunt.loadNpmTasks('grunt-contrib-clean'); - grunt.loadNpmTasks('grunt-contrib-concat'); - grunt.loadNpmTasks('grunt-contrib-copy'); - grunt.loadNpmTasks('grunt-contrib-jshint'); - grunt.loadNpmTasks('grunt-contrib-watch'); - grunt.loadNpmTasks('grunt-include-replace'); + grunt.loadNpmTasks("grunt-contrib-clean"); + grunt.loadNpmTasks("grunt-contrib-concat"); + grunt.loadNpmTasks("grunt-contrib-copy"); + grunt.loadNpmTasks("grunt-contrib-jshint"); + grunt.loadNpmTasks("grunt-contrib-watch"); + grunt.loadNpmTasks("grunt-include-replace"); // Default task. - grunt.registerTask('default', ['test']); + grunt.registerTask("default", ["test"]); //Alias for - grunt.registerTask('lint', ['jshint']); + grunt.registerTask("lint", ["jshint"]); //Testing - grunt.registerTask('test', ['clean:build', 'jshint', 'concat', 'yuitest']); - grunt.registerTask('rhino', ['clean:build', 'jshint', 'concat', 'test_rhino']); + grunt.registerTask("test", ["clean:build", "jshint", "concat", "yuitest"]); + grunt.registerTask("rhino", ["clean:build", "jshint", "concat", "test_rhino"]); - grunt.registerTask('release', ['test', 'clean:release', 'copy:release', 'includereplace:release', 'changelog']); + grunt.registerTask("release", ["test", "clean:release", "copy:release", "includereplace:release", "changelog"]); //Run the YUITest suite - grunt.registerMultiTask('yuitest', 'Run the YUITests for the project', function() { + grunt.registerMultiTask("yuitest", "Run the YUITests for the project", function() { /*jshint evil:true, node: true */ var start = Date.now(); var YUITest = require("yuitest"); - var CSSLint = require('./build/csslint-node').CSSLint; + var CSSLint = require("./build/csslint-node").CSSLint; var files = this.filesSrc; var TestRunner = YUITest.TestRunner; var done = this.async(); @@ -366,27 +366,27 @@ module.exports = function(grunt) { TestRunner.run(); }); - grunt.registerMultiTask('changelog', 'Write the changlog file', function() { + grunt.registerMultiTask("changelog", "Write the changlog file", function() { var done = this.async(); var lastTag; var files = this.filesSrc; grunt.util.spawn({ - cmd: 'git', - args: ['tag'] + cmd: "git", + args: ["tag"] }, function(error, result, code) { //Find the latest git tag var tags = result.stdout.split("\n"), - semver = tags[0].replace('v','').split('.'), + semver = tags[0].replace("v","").split("."), major = parseInt(semver[0], 10), minor = parseInt(semver[1], 10), patch = parseInt(semver[2], 10); //A simple array sort can't be used because of the comparison of - //the strings '0.9.9' > '0.9.10' + //the strings "0.9.9" > "0.9.10" for (var i = 1, len = tags.length; i < len; i++) { - semver = tags[i].replace('v','').split('.'); + semver = tags[i].replace("v","").split("."); var currentMajor = parseInt(semver[0], 10); if (currentMajor < major) { @@ -410,21 +410,21 @@ module.exports = function(grunt) { } } - lastTag = 'v' + major + '.' + minor + '.' + patch; + lastTag = "v" + major + "." + minor + "." + patch; - grunt.verbose.write('Last tag: ' + lastTag).writeln(); + grunt.verbose.write("Last tag: " + lastTag).writeln(); // grunt.util.spawn({ - cmd: 'git', - args: ['log', '--pretty=format:"* %s (%an)"', lastTag + '..HEAD'] + cmd: "git", + args: ["log", "--pretty=format:'* %s (%an)'", lastTag + "..HEAD"] }, function(error, result, code) { - var prettyPrint = result.stdout.split('\"\n\"').join('\n').replace(/\"$/, '').replace(/^\"/, ''); + var prettyPrint = result.stdout.split("'\n'").join("\n").replace(/\"$/, "").replace(/^\"/, ""); grunt.verbose.writeln().write(prettyPrint).writeln(); - var template = '<%= grunt.template.today("mmmm d, yyyy") %> - v<%= pkg.version %>\n\n' + - prettyPrint + '\n\n' + + var template = "<%= grunt.template.today('mmmm d, yyyy') %> - v<%= pkg.version %>\n\n" + + prettyPrint + "\n\n" + grunt.file.read(files[0]); grunt.file.write(files[0], grunt.template.process(template)); @@ -436,16 +436,16 @@ module.exports = function(grunt) { }); //Run test suite through rhino - grunt.registerMultiTask('test_rhino', 'Run the test suite through rhino', function() { + grunt.registerMultiTask("test_rhino", "Run the test suite through rhino", function() { var done = this.async(); var files = this.filesSrc; var progress = files.length; files.forEach(function(filepath) { grunt.util.spawn({ - cmd: 'java', - args: ['-jar', 'lib/js.jar', 'lib/yuitest-rhino-cli.js', 'build/csslint.js', filepath], - opts: {stdio: 'inherit'} + cmd: "java", + args: ["-jar", "lib/js.jar", "lib/yuitest-rhino-cli.js", "build/csslint.js", filepath], + opts: {stdio: "inherit"} }, function(error, result, code) { progress--; if (progress === 0) { diff --git a/src/cli/common.js b/src/cli/common.js index efacc973..61548a77 100644 --- a/src/cli/common.js +++ b/src/cli/common.js @@ -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]*", @@ -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"; @@ -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); } diff --git a/src/core/CSSLint.js b/src/core/CSSLint.js index 6fd28279..215b555a 100644 --- a/src/core/CSSLint.js +++ b/src/core/CSSLint.js @@ -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(); diff --git a/src/formatters/checkstyle-xml.js b/src/formatters/checkstyle-xml.js index d165a530..15bb7da8 100644 --- a/src/formatters/checkstyle-xml.js +++ b/src/formatters/checkstyle-xml.js @@ -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,""); }; diff --git a/src/formatters/junit-xml.js b/src/formatters/junit-xml.js index 49196247..85b263e1 100644 --- a/src/formatters/junit-xml.js +++ b/src/formatters/junit-xml.js @@ -31,8 +31,8 @@ CSSLint.addFormatter({ var messages = results.messages, output = [], tests = { - 'error': 0, - 'failure': 0 + "error": 0, + "failure": 0 }; /** @@ -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,""); }; /** @@ -76,7 +76,7 @@ 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) { @@ -84,7 +84,7 @@ CSSLint.addFormatter({ // build the test case seperately, once joined // we'll add it to a custom array filtered by type output.push(""); - output.push("<" + type + " message=\"" + escapeSpecialCharacters(message.message) + "\">"); + output.push("<" + type + " message=\"" + escapeSpecialCharacters(message.message) + "\">"); output.push(""); tests[type] += 1; diff --git a/src/rules/bulletproof-font-face.js b/src/rules/bulletproof-font-face.js index 80b1aad8..e5f39b86 100644 --- a/src/rules/bulletproof-font-face.js +++ b/src/rules/bulletproof-font-face.js @@ -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 diff --git a/src/rules/compatible-vendor-prefixes.js b/src/rules/compatible-vendor-prefixes.js index 546ff5b4..82887725 100644 --- a/src/rules/compatible-vendor-prefixes.js +++ b/src/rules/compatible-vendor-prefixes.js @@ -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); diff --git a/src/rules/duplicate-background-images.js b/src/rules/duplicate-background-images.js index 4597a9f2..a9fee588 100644 --- a/src/rules/duplicate-background-images.js +++ b/src/rules/duplicate-background-images.js @@ -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 { diff --git a/src/rules/order-alphabetical.js b/src/rules/order-alphabetical.js index ec16da7c..84386ac3 100644 --- a/src/rules/order-alphabetical.js +++ b/src/rules/order-alphabetical.js @@ -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); diff --git a/src/rules/selector-max-approaching.js b/src/rules/selector-max-approaching.js index 63d50634..f16da681 100644 --- a/src/rules/selector-max-approaching.js +++ b/src/rules/selector-max-approaching.js @@ -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; }); diff --git a/src/rules/selector-max.js b/src/rules/selector-max.js index 0d35aa8c..d7182c29 100644 --- a/src/rules/selector-max.js +++ b/src/rules/selector-max.js @@ -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; }); diff --git a/tests/core/CSSLint.js b/tests/core/CSSLint.js index 08166fb0..efbf9aa3 100644 --- a/tests/core/CSSLint.js +++ b/tests/core/CSSLint.js @@ -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"]); } })); diff --git a/tests/formatters/checkstyle-xml.js b/tests/formatters/checkstyle-xml.js index 93900d9c..cdb2d3ef 100644 --- a/tests/formatters/checkstyle-xml.js +++ b/tests/formatters/checkstyle-xml.js @@ -27,14 +27,14 @@ }, "Formatter should escape special characters": function() { - var specialCharsSting = 'sneaky, "sneaky", , sneak & sneaky', + var specialCharsSting = "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 = "", - error1 = "", - error2 = "", + error1 = "", + error2 = "", expected = "" + file + error1 + error2 + "", actual = CSSLint.format(result, "FILE", "checkstyle-xml"); Assert.areEqual(expected, actual); diff --git a/tests/formatters/compact.js b/tests/formatters/compact.js index 0cf92b40..e3da5c85 100644 --- a/tests/formatters/compact.js +++ b/tests/formatters/compact.js @@ -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", @@ -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", diff --git a/tests/formatters/csslint-xml.js b/tests/formatters/csslint-xml.js index d1aed275..6086e9fb 100644 --- a/tests/formatters/csslint-xml.js +++ b/tests/formatters/csslint-xml.js @@ -26,7 +26,7 @@ }, "Formatter should escape double quotes": function() { - var doubleQuotedEvidence = 'sneaky, "sneaky", , sneak & sneaky', + var doubleQuotedEvidence = "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: [] } diff --git a/tests/formatters/junit-xml.js b/tests/formatters/junit-xml.js index b1d00472..0a223eb1 100644 --- a/tests/formatters/junit-xml.js +++ b/tests/formatters/junit-xml.js @@ -34,7 +34,7 @@ "Formatter should escape special characters": function() { - var specialCharsSting = 'sneaky, "sneaky", ', + var specialCharsSting = "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: [] } diff --git a/tests/formatters/lint-xml.js b/tests/formatters/lint-xml.js index 3188e681..a39d9e5b 100644 --- a/tests/formatters/lint-xml.js +++ b/tests/formatters/lint-xml.js @@ -27,7 +27,7 @@ }, "Formatter should escape double quotes": function() { - var doubleQuotedEvidence = 'sneaky, "sneaky", , sneak & sneaky', + var doubleQuotedEvidence = "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: [] } diff --git a/tests/formatters/text.js b/tests/formatters/text.js index 197cbfc4..7abaa0bd 100644 --- a/tests/formatters/text.js +++ b/tests/formatters/text.js @@ -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, @@ -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",