Skip to content

Commit 0e7ef63

Browse files
committed
Use the default (80 characters) width
1 parent aed3383 commit 0e7ef63

21 files changed

+104
-30
lines changed

.prettierrc

-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
{
2-
"printWidth": 100,
32
"singleQuote": true,
43
"trailingComma": "all"
54
}

src/TemplateTag/TemplateTag.js

+11-4
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,10 @@ export default class TemplateTag {
7373
* @return {String} - the result of joining this iteration's processed substitution with the result
7474
*/
7575
processSubstitutions(substitutions, resultSoFar, remainingPart) {
76-
const substitution = this.transformSubstitution(substitutions.shift(), resultSoFar);
76+
const substitution = this.transformSubstitution(
77+
substitutions.shift(),
78+
resultSoFar,
79+
);
7780
return resultSoFar + substitution + remainingPart;
7881
}
7982

@@ -84,7 +87,8 @@ export default class TemplateTag {
8487
* @return {String} - The final results of processing each transformer
8588
*/
8689
transformString(str) {
87-
const cb = (res, transform) => (transform.onString ? transform.onString(res) : res);
90+
const cb = (res, transform) =>
91+
transform.onString ? transform.onString(res) : res;
8892
return this.transformers.reduce(cb, str);
8993
}
9094

@@ -97,7 +101,9 @@ export default class TemplateTag {
97101
*/
98102
transformSubstitution(substitution, resultSoFar) {
99103
const cb = (res, transform) =>
100-
transform.onSubstitution ? transform.onSubstitution(res, resultSoFar) : res;
104+
transform.onSubstitution
105+
? transform.onSubstitution(res, resultSoFar)
106+
: res;
101107
return this.transformers.reduce(cb, substitution);
102108
}
103109

@@ -108,7 +114,8 @@ export default class TemplateTag {
108114
* @return {String} - The final results of processing each transformer
109115
*/
110116
transformEndResult(endResult) {
111-
const cb = (res, transform) => (transform.onEndResult ? transform.onEndResult(res) : res);
117+
const cb = (res, transform) =>
118+
transform.onEndResult ? transform.onEndResult(res) : res;
112119
return this.transformers.reduce(cb, endResult);
113120
}
114121
}

src/html/html.test.js

+4-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,10 @@ test('converts strings containing newlines into proper indented output', async t
3232

3333
test('does not introduce excess newlines', async t => {
3434
const newlines = '<li>one</li>\n<li>two</li>';
35-
const expected = await readFromFixture(__dirname, 'newline-conversion-after-newline');
35+
const expected = await readFromFixture(
36+
__dirname,
37+
'newline-conversion-after-newline',
38+
);
3639
const actual = html`
3740
<h1>${val}${nil}</h1>
3841
<ul>

src/index.test.js

+4-1
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@ test('common-tags exports all the right modules as props', async t => {
2323
const modules = t.context.modules;
2424
t.plan(modules.length);
2525
modules.forEach(module => {
26-
t.true(require('./index')[module] != null, `${module} is not exported properly`);
26+
t.true(
27+
require('./index')[module] != null,
28+
`${module} is not exported properly`,
29+
);
2730
});
2831
});

src/inlineArrayTransformer/inlineArrayTransformer.test.js

+18-5
Original file line numberDiff line numberDiff line change
@@ -9,22 +9,35 @@ test('only operates on arrays', t => {
99

1010
test('includes an array as a comma-separated list', t => {
1111
const tag = new TemplateTag(inlineArrayTransformer({ separator: ',' }));
12-
t.is(tag`I like ${['apple', 'banana', 'kiwi']}`, 'I like apple, banana, kiwi');
12+
t.is(
13+
tag`I like ${['apple', 'banana', 'kiwi']}`,
14+
'I like apple, banana, kiwi',
15+
);
1316
});
1417

1518
test('replaces last separator with a conjunction', t => {
16-
const tag = new TemplateTag(inlineArrayTransformer({ separator: ',', conjunction: 'and' }));
17-
t.is(tag`I like ${['apple', 'banana', 'kiwi']}`, 'I like apple, banana and kiwi');
19+
const tag = new TemplateTag(
20+
inlineArrayTransformer({ separator: ',', conjunction: 'and' }),
21+
);
22+
t.is(
23+
tag`I like ${['apple', 'banana', 'kiwi']}`,
24+
'I like apple, banana and kiwi',
25+
);
1826
});
1927

2028
test('does not use a conjunction if there is only one item in an array', t => {
21-
const tag = new TemplateTag(inlineArrayTransformer({ separator: ',', conjunction: 'and' }));
29+
const tag = new TemplateTag(
30+
inlineArrayTransformer({ separator: ',', conjunction: 'and' }),
31+
);
2232
t.is(tag`I like ${['apple']}`, 'I like apple');
2333
});
2434

2535
test('does not require preceded whitespace', t => {
2636
const tag = new TemplateTag(inlineArrayTransformer({ separator: ',' }));
27-
t.is(tag`My friends are (${['bob', 'sally', 'jim']})`, 'My friends are (bob, sally, jim)');
37+
t.is(
38+
tag`My friends are (${['bob', 'sally', 'jim']})`,
39+
'My friends are (bob, sally, jim)',
40+
);
2841
});
2942

3043
test('supports serial/oxford separators', t => {

src/oneLineCommaListsAnd/oneLineCommaListsAnd.test.js

+4-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,10 @@ test('includes arrays as comma-separated list on one line with "and"', async t =
1616

1717
test('only returns the first item of a single element array', async t => {
1818
const fruits = ['apple'];
19-
const expected = await readFromFixture(__dirname, 'oneLineCommaListsAndSingleItem');
19+
const expected = await readFromFixture(
20+
__dirname,
21+
'oneLineCommaListsAndSingleItem',
22+
);
2023
const actual = oneLineCommaListsAnd`
2124
Doge <3's these fruits: ${fruits}
2225
they are ${val}

src/oneLineCommaListsOr/oneLineCommaListsOr.test.js

+4-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,10 @@ test('includes arrays as comma-separated list on one line with "or"', async t =>
1616

1717
test('only returns the first item of a single element array', async t => {
1818
const fruits = ['apple'];
19-
const expected = await readFromFixture(__dirname, 'oneLineCommaListsOrSingleItem');
19+
const expected = await readFromFixture(
20+
__dirname,
21+
'oneLineCommaListsOrSingleItem',
22+
);
2023
const actual = oneLineCommaListsOr`
2124
Doge <3's these fruits: ${fruits}
2225
they are ${val}

src/removeNonPrintingValuesTransformer/removeNonPrintingValuesTransformer.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
const isValidValue = x => x != null && !Number.isNaN(x) && typeof x !== 'boolean';
1+
const isValidValue = x =>
2+
x != null && !Number.isNaN(x) && typeof x !== 'boolean';
23

34
const removeNonPrintingValuesTransformer = () => ({
45
onSubstitution(substitution) {

src/removeNonPrintingValuesTransformer/removeNonPrintingValuesTransformer.test.js

+4-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,10 @@ test('removes NaN', t => {
2323
});
2424

2525
test('removes non-printing array values', t => {
26-
const remove = new TemplateTag(removeNonPrintingValuesTransformer, inlineArrayTransformer);
26+
const remove = new TemplateTag(
27+
removeNonPrintingValuesTransformer,
28+
inlineArrayTransformer,
29+
);
2730
const val = ['foo', undefined, 'bar', null];
2831
t.is(remove`a ${val} z`, 'a foo bar z');
2932
});

src/replaceResultTransformer/replaceResultTransformer.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,9 @@
77
const replaceResultTransformer = (replaceWhat, replaceWith) => ({
88
onEndResult(endResult) {
99
if (replaceWhat == null || replaceWith == null) {
10-
throw new Error('replaceResultTransformer requires at least 2 arguments.');
10+
throw new Error(
11+
'replaceResultTransformer requires at least 2 arguments.',
12+
);
1113
}
1214
return endResult.replace(replaceWhat, replaceWith);
1315
},

src/replaceResultTransformer/replaceResultTransformer.test.js

+4-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,10 @@ import replaceResultTransformer from './replaceResultTransformer';
44
import trimResultTransformer from '../trimResultTransformer';
55

66
test('replaces sequential whitespace with a single space', t => {
7-
const oneLine = new TemplateTag(replaceResultTransformer(/(?:\s+)/g, ' '), trimResultTransformer);
7+
const oneLine = new TemplateTag(
8+
replaceResultTransformer(/(?:\s+)/g, ' '),
9+
trimResultTransformer,
10+
);
811
const expected = 'foo bar baz';
912
const actual = oneLine`
1013
foo

src/replaceStringTransformer/replaceStringTransformer.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
const replaceStringTransformer = (replaceWhat, replaceWith) => ({
22
onString(str) {
33
if (replaceWhat == null || replaceWith == null) {
4-
throw new Error('replaceStringTransformer requires at least 2 arguments.');
4+
throw new Error(
5+
'replaceStringTransformer requires at least 2 arguments.',
6+
);
57
}
68

79
return str.replace(replaceWhat, replaceWith);

src/replaceStringTransformer/replaceStringTransformer.test.js

+4-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,10 @@ test('only operates on strings', t => {
77
replaceStringTransformer(/</g, '&lt;'),
88
replaceStringTransformer(/>/g, '&gt;'),
99
);
10-
t.is(tag`<h1>foo${'<bar></bar>'}</h1>`, '&lt;h1&gt;foo<bar></bar>&lt;/h1&gt;');
10+
t.is(
11+
tag`<h1>foo${'<bar></bar>'}</h1>`,
12+
'&lt;h1&gt;foo<bar></bar>&lt;/h1&gt;',
13+
);
1114
});
1215

1316
test('throws error if no arguments are supplied when used', t => {

src/replaceSubstitutionTransformer/replaceSubstitutionTransformer.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
const replaceSubstitutionTransformer = (replaceWhat, replaceWith) => ({
22
onSubstitution(substitution, resultSoFar) {
33
if (replaceWhat == null || replaceWith == null) {
4-
throw new Error('replaceSubstitutionTransformer requires at least 2 arguments.');
4+
throw new Error(
5+
'replaceSubstitutionTransformer requires at least 2 arguments.',
6+
);
57
}
68

79
// Do not touch if null or undefined

src/replaceSubstitutionTransformer/replaceSubstitutionTransformer.test.js

+4-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,10 @@ test('only operates on substitutions', t => {
77
replaceSubstitutionTransformer(/</g, '&lt;'),
88
replaceSubstitutionTransformer(/>/g, '&gt;'),
99
);
10-
t.is(tag`<h1>foo${'<bar></bar>'}</h1>`, '<h1>foo&lt;bar&gt;&lt;/bar&gt;</h1>');
10+
t.is(
11+
tag`<h1>foo${'<bar></bar>'}</h1>`,
12+
'<h1>foo&lt;bar&gt;&lt;/bar&gt;</h1>',
13+
);
1114
});
1215

1316
test('does not touch undefined and null substitutions', t => {

src/splitStringTransformer/splitStringTransformer.test.js

+4-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,10 @@ import inlineArrayTransformer from '../inlineArrayTransformer';
44
import splitStringTransformer from './splitStringTransformer';
55

66
test('splits a string substitution into an array by the specified character', t => {
7-
const tag = new TemplateTag(splitStringTransformer('\n'), inlineArrayTransformer);
7+
const tag = new TemplateTag(
8+
splitStringTransformer('\n'),
9+
inlineArrayTransformer,
10+
);
811
t.is(tag`foo ${'bar\nbaz'}`, 'foo bar baz');
912
});
1013

src/stripIndent/stripIndent.js

+4-1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@ import TemplateTag from '../TemplateTag';
22
import stripIndentTransformer from '../stripIndentTransformer';
33
import trimResultTransformer from '../trimResultTransformer';
44

5-
const stripIndent = new TemplateTag(stripIndentTransformer, trimResultTransformer);
5+
const stripIndent = new TemplateTag(
6+
stripIndentTransformer,
7+
trimResultTransformer,
8+
);
69

710
export default stripIndent;

src/stripIndentTransformer/stripIndentTransformer.test.js

+12-3
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,10 @@ import trimResultTransformer from '../trimResultTransformer';
55
import { readFromFixture } from '../utils';
66

77
test('default behaviour removes the leading indent, but preserves the rest', async t => {
8-
const stripIndent = new TemplateTag(stripIndentTransformer, trimResultTransformer);
8+
const stripIndent = new TemplateTag(
9+
stripIndentTransformer,
10+
trimResultTransformer,
11+
);
912
const expected = await readFromFixture(__dirname, 'stripIndent');
1013
const actual = stripIndent`
1114
foo bar baz
@@ -17,14 +20,20 @@ test('default behaviour removes the leading indent, but preserves the rest', asy
1720
});
1821

1922
test('type "initial" does not remove indents if there is no need to do so', t => {
20-
const stripIndent = new TemplateTag(stripIndentTransformer, trimResultTransformer);
23+
const stripIndent = new TemplateTag(
24+
stripIndentTransformer,
25+
trimResultTransformer,
26+
);
2127
t.is(stripIndent``, '');
2228
t.is(stripIndent`foo`, 'foo');
2329
t.is(stripIndent`foo\nbar`, 'foo\nbar');
2430
});
2531

2632
test('removes all indents if type is "all"', async t => {
27-
const stripIndents = new TemplateTag(stripIndentTransformer('all'), trimResultTransformer);
33+
const stripIndents = new TemplateTag(
34+
stripIndentTransformer('all'),
35+
trimResultTransformer,
36+
);
2837
const expected = await readFromFixture(__dirname, 'stripIndents');
2938
const actual = stripIndents`
3039
foo bar baz

src/stripIndents/stripIndents.js

+4-1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@ import TemplateTag from '../TemplateTag';
22
import stripIndentTransformer from '../stripIndentTransformer';
33
import trimResultTransformer from '../trimResultTransformer';
44

5-
const stripIndents = new TemplateTag(stripIndentTransformer('all'), trimResultTransformer);
5+
const stripIndents = new TemplateTag(
6+
stripIndentTransformer('all'),
7+
trimResultTransformer,
8+
);
69

710
export default stripIndents;

src/trimResultTransformer/trimResultTransformer.test.js

+4-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,10 @@ test('throws an error if invalid side supplied', t => {
3434
});
3535

3636
test('can be used sequentially', t => {
37-
const trimStart = new TemplateTag(stripIndentTransformer, trimResultTransformer('start'));
37+
const trimStart = new TemplateTag(
38+
stripIndentTransformer,
39+
trimResultTransformer('start'),
40+
);
3841
t.is(trimStart` foo `, 'foo ');
3942
t.is(trimStart` bar `, 'bar ');
4043
});

src/utils/index.test.js

+4-1
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@ test('utils exports all the right modules as props', async t => {
2323
const modules = t.context.modules;
2424
t.plan(modules.length);
2525
modules.forEach(module => {
26-
t.true(require('./index')[module] != null, `${module} is not exported properly`);
26+
t.true(
27+
require('./index')[module] != null,
28+
`${module} is not exported properly`,
29+
);
2730
});
2831
});

0 commit comments

Comments
 (0)