Skip to content

Commit

Permalink
Lint
Browse files Browse the repository at this point in the history
  • Loading branch information
hail2u committed Dec 27, 2016
1 parent a3759df commit 0d7ae9f
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 40 deletions.
46 changes: 24 additions & 22 deletions bin/mqpacker.js
Expand Up @@ -51,28 +51,30 @@ Examples:
}

function pack(s, o) {
mqpacker.pack(s, o).then(function (result) {
if (!o.to) {
process.stdout.write(result.css);

return;
}

fs.writeFileSync(o.to, result.css);

if (result.map) {
fs.writeFileSync(`${o.to}.map`, result.map);
}
}).catch(function (error) {
if (error.name === "CssSyntaxError") {
console.error(
`${error.file}:${error.line}:${error.column}: ${error.reason}`
);
process.exit(1);
}

throw error;
});
mqpacker.pack(s, o)
.then(function (result) {
if (!o.to) {
process.stdout.write(result.css);

return;
}

fs.writeFileSync(o.to, result.css);

if (result.map) {
fs.writeFileSync(`${o.to}.map`, result.map);
}
})
.catch(function (error) {
if (error.name === "CssSyntaxError") {
console.error(
`${error.file}:${error.line}:${error.column}: ${error.reason}`
);
process.exit(1);
}

throw error;
});
}

if (argv._.length < 1) {
Expand Down
30 changes: 12 additions & 18 deletions index.js
Expand Up @@ -27,9 +27,6 @@ function parseQueryList(queryList) {
const expressions = {};

list.space(query).forEach(function (expression) {
let feature;
let value;

expression = expression.toLowerCase();

if (expression === "and") {
Expand All @@ -43,8 +40,8 @@ function parseQueryList(queryList) {
}

expression = list.split(expression.replace(/^\(|\)$/g, ""), [":"]);
feature = expression[0];
value = expression[1];
const feature = expression[0];
const value = expression[1];

if (!expressions[feature]) {
expressions[feature] = [];
Expand All @@ -59,17 +56,14 @@ function parseQueryList(queryList) {
}

function inspectLength(length) {
let num;
let unit;

length = /(-?\d*\.?\d+)(ch|em|ex|px|rem)/.exec(length);

if (!length) {
return Number.MAX_VALUE;
}

num = length[1];
unit = length[2];
let num = length[1];
const unit = length[2];

switch (unit) {
case "ch":
Expand Down Expand Up @@ -137,11 +131,13 @@ function sortQueryLists(queryLists, sort) {
index: i,
value: pickMinimumMinWidth(e)
};
}).sort(function (a, b) {
return a.value - b.value;
}).map(function (e) {
return queryLists[e.index];
});
})
.sort(function (a, b) {
return a.value - b.value;
})
.map(function (e) {
return queryLists[e.index];
});
}

module.exports = postcss.plugin(pkg.name, function (opts) {
Expand All @@ -164,10 +160,8 @@ module.exports = postcss.plugin(pkg.name, function (opts) {
}

css.walkAtRules("media", function (atRule) {
let past;
const queryList = atRule.params;

past = queries[queryList];
const past = queries[queryList];

if (typeof past === "object") {
atRule.each(function (rule) {
Expand Down

0 comments on commit 0d7ae9f

Please sign in to comment.