From 8069b003f4f754689207167e3f4dbe92e1192abc Mon Sep 17 00:00:00 2001 From: Daniel Date: Sun, 11 Mar 2018 14:15:17 +0100 Subject: [PATCH 1/3] Added Gulp I have created a gulpfile.js with the same tasks of grunt, replaced npm script and finally ad .jshintrc for jshint --- .jshintrc | 22 ++++++++++++++++++++ gulpfile.js | 58 ++++++++++++++++++++++++++++++++++++++++++++++++++++ package.json | 24 +++++++++++++++++----- 3 files changed, 99 insertions(+), 5 deletions(-) create mode 100644 .jshintrc create mode 100644 gulpfile.js diff --git a/.jshintrc b/.jshintrc new file mode 100644 index 0000000..fe80948 --- /dev/null +++ b/.jshintrc @@ -0,0 +1,22 @@ +{ + "curly": false, + "eqeqeq": true, + "immed": true, + "esnext": true, + "latedef": "nofunc", + "newcap": true, + "noarg": true, + "sub": true, + "undef": true, + "eqnull": true, + "browser": true, + "expr": true, + "globals": { + "head": false, + "module": false, + "console": false, + "unescape": false, + "define": false, + "exports": false + } +} \ No newline at end of file diff --git a/gulpfile.js b/gulpfile.js new file mode 100644 index 0000000..a44ae9b --- /dev/null +++ b/gulpfile.js @@ -0,0 +1,58 @@ +const gulp = require('gulp') +const jshint = require('gulp-jshint') +const uglify = require('gulp-uglify') +const rename = require('gulp-rename') +const sass = require('gulp-sass') +const autoprefixer = require('gulp-autoprefixer') +const minify = require('gulp-clean-css') +const qunit = require('gulp-qunit') +const zip = require('gulp-zip') +const connect = require('gulp-connect') + +gulp.task('js', function () { + return gulp.src(['./js/reveal.js']).pipe(uglify()).pipe(rename('reveal.min.js')).pipe(gulp.dest('./js')) +}) + +gulp.task('css-themes', function () { + return gulp.src(['./css/theme/source/*.{sass,scss}']).pipe(sass()).pipe(gulp.dest('./css/theme')) +}) + +gulp.task('css-core', gulp.series(function () { + return gulp.src(['css/reveal.scss']).pipe(sass()).pipe(autoprefixer()).pipe(gulp.dest('./css')) +}, function () { + return gulp.src(['css/reveal.css']).pipe(minify({ + compatibility: 'ie9' + })).pipe(rename('reveal.min.css')).pipe(gulp.dest('./css')) +})) + +gulp.task('css', gulp.parallel('css-themes', 'css-core')) + +gulp.task('test', gulp.parallel(function () { + return gulp.src(['./js/reveal.js']).pipe(jshint()).pipe(jshint.reporter('default')).pipe(jshint.reporter('fail')); +}, function () { + return gulp.src(['./test/*.html']).pipe(qunit()) +})) + +gulp.task('default', gulp.series(gulp.parallel('js', 'css'), 'test')) + +gulp.task('package', gulp.series('default', function () { + return gulp.src([ + './index.html', + './css/**', + './js/**', + './lib/**', + './images/**', + './plugin/**', + './**.md' + ]).pipe(zip('reveal-js-presentation.zip')).pipe(gulp.dest('./')) +})) + +gulp.task('serve', function () { + connect.server({ + root: '.', + livereload: true, + open: true, + useAvailablePort: true + }) + gulp.watch(['js/reveal.js'], gulp.series('js')) +}) \ No newline at end of file diff --git a/package.json b/package.json index 9bb5d29..c4efa30 100644 --- a/package.json +++ b/package.json @@ -6,9 +6,9 @@ "subdomain": "revealjs", "main": "js/reveal.js", "scripts": { - "test": "grunt test", - "start": "grunt serve", - "build": "grunt" + "test": "gulp test", + "start": "gulp serve", + "build": "gulp" }, "author": { "name": "Hakim El Hattab", @@ -33,11 +33,25 @@ "grunt-contrib-qunit": "^2.0.0", "grunt-contrib-uglify": "^3.3.0", "grunt-contrib-watch": "^1.0.0", - "grunt-sass": "^2.0.0", "grunt-retire": "^1.0.7", + "grunt-sass": "^2.0.0", "grunt-zip": "~0.17.1", + "gulp": "^4.0.0", + "gulp-autoprefixer": "^5.0.0", + "gulp-clean-css": "^3.9.3", + "gulp-connect": "^5.5.0", + "gulp-jshint": "^2.1.0", + "gulp-qunit": "^2.0.1", + "gulp-rename": "^1.2.2", + "gulp-sass": "^3.1.0", + "gulp-uglify": "^3.0.0", + "gulp-zip": "^4.1.0", + "jshint": "^2.9.5", "mustache": "^2.3.0", "socket.io": "^1.7.3" }, - "license": "MIT" + "license": "MIT", + "dependencies": { + "npm": "^5.7.1" + } } From fb5f4c034a453f0246a3a03897b033739376c694 Mon Sep 17 00:00:00 2001 From: Daniel Date: Sun, 11 Mar 2018 17:52:37 +0100 Subject: [PATCH 2/3] Added the remaining gulp watch I forgot them :anguished: --- gulpfile.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/gulpfile.js b/gulpfile.js index a44ae9b..3326a68 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -55,4 +55,8 @@ gulp.task('serve', function () { useAvailablePort: true }) gulp.watch(['js/reveal.js'], gulp.series('js')) + gulp.watch(['css/theme/source/*.{sass,scss}', + 'css/theme/template/*.{sass,scss}', + ], gulp.series('css-themes')) + gulp.watch(['css/reveal.scss'], gulp.series('css-core')) }) \ No newline at end of file From 4818acbaf037b7c2976b4e699e73adf20966c545 Mon Sep 17 00:00:00 2001 From: Daniel Panero Date: Mon, 14 May 2018 20:01:59 +0200 Subject: [PATCH 3/3] Removed .jshintrc and added eslint instead of jshint I added the same jshint configuration/rules in package.json and I replaced some old function with arrow function to improve legibility --- .jshintrc | 22 ---------------------- gulpfile.js | 36 +++++++++++++++--------------------- package.json | 35 ++++++++++++++++++++++++++++++++++- 3 files changed, 49 insertions(+), 44 deletions(-) delete mode 100644 .jshintrc diff --git a/.jshintrc b/.jshintrc deleted file mode 100644 index fe80948..0000000 --- a/.jshintrc +++ /dev/null @@ -1,22 +0,0 @@ -{ - "curly": false, - "eqeqeq": true, - "immed": true, - "esnext": true, - "latedef": "nofunc", - "newcap": true, - "noarg": true, - "sub": true, - "undef": true, - "eqnull": true, - "browser": true, - "expr": true, - "globals": { - "head": false, - "module": false, - "console": false, - "unescape": false, - "define": false, - "exports": false - } -} \ No newline at end of file diff --git a/gulpfile.js b/gulpfile.js index 3326a68..0989303 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -1,5 +1,5 @@ const gulp = require('gulp') -const jshint = require('gulp-jshint') +const eslint = require('gulp-eslint') const uglify = require('gulp-uglify') const rename = require('gulp-rename') const sass = require('gulp-sass') @@ -9,34 +9,28 @@ const qunit = require('gulp-qunit') const zip = require('gulp-zip') const connect = require('gulp-connect') -gulp.task('js', function () { - return gulp.src(['./js/reveal.js']).pipe(uglify()).pipe(rename('reveal.min.js')).pipe(gulp.dest('./js')) -}) +gulp.task('js', () => gulp.src(['./js/reveal.js']).pipe(uglify()).pipe(rename('reveal.min.js')).pipe(gulp.dest('./js'))) -gulp.task('css-themes', function () { - return gulp.src(['./css/theme/source/*.{sass,scss}']).pipe(sass()).pipe(gulp.dest('./css/theme')) -}) +gulp.task('css-themes', () => gulp.src(['./css/theme/source/*.{sass,scss}']).pipe(sass()).pipe(gulp.dest('./css/theme'))) -gulp.task('css-core', gulp.series(function () { - return gulp.src(['css/reveal.scss']).pipe(sass()).pipe(autoprefixer()).pipe(gulp.dest('./css')) -}, function () { - return gulp.src(['css/reveal.css']).pipe(minify({ +gulp.task('css-core', gulp.series( + () => gulp.src(['css/reveal.scss']).pipe(sass()).pipe(autoprefixer()).pipe(gulp.dest('./css')), + () => gulp.src(['css/reveal.css']).pipe(minify({ compatibility: 'ie9' })).pipe(rename('reveal.min.css')).pipe(gulp.dest('./css')) -})) +)) gulp.task('css', gulp.parallel('css-themes', 'css-core')) -gulp.task('test', gulp.parallel(function () { - return gulp.src(['./js/reveal.js']).pipe(jshint()).pipe(jshint.reporter('default')).pipe(jshint.reporter('fail')); -}, function () { - return gulp.src(['./test/*.html']).pipe(qunit()) -})) +gulp.task('test', gulp.series( + () => gulp.src(['./js/reveal.js']).pipe(eslint({useEslintrc: true})).pipe(eslint.format()), + () => gulp.src(['./test/*.html']).pipe(qunit()) +)) gulp.task('default', gulp.series(gulp.parallel('js', 'css'), 'test')) -gulp.task('package', gulp.series('default', function () { - return gulp.src([ +gulp.task('package', gulp.series('default', () => + gulp.src([ './index.html', './css/**', './js/**', @@ -45,9 +39,9 @@ gulp.task('package', gulp.series('default', function () { './plugin/**', './**.md' ]).pipe(zip('reveal-js-presentation.zip')).pipe(gulp.dest('./')) -})) +)) -gulp.task('serve', function () { +gulp.task('serve', () => { connect.server({ root: '.', livereload: true, diff --git a/package.json b/package.json index c4efa30..9e96d0d 100644 --- a/package.json +++ b/package.json @@ -40,7 +40,7 @@ "gulp-autoprefixer": "^5.0.0", "gulp-clean-css": "^3.9.3", "gulp-connect": "^5.5.0", - "gulp-jshint": "^2.1.0", + "gulp-eslint": "^4.0.2", "gulp-qunit": "^2.0.1", "gulp-rename": "^1.2.2", "gulp-sass": "^3.1.0", @@ -53,5 +53,38 @@ "license": "MIT", "dependencies": { "npm": "^5.7.1" + }, + "eslintConfig": { + "env": { + "browser": true + }, + "globals": { + "head": false, + "module": false, + "console": false, + "unescape": false, + "define": false, + "exports": false + }, + "rules": { + "curly": 0, + "eqeqeq": 2, + "wrap-iife": [ + 2, + "any" + ], + "no-use-before-define": [ + 2, + { + "functions": false + } + ], + "new-cap": 2, + "no-caller": 2, + "dot-notation": 0, + "no-undef": 2, + "no-eq-null": 2, + "no-unused-expressions": 2 + } } }