From f141069f3f828011477eb011b700d44024e8d243 Mon Sep 17 00:00:00 2001 From: Ilya Rogov Date: Sun, 25 Mar 2018 23:47:05 +0300 Subject: [PATCH 1/2] Update supported versions Node.js Fix error: npm is known not to run on Node.js v0.12.18 You'll need to upgrade to a newer version in order to use this version of npm. Supported versions are 4, 6, 7, 8, 9. You can find the --- .travis.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 6e7e2ac..683c874 100644 --- a/.travis.yml +++ b/.travis.yml @@ -5,9 +5,10 @@ sudo: false language: node_js node_js: - - "0.12" - "4" - - "5" + - "6" + - "8" + - "node" branches: only: From a7fbdcf4d01febaaf6c7b5939621dabd5afdf029 Mon Sep 17 00:00:00 2001 From: Ilya Rogov Date: Sun, 25 Mar 2018 17:52:00 +0300 Subject: [PATCH 2/2] #6 Add alias @ for symbol start entity --- lib/index.js | 8 ++++++++ test/lib/index.js | 25 +++++++++++++++++++++++++ 2 files changed, 33 insertions(+) diff --git a/lib/index.js b/lib/index.js index 4e59afa..25d71c4 100644 --- a/lib/index.js +++ b/lib/index.js @@ -22,6 +22,14 @@ function buildSelector (ctx, mod) { } export default postcss.plugin('pobem', () => (css) => { + css.walkAtRules(/block|elem|mod/, function (rule) { + rule.replaceWith(postcss.rule({ + selector: rule.name + rule.params, + nodes: rule.nodes, + raws: rule.raws, + source: rule.source + })); + }); css.walkRules((rule) => { rule.selector = rule.selector .replace(/[.:]?(block\(.+)/g, (match, raw) => { diff --git a/test/lib/index.js b/test/lib/index.js index 031fd4c..485590b 100644 --- a/test/lib/index.js +++ b/test/lib/index.js @@ -12,6 +12,31 @@ const test = (selector, result) => { }; describe('plugin', () => { + describe('Aliases for start entity', () => { + it('dot', () => { + test( + '.block(foo)', + '.foo' + ); + }); + it('colon', () => { + test( + ':block(foo)', + '.foo' + ); + }); + it('at', () => { + test( + '@block(foo)', + '.foo' + ); + test( + '@media', + '@media' + ); + }); + }); + describe('block', () => { it('simple', () => { test(