Skip to content

Commit 4f6404f

Browse files
committed
internal: linter #cleanup
1 parent 0b7ed81 commit 4f6404f

File tree

4 files changed

+22
-19
lines changed

4 files changed

+22
-19
lines changed

index.js

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,11 @@ var stringHash = require('string-hash');
1212
*/
1313
function createScopedNameFunc (plugin) {
1414
var orig = plugin.generateScopedName;
15-
return function (name, path, css) {
15+
return function (name, filename, css) {
1616
var hash = stringHash(css).toString(36).substr(0, 5);
1717
return orig.apply(plugin, arguments) + '___' + hash;
18-
}
19-
};
18+
};
19+
}
2020

2121
/*
2222
@@ -56,9 +56,10 @@ module.exports = function (browserify, options) {
5656
var plugins = options.use || options.u;
5757
if (!plugins) {
5858
plugins = Core.defaultPlugins;
59-
} else {
59+
}
60+
else {
6061
if (typeof plugins === 'string') {
61-
plugins = [ plugins ];
62+
plugins = [plugins];
6263
}
6364
}
6465

@@ -84,7 +85,8 @@ module.exports = function (browserify, options) {
8485

8586
if (name in options) {
8687
plugin = plugin(options[name]);
87-
} else {
88+
}
89+
else {
8890
plugin = plugin.postcss || plugin();
8991
}
9092

@@ -119,7 +121,7 @@ module.exports = function (browserify, options) {
119121
loader.tokensByFile = tokensByFile;
120122

121123
loader.fetch(path.relative(rootDir, filename), '/').then(function (tokens) {
122-
var output = "module.exports = " + JSON.stringify(tokens);
124+
var output = 'module.exports = ' + JSON.stringify(tokens);
123125

124126
assign(tokensByFile, loader.tokensByFile);
125127

@@ -138,13 +140,12 @@ module.exports = function (browserify, options) {
138140
global: true
139141
});
140142

141-
browserify.on('bundle', function(bundle) {
142-
bundle.on('end', function() {
143+
browserify.on('bundle', function (bundle) {
144+
bundle.on('end', function () {
143145
// Combine the collected sources into a single CSS file
144-
var css = Object.keys(sourceByFile).map(function(file) {
146+
var css = Object.keys(sourceByFile).map(function (file) {
145147
return sourceByFile[file];
146148
}).join('\n');
147-
var args = arguments;
148149

149150
fs.writeFile(cssOutFilename, css, function (err) {
150151
if (err) {
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
var styles = require('./styles.css');
2+
module.exports = styles;
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
var styles = require('cool-styles/styles.css');
2+
module.exports = styles;

tests/index.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,6 @@ var path = require('path');
88
var casesDir = path.join(__dirname, 'cases');
99
var cssOutFilename = 'out.css';
1010

11-
// test cases are expected to have:
12-
// - main.js (entry point)
13-
// - expected.css (what to expect from css-modulesify output)
14-
fs.readdirSync(path.join(__dirname, 'cases')).forEach(runTestCase);
15-
1611
function runTestCase (dir) {
1712
tape('case: ' + dir, function (t) {
1813
var fakeFs = {
@@ -32,11 +27,11 @@ function runTestCase (dir) {
3227
var b = browserify();
3328
b.add(path.join(casesDir, dir, 'main.js'));
3429
b.plugin(cssModulesify, {
35-
rootDir: path.join(casesDir, dir),
36-
output: cssOutFilename
30+
rootDir: path.join(casesDir, dir)
31+
, output: cssOutFilename
3732
});
3833

39-
b.bundle(function (err, buf) {
34+
b.bundle(function (err) {
4035
if (err) {
4136
console.error(err);
4237
return t.fail('Unexpected error');
@@ -46,3 +41,8 @@ function runTestCase (dir) {
4641
});
4742
});
4843
}
44+
45+
// test cases are expected to have:
46+
// - main.js (entry point)
47+
// - expected.css (what to expect from css-modulesify output)
48+
fs.readdirSync(path.join(__dirname, 'cases')).forEach(runTestCase);

0 commit comments

Comments
 (0)