diff --git a/Gruntfile.js b/Gruntfile.js
index 5c06db0..0dc1f3e 100644
--- a/Gruntfile.js
+++ b/Gruntfile.js
@@ -116,7 +116,8 @@ module.exports = function ( grunt ) {
eslint: {
options: {
extensions: [ '.js', '.json' ],
- cache: true
+ cache: true,
+ fix: grunt.option( 'fix' )
},
main: [
'**/*.{js,json}',
diff --git a/build/moduleUtils.js b/build/moduleUtils.js
index f3dc395..58f3128 100644
--- a/build/moduleUtils.js
+++ b/build/moduleUtils.js
@@ -4,7 +4,9 @@
* Code shared with the OOjs UI project
*/
-var self = module.exports = {
+'use strict';
+
+const self = module.exports = {
/**
* Expand an array of file paths and variant-objects into
* a flattened list by variant.
@@ -40,16 +42,15 @@ var self = module.exports = {
// (which will compile the less code) and the concat task
// (which will prepend intro.css without it being stripped
// like recess would).
- var targets = { default: [] };
+ const targets = { default: [] };
resources.forEach( function ( filepath ) {
- var variant, buffer;
if ( typeof filepath !== 'object' ) {
filepath = { default: filepath };
}
// Fetch copy of buffer before filepath/variant loop, otherwise
// it can incorrectly include the default file in a non-default variant.
- buffer = targets.default.slice();
- for ( variant in filepath ) {
+ const buffer = targets.default.slice();
+ for ( const variant in filepath ) {
if ( !targets[ variant ] ) {
targets[ variant ] = buffer.slice();
}
@@ -69,16 +70,16 @@ var self = module.exports = {
*/
makeBuildList: function ( modules, targets ) {
/**
- * Given a list of modules and targets, returns an object splitting the scripts
- * and styles.
- *
- * @param {Array} modules List of modules
- * @param {Array} buildlist List of targets to work through
- * @param {Object|null} filelist Object to extend
- * @return {Object} Object of two arrays listing the file paths
- */
+ * Given a list of modules and targets, returns an object splitting the scripts
+ * and styles.
+ *
+ * @param {Array} modules List of modules
+ * @param {Array} buildlist List of targets to work through
+ * @param {Object|null} filelist Object to extend
+ * @return {Object} Object of two arrays listing the file paths
+ */
function expandBuildList( modules, buildlist, filelist ) {
- var build, moduleName, script, style;
+ let build, moduleName, script, style;
filelist = filelist || {};
filelist.scripts = filelist.scripts || [];
@@ -115,7 +116,7 @@ var self = module.exports = {
* @return {Array} Flat list of file paths
*/
buildDependencyList: function ( modules, load, list ) {
- var i, module;
+ let i, module;
list = list || [];
diff --git a/build/prependPaths.js b/build/prependPaths.js
index bca7c1b..9596703 100644
--- a/build/prependPaths.js
+++ b/build/prependPaths.js
@@ -1,5 +1,7 @@
+'use strict';
+
function prependPaths( prefix, val ) {
- var ob, k, v;
+ let ob, k, v;
if ( Array.isArray( val ) ) {
return val.map( function ( item ) {
return prependPaths( prefix, item );
diff --git a/build/tasks/buildloader.js b/build/tasks/buildloader.js
index a47e141..46b2fa4 100644
--- a/build/tasks/buildloader.js
+++ b/build/tasks/buildloader.js
@@ -2,11 +2,12 @@
* Build a static loader file from a template
*/
+'use strict';
+
module.exports = function ( grunt ) {
grunt.registerMultiTask( 'buildloader', function () {
- var configScript,
- styles = [],
+ const styles = [],
scripts = [],
loadedModules = [],
targetFile = this.data.targetFile,
@@ -21,17 +22,17 @@ module.exports = function ( grunt ) {
placeholders = this.data.placeholders || {},
dir = this.data.dir,
langList = this.data.langList !== undefined ? this.data.langList : true,
- text = grunt.file.read( this.data.template ),
done = this.async(),
moduleUtils = require( '../moduleUtils' ),
stringifyObject = require( 'stringify-object' );
+ let text = grunt.file.read( this.data.template );
function scriptTag( src ) {
return indent + '';
}
function styleTag( group, src ) {
- var rtlFilepath = src.file.replace( /\.css$/, '.rtl.css' );
+ const rtlFilepath = src.file.replace( /\.css$/, '.rtl.css' );
if ( grunt.file.exists( rtlFilepath ) ) {
if ( !dir ) {
@@ -64,30 +65,28 @@ module.exports = function ( grunt ) {
}
function placeholder( input, id, replacement, callback ) {
- var output,
- rComment = new RegExp( '', 'm' );
+ const rComment = new RegExp( '', 'm' );
if ( typeof replacement === 'function' ) {
replacement( function ( response ) {
- output = input.replace( rComment, response );
+ const output = input.replace( rComment, response );
callback( output );
} );
} else {
- output = input.replace( rComment, replacement );
+ const output = input.replace( rComment, replacement );
callback( output );
}
}
function addModules( load ) {
- var module, moduleStyles, moduleScripts, dependency,
- dependencies = moduleUtils.buildDependencyList( modules, load );
- for ( dependency in dependencies ) {
- module = dependencies[ dependency ];
+ const dependencies = moduleUtils.buildDependencyList( modules, load );
+ for ( const dependency in dependencies ) {
+ const module = dependencies[ dependency ];
if ( loadedModules.indexOf( module ) > -1 ) {
continue;
}
loadedModules.push( module );
if ( modules[ module ].scripts ) {
- moduleScripts = modules[ module ].scripts
+ const moduleScripts = modules[ module ].scripts
.map( expand ).filter( filter.bind( this, 'scripts' ) ).map( scriptTag )
.join( '\n' );
if ( moduleScripts ) {
@@ -95,7 +94,7 @@ module.exports = function ( grunt ) {
}
}
if ( modules[ module ].styles ) {
- moduleStyles = modules[ module ].styles
+ const moduleStyles = modules[ module ].styles
.map( expand ).filter( filter.bind( this, 'styles' ) ).map( styleTag.bind( styleTag, modules[ module ].styleGroup ) )
.join( '\n' );
if ( moduleStyles ) {
@@ -108,7 +107,7 @@ module.exports = function ( grunt ) {
addModules( load );
if ( i18n.length || demoPages ) {
- configScript = indent + '