postcss-ordered-values
Advanced tools
Comparing version 5.0.1 to 5.0.2
@@ -14,10 +14,10 @@ "use strict"; | ||
const strValues = ['auto', 'inherit', 'unset', 'initial']; | ||
function hasUnit(value) { | ||
const parsedVal = (0, _postcssValueParser.unit)(value); | ||
return parsedVal && parsedVal.unit !== ''; | ||
} | ||
const column = columns => { | ||
let newValue = { | ||
front: '', | ||
back: '' | ||
}; | ||
let shouldNormalize = false; | ||
const widths = []; | ||
const other = []; | ||
columns.walk(node => { | ||
@@ -29,18 +29,13 @@ const { | ||
if (type === 'word' && strValues.indexOf(value.toLowerCase())) { | ||
const parsedVal = (0, _postcssValueParser.unit)(value); | ||
if (parsedVal.unit !== '') { | ||
// surely its the column's width | ||
// it needs to be at the front | ||
newValue.front = `${newValue.front} ${value}`; | ||
shouldNormalize = true; | ||
if (type === 'word') { | ||
if (hasUnit(value)) { | ||
widths.push(value); | ||
} else { | ||
other.push(value); | ||
} | ||
} else if (type === 'word') { | ||
newValue.back = `${newValue.back} ${value}`; | ||
} | ||
}); | ||
}); // only transform if declaration is not invalid or a single value | ||
if (shouldNormalize) { | ||
return `${newValue.front.trimStart()} ${newValue.back.trimStart()}`; | ||
if (other.length === 1 && widths.length === 1) { | ||
return `${widths[0].trimStart()} ${other[0].trimStart()}`; | ||
} | ||
@@ -47,0 +42,0 @@ |
{ | ||
"name": "postcss-ordered-values", | ||
"version": "5.0.1", | ||
"version": "5.0.2", | ||
"description": "Ensure values are ordered consistently in your CSS.", | ||
@@ -11,5 +11,5 @@ "main": "dist/index.js", | ||
"scripts": { | ||
"prebuild": "del-cli dist", | ||
"prebuild": "rimraf dist", | ||
"build": "cross-env BABEL_ENV=publish babel src --config-file ../../babel.config.json --out-dir dist --ignore \"**/__tests__/\" && node script/buildListStyleType.js", | ||
"prepublish": "yarn build" | ||
"prepare": "yarn build" | ||
}, | ||
@@ -46,3 +46,3 @@ "keywords": [ | ||
}, | ||
"gitHead": "28c247175032fa03f04911cde56ad82d74d211cc" | ||
"gitHead": "39b4cc089e8825d308df1fa8a7313d38d8f1f2f7" | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
25395
16
697