Add jQuery JSCS style checking
Grunt is bumped due to a bad peerDependency in the grunt pluginpull/1/head
parent
2d2efc545e
commit
67dce05429
@ -1,55 +1,95 @@
|
|||||||
/*jshint node: true */
|
/*jshint node: true */
|
||||||
module.exports = function(grunt) {
|
module.exports = function(grunt) {
|
||||||
|
|
||||||
// Project configuration.
|
// Project configuration.
|
||||||
grunt.initConfig({
|
grunt.initConfig({
|
||||||
// Metadata.
|
// Metadata.
|
||||||
pkg: grunt.file.readJSON("package.json"),
|
pkg: grunt.file.readJSON("package.json"),
|
||||||
banner: "/*! <%= pkg.name %> - v<%= pkg.version %> - " +
|
banner: "/*! <%= pkg.name %> - v<%= pkg.version %> - " +
|
||||||
"* Copyright (c) <%= grunt.template.today('yyyy') %> IOLA and <%= pkg.author.name %>;" +
|
"* Copyright (c) <%= grunt.template.today('yyyy') %> IOLA and <%= pkg.author.name %>;" +
|
||||||
" Licensed <%= pkg.license %> */\n",
|
" Licensed <%= pkg.license %> */\n",
|
||||||
// Task configuration.
|
// Task configuration.
|
||||||
uglify: {
|
uglify: {
|
||||||
options: {
|
options: {
|
||||||
banner: "<%= banner %>"
|
banner: "<%= banner %>"
|
||||||
},
|
},
|
||||||
dist: {
|
dist: {
|
||||||
expand: true,
|
expand: true,
|
||||||
flatten: true,
|
flatten: true,
|
||||||
src: ["jquery.*.js", "!jquery.js"],
|
src: ["jquery.*.js", "!jquery.js"],
|
||||||
dest: "dist/",
|
dest: "dist/",
|
||||||
rename: function(base, path) {
|
rename: function(base, path) {
|
||||||
return base + path.replace(/\.js/, ".min.js");
|
return base + path.replace(/\.js/, ".min.js");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
jshint: {
|
jshint: {
|
||||||
options: grunt.file.readJSON(".jshintrc"),
|
options: grunt.file.readJSON(".jshintrc"),
|
||||||
gruntfile: {
|
gruntfile: {
|
||||||
src: "Gruntfile.js"
|
src: "Gruntfile.js"
|
||||||
},
|
},
|
||||||
flot: {
|
flot: {
|
||||||
src: ["jquery.flot*.js"]
|
src: ["jquery.flot*.js"]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
watch: {
|
watch: {
|
||||||
gruntfile: {
|
gruntfile: {
|
||||||
files: "Gruntfile.js",
|
files: "Gruntfile.js",
|
||||||
tasks: ["jshint:gruntfile"]
|
tasks: ["jshint:gruntfile"]
|
||||||
},
|
},
|
||||||
flot: {
|
flot: {
|
||||||
files: "<%= jshint.flot.src %>",
|
files: "<%= jshint.flot.src %>",
|
||||||
tasks: ["jshint:flot"]
|
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.
|
// These plugins provide necessary tasks.
|
||||||
grunt.registerTask("default", ["jshint", "uglify"]);
|
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"]);
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|||||||
Loading…
Reference in New Issue