Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 0 additions & 14 deletions .codeclimate.yml

This file was deleted.

8 changes: 4 additions & 4 deletions __mocks__/Node.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export default class Node {
* [parent]: { type: string },
* }} props
*/
constructor (props) {
constructor(props) {
this.nodes = [];
this.selector = props.selector;
this.params = props.params;
Expand All @@ -37,19 +37,19 @@ export default class Node {
*
* @returns {Node}
*/
addNode (node) {
addNode(node) {
node.parent = this;

this.nodes.push(node);

return this;
}

error (message) {
error(message) {
throw new Error(message);
}

remove () {
remove() {
// ...
}
}
12 changes: 6 additions & 6 deletions __mocks__/Root.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@ export default class Root {
/**
* @param {Object} [source]
*/
constructor (source) {
this.type = 'root';
constructor(source) {
this.type = "root";
this.nodes = [];
this.source = {
input: {
file: 'non/existent/file/path.css',
},
file: "non/existent/file/path.css"
}
};
}

Expand All @@ -21,15 +21,15 @@ export default class Root {
*
* @returns {Node}
*/
addNode (node) {
addNode(node) {
node.parent = this;

this.nodes.push(node);

return this;
}

walk (cb) {
walk(cb) {
this.nodes.forEach(cb);
}
}
9 changes: 5 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,13 @@
"babel-polyfill": "^6.23.0",
"babel-preset-es2015": "^6.22.0",
"coveralls": "^2.11.16",
"eslint": "^3.15.0",
"eslint-config-prettier": "^1.5.0",
"eslint": "^3.19.0",
"eslint-config-prettier": "^1.7.0",
"eslint-plugin-prettier": "^2.0.1",
"husky": "^0.13.3",
"jest": "^19.0.2",
"lint-staged": "^3.4.0",
"prettier": "^0.22.0"
"prettier": "^1.2.2"
},
"scripts": {
"pretest": "yarn run lint",
Expand All @@ -61,7 +61,8 @@
"watch:test": "jest --watch --notify",
"prepublish": "yarn run build",
"precommit": "lint-staged",
"eslint-check": "eslint --print-config .eslintrc.js | eslint-config-prettier-check"
"eslint-check": "eslint --print-config .eslintrc.js | eslint-config-prettier-check",
"prettify": "prettier --write --tab-width=4 '{src|__mocks__}/**/*.js'"
},
"lint-staged": {
"*.js": [
Expand Down
13 changes: 8 additions & 5 deletions src/postcss/containerQuery.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,11 @@ function addStylesToDefaultQuery(
* @param {Node} node
*/
function shouldProcessNode(node) {
return node.parent.type === "root" ||
return (
node.parent.type === "root" ||
(node.parent.type === "atrule" &&
["container", "media"].indexOf(node.parent.name) !== -1);
["container", "media"].indexOf(node.parent.name) !== -1)
);
}

/**
Expand Down Expand Up @@ -88,7 +90,8 @@ function containerQuery(options = {}) {
flushCurrentContainerData(newContainer);
}

const isContainer = newContainer !== null ||
const isContainer =
newContainer !== null ||
node.selector === currentContainerSelector;

if (currentContainerSelector !== null) {
Expand Down Expand Up @@ -116,8 +119,8 @@ function containerQuery(options = {}) {
return;
}

const isContainer = elementRule.selector ===
currentContainerSelector;
const isContainer =
elementRule.selector === currentContainerSelector;
let element = {
selector: elementRule.selector,
styles: getStylesObjectFromNode(
Expand Down
2 changes: 1 addition & 1 deletion src/postcss/containerQuery.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ test("proper json and css output", () => {

return postcss([
containerQuery({
getJSON: (cssPath, json) => containersJSON = json
getJSON: (cssPath, json) => (containersJSON = json)
})
])
.process(
Expand Down
6 changes: 4 additions & 2 deletions src/postcss/isValueUsingContainerUnits.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,14 @@ export default function isValueUsingContainerUnits(value) {

const unit = match[3];

return unit !== HEIGHT_UNIT &&
return (
unit !== HEIGHT_UNIT &&
unit !== WIDTH_UNIT &&
unit !== MIN_UNIT &&
unit !== MAX_UNIT &&
(unit.indexOf(HEIGHT_UNIT) === 0 ||
unit.indexOf(WIDTH_UNIT) === 0 ||
unit.indexOf(MIN_UNIT) === 0 ||
unit.indexOf(MAX_UNIT) === 0);
unit.indexOf(MAX_UNIT) === 0)
);
}
3 changes: 2 additions & 1 deletion src/runtime/adjustContainer.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,8 @@ describe("query styles should be applied, then removed when conditions no longer
});

test("shouldn't adjust if the configuration is null (invalid)", () => {
const getContainerDimensionsMock = require("./getContainerDimensions").default;
const getContainerDimensionsMock = require("./getContainerDimensions")
.default;

adjustContainer(container);

Expand Down
6 changes: 4 additions & 2 deletions src/runtime/convertSingleValue.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,13 @@ export default function convertSingleValue(dimensions, value) {

const normalisedUnit = normaliseUnit(unit);

const relativeToHeight = unit.indexOf(HEIGHT_UNIT) === 0 ||
const relativeToHeight =
unit.indexOf(HEIGHT_UNIT) === 0 ||
(unit.indexOf(MIN_UNIT) === 0 &&
dimensions.height < dimensions.width) ||
(unit.indexOf(MAX_UNIT) === 0 && dimensions.height > dimensions.width);
const relativeToWidth = unit.indexOf(WIDTH_UNIT) === 0 ||
const relativeToWidth =
unit.indexOf(WIDTH_UNIT) === 0 ||
(unit.indexOf(MIN_UNIT) === 0 &&
dimensions.height >= dimensions.width) ||
(unit.indexOf(MAX_UNIT) === 0 && dimensions.height <= dimensions.width);
Expand Down
24 changes: 16 additions & 8 deletions src/runtime/getConditionFunction.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,23 +92,31 @@ function convertConditionArrayToFunction(condition) {
} else if (feature === "aspect-ratio") {
if (operation === ">") {
return containerDimensions => {
return containerDimensions.width / containerDimensions.height >
value;
return (
containerDimensions.width / containerDimensions.height >
value
);
};
} else if (operation === ">=") {
return containerDimensions => {
return containerDimensions.width / containerDimensions.height >=
value;
return (
containerDimensions.width / containerDimensions.height >=
value
);
};
} else if (operation === "<") {
return containerDimensions => {
return containerDimensions.width / containerDimensions.height <
value;
return (
containerDimensions.width / containerDimensions.height <
value
);
};
} else if (operation === "<=") {
return containerDimensions => {
return containerDimensions.width / containerDimensions.height <=
value;
return (
containerDimensions.width / containerDimensions.height <=
value
);
};
}
} else if (feature === "orientation") {
Expand Down
60 changes: 24 additions & 36 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -149,13 +149,9 @@ assert-plus@^0.2.0:
version "0.2.0"
resolved "https://registry.yarnpkg.com/assert-plus/-/assert-plus-0.2.0.tgz#d74e1b87e7affc0db8aadb7021f3fe48101ab234"

ast-types@0.8.18:
version "0.8.18"
resolved "https://registry.yarnpkg.com/ast-types/-/ast-types-0.8.18.tgz#c8b98574898e8914e9d8de74b947564a9fe929af"

ast-types@0.9.4:
version "0.9.4"
resolved "https://registry.yarnpkg.com/ast-types/-/ast-types-0.9.4.tgz#410d1f81890aeb8e0a38621558ba5869ae53c91b"
ast-types@0.9.8:
version "0.9.8"
resolved "https://registry.yarnpkg.com/ast-types/-/ast-types-0.9.8.tgz#6cb6a40beba31f49f20928e28439fc14a3dab078"

async-each@^1.0.0:
version "1.0.1"
Expand Down Expand Up @@ -632,9 +628,9 @@ babel-types@^6.18.0, babel-types@^6.19.0, babel-types@^6.22.0, babel-types@^6.23
lodash "^4.2.0"
to-fast-properties "^1.0.1"

babylon@6.15.0:
version "6.15.0"
resolved "https://registry.yarnpkg.com/babylon/-/babylon-6.15.0.tgz#ba65cfa1a80e1759b0e89fb562e27dccae70348e"
babylon@7.0.0-beta.8:
version "7.0.0-beta.8"
resolved "https://registry.yarnpkg.com/babylon/-/babylon-7.0.0-beta.8.tgz#2bdc5ae366041442c27e068cce6f0d7c06ea9949"

babylon@^6.11.0, babylon@^6.13.0, babylon@^6.15.0:
version "6.16.1"
Expand Down Expand Up @@ -828,10 +824,6 @@ color-name@^1.1.1:
version "1.1.2"
resolved "https://registry.yarnpkg.com/color-name/-/color-name-1.1.2.tgz#5c8ab72b64bd2215d617ae9559ebb148475cf98d"

colors@>=0.6.2:
version "1.1.2"
resolved "https://registry.yarnpkg.com/colors/-/colors-1.1.2.tgz#168a4701756b6a7f51a12ce0c97bfa28c084ed63"

combined-stream@^1.0.5, combined-stream@~1.0.5:
version "1.0.5"
resolved "https://registry.yarnpkg.com/combined-stream/-/combined-stream-1.0.5.tgz#938370a57b4a51dea2c77c15d5c5fdf895164009"
Expand Down Expand Up @@ -1104,9 +1096,9 @@ escope@^3.6.0:
esrecurse "^4.1.0"
estraverse "^4.1.1"

eslint-config-prettier@^1.5.0:
version "1.5.0"
resolved "https://registry.yarnpkg.com/eslint-config-prettier/-/eslint-config-prettier-1.5.0.tgz#969b6d21b2eb2574a6810426507f755072db1963"
eslint-config-prettier@^1.7.0:
version "1.7.0"
resolved "https://registry.yarnpkg.com/eslint-config-prettier/-/eslint-config-prettier-1.7.0.tgz#cda3ce22df1e852daa9370f1f3446e8b8a02ce44"
dependencies:
get-stdin "^5.0.1"

Expand All @@ -1116,9 +1108,9 @@ eslint-plugin-prettier@^2.0.1:
dependencies:
requireindex "~1.1.0"

eslint@^3.15.0:
version "3.18.0"
resolved "https://registry.yarnpkg.com/eslint/-/eslint-3.18.0.tgz#647e985c4ae71502d20ac62c109f66d5104c8a4b"
eslint@^3.19.0:
version "3.19.0"
resolved "https://registry.yarnpkg.com/eslint/-/eslint-3.19.0.tgz#c8fc6201c7f40dd08941b87c085767386a679acc"
dependencies:
babel-code-frame "^6.16.0"
chalk "^1.1.3"
Expand Down Expand Up @@ -1332,13 +1324,9 @@ flat-cache@^1.2.1:
graceful-fs "^4.1.2"
write "^0.2.1"

flow-parser@0.40.0:
version "0.40.0"
resolved "https://registry.yarnpkg.com/flow-parser/-/flow-parser-0.40.0.tgz#b3444742189093323c4319c4fe9d35391f46bcbc"
dependencies:
ast-types "0.8.18"
colors ">=0.6.2"
minimist ">=0.2.0"
flow-parser@0.43.0:
version "0.43.0"
resolved "https://registry.yarnpkg.com/flow-parser/-/flow-parser-0.43.0.tgz#e2b8eb1ac83dd53f7b6b04a7c35b6a52c33479b7"

for-in@^1.0.1:
version "1.0.2"
Expand Down Expand Up @@ -2073,14 +2061,14 @@ js-tokens@^3.0.0:
version "3.0.1"
resolved "https://registry.yarnpkg.com/js-tokens/-/js-tokens-3.0.1.tgz#08e9f132484a2c45a30907e9dc4d5567b7f114d7"

js-yaml@3.6.1, js-yaml@^3.4.3, js-yaml@^3.5.1:
js-yaml@3.6.1, js-yaml@^3.4.3:
version "3.6.1"
resolved "https://registry.yarnpkg.com/js-yaml/-/js-yaml-3.6.1.tgz#6e5fe67d8b205ce4d22fad05b7781e8dadcc4b30"
dependencies:
argparse "^1.0.7"
esprima "^2.6.0"

js-yaml@^3.7.0:
js-yaml@^3.5.1, js-yaml@^3.7.0:
version "3.8.2"
resolved "https://registry.yarnpkg.com/js-yaml/-/js-yaml-3.8.2.tgz#02d3e2c0f6beab20248d412c352203827d786721"
dependencies:
Expand Down Expand Up @@ -2358,7 +2346,7 @@ minimist@0.0.8, minimist@~0.0.1:
version "0.0.8"
resolved "https://registry.yarnpkg.com/minimist/-/minimist-0.0.8.tgz#857fcabfc3397d2625b8228262e86aa7a011b05d"

minimist@1.2.0, minimist@>=0.2.0, minimist@^1.1.1, minimist@^1.2.0:
minimist@1.2.0, minimist@^1.1.1, minimist@^1.2.0:
version "1.2.0"
resolved "https://registry.yarnpkg.com/minimist/-/minimist-1.2.0.tgz#a35008b20f41383eec1fb914f4cd5df79a264284"

Expand Down Expand Up @@ -2657,16 +2645,16 @@ preserve@^0.2.0:
version "0.2.0"
resolved "https://registry.yarnpkg.com/preserve/-/preserve-0.2.0.tgz#815ed1f6ebc65926f865b310c0713bcb3315ce4b"

prettier@^0.22.0:
version "0.22.0"
resolved "https://registry.yarnpkg.com/prettier/-/prettier-0.22.0.tgz#7b37c4480d0858180407e5a8e13f0f47da7385d2"
prettier@^1.2.2:
version "1.2.2"
resolved "https://registry.yarnpkg.com/prettier/-/prettier-1.2.2.tgz#22d17c1132faaaea1f1d4faea31f19f7a1959f3e"
dependencies:
ast-types "0.9.4"
ast-types "0.9.8"
babel-code-frame "6.22.0"
babylon "6.15.0"
babylon "7.0.0-beta.8"
chalk "1.1.3"
esutils "2.0.2"
flow-parser "0.40.0"
flow-parser "0.43.0"
get-stdin "5.0.1"
glob "7.1.1"
jest-validate "19.0.0"
Expand Down