diff --git a/.jsbeautifyrc b/.jsbeautifyrc new file mode 100644 index 0000000000..276106b52b --- /dev/null +++ b/.jsbeautifyrc @@ -0,0 +1,22 @@ +{ + "indent_size": 4, + "indent_char": " ", + "eol": "\n", + "indent_level": 0, + "indent_with_tabs": false, + "preserve_newlines": true, + "max_preserve_newlines": 10, + "jslint_happy": false, + "space_after_anon_function": false, + "brace_style": "collapse", + "keep_array_indentation": false, + "keep_function_indentation": false, + "space_before_conditional": true, + "break_chained_methods": false, + "eval_code": false, + "unescape_strings": false, + "wrap_line_length": 0, + "wrap_attributes": "auto", + "wrap_attributes_indent_size": 4, + "end_with_newline": false +} \ No newline at end of file diff --git a/gulpfile.js b/gulpfile.js new file mode 100644 index 0000000000..a0ba38548b --- /dev/null +++ b/gulpfile.js @@ -0,0 +1,25 @@ +var gulp = require('gulp'); +var jshint = require('gulp-jshint'); +var stylish = require('jshint-stylish'); +var prettify = require('gulp-jsbeautifier'); + + + +/** + * Jshint + */ +gulp.task('jshint', function() { + return gulp.src(['./api/**/*.js', './assets/js/app/**/*.js', './test/**/*.js', '!./api/hooks']) + .pipe(jshint()) + .pipe(jshint.reporter(stylish)); +}); + + +/** + * Beautify JS code + */ +gulp.task('format-js', function() { + gulp.src(['./api/**/*.js', '!./api/hooks' ]) + .pipe(prettify({config: '.jsbeautifyrc', mode: 'VERIFY_AND_WRITE'})) + .pipe(gulp.dest('./api')); +}); \ No newline at end of file diff --git a/package.json b/package.json index b22a076436..9a8949731c 100755 --- a/package.json +++ b/package.json @@ -61,5 +61,11 @@ "url": "git://github.com/root/gladys.git" }, "author": "Pierre-Gilles Leymarie", - "license": "Creative Commons 3.0 France" + "license": "Creative Commons 3.0 France", + "devDependencies": { + "gulp": "^3.9.0", + "gulp-jsbeautifier": "^1.0.1", + "gulp-jshint": "^1.11.2", + "jshint-stylish": "^2.0.1" + } }