From 00a7cc393a2551276becc5b21ecfa03424d95948 Mon Sep 17 00:00:00 2001 From: Wesley Cho Date: Tue, 15 Dec 2015 02:08:06 -0500 Subject: [PATCH] chore: leverage es6 in gruntfile - Add some ES6 usage in gruntfile Closes #5076 --- .eslintrc | 4 ++++ Gruntfile.js | 30 +++++++++++++++--------------- 2 files changed, 19 insertions(+), 15 deletions(-) diff --git a/.eslintrc b/.eslintrc index e754434..8540796 100644 --- a/.eslintrc +++ b/.eslintrc @@ -1,4 +1,8 @@ { + "env": { + "browser": true, + "es6": true + }, "rules": { "comma-dangle": 2, "no-cond-assign": 2, diff --git a/Gruntfile.js b/Gruntfile.js index 88da687..a98fa32 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -103,7 +103,7 @@ module.exports = function(grunt) { module: null, // no bundle module for all the html2js templates base: '.', rename: function(moduleName) { - return 'uib/' + moduleName; + return `uib/${moduleName}`; } }, files: [{ @@ -194,7 +194,7 @@ module.exports = function(grunt) { // Default task. grunt.registerTask('default', ['before-test', 'test', 'after-test']); - grunt.registerTask('enforce', 'Install commit message enforce script if it doesn\'t exist', function() { + grunt.registerTask('enforce', `Install commit message enforce script if it doesn't exist`, function() { if (!grunt.file.exists('.git/hooks/commit-msg')) { grunt.file.copy('misc/validate-commit-msg.js', '.git/hooks/commit-msg'); require('fs').chmodSync('.git/hooks/commit-msg', '0755'); @@ -227,22 +227,22 @@ module.exports = function(grunt) { var module = { name: name, - moduleName: enquote('ui.bootstrap.' + name), + moduleName: enquote(`ui.bootstrap.${name}`), displayName: ucwords(breakup(name, ' ')), - srcFiles: grunt.file.expand('src/'+name+'/*.js'), - cssFiles: grunt.file.expand('src/'+name+'/*.css'), - tplFiles: grunt.file.expand('template/'+name+'/*.html'), - tpljsFiles: grunt.file.expand('template/'+name+'/*.html.js'), - tplModules: grunt.file.expand('template/'+name+'/*.html').map(enquoteUibDir), + srcFiles: grunt.file.expand(`src/${name}/*.js`), + cssFiles: grunt.file.expand(`src/${name}/*.css`), + tplFiles: grunt.file.expand(`template/${name}/*.html`), + tpljsFiles: grunt.file.expand(`template/${name}/*.html.js`), + tplModules: grunt.file.expand(`template/${name}/*.html`).map(enquoteUibDir), dependencies: dependenciesForModule(name), docs: { - md: grunt.file.expand('src/'+name+'/docs/*.md') + md: grunt.file.expand(`src/${name}/docs/*.md`) .map(grunt.file.read).map(function(str) { return marked(str); }).join('\n'), - js: grunt.file.expand('src/'+name+'/docs/*.js') + js: grunt.file.expand(`src/${name}/docs/*.js`) .map(grunt.file.read).join('\n'), - html: grunt.file.expand('src/'+name+'/docs/*.html') + html: grunt.file.expand(`src/${name}/docs/*.html`) .map(grunt.file.read).join('\n') } }; @@ -399,7 +399,7 @@ module.exports = function(grunt) { var jsContent = versions.map(function(version) { return { version: version, - url: '/bootstrap/versioned-docs/' + version + url: `/bootstrap/versioned-docs/${version}` }; }); jsContent.unshift({ @@ -407,7 +407,7 @@ module.exports = function(grunt) { url: '/bootstrap' }); grunt.file.write(versionsMappingFile, JSON.stringify(jsContent)); - grunt.log.writeln('File ' + versionsMappingFile.cyan + ' created.'); + grunt.log.writeln(`File ${versionsMappingFile.cyan} created.`); done(); }); @@ -422,7 +422,7 @@ module.exports = function(grunt) { js; state.css.push(css); - if(minify){ + if (minify) { css = css .replace(/\r?\n/g, '') .replace(/\/\*.*?\*\//g, '') @@ -437,7 +437,7 @@ module.exports = function(grunt) { .replace(/\\/g, '\\\\') .replace(/'/g, "\\'") .replace(/\r?\n/g, '\\n'); - js = "angular.module('ui.bootstrap.carousel').run(function() {!angular.$$csp() && angular.element(document).find('head').prepend(''); })"; + js = `angular.module('ui.bootstrap.carousel').run(function() {!angular.$$csp() && angular.element(document).find('head').prepend(''); })`; state.js.push(js); return state;