Skip to content

Commit

Permalink
Lint
Browse files Browse the repository at this point in the history
  • Loading branch information
hail2u committed Feb 2, 2017
1 parent 72f63f6 commit b9f62ae
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 15 deletions.
4 changes: 2 additions & 2 deletions bin/mqpacker.js
Expand Up @@ -51,7 +51,7 @@ Examples:

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

Expand All @@ -64,7 +64,7 @@ function pack(s, o) {
fs.writeFileSync(`${o.to}.map`, result.map);
}
})
.catch(function (error) {
.catch((error) => {
if (error.name === "CssSyntaxError") {
console.error(
`${error.file}:${error.line}:${error.column}: ${error.reason}`
Expand Down
26 changes: 13 additions & 13 deletions index.js
Expand Up @@ -23,10 +23,10 @@ function isSourceMapAnnotation(rule) {
function parseQueryList(queryList) {
const queries = [];

list.comma(queryList).forEach(function (query) {
list.comma(queryList).forEach((query) => {
const expressions = {};

list.space(query).forEach(function (expression) {
list.space(query).forEach((expression) => {
expression = expression.toLowerCase();

if (expression === "and") {
Expand Down Expand Up @@ -94,19 +94,19 @@ function inspectLength(length) {
function pickMinimumMinWidth(expressions) {
const minWidths = [];

expressions.forEach(function (feature) {
expressions.forEach((feature) => {
let minWidth = feature["min-width"];

if (!minWidth || feature.not || feature.print) {
minWidth = [null];
}

minWidths.push(minWidth.map(inspectLength).sort(function (a, b) {
minWidths.push(minWidth.map(inspectLength).sort((a, b) => {
return b - a;
})[0]);
});

return minWidths.sort(function (a, b) {
return minWidths.sort((a, b) => {
return a - b;
})[0];
}
Expand All @@ -122,25 +122,25 @@ function sortQueryLists(queryLists, sort) {
return queryLists.sort(sort);
}

queryLists.forEach(function (queryList) {
queryLists.forEach((queryList) => {
mapQueryLists.push(parseQueryList(queryList));
});

return mapQueryLists.map(function (e, i) {
return mapQueryLists.map((e, i) => {
return {
index: i,
value: pickMinimumMinWidth(e)
};
})
.sort(function (a, b) {
.sort((a, b) => {
return a.value - b.value;
})
.map(function (e) {
.map((e) => {
return queryLists[e.index];
});
}

module.exports = postcss.plugin(pkg.name, function (opts) {
module.exports = postcss.plugin(pkg.name, (opts) => {
if (!opts) {
opts = {};
}
Expand All @@ -159,12 +159,12 @@ module.exports = postcss.plugin(pkg.name, function (opts) {
sourceMap = null;
}

css.walkAtRules("media", function (atRule) {
css.walkAtRules("media", (atRule) => {
const queryList = atRule.params;
const past = queries[queryList];

if (typeof past === "object") {
atRule.each(function (rule) {
atRule.each((rule) => {
past.append(rule.clone());
});
} else {
Expand All @@ -175,7 +175,7 @@ module.exports = postcss.plugin(pkg.name, function (opts) {
atRule.remove();
});

sortQueryLists(queryLists, opts.sort).forEach(function (queryList) {
sortQueryLists(queryLists, opts.sort).forEach((queryList) => {
css.append(queries[queryList]);
});

Expand Down

0 comments on commit b9f62ae

Please sign in to comment.