Skip to content

Commit

Permalink
Adds Prettier, Updates config, and Runs
Browse files Browse the repository at this point in the history
This also adds a pre-commit hook for Prettier. 👍
  • Loading branch information
peterramsing committed Jun 16, 2018
1 parent efe6879 commit 8ad4dac
Show file tree
Hide file tree
Showing 37 changed files with 1,138 additions and 896 deletions.
43 changes: 18 additions & 25 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,33 +1,26 @@
module.exports = {
'env': {
'es6': true,
'node': true
env: {
es6: true,
node: true
},
'extends': 'eslint:recommended',
'parserOptions': {
'sourceType': 'module'
plugins: ['prettier'],
extends: 'eslint:recommended',
parserOptions: {
sourceType: 'module'
},
'rules': {
rules: {
'eol-last': 2,
'no-multiple-empty-lines': [
2,
{ max: 2, maxEOF: 1 }
],
'indent': [
'error',
2
],
'linebreak-style': [
'no-multiple-empty-lines': [2, { max: 2, maxEOF: 1 }],
indent: ['error', 2],
'linebreak-style': ['error', 'unix'],
quotes: [
'error',
'unix'
'single',
{
avoidEscape: true
}
],
'quotes': [
'error',
'single'
],
'semi': [
'error',
'always'
]
semi: ['error', 'always'],
'prettier/prettier': 'error'
}
};
3 changes: 3 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"singleQuote": true
}
1 change: 0 additions & 1 deletion lib/_lg-logic.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
module.exports = {

calcValue: function(fraction, gutter, rounder, unit) {
var calcValue = '';
var gutterLogic = '';
Expand Down
2 changes: 1 addition & 1 deletion lib/lg-gutter.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ var lostGutterLocal = require('./lost-vars-gutter-local');
module.exports = function lgGutter(css, settings) {
var gutter, newValue;

css.walkDecls( declaration => {
css.walkDecls(declaration => {
if (
/(\$lost-gutter)/g.test(declaration.value) &&
!/(\$lost-gutter-local)/g.test(declaration.value)
Expand Down
53 changes: 42 additions & 11 deletions lib/lost-align.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,10 @@ module.exports = function lostAlign(css, settings) {
['position', 'top', 'right', 'bottom', 'left', 'transform'],
['absolute', '0', 'auto', 'auto', '0', 'translate(0, 0)']
);
} else if (alignDirection === 'top-center' || alignDirection === 'top') {
} else if (
alignDirection === 'top-center' ||
alignDirection === 'top'
) {
newBlock(
decl,
' > *',
Expand All @@ -65,21 +68,30 @@ module.exports = function lostAlign(css, settings) {
['position', 'top', 'right', 'bottom', 'left', 'transform'],
['absolute', '0', '0', 'auto', 'auto', 'translate(0, 0)']
);
} else if (alignDirection === 'middle-left' || alignDirection === 'left') {
} else if (
alignDirection === 'middle-left' ||
alignDirection === 'left'
) {
newBlock(
decl,
' > *',
['position', 'top', 'right', 'bottom', 'left', 'transform'],
['absolute', '50%', 'auto', 'auto', '0', 'translate(0, -50%)']
);
} else if (alignDirection === 'middle-center' || alignDirection === 'center') {
} else if (
alignDirection === 'middle-center' ||
alignDirection === 'center'
) {
newBlock(
decl,
' > *',
['position', 'top', 'right', 'bottom', 'left', 'transform'],
['absolute', '50%', 'auto', 'auto', '50%', 'translate(-50%, -50%)']
);
} else if (alignDirection === 'middle-right' || alignDirection === 'right') {
} else if (
alignDirection === 'middle-right' ||
alignDirection === 'right'
) {
newBlock(
decl,
' > *',
Expand All @@ -93,7 +105,10 @@ module.exports = function lostAlign(css, settings) {
['position', 'top', 'right', 'bottom', 'left', 'transform'],
['absolute', 'auto', 'auto', '0', '0', 'translate(0, 0)']
);
} else if (alignDirection === 'bottom-center' || alignDirection === 'bottom') {
} else if (
alignDirection === 'bottom-center' ||
alignDirection === 'bottom'
) {
newBlock(
decl,
' > *',
Expand All @@ -108,7 +123,9 @@ module.exports = function lostAlign(css, settings) {
['absolute', 'auto', '0', '0', 'auto', 'translate(0, 0)']
);
} else {
throw decl.error(`lost-align: direction '${alignDirection}' is unknown.`);
throw decl.error(
`lost-align: direction '${alignDirection}' is unknown.`
);
}
}
} else if (alignDirection === 'reset') {
Expand Down Expand Up @@ -162,21 +179,30 @@ module.exports = function lostAlign(css, settings) {
['justify-content', 'align-items'],
['flex-end', 'flex-start']
);
} else if (alignDirection === 'middle-left' || alignDirection === 'left') {
} else if (
alignDirection === 'middle-left' ||
alignDirection === 'left'
) {
newBlock(
decl,
'',
['justify-content', 'align-items'],
['flex-start', 'center']
);
} else if (alignDirection === 'middle-center' || alignDirection === 'center') {
} else if (
alignDirection === 'middle-center' ||
alignDirection === 'center'
) {
newBlock(
decl,
'',
['justify-content', 'align-items'],
['center', 'center']
);
} else if (alignDirection === 'middle-right' || alignDirection === 'right') {
} else if (
alignDirection === 'middle-right' ||
alignDirection === 'right'
) {
newBlock(
decl,
'',
Expand All @@ -190,7 +216,10 @@ module.exports = function lostAlign(css, settings) {
['justify-content', 'align-items'],
['flex-start', 'flex-end']
);
} else if (alignDirection === 'bottom-center' || alignDirection === 'bottom') {
} else if (
alignDirection === 'bottom-center' ||
alignDirection === 'bottom'
) {
newBlock(
decl,
'',
Expand All @@ -205,7 +234,9 @@ module.exports = function lostAlign(css, settings) {
['flex-end', 'flex-end']
);
} else {
throw decl.error(`lost-align: direction '${alignDirection}' is unknown.`);
throw decl.error(
`lost-align: direction '${alignDirection}' is unknown.`
);
}
}
decl.remove();
Expand Down
48 changes: 32 additions & 16 deletions lib/lost-center.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ module.exports = function lostCenterDecl(css, settings, result) {
var lostColumnGutter = 0;
var validUnits = ['%', 'vw'];

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

if(lostCenterFlexbox !== 'flex') {
if (lostCenterFlexbox !== 'flex') {
lostCenterFlexbox = settings.flexbox;
}

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

lostCenterFlexbox = lgLogic.parseLostProperty(decl.parent.nodes, 'lost-center-flexbox', lostCenterFlexbox);
lostCenterPadding = lgLogic.parseLostProperty(decl.parent.nodes, 'lost-center-padding', lostCenterPadding);
lostColumnRounder = lgLogic.parseLostProperty(decl.parent.nodes, 'lost-column-rounder', lostColumnRounder);

lostUnit = lgLogic.parseLostProperty(decl.parent.nodes, 'lost-unit', lostUnit);
lostCenterFlexbox = lgLogic.parseLostProperty(
decl.parent.nodes,
'lost-center-flexbox',
lostCenterFlexbox
);
lostCenterPadding = lgLogic.parseLostProperty(
decl.parent.nodes,
'lost-center-padding',
lostCenterPadding
);
lostColumnRounder = lgLogic.parseLostProperty(
decl.parent.nodes,
'lost-column-rounder',
lostColumnRounder
);

lostUnit = lgLogic.parseLostProperty(
decl.parent.nodes,
'lost-unit',
lostUnit
);

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

if(declArr[0] !== undefined && isFractionValue(declArr[0])) {
lostCenterMaxWidth = lgLogic.calcValue(declArr[0], lostColumnGutter, lostColumnRounder, lostUnit);
if (declArr[0] !== undefined && isFractionValue(declArr[0])) {
lostCenterMaxWidth = lgLogic.calcValue(
declArr[0],
lostColumnGutter,
lostColumnRounder,
lostUnit
);
} else {
lostCenterMaxWidth = declArr[0];
}
Expand All @@ -58,15 +79,10 @@ module.exports = function lostCenterDecl(css, settings, result) {
decl,
':after',
['content', 'display', 'clear'],
['\'\'', 'table', 'both']
["''", 'table', 'both']
);

newBlock(
decl,
':before',
['content', 'display'],
['\'\'', 'table']
);
newBlock(decl, ':before', ['content', 'display'], ["''", 'table']);
} else {
decl.cloneBefore({
prop: 'display',
Expand Down
Loading

0 comments on commit 8ad4dac

Please sign in to comment.