Skip to content

Instantly share code, notes, and snippets.

@lavaldi
Last active April 19, 2016 19:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lavaldi/c8926a84406302fa594cb4fbab88db9c to your computer and use it in GitHub Desktop.
Save lavaldi/c8926a84406302fa594cb4fbab88db9c to your computer and use it in GitHub Desktop.
Task of gulp to pass ES6 to ES5 with ESLint
{
"env": {
"es6": true,
"browser": true,
"node": true
},
"globals": {
"jQuery": true,
"$": true
},
"rules": {
"eqeqeq": "off",
"arrow-body-style": ["error", "always"],
"comma-spacing": ["error", { "before": false, "after": true }],
"indent": ["error", 2],
"prefer-const": "error",
"space-infix-ops": ["error"],
"space-before-function-paren": ["error", { "anonymous": "never", "named": "always" }]
}
}
gulp.task('js:es6', function () {
return gulp.src(pathFiles.frontend.js + '/modules/**/*.js')
.pipe(plugins.recursiveConcat({ extname: '.js' })) // concatenate files
.pipe(plugins.eslint({config: pathFiles.frontend.config + '/.eslintrc.json'}))
.pipe(plugins.eslint.format())
.pipe(plugins.eslint.failAfterError())
.pipe(plugins.iife({ prependSemicolon: false })) // push "use strick" and encompasses the modules
.pipe(plugins.babel({ presets: ['es2015'] })) / ES6 to ES5
.pipe(plugins.if(config.PROD, plugins.uglify({
mangle : true,
compress: {
drop_console: true
}
})))
.pipe(gulp.dest(pathFiles.dest.js + '/modules'))
.on('end', functions.successHandler);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment