Skip to content
This repository was archived by the owner on Jun 11, 2024. It is now read-only.

Commit 6c4c0e9

Browse files
committed
Fix ESLint errors in lib/*
1 parent f3d12e5 commit 6c4c0e9

File tree

3 files changed

+92
-93
lines changed

3 files changed

+92
-93
lines changed

lib/themeroller-image.js

+35-32
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
var cache, imVersion,
22
async = require( "async" ),
33
Cache = require( "./cache" ),
4-
im = require( "gm" ).subClass({ imageMagick: true }),
4+
im = require( "gm" ).subClass( { imageMagick: true } ),
55
semver = require( "semver" ),
66
dimensionLimit = 3000,
77
namedColors = require( "./themeroller-colors" );
@@ -10,9 +10,9 @@ cache = new Cache( "Image Cache" );
1010

1111
function expandColor( color ) {
1212
if ( color.length === 3 && /^[0-9a-f]+$/i.test( color ) ) {
13-
return [ 0, 0, 1, 1, 2, 2 ].map(function( i ) {
13+
return [ 0, 0, 1, 1, 2, 2 ].map( function( i ) {
1414
return color[ i ];
15-
}).join( "" );
15+
} ).join( "" );
1616
}
1717
return color;
1818
}
@@ -28,11 +28,11 @@ function hashColor( color ) {
2828
function pick( obj ) {
2929
var copy = {};
3030
var keys = [].concat.apply( [], [].slice.call( arguments, 1 ) );
31-
keys.forEach(function( key ) {
31+
keys.forEach( function( key ) {
3232
if ( key in obj ) {
3333
copy[ key ] = obj[ key ];
3434
}
35-
});
35+
} );
3636
return copy;
3737
}
3838

@@ -49,56 +49,58 @@ function stream2Buffer( callback ) {
4949
stdin.on( "data", function( chunk ) {
5050
chunks.push( chunk );
5151
dataLen += chunk.length;
52-
});
52+
} );
5353

5454
stderr.on( "data", function( chunk ) {
5555
err += chunk;
56-
});
56+
} );
5757

5858
stdin.on( "end", function() {
5959
var i = 0,
6060
buffer = Buffer.alloc( dataLen );
6161
if ( err.length ) {
6262
return callback( new Error( err ) );
6363
}
64-
chunks.forEach(function ( chunk ) {
64+
chunks.forEach( function( chunk ) {
6565
chunk.copy( buffer, i, 0, chunk.length );
6666
i += chunk.length;
67-
});
67+
} );
6868
callback( null, buffer );
69-
});
69+
} );
7070

7171
stdin.on( "error", function( err ) {
7272
callback( err );
73-
});
73+
} );
7474
};
7575
}
7676

7777
function validateColor( color ) {
7878
color = color.replace( /^#/, "" );
7979
if ( ( color.length === 3 || color.length === 6 ) && /^[0-9a-f]+$/i.test( color ) ) {
80+
8081
// ok
8182
} else if ( namedColors.indexOf( color.toLowerCase() ) !== -1 ) {
83+
8284
// ok
8385
} else {
8486
throw new Error( "invalid color \"" + color + "\"" );
8587
}
8688
}
8789

8890
function validateDimension( params, dimensionParams ) {
89-
var invalidParams = dimensionParams.filter(function( param ) {
91+
var invalidParams = dimensionParams.filter( function( param ) {
9092
return parseInt( params[ param ], 10 ) > dimensionLimit;
91-
});
93+
} );
9294

9395
if ( invalidParams.length ) {
9496
throw new Error( "dimension bigger than allowed limit " + JSON.stringify( pick( params, invalidParams ) ) );
9597
}
9698
}
9799

98100
function validateInteger( params, integerParams ) {
99-
var invalidParams = integerParams.filter(function( param ) {
100-
return isNaN( parseInt( params[ param ], 10 ) ) || (/[^0-9]/).test( params[ param ] );
101-
});
101+
var invalidParams = integerParams.filter( function( param ) {
102+
return isNaN( parseInt( params[ param ], 10 ) ) || ( /[^0-9]/ ).test( params[ param ] );
103+
} );
102104

103105
if ( invalidParams.length ) {
104106
throw new Error( "got a non-integer " + JSON.stringify( pick( params, invalidParams ) ) );
@@ -113,9 +115,9 @@ function validateOpacity( opacity ) {
113115
}
114116

115117
function validatePresence( params, requiredParams ) {
116-
var missingParams = requiredParams.filter(function( param ) {
118+
var missingParams = requiredParams.filter( function( param ) {
117119
return !params[ param ];
118-
});
120+
} );
119121

120122
if ( missingParams.length ) {
121123
throw new Error( "missing \"" + missingParams.join( "\", \"" ) + "\"" );
@@ -151,7 +153,7 @@ generateIcon = function( params, callback ) {
151153
// IM > 6.7.9: (see #132 http://git.io/gfSacg)
152154
// $ convert <icons_mask_filename> -set colorspace RGB -background <color> -alpha shape -set colorspace sRGB output.png
153155

154-
imageQueue.push(function( innerCallback ) {
156+
imageQueue.push( function( innerCallback ) {
155157
try {
156158
if ( semver.gt( imVersion, "6.7.9" ) ) {
157159
im( __dirname + "/../assets/icon/mask.png" )
@@ -166,7 +168,7 @@ generateIcon = function( params, callback ) {
166168
.out( "-alpha", "shape" )
167169
.stream( "png", stream2Buffer( innerCallback ) );
168170
}
169-
} catch( err ) {
171+
} catch ( err ) {
170172
return innerCallback( err );
171173
}
172174
}, callback );
@@ -183,12 +185,12 @@ generateTexture = function( params, callback ) {
183185
// http://www.imagemagick.org/Usage/compose/#dissolve
184186
// $ convert -size <width>x<height> 'xc:<color>' <texture_filename> -compose dissolve -define compose:args=<opacity>,100 -composite output.png
185187

186-
imageQueue.push(function( innerCallback ) {
188+
imageQueue.push( function( innerCallback ) {
187189
try {
188190
im( params.width, params.height, color )
189191
.out( __dirname + "/../assets/texture/" + filename, "-compose", "dissolve", "-define", "compose:args=" + params.opacity + ",100", "-composite" )
190192
.stream( "png", stream2Buffer( innerCallback ) );
191-
} catch( err ) {
193+
} catch ( err ) {
192194
return innerCallback( err );
193195
}
194196
}, callback );
@@ -314,19 +316,19 @@ Image.prototype = {
314316
cached.data = data;
315317
delete cached.callbacks;
316318
}
317-
callbacks.forEach(function( callback ) {
319+
callbacks.forEach( function( callback ) {
318320
callback( err, filename, data );
319-
});
321+
} );
320322
delete cached.callbacks;
321323
if ( err ) {
322324
cache.destroy( filename );
323325
}
324-
});
326+
} );
325327
}
326328
};
327329

328330
// Check the ImageMagick installation using node-gm (in a hacky way).
329-
async.series([
331+
async.series( [
330332
function( callback ) {
331333
var wrappedCallback = function( err ) {
332334
if ( err ) {
@@ -335,15 +337,15 @@ async.series([
335337
callback();
336338
};
337339
try {
338-
im()._spawn([ "convert", "-version" ], true, wrappedCallback );
339-
} catch( err ) {
340+
im()._spawn( [ "convert", "-version" ], true, wrappedCallback );
341+
} catch ( err ) {
340342
return wrappedCallback( err );
341343
}
342344
},
343345
function( callback ) {
344-
im()._spawn([ "convert", "-version" ], false, stream2Buffer(function( err, buffer ) {
346+
im()._spawn( [ "convert", "-version" ], false, stream2Buffer( function( _err, buffer ) {
345347
var output = buffer.toString( "utf8" );
346-
if ( !(/ImageMagick/).test( output ) ) {
348+
if ( !( /ImageMagick/ ).test( output ) ) {
347349
return callback( new Error( "ImageMagick not installed.\n" + output ) );
348350
}
349351
imVersion = output.split( "\n" )[ 0 ].replace( /^Version: ImageMagick ([^ ]*).*/, "$1" );
@@ -352,13 +354,14 @@ async.series([
352354
}
353355
imageQueue.resume();
354356
callback();
355-
}));
357+
} ) );
356358
}
357359
], function( err ) {
358360
if ( err ) {
361+
359362
// On error, abort
360363
throw new Error( err );
361364
}
362-
});
365+
} );
363366

364367
module.exports = Image;

lib/themeroller-textures.js

+25-25
Original file line numberDiff line numberDiff line change
@@ -1,122 +1,122 @@
11
// Hard coded textures
2-
module.exports = [{
2+
module.exports = [ {
33
"type": "flat",
44
"width": "40",
55
"height": "100",
66
"repeat": "repeat-x"
7-
},{
7+
}, {
88
"type": "glass",
99
"width": "1",
1010
"height": "400",
1111
"repeat": "repeat-x"
12-
},{
12+
}, {
1313
"type": "highlight_soft",
1414
"width": "1",
1515
"height": "100",
1616
"repeat": "repeat-x"
17-
},{
17+
}, {
1818
"type": "highlight_hard",
1919
"width": "1",
2020
"height": "100",
2121
"repeat": "repeat-x"
22-
},{
22+
}, {
2323
"type": "inset_soft",
2424
"width": "1",
2525
"height": "100",
2626
"repeat": "repeat-x"
27-
},{
27+
}, {
2828
"type": "inset_hard",
2929
"width": "1",
3030
"height": "100",
3131
"repeat": "repeat-x"
32-
},{
32+
}, {
3333
"type": "diagonals_small",
3434
"width": "40",
3535
"height": "40",
3636
"repeat": "repeat"
37-
},{
37+
}, {
3838
"type": "diagonals_medium",
3939
"width": "40",
4040
"height": "40",
4141
"repeat": "repeat"
42-
},{
42+
}, {
4343
"type": "diagonals_thick",
4444
"width": "40",
4545
"height": "40",
4646
"repeat": "repeat"
47-
},{
47+
}, {
4848
"type": "dots_small",
4949
"width": "2",
5050
"height": "2",
5151
"repeat": "repeat"
52-
},{
52+
}, {
5353
"type": "dots_medium",
5454
"width": "4",
5555
"height": "4",
5656
"repeat": "repeat"
57-
},{
57+
}, {
5858
"type": "white_lines",
5959
"width": "40",
6060
"height": "100",
6161
"repeat": "repeat"
62-
},{
62+
}, {
6363
"type": "gloss_wave",
6464
"width": "500",
6565
"height": "100",
6666
"repeat": "repeat-x"
67-
},{
67+
}, {
6868
"type": "diamond",
6969
"width": "10",
7070
"height": "8",
7171
"repeat": "repeat"
72-
},{
72+
}, {
7373
"type": "loop",
7474
"width": "21",
7575
"height": "21",
7676
"repeat": "repeat"
77-
},{
77+
}, {
7878
"type": "carbon_fiber",
7979
"width": "8",
8080
"height": "9",
8181
"repeat": "repeat"
82-
},{
82+
}, {
8383
"type": "diagonal_maze",
8484
"width": "10",
8585
"height": "10",
8686
"repeat": "repeat"
87-
},{
87+
}, {
8888
"type": "diamond_ripple",
8989
"width": "22",
9090
"height": "22",
9191
"repeat": "repeat"
92-
},{
92+
}, {
9393
"type": "hexagon",
9494
"width": "12",
9595
"height": "10",
9696
"repeat": "repeat"
97-
},{
97+
}, {
9898
"type": "layered_circles",
9999
"width": "13",
100100
"height": "13",
101101
"repeat": "repeat"
102-
},{
102+
}, {
103103
"type": "3D_boxes",
104104
"width": "12",
105105
"height": "10",
106106
"repeat": "repeat"
107-
},{
107+
}, {
108108
"type": "glow_ball",
109109
"width": "600",
110110
"height": "600",
111111
"repeat": "repeat-x"
112-
},{
112+
}, {
113113
"type": "spotlight",
114114
"width": "600",
115115
"height": "600",
116116
"repeat": "repeat-x"
117-
},{
117+
}, {
118118
"type": "fine_grain",
119119
"width": "60",
120120
"height": "60",
121121
"repeat": "repeat"
122-
}];
122+
} ];

0 commit comments

Comments
 (0)