diff --git a/.jshintignore b/.jshintignore new file mode 100644 index 00000000..6938f22b --- /dev/null +++ b/.jshintignore @@ -0,0 +1,4 @@ +node_modules/ +release/ +lib/ +build/ diff --git a/.jshintrc b/.jshintrc new file mode 100644 index 00000000..4b0ffdce --- /dev/null +++ b/.jshintrc @@ -0,0 +1,18 @@ +{ + "curly": true, + "immed": true, + "latedef": true, + "newcap": true, + "noarg": true, + "sub": true, + "undef": true, + "boss": true, + "eqnull": true, + "forin": true, + "noempty": true, + "rhino": false, + "jquery": true, + "globals": { + "CSSLint": true + } +} \ No newline at end of file diff --git a/Gruntfile.js b/Gruntfile.js index 2e428b61..b72b7a80 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -156,24 +156,7 @@ module.exports = function(grunt) { }, jshint: { options: { - curly: true, - //eqeqeq: true, TODO: Leaving off due to errors - immed: true, - latedef: true, - newcap: true, - noarg: true, - sub: true, - undef: true, - //unused: true, TODO: Leaving off due to errors around unused instances of CSSLint - boss: true, - eqnull: true, - // Copied from build.xml - forin: true, - noempty: true, - rhino: false, - globals: { - jQuery: true - } + jshintrc: ".jshintrc" }, gruntfile: { src: 'Gruntfile.js' diff --git a/package.json b/package.json index 72c49c5c..e9d4d99e 100644 --- a/package.json +++ b/package.json @@ -41,12 +41,12 @@ }, "devDependencies": { "grunt": "~0.4.1", - "grunt-contrib-jshint": "~0.5.4", - "grunt-contrib-concat": "~0.3.0", - "grunt-contrib-watch": "~0.4.4", - "yuitest": "~0.7.9", "grunt-contrib-clean": "~0.4.1", + "grunt-contrib-concat": "~0.3.0", "grunt-contrib-copy": "~0.4.1", - "grunt-include-replace": "~0.4.0" + "grunt-contrib-jshint": "~0.10.0", + "grunt-contrib-watch": "~0.4.4", + "grunt-include-replace": "~0.4.0", + "yuitest": "~0.7.9" } } diff --git a/src/cli/common.js b/src/cli/common.js index 1c0653e3..efacc973 100644 --- a/src/cli/common.js +++ b/src/cli/common.js @@ -2,7 +2,7 @@ * Encapsulates all of the CLI functionality. The api argument simply * provides environment-specific functionality. */ -/*global CSSLint*/ + function cli(api){ var globalOptions = { diff --git a/src/core/Reporter.js b/src/core/Reporter.js index a2beede2..71200563 100644 --- a/src/core/Reporter.js +++ b/src/core/Reporter.js @@ -1,4 +1,3 @@ -/*global CSSLint*/ /** * An instance of Report is used to report results of the * verification back to the main API. @@ -158,4 +157,4 @@ Reporter.prototype = { }; //expose for testing purposes -CSSLint._Reporter = Reporter; \ No newline at end of file +CSSLint._Reporter = Reporter; diff --git a/src/core/Util.js b/src/core/Util.js index 9234afd7..90ef1ebf 100644 --- a/src/core/Util.js +++ b/src/core/Util.js @@ -1,6 +1,3 @@ - -/*global CSSLint*/ - /* * Utility functions that make life easier. */ @@ -59,4 +56,4 @@ CSSLint.Util = { } } } -}; \ No newline at end of file +}; diff --git a/src/formatters/checkstyle-xml.js b/src/formatters/checkstyle-xml.js index 7fc2ddf8..f6ae54b6 100644 --- a/src/formatters/checkstyle-xml.js +++ b/src/formatters/checkstyle-xml.js @@ -1,4 +1,3 @@ -/*global CSSLint*/ (function() { /** @@ -106,4 +105,4 @@ } }); -}()); \ No newline at end of file +}()); diff --git a/src/formatters/compact.js b/src/formatters/compact.js index d753a9c5..2de9a927 100644 --- a/src/formatters/compact.js +++ b/src/formatters/compact.js @@ -1,4 +1,3 @@ -/*global CSSLint*/ CSSLint.addFormatter({ //format information id: "compact", diff --git a/src/formatters/csslint-xml.js b/src/formatters/csslint-xml.js index 850083c6..2dc2396c 100644 --- a/src/formatters/csslint-xml.js +++ b/src/formatters/csslint-xml.js @@ -1,4 +1,3 @@ -/*global CSSLint*/ CSSLint.addFormatter({ //format information id: "csslint-xml", @@ -65,4 +64,4 @@ CSSLint.addFormatter({ return output.join(""); } -}); \ No newline at end of file +}); diff --git a/src/formatters/junit-xml.js b/src/formatters/junit-xml.js index c7efbccb..49196247 100644 --- a/src/formatters/junit-xml.js +++ b/src/formatters/junit-xml.js @@ -1,4 +1,3 @@ -/*global CSSLint*/ CSSLint.addFormatter({ //format information id: "junit-xml", @@ -102,4 +101,4 @@ CSSLint.addFormatter({ return output.join(""); } -}); \ No newline at end of file +}); diff --git a/src/formatters/lint-xml.js b/src/formatters/lint-xml.js index 6499ffd9..ad3b6c28 100644 --- a/src/formatters/lint-xml.js +++ b/src/formatters/lint-xml.js @@ -1,4 +1,3 @@ -/*global CSSLint*/ CSSLint.addFormatter({ //format information id: "lint-xml", @@ -66,4 +65,4 @@ CSSLint.addFormatter({ return output.join(""); } -}); \ No newline at end of file +}); diff --git a/src/formatters/text.js b/src/formatters/text.js index 8e647baf..d0669f86 100644 --- a/src/formatters/text.js +++ b/src/formatters/text.js @@ -1,4 +1,3 @@ -/*global CSSLint*/ CSSLint.addFormatter({ //format information id: "text", diff --git a/src/rules/adjoining-classes.js b/src/rules/adjoining-classes.js index 2edb4841..f23094c9 100644 --- a/src/rules/adjoining-classes.js +++ b/src/rules/adjoining-classes.js @@ -1,7 +1,7 @@ -/*global CSSLint*/ /* * Rule: Don't use adjoining classes (.foo.bar). */ + CSSLint.addRule({ //rule information @@ -42,4 +42,4 @@ CSSLint.addRule({ }); } -}); \ No newline at end of file +}); diff --git a/src/rules/box-model.js b/src/rules/box-model.js index 8a1eaf50..dcd57571 100644 --- a/src/rules/box-model.js +++ b/src/rules/box-model.js @@ -1,5 +1,3 @@ -/*global CSSLint*/ - /* * Rule: Don't use width or height when using padding or border. */ @@ -98,4 +96,4 @@ CSSLint.addRule({ parser.addListener("endkeyframerule", endRule); } -}); \ No newline at end of file +}); diff --git a/src/rules/box-sizing.js b/src/rules/box-sizing.js index f044ef6f..ee7e7a07 100644 --- a/src/rules/box-sizing.js +++ b/src/rules/box-sizing.js @@ -1,8 +1,7 @@ -/*global CSSLint*/ - /* * Rule: box-sizing doesn't work in IE6 and IE7. */ + CSSLint.addRule({ //rule information @@ -25,4 +24,4 @@ CSSLint.addRule({ }); } -}); \ No newline at end of file +}); diff --git a/src/rules/bulletproof-font-face.js b/src/rules/bulletproof-font-face.js index 49a3230b..80b1aad8 100644 --- a/src/rules/bulletproof-font-face.js +++ b/src/rules/bulletproof-font-face.js @@ -2,7 +2,7 @@ * Rule: Use the bulletproof @font-face syntax to avoid 404's in old IE * (http://www.fontspring.com/blog/the-new-bulletproof-font-face-syntax) */ -/*global CSSLint*/ + CSSLint.addRule({ //rule information @@ -63,4 +63,4 @@ CSSLint.addRule({ } }); } -}); \ No newline at end of file +}); diff --git a/src/rules/compatible-vendor-prefixes.js b/src/rules/compatible-vendor-prefixes.js index 32ad83cf..546ff5b4 100644 --- a/src/rules/compatible-vendor-prefixes.js +++ b/src/rules/compatible-vendor-prefixes.js @@ -2,7 +2,7 @@ * Rule: Include all compatible vendor prefixes to reach a wider * range of users. */ -/*global CSSLint*/ + CSSLint.addRule({ //rule information @@ -183,4 +183,4 @@ CSSLint.addRule({ } }); } -}); \ No newline at end of file +}); diff --git a/src/rules/display-property-grouping.js b/src/rules/display-property-grouping.js index 53db9b97..15d48d1e 100644 --- a/src/rules/display-property-grouping.js +++ b/src/rules/display-property-grouping.js @@ -5,7 +5,7 @@ * - vertical-align should not be used with block * - margin, float should not be used with table-* */ -/*global CSSLint*/ + CSSLint.addRule({ //rule information @@ -114,4 +114,4 @@ CSSLint.addRule({ } -}); \ No newline at end of file +}); diff --git a/src/rules/duplicate-background-images.js b/src/rules/duplicate-background-images.js index 5cff53d6..4597a9f2 100644 --- a/src/rules/duplicate-background-images.js +++ b/src/rules/duplicate-background-images.js @@ -1,7 +1,7 @@ /* * Rule: Disallow duplicate background-images (using url). */ -/*global CSSLint*/ + CSSLint.addRule({ //rule information @@ -34,4 +34,4 @@ CSSLint.addRule({ } }); } -}); \ No newline at end of file +}); diff --git a/src/rules/duplicate-properties.js b/src/rules/duplicate-properties.js index de111672..c56a3440 100644 --- a/src/rules/duplicate-properties.js +++ b/src/rules/duplicate-properties.js @@ -2,7 +2,7 @@ * Rule: Duplicate properties must appear one after the other. If an already-defined * property appears somewhere else in the rule, then it's likely an error. */ -/*global CSSLint*/ + CSSLint.addRule({ //rule information @@ -43,4 +43,4 @@ CSSLint.addRule({ } -}); \ No newline at end of file +}); diff --git a/src/rules/empty-rules.js b/src/rules/empty-rules.js index ae59a010..2048b989 100644 --- a/src/rules/empty-rules.js +++ b/src/rules/empty-rules.js @@ -1,7 +1,7 @@ /* * Rule: Style rules without any properties defined should be removed. */ -/*global CSSLint*/ + CSSLint.addRule({ //rule information @@ -31,4 +31,4 @@ CSSLint.addRule({ }); } -}); \ No newline at end of file +}); diff --git a/src/rules/errors.js b/src/rules/errors.js index 0aa7d3a0..b732e5f3 100644 --- a/src/rules/errors.js +++ b/src/rules/errors.js @@ -1,7 +1,7 @@ /* * Rule: There should be no syntax errors. (Duh.) */ -/*global CSSLint*/ + CSSLint.addRule({ //rule information @@ -20,4 +20,4 @@ CSSLint.addRule({ } -}); \ No newline at end of file +}); diff --git a/src/rules/fallback-colors.js b/src/rules/fallback-colors.js index af3c2d6b..e7492ed5 100644 --- a/src/rules/fallback-colors.js +++ b/src/rules/fallback-colors.js @@ -1,5 +1,3 @@ - -/*global CSSLint*/ CSSLint.addRule({ //rule information @@ -74,4 +72,4 @@ CSSLint.addRule({ } -}); \ No newline at end of file +}); diff --git a/src/rules/floats.js b/src/rules/floats.js index 0d909a73..5dbfb99f 100644 --- a/src/rules/floats.js +++ b/src/rules/floats.js @@ -2,7 +2,7 @@ * Rule: You shouldn't use more than 10 floats. If you do, there's probably * room for some abstraction. */ -/*global CSSLint*/ + CSSLint.addRule({ //rule information @@ -33,4 +33,4 @@ CSSLint.addRule({ }); } -}); \ No newline at end of file +}); diff --git a/src/rules/font-faces.js b/src/rules/font-faces.js index 94be81d3..10c9e735 100644 --- a/src/rules/font-faces.js +++ b/src/rules/font-faces.js @@ -1,7 +1,7 @@ /* * Rule: Avoid too many @font-face declarations in the same stylesheet. */ -/*global CSSLint*/ + CSSLint.addRule({ //rule information @@ -27,4 +27,4 @@ CSSLint.addRule({ }); } -}); \ No newline at end of file +}); diff --git a/src/rules/font-sizes.js b/src/rules/font-sizes.js index 327b96b0..20f96ceb 100644 --- a/src/rules/font-sizes.js +++ b/src/rules/font-sizes.js @@ -2,7 +2,6 @@ * Rule: You shouldn't need more than 9 font-size declarations. */ -/*global CSSLint*/ CSSLint.addRule({ //rule information @@ -32,4 +31,4 @@ CSSLint.addRule({ }); } -}); \ No newline at end of file +}); diff --git a/src/rules/gradients.js b/src/rules/gradients.js index eb69ee63..77f27e95 100644 --- a/src/rules/gradients.js +++ b/src/rules/gradients.js @@ -1,7 +1,7 @@ /* * Rule: When using a vendor-prefixed gradient, make sure to use them all. */ -/*global CSSLint*/ + CSSLint.addRule({ //rule information diff --git a/src/rules/ids.js b/src/rules/ids.js index 18f100ce..04c877bc 100644 --- a/src/rules/ids.js +++ b/src/rules/ids.js @@ -1,7 +1,7 @@ /* * Rule: Don't use IDs for selectors. */ -/*global CSSLint*/ + CSSLint.addRule({ //rule information @@ -47,4 +47,4 @@ CSSLint.addRule({ }); } -}); \ No newline at end of file +}); diff --git a/src/rules/import.js b/src/rules/import.js index 040453b3..67b51e0a 100644 --- a/src/rules/import.js +++ b/src/rules/import.js @@ -1,7 +1,7 @@ /* * Rule: Don't use @import, use instead. */ -/*global CSSLint*/ + CSSLint.addRule({ //rule information @@ -20,4 +20,4 @@ CSSLint.addRule({ } -}); \ No newline at end of file +}); diff --git a/src/rules/important.js b/src/rules/important.js index 3177962d..0c53b664 100644 --- a/src/rules/important.js +++ b/src/rules/important.js @@ -3,7 +3,7 @@ * war. Display a warning on !important declarations, an error if it's * used more at least 10 times. */ -/*global CSSLint*/ + CSSLint.addRule({ //rule information @@ -34,4 +34,4 @@ CSSLint.addRule({ }); } -}); \ No newline at end of file +}); diff --git a/src/rules/known-properties.js b/src/rules/known-properties.js index bfc63b0e..7ef7af6f 100644 --- a/src/rules/known-properties.js +++ b/src/rules/known-properties.js @@ -2,7 +2,7 @@ * Rule: Properties should be known (listed in CSS3 specification) or * be a vendor-prefixed property. */ -/*global CSSLint*/ + CSSLint.addRule({ //rule information @@ -26,4 +26,4 @@ CSSLint.addRule({ }); } -}); \ No newline at end of file +}); diff --git a/src/rules/outline-none.js b/src/rules/outline-none.js index 9f1044f4..b67fa1d2 100644 --- a/src/rules/outline-none.js +++ b/src/rules/outline-none.js @@ -2,7 +2,7 @@ * Rule: outline: none or outline: 0 should only be used in a :focus rule * and only if there are other properties in the same rule. */ -/*global CSSLint*/ + CSSLint.addRule({ //rule information @@ -70,4 +70,4 @@ CSSLint.addRule({ } -}); \ No newline at end of file +}); diff --git a/src/rules/overqualified-elements.js b/src/rules/overqualified-elements.js index e9972d0b..cceb8830 100644 --- a/src/rules/overqualified-elements.js +++ b/src/rules/overqualified-elements.js @@ -1,7 +1,7 @@ /* * Rule: Don't use classes or IDs with elements (a.foo or a#foo). */ -/*global CSSLint*/ + CSSLint.addRule({ //rule information @@ -60,4 +60,4 @@ CSSLint.addRule({ }); } -}); \ No newline at end of file +}); diff --git a/src/rules/qualified-headings.js b/src/rules/qualified-headings.js index a54249c2..5000fdac 100644 --- a/src/rules/qualified-headings.js +++ b/src/rules/qualified-headings.js @@ -1,7 +1,7 @@ /* * Rule: Headings (h1-h6) should not be qualified (namespaced). */ -/*global CSSLint*/ + CSSLint.addRule({ //rule information @@ -35,4 +35,4 @@ CSSLint.addRule({ }); } -}); \ No newline at end of file +}); diff --git a/src/rules/regex-selectors.js b/src/rules/regex-selectors.js index 4afa01a4..030f88e1 100644 --- a/src/rules/regex-selectors.js +++ b/src/rules/regex-selectors.js @@ -1,7 +1,7 @@ /* * Rule: Selectors that look like regular expressions are slow and should be avoided. */ -/*global CSSLint*/ + CSSLint.addRule({ //rule information @@ -41,4 +41,4 @@ CSSLint.addRule({ }); } -}); \ No newline at end of file +}); diff --git a/src/rules/rules-count.js b/src/rules/rules-count.js index b7712ff2..ff0b22f9 100644 --- a/src/rules/rules-count.js +++ b/src/rules/rules-count.js @@ -1,7 +1,7 @@ /* * Rule: Total number of rules should not exceed x. */ -/*global CSSLint*/ + CSSLint.addRule({ //rule information @@ -25,4 +25,4 @@ CSSLint.addRule({ }); } -}); \ No newline at end of file +}); diff --git a/src/rules/selector-max-approaching.js b/src/rules/selector-max-approaching.js index c7df1d24..63d50634 100644 --- a/src/rules/selector-max-approaching.js +++ b/src/rules/selector-max-approaching.js @@ -1,7 +1,7 @@ /* * Rule: Warn people with approaching the IE 4095 limit */ -/*global CSSLint*/ + CSSLint.addRule({ //rule information diff --git a/src/rules/selector-max.js b/src/rules/selector-max.js index c5b085d7..0d35aa8c 100644 --- a/src/rules/selector-max.js +++ b/src/rules/selector-max.js @@ -1,7 +1,7 @@ /* * Rule: Warn people past the IE 4095 limit */ -/*global CSSLint*/ + CSSLint.addRule({ //rule information @@ -25,4 +25,4 @@ CSSLint.addRule({ }); } -}); \ No newline at end of file +}); diff --git a/src/rules/shorthand.js b/src/rules/shorthand.js index 90ee3e98..68bb3a2f 100644 --- a/src/rules/shorthand.js +++ b/src/rules/shorthand.js @@ -2,7 +2,7 @@ * Rule: Use shorthand properties where possible. * */ -/*global CSSLint*/ + CSSLint.addRule({ //rule information @@ -84,4 +84,4 @@ CSSLint.addRule({ } -}); \ No newline at end of file +}); diff --git a/src/rules/star-property-hack.js b/src/rules/star-property-hack.js index c33ec699..7f4f91b3 100644 --- a/src/rules/star-property-hack.js +++ b/src/rules/star-property-hack.js @@ -2,7 +2,7 @@ * Rule: Don't use properties with a star prefix. * */ -/*global CSSLint*/ + CSSLint.addRule({ //rule information @@ -24,4 +24,4 @@ CSSLint.addRule({ } }); } -}); \ No newline at end of file +}); diff --git a/src/rules/text-indent.js b/src/rules/text-indent.js index 49e8f1de..62d7cc7f 100644 --- a/src/rules/text-indent.js +++ b/src/rules/text-indent.js @@ -2,7 +2,7 @@ * Rule: Don't use text-indent for image replacement if you need to support rtl. * */ -/*global CSSLint*/ + CSSLint.addRule({ //rule information @@ -50,4 +50,4 @@ CSSLint.addRule({ } -}); \ No newline at end of file +}); diff --git a/src/rules/underscore-property-hack.js b/src/rules/underscore-property-hack.js index 1761f45e..0da1747c 100644 --- a/src/rules/underscore-property-hack.js +++ b/src/rules/underscore-property-hack.js @@ -2,7 +2,7 @@ * Rule: Don't use properties with a underscore prefix. * */ -/*global CSSLint*/ + CSSLint.addRule({ //rule information @@ -24,4 +24,4 @@ CSSLint.addRule({ } }); } -}); \ No newline at end of file +}); diff --git a/src/rules/unique-headings.js b/src/rules/unique-headings.js index 11a9f30e..704e69e5 100644 --- a/src/rules/unique-headings.js +++ b/src/rules/unique-headings.js @@ -1,7 +1,7 @@ /* * Rule: Headings (h1-h6) should be defined only once. */ -/*global CSSLint*/ + CSSLint.addRule({ //rule information @@ -14,7 +14,7 @@ CSSLint.addRule({ init: function(parser, reporter){ var rule = this; - var headings = { + var headings = { h1: 0, h2: 0, h3: 0, @@ -71,4 +71,4 @@ CSSLint.addRule({ }); } -}); \ No newline at end of file +}); diff --git a/src/rules/universal-selector.js b/src/rules/universal-selector.js index 9325ef47..6629c15b 100644 --- a/src/rules/universal-selector.js +++ b/src/rules/universal-selector.js @@ -1,7 +1,7 @@ /* * Rule: Don't use universal selector because it's slow. */ -/*global CSSLint*/ + CSSLint.addRule({ //rule information @@ -32,4 +32,4 @@ CSSLint.addRule({ }); } -}); \ No newline at end of file +}); diff --git a/src/rules/unqualified-attributes.js b/src/rules/unqualified-attributes.js index 6151df61..671c3b82 100644 --- a/src/rules/unqualified-attributes.js +++ b/src/rules/unqualified-attributes.js @@ -1,7 +1,7 @@ /* * Rule: Don't use unqualified attribute selectors because they're just like universal selectors. */ -/*global CSSLint*/ + CSSLint.addRule({ //rule information @@ -39,4 +39,4 @@ CSSLint.addRule({ }); } -}); \ No newline at end of file +}); diff --git a/src/rules/vendor-prefix.js b/src/rules/vendor-prefix.js index ee5c9a7d..59cd247f 100644 --- a/src/rules/vendor-prefix.js +++ b/src/rules/vendor-prefix.js @@ -2,7 +2,7 @@ * Rule: When using a vendor-prefixed property, make sure to * include the standard one. */ -/*global CSSLint*/ + CSSLint.addRule({ //rule information @@ -140,4 +140,4 @@ CSSLint.addRule({ parser.addListener("endkeyframerule", endRule); } -}); \ No newline at end of file +}); diff --git a/src/rules/zero-units.js b/src/rules/zero-units.js index 54dbae18..08886ee8 100644 --- a/src/rules/zero-units.js +++ b/src/rules/zero-units.js @@ -1,7 +1,7 @@ /* * Rule: You don't need to specify units when a value is 0. */ -/*global CSSLint*/ + CSSLint.addRule({ //rule information @@ -31,4 +31,4 @@ CSSLint.addRule({ } -}); \ No newline at end of file +}); diff --git a/src/worker/Worker.js b/src/worker/Worker.js index e2246044..7eec9f1a 100644 --- a/src/worker/Worker.js +++ b/src/worker/Worker.js @@ -1,11 +1,11 @@ /* * Web worker for CSSLint */ -/*global self, CSSLint, JSON*/ +/*global self, JSON*/ //message indicates to start linting self.onmessage = function(event){ - var data = event.data, + var data = event.data, message, text, ruleset, @@ -23,4 +23,4 @@ self.onmessage = function(event){ //Not all browsers support structured clone, so JSON stringify results self.postMessage(JSON.stringify(results)); -}; \ No newline at end of file +};