From c1ec7aee12f9a5759990c27c5fb4aef171149d9d Mon Sep 17 00:00:00 2001 From: Jonathan Neal Date: Wed, 10 May 2017 20:02:29 -0400 Subject: [PATCH 1/2] Use PostCSS 6 - Also, update jscs, jshint, and tape --- .travis.yml | 2 ++ package.json | 8 ++++---- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/.travis.yml b/.travis.yml index 587bd3e..8524235 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1 +1,3 @@ language: node_js +node_js: + - 4 diff --git a/package.json b/package.json index 55f642d..dc9ca32 100644 --- a/package.json +++ b/package.json @@ -20,13 +20,13 @@ "index.js" ], "dependencies": { - "postcss": "^5.0.4" + "postcss": "^6.0.1" }, "devDependencies": { - "jscs": "^2.1.0", - "jshint": "^2.8.0", + "jscs": "^3.0.7", + "jshint": "^2.9.4", "npmpub": "^3.1.0", - "tape": "^4.0.3" + "tape": "^4.6.3" }, "scripts": { "lint": "npm run jscs && npm run jshint", From 3c31f6a072ab1d12ee4cc122d20c1a999f9ed864 Mon Sep 17 00:00:00 2001 From: Jonathan Neal Date: Wed, 10 May 2017 20:19:00 -0400 Subject: [PATCH 2/2] Use Node 4 syntax --- index.js | 72 ++++++++++++++++++++++++++++---------------------------- 1 file changed, 36 insertions(+), 36 deletions(-) diff --git a/index.js b/index.js index 6ff158c..a947385 100755 --- a/index.js +++ b/index.js @@ -1,11 +1,13 @@ -var postcss = require("postcss"); +"use strict"; + +const postcss = require("postcss"); /** * font variant convertion map * * @type {Object} */ -var fontVariantProperties = { +const fontVariantProperties = { "font-variant-ligatures": { "common-ligatures": "\"liga\", \"clig\"", "no-common-ligatures": "\"liga\", \"clig off\"", @@ -55,9 +57,9 @@ var fontVariantProperties = { } // The `font-variant` property is a shorthand for all the others. -for (var prop in fontVariantProperties) { - var keys = fontVariantProperties[prop] - for (var key in keys) { +for (let prop in fontVariantProperties) { + let keys = fontVariantProperties[prop] + for (let key in keys) { if (!(key in fontVariantProperties["font-variant"])) { fontVariantProperties["font-variant"][key] = keys[key] } @@ -67,8 +69,8 @@ for (var prop in fontVariantProperties) { // Find font-feature-settings declaration before given declaration, // create if does not exist function getFontFeatureSettingsPrevTo(decl) { - var fontFeatureSettings = null; - decl.parent.walkDecls(function(decl) { + let fontFeatureSettings = null; + decl.parent.walkDecls((decl) => { if (decl.prop === "font-feature-settings") { fontFeatureSettings = decl; } @@ -86,36 +88,34 @@ function getFontFeatureSettingsPrevTo(decl) { /** * Expose the font-variant plugin. */ -module.exports = postcss.plugin("postcss-font-variant", function() { - return function(styles) { - styles.walkRules(function(rule) { - var fontFeatureSettings = null - // read custom media queries - rule.walkDecls(function(decl) { - if (!fontVariantProperties[decl.prop]) { - return null - } +module.exports = postcss.plugin("postcss-font-variant", () => (styles) => { + styles.walkRules((rule) => { + let fontFeatureSettings = null + // read custom media queries + rule.walkDecls((decl) => { + if (!fontVariantProperties[decl.prop]) { + return null + } - var newValue = decl.value - if (decl.prop === "font-variant") { - newValue = decl.value.split(/\s+/g).map(function(val) { - return fontVariantProperties["font-variant"][val] - }).join(", ") - } - else if (fontVariantProperties[decl.prop][decl.value]) { - newValue = fontVariantProperties[decl.prop][decl.value] - } + let newValue = decl.value + if (decl.prop === "font-variant") { + newValue = decl.value.split(/\s+/g).map( + (val) => fontVariantProperties["font-variant"][val] + ).join(", ") + } + else if (fontVariantProperties[decl.prop][decl.value]) { + newValue = fontVariantProperties[decl.prop][decl.value] + } - if (fontFeatureSettings === null) { - fontFeatureSettings = getFontFeatureSettingsPrevTo(decl); - } - if (fontFeatureSettings.value && fontFeatureSettings.value !== newValue) { - fontFeatureSettings.value += ", " + newValue; - } - else { - fontFeatureSettings.value = newValue; - } - }) + if (fontFeatureSettings === null) { + fontFeatureSettings = getFontFeatureSettingsPrevTo(decl); + } + if (fontFeatureSettings.value && fontFeatureSettings.value !== newValue) { + fontFeatureSettings.value += ", " + newValue; + } + else { + fontFeatureSettings.value = newValue; + } }) - } + }) })