diff --git a/Gruntfile.js b/Gruntfile.js index a443273..a18a6f6 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -1,55 +1,95 @@ /*jshint node: true */ module.exports = function(grunt) { - // Project configuration. - grunt.initConfig({ - // Metadata. - pkg: grunt.file.readJSON("package.json"), - banner: "/*! <%= pkg.name %> - v<%= pkg.version %> - " + - "* Copyright (c) <%= grunt.template.today('yyyy') %> IOLA and <%= pkg.author.name %>;" + - " Licensed <%= pkg.license %> */\n", - // Task configuration. - uglify: { - options: { - banner: "<%= banner %>" - }, - dist: { - expand: true, - flatten: true, - src: ["jquery.*.js", "!jquery.js"], - dest: "dist/", - rename: function(base, path) { - return base + path.replace(/\.js/, ".min.js"); - } - } - }, - jshint: { - options: grunt.file.readJSON(".jshintrc"), - gruntfile: { - src: "Gruntfile.js" - }, - flot: { - src: ["jquery.flot*.js"] - } - }, - watch: { - gruntfile: { - files: "Gruntfile.js", - tasks: ["jshint:gruntfile"] - }, - flot: { - files: "<%= jshint.flot.src %>", - tasks: ["jshint:flot"] - } - } - }); + // Project configuration. + grunt.initConfig({ + // Metadata. + pkg: grunt.file.readJSON("package.json"), + banner: "/*! <%= pkg.name %> - v<%= pkg.version %> - " + + "* Copyright (c) <%= grunt.template.today('yyyy') %> IOLA and <%= pkg.author.name %>;" + + " Licensed <%= pkg.license %> */\n", + // Task configuration. + uglify: { + options: { + banner: "<%= banner %>" + }, + dist: { + expand: true, + flatten: true, + src: ["jquery.*.js", "!jquery.js"], + dest: "dist/", + rename: function(base, path) { + return base + path.replace(/\.js/, ".min.js"); + } + } + }, + jshint: { + options: grunt.file.readJSON(".jshintrc"), + gruntfile: { + src: "Gruntfile.js" + }, + flot: { + src: ["jquery.flot*.js"] + } + }, + watch: { + gruntfile: { + files: "Gruntfile.js", + tasks: ["jshint:gruntfile"] + }, + flot: { + files: "<%= jshint.flot.src %>", + tasks: ["jshint:flot"] + } + }, + jscs: { + options: { + "requireCurlyBraces": [ "if", "else", "for", "while", "do" ], + "requireSpaceAfterKeywords": [ "if", "else", "for", "while", "do", "switch", "return" ], + "requireSpacesInFunctionExpression": { + "beforeOpeningCurlyBrace": true + }, + "disallowSpacesInFunctionExpression": { + "beforeOpeningRoundBrace": true + }, + "requireMultipleVarDecl": true, + "requireSpacesInsideObjectBrackets": "all", // Different from jQuery preset + "disallowSpacesInsideArrayBrackets": true, // Different from jQuery preset + "disallowLeftStickedOperators": [ "?", "-", "/", "*", "=", "==", "===", "!=", "!==", ">", ">=", "<", "<=" ], + "disallowRightStickedOperators": [ "?", "/", "*", ":", "=", "==", "===", "!=", "!==", ">", ">=", "<", "<="], + "requireSpaceBeforeBinaryOperators": ["+", "-", "/", "*", "=", "==", "===", "!=", "!=="], + "disallowSpaceAfterPrefixUnaryOperators": ["++", "--", "+", "-"], + "disallowSpaceBeforePostfixUnaryOperators": ["++", "--"], + "requireRightStickedOperators": [ "!" ], + "requireLeftStickedOperators": [ "," ], + "disallowKeywords": [ "with" ], + "disallowMultipleLineBreaks": true, + "disallowKeywordsOnNewLine": [ "else" ], + "requireLineFeedAtFileEnd": true, + "disallowSpaceAfterObjectKeys": true, + "validateJSDoc": { + "checkParamNames": true, + "checkRedundantParams": true, + "requireParamTypes": true + }, + "validateQuoteMarks": "\"", + reporter: "checkstyle", + reporterOutput: "jscs.xml" + }, + flot: { + src: "<%= jshint.flot.src %>" + } - // These plugins provide necessary tasks. - grunt.loadNpmTasks("grunt-contrib-uglify"); - grunt.loadNpmTasks("grunt-contrib-jshint"); - grunt.loadNpmTasks("grunt-contrib-watch"); + } + }); - // Default task. - grunt.registerTask("default", ["jshint", "uglify"]); + // These plugins provide necessary tasks. + grunt.loadNpmTasks("grunt-contrib-uglify"); + grunt.loadNpmTasks("grunt-contrib-jshint"); + grunt.loadNpmTasks("grunt-contrib-watch"); + grunt.loadNpmTasks("grunt-jscs-checker"); + + // Default task. + grunt.registerTask("default", ["jshint", "uglify"]); }; diff --git a/package.json b/package.json index 179c0ef..5e778ab 100644 --- a/package.json +++ b/package.json @@ -36,10 +36,11 @@ "url": "https://github.com/flot/flot/issues" }, "devDependencies": { - "grunt": "~0.4.1", + "grunt": "~0.4.2", "grunt-contrib-jshint": "~0.6.4", "grunt-contrib-uglify": "~0.2.4", - "grunt-contrib-watch": "~0.5.3" + "grunt-contrib-watch": "~0.5.3", + "grunt-jscs-checker": "~0.3.2" }, "maintainers": [ {