Skip to content

Commit 9ebffd0

Browse files
authored
Merge pull request #414 from peterramsing/add-prettier
Adds Prettier, Updates config, and Runs
2 parents efe6879 + 8ad4dac commit 9ebffd0

37 files changed

+1138
-896
lines changed

.eslintrc.js

Lines changed: 18 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,26 @@
11
module.exports = {
2-
'env': {
3-
'es6': true,
4-
'node': true
2+
env: {
3+
es6: true,
4+
node: true
55
},
6-
'extends': 'eslint:recommended',
7-
'parserOptions': {
8-
'sourceType': 'module'
6+
plugins: ['prettier'],
7+
extends: 'eslint:recommended',
8+
parserOptions: {
9+
sourceType: 'module'
910
},
10-
'rules': {
11+
rules: {
1112
'eol-last': 2,
12-
'no-multiple-empty-lines': [
13-
2,
14-
{ max: 2, maxEOF: 1 }
15-
],
16-
'indent': [
17-
'error',
18-
2
19-
],
20-
'linebreak-style': [
13+
'no-multiple-empty-lines': [2, { max: 2, maxEOF: 1 }],
14+
indent: ['error', 2],
15+
'linebreak-style': ['error', 'unix'],
16+
quotes: [
2117
'error',
22-
'unix'
18+
'single',
19+
{
20+
avoidEscape: true
21+
}
2322
],
24-
'quotes': [
25-
'error',
26-
'single'
27-
],
28-
'semi': [
29-
'error',
30-
'always'
31-
]
23+
semi: ['error', 'always'],
24+
'prettier/prettier': 'error'
3225
}
3326
};

.prettierrc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"singleQuote": true
3+
}

lib/_lg-logic.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
module.exports = {
2-
32
calcValue: function(fraction, gutter, rounder, unit) {
43
var calcValue = '';
54
var gutterLogic = '';

lib/lg-gutter.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ var lostGutterLocal = require('./lost-vars-gutter-local');
44
module.exports = function lgGutter(css, settings) {
55
var gutter, newValue;
66

7-
css.walkDecls( declaration => {
7+
css.walkDecls(declaration => {
88
if (
99
/(\$lost-gutter)/g.test(declaration.value) &&
1010
!/(\$lost-gutter-local)/g.test(declaration.value)

lib/lost-align.js

Lines changed: 42 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,10 @@ module.exports = function lostAlign(css, settings) {
5151
['position', 'top', 'right', 'bottom', 'left', 'transform'],
5252
['absolute', '0', 'auto', 'auto', '0', 'translate(0, 0)']
5353
);
54-
} else if (alignDirection === 'top-center' || alignDirection === 'top') {
54+
} else if (
55+
alignDirection === 'top-center' ||
56+
alignDirection === 'top'
57+
) {
5558
newBlock(
5659
decl,
5760
' > *',
@@ -65,21 +68,30 @@ module.exports = function lostAlign(css, settings) {
6568
['position', 'top', 'right', 'bottom', 'left', 'transform'],
6669
['absolute', '0', '0', 'auto', 'auto', 'translate(0, 0)']
6770
);
68-
} else if (alignDirection === 'middle-left' || alignDirection === 'left') {
71+
} else if (
72+
alignDirection === 'middle-left' ||
73+
alignDirection === 'left'
74+
) {
6975
newBlock(
7076
decl,
7177
' > *',
7278
['position', 'top', 'right', 'bottom', 'left', 'transform'],
7379
['absolute', '50%', 'auto', 'auto', '0', 'translate(0, -50%)']
7480
);
75-
} else if (alignDirection === 'middle-center' || alignDirection === 'center') {
81+
} else if (
82+
alignDirection === 'middle-center' ||
83+
alignDirection === 'center'
84+
) {
7685
newBlock(
7786
decl,
7887
' > *',
7988
['position', 'top', 'right', 'bottom', 'left', 'transform'],
8089
['absolute', '50%', 'auto', 'auto', '50%', 'translate(-50%, -50%)']
8190
);
82-
} else if (alignDirection === 'middle-right' || alignDirection === 'right') {
91+
} else if (
92+
alignDirection === 'middle-right' ||
93+
alignDirection === 'right'
94+
) {
8395
newBlock(
8496
decl,
8597
' > *',
@@ -93,7 +105,10 @@ module.exports = function lostAlign(css, settings) {
93105
['position', 'top', 'right', 'bottom', 'left', 'transform'],
94106
['absolute', 'auto', 'auto', '0', '0', 'translate(0, 0)']
95107
);
96-
} else if (alignDirection === 'bottom-center' || alignDirection === 'bottom') {
108+
} else if (
109+
alignDirection === 'bottom-center' ||
110+
alignDirection === 'bottom'
111+
) {
97112
newBlock(
98113
decl,
99114
' > *',
@@ -108,7 +123,9 @@ module.exports = function lostAlign(css, settings) {
108123
['absolute', 'auto', '0', '0', 'auto', 'translate(0, 0)']
109124
);
110125
} else {
111-
throw decl.error(`lost-align: direction '${alignDirection}' is unknown.`);
126+
throw decl.error(
127+
`lost-align: direction '${alignDirection}' is unknown.`
128+
);
112129
}
113130
}
114131
} else if (alignDirection === 'reset') {
@@ -162,21 +179,30 @@ module.exports = function lostAlign(css, settings) {
162179
['justify-content', 'align-items'],
163180
['flex-end', 'flex-start']
164181
);
165-
} else if (alignDirection === 'middle-left' || alignDirection === 'left') {
182+
} else if (
183+
alignDirection === 'middle-left' ||
184+
alignDirection === 'left'
185+
) {
166186
newBlock(
167187
decl,
168188
'',
169189
['justify-content', 'align-items'],
170190
['flex-start', 'center']
171191
);
172-
} else if (alignDirection === 'middle-center' || alignDirection === 'center') {
192+
} else if (
193+
alignDirection === 'middle-center' ||
194+
alignDirection === 'center'
195+
) {
173196
newBlock(
174197
decl,
175198
'',
176199
['justify-content', 'align-items'],
177200
['center', 'center']
178201
);
179-
} else if (alignDirection === 'middle-right' || alignDirection === 'right') {
202+
} else if (
203+
alignDirection === 'middle-right' ||
204+
alignDirection === 'right'
205+
) {
180206
newBlock(
181207
decl,
182208
'',
@@ -190,7 +216,10 @@ module.exports = function lostAlign(css, settings) {
190216
['justify-content', 'align-items'],
191217
['flex-start', 'flex-end']
192218
);
193-
} else if (alignDirection === 'bottom-center' || alignDirection === 'bottom') {
219+
} else if (
220+
alignDirection === 'bottom-center' ||
221+
alignDirection === 'bottom'
222+
) {
194223
newBlock(
195224
decl,
196225
'',
@@ -205,7 +234,9 @@ module.exports = function lostAlign(css, settings) {
205234
['flex-end', 'flex-end']
206235
);
207236
} else {
208-
throw decl.error(`lost-align: direction '${alignDirection}' is unknown.`);
237+
throw decl.error(
238+
`lost-align: direction '${alignDirection}' is unknown.`
239+
);
209240
}
210241
}
211242
decl.remove();

lib/lost-center.js

Lines changed: 32 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ module.exports = function lostCenterDecl(css, settings, result) {
1313
var lostColumnGutter = 0;
1414
var validUnits = ['%', 'vw'];
1515

16-
var isFractionValue = (value) => {
16+
var isFractionValue = value => {
1717
var lostFractionPattern = /^\d+\/\d+$/;
1818
return lostFractionPattern.test(value);
1919
};
@@ -24,7 +24,7 @@ module.exports = function lostCenterDecl(css, settings, result) {
2424
lostCenterPadding = declArr[1];
2525
}
2626

27-
if(lostCenterFlexbox !== 'flex') {
27+
if (lostCenterFlexbox !== 'flex') {
2828
lostCenterFlexbox = settings.flexbox;
2929
}
3030

@@ -36,19 +36,40 @@ module.exports = function lostCenterDecl(css, settings, result) {
3636
lostCenterFlexbox = 'no-flex';
3737
}
3838

39-
lostCenterFlexbox = lgLogic.parseLostProperty(decl.parent.nodes, 'lost-center-flexbox', lostCenterFlexbox);
40-
lostCenterPadding = lgLogic.parseLostProperty(decl.parent.nodes, 'lost-center-padding', lostCenterPadding);
41-
lostColumnRounder = lgLogic.parseLostProperty(decl.parent.nodes, 'lost-column-rounder', lostColumnRounder);
42-
43-
lostUnit = lgLogic.parseLostProperty(decl.parent.nodes, 'lost-unit', lostUnit);
39+
lostCenterFlexbox = lgLogic.parseLostProperty(
40+
decl.parent.nodes,
41+
'lost-center-flexbox',
42+
lostCenterFlexbox
43+
);
44+
lostCenterPadding = lgLogic.parseLostProperty(
45+
decl.parent.nodes,
46+
'lost-center-padding',
47+
lostCenterPadding
48+
);
49+
lostColumnRounder = lgLogic.parseLostProperty(
50+
decl.parent.nodes,
51+
'lost-column-rounder',
52+
lostColumnRounder
53+
);
54+
55+
lostUnit = lgLogic.parseLostProperty(
56+
decl.parent.nodes,
57+
'lost-unit',
58+
lostUnit
59+
);
4460

4561
if (!lgLogic.validateUnit(lostUnit, validUnits)) {
4662
decl.warn(result, `${lostUnit} is not a valid unit for lost-center`);
4763
lostUnit = settings.gridUnit;
4864
}
4965

50-
if(declArr[0] !== undefined && isFractionValue(declArr[0])) {
51-
lostCenterMaxWidth = lgLogic.calcValue(declArr[0], lostColumnGutter, lostColumnRounder, lostUnit);
66+
if (declArr[0] !== undefined && isFractionValue(declArr[0])) {
67+
lostCenterMaxWidth = lgLogic.calcValue(
68+
declArr[0],
69+
lostColumnGutter,
70+
lostColumnRounder,
71+
lostUnit
72+
);
5273
} else {
5374
lostCenterMaxWidth = declArr[0];
5475
}
@@ -58,15 +79,10 @@ module.exports = function lostCenterDecl(css, settings, result) {
5879
decl,
5980
':after',
6081
['content', 'display', 'clear'],
61-
['\'\'', 'table', 'both']
82+
["''", 'table', 'both']
6283
);
6384

64-
newBlock(
65-
decl,
66-
':before',
67-
['content', 'display'],
68-
['\'\'', 'table']
69-
);
85+
newBlock(decl, ':before', ['content', 'display'], ["''", 'table']);
7086
} else {
7187
decl.cloneBefore({
7288
prop: 'display',

0 commit comments

Comments
 (0)