Skip to content

Commit 00e5686

Browse files
committed
style: Update style to Prettier
1 parent 722d531 commit 00e5686

File tree

10 files changed

+70
-69
lines changed

10 files changed

+70
-69
lines changed

src/index.js

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,7 @@ export default function loader(html, map, meta) {
3131
this._module.type = 'text/html';
3232

3333
const template = options.template
34-
? typeof options.template === 'string'
35-
? options.template
36-
: '_'
34+
? typeof options.template === 'string' ? options.template : '_'
3735
: false;
3836

3937
const plugins = [];
@@ -65,14 +63,14 @@ export default function loader(html, map, meta) {
6563
// => import HTML__URL__${idx} from './file.png';
6664
if (urls) {
6765
urls = Object.keys(urls)
68-
.map(url => `import ${url} from '${urls[url]}';`)
66+
.map((url) => `import ${url} from '${urls[url]}';`)
6967
.join('\n');
7068
}
7169
// <import src="./file.html">
7270
// => import HTML__IMPORT__${idx} from './file.html';
7371
if (imports) {
7472
imports = Object.keys(imports)
75-
.map(i => `import ${i} from '${imports[i]}';`)
73+
.map((i) => `import ${i} from '${imports[i]}';`)
7674
.join('\n');
7775
}
7876

src/lib/plugins/import.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,14 @@ const TEST_URL = /^\w+:\/\//;
66
// add filter method for urls (e.g `options.import`) (#158)
77
const filter = (url, options) => {
88
return TEST_URL.test(url) || url.startsWith('//');
9-
}
9+
};
1010

11-
export default function (options = {}) {
12-
return function (tree) {
11+
export default function(options = {}) {
12+
return function(tree) {
1313
let idx = 0;
1414
const imports = {};
1515

16-
tree.match([ { tag: 'import' }, { tag: 'include' } ], (node) => {
16+
tree.match([{ tag: 'import' }, { tag: 'include' }], (node) => {
1717
if (node.attrs && node.attrs.src) {
1818
// Remove <import>/<include> tag
1919
node.tag = false;
@@ -37,7 +37,7 @@ export default function (options = {}) {
3737
});
3838

3939
// Add imports to result.messages
40-
tree.messages.push(imports)
40+
tree.messages.push(imports);
4141

4242
return tree;
4343
};

src/lib/plugins/url.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,17 @@ const TEST_URL = /^\w+:\/\//;
88
const MATCH_ATTRS = [
99
{ attrs: { src: true } },
1010
{ attrs: { href: true } },
11-
{ attrs: { srcset: true } }
11+
{ attrs: { srcset: true } },
1212
];
1313

1414
// TODO(michael-ciniawsky)
1515
// add filter method for urls (e.g `options.url.filter`) (#158)
1616
const filter = (url, options) => {
1717
return TEST_URL.test(url) || url.startsWith('//');
18-
}
18+
};
1919

20-
export default function (options = {}) {
21-
return function (tree) {
20+
export default function(options = {}) {
21+
return function(tree) {
2222
let idx = 0;
2323
const urls = {};
2424

test/Errors.test.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@ describe('Errors', () => {
88
loader: {
99
test: /\.html$/,
1010
options: {
11-
minimize: true
12-
}
13-
}
11+
minimize: true,
12+
},
13+
},
1414
};
1515

1616
const stats = await webpack('error.js', config);

test/e2e/html.test.js

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,27 +12,27 @@ describe('E2E', () => {
1212
use: [
1313
{
1414
loader: path.resolve('./src'),
15-
options: {}
16-
}
17-
]
15+
options: {},
16+
},
17+
],
1818
},
1919
{
2020
test: /\.png$/,
21-
use: [ 'file-loader' ]
22-
}
23-
]
21+
use: ['file-loader'],
22+
},
23+
],
2424
};
2525

2626
const stats = await webpack('e2e/html.js', config);
2727
const { assets } = stats.compilation;
2828

2929
const scripts = {
3030
main: assets['main.js'].source(),
31-
runtime: assets['runtime.js'].source()
31+
runtime: assets['runtime.js'].source(),
3232
};
3333

34-
const { window } = dom([ scripts.runtime, scripts.main ]);
34+
const { window } = dom([scripts.runtime, scripts.main]);
3535

3636
expect(window.document.body.innerHTML).toMatchSnapshot();
37-
})
38-
})
37+
});
38+
});

test/e2e/template.test.js

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,27 +12,27 @@ describe('E2E', () => {
1212
use: [
1313
{
1414
loader: path.resolve('./src'),
15-
options: { template: true }
16-
}
17-
]
15+
options: { template: true },
16+
},
17+
],
1818
},
1919
{
2020
test: /\.png$/,
21-
use: [ 'file-loader' ]
22-
}
23-
]
21+
use: ['file-loader'],
22+
},
23+
],
2424
};
2525

2626
const stats = await webpack('e2e/template.js', config);
2727
const { assets } = stats.compilation;
2828

2929
const scripts = {
3030
main: assets['main.js'].source(),
31-
runtime: assets['runtime.js'].source()
31+
runtime: assets['runtime.js'].source(),
3232
};
3333

34-
const { window } = dom([ scripts.runtime, scripts.main ]);
34+
const { window } = dom([scripts.runtime, scripts.main]);
3535

3636
expect(window.document.body.innerHTML).toMatchSnapshot();
37-
})
38-
})
37+
});
38+
});

test/helpers/compiler.js

Lines changed: 22 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -16,37 +16,38 @@ const modules = (config) => {
1616
? config.rules
1717
: config.loader
1818
? [
19-
{
20-
test: config.loader.test || /\.txt$/,
21-
use: {
22-
loader: path.resolve(__dirname, '../../src'),
23-
options: config.loader.options || {},
19+
{
20+
test: config.loader.test || /\.txt$/,
21+
use: {
22+
loader: path.resolve(__dirname, '../../src'),
23+
options: config.loader.options || {},
24+
},
2425
},
25-
},
26-
]
26+
]
2727
: [],
2828
};
2929
};
3030

31-
const plugins = config => ([
32-
new webpack.optimize.CommonsChunkPlugin({
33-
names: ['runtime'],
34-
minChunks: Infinity,
35-
}),
36-
].concat(config.plugins || []));
31+
const plugins = (config) =>
32+
[
33+
new webpack.optimize.CommonsChunkPlugin({
34+
names: ['runtime'],
35+
minChunks: Infinity,
36+
}),
37+
].concat(config.plugins || []);
3738

3839
const output = (config) => {
3940
return {
4041
path: path.resolve(
4142
__dirname,
42-
`../outputs/${config.output ? config.output : ''}`,
43+
`../outputs/${config.output ? config.output : ''}`
4344
),
4445
filename: '[name].js',
4546
chunkFilename: '[name].chunk.js',
4647
};
4748
};
4849

49-
module.exports = function (fixture, config, options) {
50+
module.exports = function(fixture, config, options) {
5051
config = {
5152
devtool: config.devtool || 'sourcemap',
5253
context: path.resolve(__dirname, '..', 'fixtures'),
@@ -64,9 +65,11 @@ module.exports = function (fixture, config, options) {
6465

6566
if (!options.output) compiler.outputFileSystem = new MemoryFS();
6667

67-
return new Promise((resolve, reject) => compiler.run((err, stats) => {
68-
if (err) reject(err);
68+
return new Promise((resolve, reject) =>
69+
compiler.run((err, stats) => {
70+
if (err) reject(err);
6971

70-
resolve(stats);
71-
}));
72+
resolve(stats);
73+
})
74+
);
7275
};

test/helpers/dom.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,13 @@ const html = (scripts) => `
1313
</body>
1414
</html>`;
1515

16-
const virtualConsole = new VirtualConsole().sendTo(console)
16+
const virtualConsole = new VirtualConsole().sendTo(console);
1717

18-
export default function (scripts) {
19-
const dom = new JSDOM(
20-
html(scripts),
21-
{ runScripts: "dangerously", virtualConsole }
22-
);
18+
export default function(scripts) {
19+
const dom = new JSDOM(html(scripts), {
20+
runScripts: 'dangerously',
21+
virtualConsole,
22+
});
2323

2424
return dom;
25-
};
25+
}

test/loader.test.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
/* eslint-disable */
22
import webpack from './helpers/compiler';
33

4-
describe("Loader", () => {
4+
describe('Loader', () => {
55
test('Defaults', async () => {
66
const config = {
77
loader: {
88
test: /\.html$/,
9-
options: {}
10-
}
9+
options: {},
10+
},
1111
};
1212

1313
const stats = await webpack('fixture.js', config);

test/options/minimize.test.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@ describe('Options', () => {
88
loader: {
99
test: /\.html$/,
1010
options: {
11-
minimize: true
12-
}
13-
}
11+
minimize: true,
12+
},
13+
},
1414
};
1515

1616
const stats = await webpack('options/minimize/fixture.js', config);

0 commit comments

Comments
 (0)