Skip to content

Commit 9c87370

Browse files
committed
Remove semicolons.
1 parent b04095a commit 9c87370

File tree

5 files changed

+130
-130
lines changed

5 files changed

+130
-130
lines changed

src/__tests__/index.js

+33-33
Original file line numberDiff line numberDiff line change
@@ -1,152 +1,152 @@
1-
import test from 'ava';
1+
import test from 'ava'
22

3-
import reduceCalc from '..';
3+
import reduceCalc from '..'
44

55
function testFixture(t, fixture, expected = null, precision = 5) {
66
if (expected === null)
7-
expected = fixture;
7+
expected = fixture
88

9-
const out = reduceCalc(fixture, precision);
10-
t.deepEqual(out, expected);
9+
const out = reduceCalc(fixture, precision)
10+
t.deepEqual(out, expected)
1111
}
1212

1313
function testThrows(t, fixture, expected, precision = 5) {
14-
t.throws(() => reduceCalc(fixture, precision), expected);
14+
t.throws(() => reduceCalc(fixture, precision), expected)
1515
}
1616

1717
test(
1818
'should reduce simple calc (1)',
1919
testFixture,
2020
'calc(1px + 1px)',
2121
'2px'
22-
);
22+
)
2323

2424
test(
2525
'should reduce simple calc (2)',
2626
testFixture,
2727
'calc(3em - 1em)',
2828
'2em'
29-
);
29+
)
3030

3131
test(
3232
'should reduce simple calc (3)',
3333
testFixture,
3434
'calc(1rem * 1.5)',
3535
'1.5rem'
36-
);
36+
)
3737

3838
test(
3939
'should reduce simple calc (4)',
4040
testFixture,
4141
'calc(2ex / 2)',
4242
'1ex'
43-
);
43+
)
4444

4545
test(
4646
'should ignore value surrounding calc function (1)',
4747
testFixture,
4848
'a calc(1px + 1px)',
4949
'a 2px'
50-
);
50+
)
5151

5252
test(
5353
'should ignore value surrounding calc function (2)',
5454
testFixture,
5555
'calc(1px + 1px) a',
5656
'2px a'
57-
);
57+
)
5858

5959
test(
6060
'should ignore value surrounding calc function (3)',
6161
testFixture,
6262
'a calc(1px + 1px) b',
6363
'a 2px b'
64-
);
64+
)
6565

6666
test(
6767
'should ignore value surrounding calc function (4)',
6868
testFixture,
6969
'a calc(1px + 1px) b calc(1em + 2em) c',
7070
'a 2px b 3em c'
71-
);
71+
)
7272

7373
test(
7474
'should reduce calc with newline characters',
7575
testFixture,
7676
'calc(\n1rem \n* 2 \n* 1.5)',
7777
'3rem'
78-
);
78+
)
7979

8080
test(
8181
'should preserve calc with incompatible units',
8282
testFixture,
8383
'calc(100% + 1px)',
8484
'calc(100% + 1px)'
85-
);
85+
)
8686

8787
test(
8888
'should parse fractions without leading zero',
8989
testFixture,
9090
'calc(2rem - .14285em)',
9191
'calc(2rem - 0.14285em)'
92-
);
92+
)
9393

9494
test(
9595
'should handle precision correctly (1)',
9696
testFixture,
9797
'calc(1/100)',
9898
'0.01'
99-
);
99+
)
100100

101101
test(
102102
'should handle precision correctly (2)',
103103
testFixture,
104104
'calc(5/1000000)',
105105
'0.00001'
106-
);
106+
)
107107

108108
test(
109109
'should handle precision correctly (3)',
110110
testFixture,
111111
'calc(5/1000000)',
112112
'0.000005',
113113
6
114-
);
114+
)
115115

116116
test(
117117
'should reduce browser-prefixed calc (1)',
118118
testFixture,
119119
'-webkit-calc(1px + 1px)',
120120
'2px'
121-
);
121+
)
122122

123123
test(
124124
'should reduce browser-prefixed calc (2)',
125125
testFixture,
126126
'-moz-calc(1px + 1px)',
127127
'2px'
128-
);
128+
)
129129

130130
test(
131131
'should discard zero values (#2) (1)',
132132
testFixture,
133133
'calc(100vw / 2 - 6px + 0px)',
134134
'calc(50vw - 6px)'
135-
);
135+
)
136136

137137
test(
138138
'should discard zero values (#2) (2)',
139139
testFixture,
140140
'calc(500px - 0px)',
141141
'500px'
142-
);
142+
)
143143

144144
test(
145145
'should not perform addition on unitless values (#3)',
146146
testFixture,
147147
'calc(1px + 1)',
148148
'calc(1px + 1)'
149-
);
149+
)
150150

151151

152152
test(
@@ -155,54 +155,54 @@ test(
155155
'calc(14px + 6 * ((100vw - 320px) / 448))',
156156
'calc(9.71px + 1.34vw)',
157157
2
158-
);
158+
)
159159

160160
test(
161161
'should produce simpler result (postcss-calc#25) (2)',
162162
testFixture,
163163
'-webkit-calc(14px + 6 * ((100vw - 320px) / 448))',
164164
'-webkit-calc(9.71px + 1.34vw)',
165165
2
166-
);
166+
)
167167

168168
test(
169169
'should reduce mixed units of time (postcss-calc#33)',
170170
testFixture,
171171
'calc(1s - 50ms)',
172172
'0.95s'
173-
);
173+
)
174174

175175
test(
176176
'should correctly reduce calc with mixed units (cssnano#211)',
177177
testFixture,
178178
'bar:calc(99.99% * 1/1 - 0rem)',
179179
'bar:99.99%'
180-
);
180+
)
181181

182182
test(
183183
'should apply algebraic reduction (cssnano#319)',
184184
testFixture,
185185
'bar:calc((100px - 1em) + (-50px + 1em))',
186186
'bar:50px'
187-
);
187+
)
188188

189189
test(
190190
'should apply optimization (cssnano#320)',
191191
testFixture,
192192
'bar:calc(50% + (5em + 5%))',
193193
'bar:calc(55% + 5em)'
194-
);
194+
)
195195

196196
test(
197197
'should throw an exception when attempting to divide by zero',
198198
testThrows,
199199
'calc(500px/0)',
200200
/Cannot divide by zero/
201-
);
201+
)
202202

203203
test(
204204
'should throw an exception when attempting to divide by unit (#1)',
205205
testThrows,
206206
'calc(500px/2px)',
207207
'Cannot divide by "px", number expected'
208-
);
208+
)

src/index.js

+13-13
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,28 @@
1-
import valueParser from 'postcss-value-parser';
1+
import valueParser from 'postcss-value-parser'
22

3-
import { parser } from './parser'; // eslint-disable-line
4-
import reducer from './lib/reducer';
5-
import stringifier from './lib/stringifier';
3+
import { parser } from './parser' // eslint-disable-line
4+
import reducer from './lib/reducer'
5+
import stringifier from './lib/stringifier'
66

7-
const MATCH_CALC = /((?:\-[a-z]+\-)?calc)/;
7+
const MATCH_CALC = /((?:\-[a-z]+\-)?calc)/
88

99
export default (value, precision = 5) => {
1010
return valueParser(value).walk(node => {
1111
// skip anything which isn't a calc() function
1212
if (node.type !== 'function' || !MATCH_CALC.test(node.value))
13-
return;
13+
return
1414

1515
// stringify calc expression and produce an AST
16-
const contents = valueParser.stringify(node.nodes);
17-
const ast = parser.parse(contents);
16+
const contents = valueParser.stringify(node.nodes)
17+
const ast = parser.parse(contents)
1818

1919
// reduce AST to its simplest form, that is, either to a single value
2020
// or a simplified calc expression
21-
const reducedAst = reducer(ast, precision);
21+
const reducedAst = reducer(ast, precision)
2222

2323
// stringify AST and write it back
24-
node.type = 'word';
25-
node.value = stringifier(node.value, reducedAst, precision);
24+
node.type = 'word'
25+
node.value = stringifier(node.value, reducedAst, precision)
2626

27-
}, true).toString();
28-
};
27+
}, true).toString()
28+
}

src/lib/convert.js

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import convertUnits from 'css-unit-converter';
1+
import convertUnits from 'css-unit-converter'
22

33
function convertNodes(left, right, precision) {
44
switch (left.type) {
@@ -7,9 +7,9 @@ function convertNodes(left, right, precision) {
77
case 'TimeValue':
88
case 'FrequencyValue':
99
case 'ResolutionValue':
10-
return convertAbsoluteLength(left, right, precision);
10+
return convertAbsoluteLength(left, right, precision)
1111
default:
12-
return { left, right };
12+
return { left, right }
1313
}
1414
}
1515

@@ -19,9 +19,9 @@ function convertAbsoluteLength(left, right, precision) {
1919
type: left.type,
2020
value: convertUnits(right.value, right.unit, left.unit, precision),
2121
unit: left.unit
22-
};
22+
}
2323
}
24-
return { left, right };
24+
return { left, right }
2525
}
2626

27-
export default convertNodes;
27+
export default convertNodes

0 commit comments

Comments
 (0)