diff --git a/.editorconfig b/.editorconfig index 8f9d77e..b807ff4 100644 --- a/.editorconfig +++ b/.editorconfig @@ -1,15 +1,18 @@ root = true -[*] -indent_style = tab +[*.*] +indent_style = space +indent_size = 4 end_of_line = lf charset = utf-8 trim_trailing_whitespace = true insert_final_newline = true [{package.json,*.yml}] -indent_style = space indent_size = 2 +[*.js] +indent_style = tab + [*.md] trim_trailing_whitespace = false diff --git a/CHANGELOG.md b/CHANGELOG.md index 81ad038..c5963f9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,20 @@ +## [0.0.19] - 02-04-2016 +### Added +- Added #34, husky + +### Change +- Change #40, update .editorconfig, change tab to space all and js to tab +- Change #5, update readme change tab to space +- Change #37, testing src instead lib +- Move #35, updtr to npm run updateDev +- Change #42, lodash merge to deep-assign + +### Remove +- Remove #36, balance-match not used + +### Fixed +- Fixed #39, resolve export default for require + ## [0.0.18] - 18-03-2016 ### Added - Added #1, ava diff --git a/README.md b/README.md index 1c609ec..a6f1a25 100644 --- a/README.md +++ b/README.md @@ -9,44 +9,44 @@ Used in conjunction with the plugin [postcss-each], [postcss-conditionals], [pos ```css /* input.css */ :root { - --array: foo, bar, baz; - --from: 1; - --to: 3; - --icon-exclude: 2; - --color-danger: red; + --array: foo, bar, baz; + --from: 1; + --to: 3; + --icon-exclude: 2; + --color-danger: red; } @each $val in var(--array) { - @import "$val.css"; + @import "$val.css"; } ``` ```css /* foo.css */ html { - background-color: var(--color-danger); + background-color: var(--color-danger); } ``` ```css /* bar.css */ .some-class { - color: #fff; - - @for $val from var(--from) to var(--to) { - @if $val != var(--icon-exclude) { - .icon-$val { - background-position: 0 $(val)px; - } - } - } + color: #fff; + + @for $val from var(--from) to var(--to) { + @if $val != var(--icon-exclude) { + .icon-$val { + background-position: 0 $(val)px; + } + } + } } ``` ```css /* baz.css */ h1 { - font-size: 24px; + font-size: 24px; } @import "biz.css"; @@ -55,29 +55,29 @@ h1 { ```css /* biz.css */ h2 { - color: olive; + color: olive; } ``` ```css /* Output example */ html { - background-color: red; + background-color: red; } .some-class { - color: #fff; - .icon-1 { - background-position: 0 1px; - } - .icon-3 { - background-position: 0 3px; - } + color: #fff; + .icon-1 { + background-position: 0 1px; + } + .icon-3 { + background-position: 0 3px; + } } h1 { - font-size: 24px; + font-size: 24px; } h2 { - color: olive; + color: olive; } ``` @@ -97,7 +97,7 @@ var fs = require("fs"); var postcss = require("postcss"); var atImport = require("postcss-import"); var atEach = require("postcss-each"); -var atVariables = require("postcss-at-rules-variables").default; +var atVariables = require("postcss-at-rules-variables"); var atIf = require('postcss-conditionals'); var atFor = require('postcss-for'); var customProperties = require("postcss-custom-properties"); @@ -111,10 +111,10 @@ var output = postcss() .use(atVariables({ /* options */ })) .use(atEach()) .use(atImport({ - plugins: [ - require("postcss-at-rules-variables").default({ /* options */ }), - require("postcss-import") - ] + plugins: [ + require("postcss-at-rules-variables").default({ /* options */ }), + require("postcss-import") + ] })) .use(atFor()) .use(atIf()) @@ -136,6 +136,6 @@ Default: `['for', 'if', 'else', 'each']` See [PostCSS](https://github.com/postcss/postcss) docs for examples for your environment. -[postcss-conditionals]: https://github.com/andyjansson/postcss-conditionals -[postcss-each]: https://github.com/outpunk/postcss-each -[postcss-for]: https://github.com/antyakushev/postcss-for +[postcss-conditionals]: https://github.com/andyjansson/postcss-conditionals +[postcss-each]: https://github.com/outpunk/postcss-each +[postcss-for]: https://github.com/antyakushev/postcss-for diff --git a/package.json b/package.json index a2dc468..5b9942d 100644 --- a/package.json +++ b/package.json @@ -1,13 +1,16 @@ { "name": "postcss-at-rules-variables", - "version": "0.0.18", + "version": "0.0.19", "description": "PostCss plugin to use CSS Custom Properties in at-rule @each, @for, @if, @else ", "main": "./lib/index.js", "scripts": { "test": "xo ./src/*.js ./test/*.js && nyc ava", "clean": "rm -rf lib && mkdir lib", "build": "npm run clean && babel src/index.js --out-file lib/index.js && npm t", - "prepublish": "updtr && npm run build" + "postinstall": "npm run updateDev", + "prepublish": "npm run build", + "prepush": "npm test", + "updateDev": "updtr" }, "keywords": [ "postcss", @@ -29,16 +32,17 @@ }, "license": "MIT", "dependencies": { - "balanced-match": "^0.3.0", - "lodash": "^4.6.1", + "deep-assign": "^2.0.0", "postcss": "^5.0.19" }, "devDependencies": { "ava": "^0.13.0", "babel-cli": "^6.6.5", + "babel-plugin-add-module-exports": "^0.1.2", "babel-preset-node5": "^11.0.0", "babel-register": "^6.7.2", "coveralls": "^2.11.8", + "husky": "^0.11.4", "nyc": "^6.1.1", "updtr": "^0.1.7", "xo": "^0.13.0" @@ -46,6 +50,9 @@ "babel": { "presets": [ "node5" + ], + "plugins": [ + "add-module-exports" ] }, "ava": { diff --git a/src/index.js b/src/index.js index 4bd7812..b38e64c 100644 --- a/src/index.js +++ b/src/index.js @@ -1,5 +1,5 @@ import postcss from 'postcss'; -import {merge} from 'lodash'; +import deepAssign from 'deep-assign'; const VAR_FUNC_IDENTIFIER = 'var'; const maps = {}; @@ -18,7 +18,7 @@ export default postcss.plugin('postcss-at-rules-variables', options => { atRules: ['for', 'if', 'else', 'each'] }; - const mergeOptions = merge(DEFAULT, options, (a, b) => { + const mergeOptions = deepAssign(DEFAULT, options, (a, b) => { if (Array.isArray(a)) { return a.concat(b); } diff --git a/test/test.js b/test/test.js index 987e309..35a7461 100644 --- a/test/test.js +++ b/test/test.js @@ -1,6 +1,6 @@ import postcss from 'postcss'; import test from 'ava'; -import plugin from '../lib/index'; +import plugin from '../src/index'; const processing = (input, opts) => { return postcss([plugin(opts)]).process(input).css; @@ -43,8 +43,8 @@ test('it change two properties for @if, @else if', t => { }); test('it change multi properties for @each', t => { - const expected = ':root{ --array: foo, bar, baz; } @each $val in foo, bar, baz'; - const value = ':root{ --array: foo, bar, baz; } @each $val in var(--array)'; + const expected = ':root{ --array: foo, bar, baz; } @each $val in foo, bar, baz @for foo, bar, baz'; + const value = ':root{ --array: foo, bar, baz; } @each $val in var(--array) @for var(--array)'; t.is(processing(value, {atRules: ['each']}), expected); });