From 84f61a0466461faf245f3f073c2ae858c2cfe10e Mon Sep 17 00:00:00 2001 From: dceejay Date: Mon, 11 May 2015 16:17:47 +0100 Subject: [PATCH] Add minimal code style to node-red-node (jscs) Optional grunt task - grunt style --- .jscsrc | 11 +++++++++++ Gruntfile.js | 15 ++++++++++++--- package.json | 1 + 3 files changed, 24 insertions(+), 3 deletions(-) create mode 100644 .jscsrc diff --git a/.jscsrc b/.jscsrc new file mode 100644 index 00000000..6b8a5051 --- /dev/null +++ b/.jscsrc @@ -0,0 +1,11 @@ +{ + "fileExtensions": [ ".js", "jscs" ], + "excludeFiles": [ "node_modules/**" ], + "validateIndentation": 4, + "requireCurlyBraces": true, + "disallowMixedSpacesAndTabs": true, + "disallowMultipleSpaces": {"allowEOLComments": true}, + //"requireSemicolons": true, + //"validateParameterSeparator": ", ", + "requireSpaceAfterKeywords": ["do","for","if","else","switch","case","try","while"] +} diff --git a/Gruntfile.js b/Gruntfile.js index 9d782907..bfab95e5 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -59,8 +59,15 @@ module.exports = function(grunt) { inlinelint: { html: ['*/*/*.html'], options: { - jshintrc:".jshintrc", - "reporter": require('jshint-stylish') + jshintrc: ".jshintrc", + reporter: require('jshint-stylish') + } + }, + jscs: { + src: "*/*/*.js", + options: { + config: ".jscsrc", + reporter: "inline" } } }); @@ -68,6 +75,8 @@ module.exports = function(grunt) { grunt.loadNpmTasks('grunt-simple-mocha'); grunt.loadNpmTasks('grunt-contrib-jshint'); grunt.loadNpmTasks('grunt-lint-inline'); + grunt.loadNpmTasks('grunt-jscs'); - grunt.registerTask('default', ['jshint:all', 'inlinelint', 'simplemocha:all'] ); + grunt.registerTask('default', ['jshint:all', 'inlinelint', 'simplemocha:all']); + grunt.registerTask('style', ['jscs']); }; diff --git a/package.json b/package.json index 3ed87967..81791e4d 100644 --- a/package.json +++ b/package.json @@ -21,6 +21,7 @@ "grunt-simple-mocha": "0.4.0", "grunt-contrib-jshint": "0.11.0", "grunt-lint-inline": "0.4.3", + "grunt-jscs": "0.8.*", "jshint-stylish": "1.0.1", "mocha": "2.1.0", "should": "4.6.5",