postcss-discard-unused
Advanced tools
Comparing version 2.2.3 to 4.0.0-rc.0
@@ -0,1 +1,8 @@ | ||
# 4.0.0-rc.0 | ||
* Breaking: Drops support for Node 0.12, we now require at least Node 4. | ||
* Breaking: Update PostCSS to 6.0.0. | ||
* Resolves an issue with the module not properly detecting namespaces | ||
within attribute selectors. | ||
# 2.2.3 | ||
@@ -2,0 +9,0 @@ |
'use strict'; | ||
exports.__esModule = true; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; | ||
var _uniqs = require('uniqs'); | ||
@@ -13,8 +13,14 @@ | ||
var _postcssSelectorParser = require('postcss-selector-parser'); | ||
var _postcssSelectorParser2 = _interopRequireDefault(_postcssSelectorParser); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
var comma = _postcss.list.comma; | ||
var space = _postcss.list.space; | ||
function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } } | ||
var comma = _postcss.list.comma, | ||
space = _postcss.list.space; | ||
var atrule = 'atrule'; | ||
@@ -28,3 +34,3 @@ var decl = 'decl'; | ||
return comma(value).reduce(function (memo, val) { | ||
return [].concat(memo, space(val)); | ||
return [].concat(_toConsumableArray(memo), _toConsumableArray(space(val))); | ||
}, cache); | ||
@@ -34,4 +40,4 @@ } | ||
function filterAtRule(_ref2) { | ||
var atRules = _ref2.atRules; | ||
var values = _ref2.values; | ||
var atRules = _ref2.atRules, | ||
values = _ref2.values; | ||
@@ -50,12 +56,11 @@ values = (0, _uniqs2.default)(values); | ||
function filterNamespace(_ref3) { | ||
var atRules = _ref3.atRules; | ||
var rules = _ref3.rules; | ||
var atRules = _ref3.atRules, | ||
rules = _ref3.rules; | ||
rules = (0, _uniqs2.default)(rules); | ||
atRules.forEach(function (atRule) { | ||
var _atRule$params$split$ = atRule.params.split(' ').filter(Boolean); | ||
var _atRule$params$split$ = atRule.params.split(' ').filter(Boolean), | ||
param = _atRule$params$split$[0], | ||
len = _atRule$params$split$.length; | ||
var param = _atRule$params$split$[0]; | ||
var len = _atRule$params$split$.length; | ||
if (len === 1) { | ||
@@ -83,4 +88,4 @@ return; | ||
function filterFont(_ref4) { | ||
var atRules = _ref4.atRules; | ||
var values = _ref4.values; | ||
var atRules = _ref4.atRules, | ||
values = _ref4.values; | ||
@@ -106,3 +111,3 @@ values = (0, _uniqs2.default)(values); | ||
exports.default = (0, _postcss.plugin)('postcss-discard-unused', function (opts) { | ||
var _fontFace$counterStyl = _extends({ | ||
var _Object$assign = Object.assign({}, { | ||
fontFace: true, | ||
@@ -112,9 +117,8 @@ counterStyle: true, | ||
namespace: true | ||
}, opts); | ||
}, opts), | ||
fontFace = _Object$assign.fontFace, | ||
counterStyle = _Object$assign.counterStyle, | ||
keyframes = _Object$assign.keyframes, | ||
namespace = _Object$assign.namespace; | ||
var fontFace = _fontFace$counterStyl.fontFace; | ||
var counterStyle = _fontFace$counterStyl.counterStyle; | ||
var keyframes = _fontFace$counterStyl.keyframes; | ||
var namespace = _fontFace$counterStyl.namespace; | ||
return function (css) { | ||
@@ -126,9 +130,21 @@ var counterStyleCache = { atRules: [], values: [] }; | ||
css.walk(function (node) { | ||
var type = node.type; | ||
var prop = node.prop; | ||
var selector = node.selector; | ||
var name = node.name; | ||
var type = node.type, | ||
prop = node.prop, | ||
selector = node.selector, | ||
name = node.name; | ||
if (type === rule && namespace && ~selector.indexOf('|')) { | ||
namespaceCache.rules = namespaceCache.rules.concat(selector.split('|')[0]); | ||
if (~selector.indexOf('[')) { | ||
// Attribute selector, so we should parse further. | ||
(0, _postcssSelectorParser2.default)(function (ast) { | ||
ast.walkAttributes(function (_ref6) { | ||
var ns = _ref6.namespace; | ||
namespaceCache.rules = namespaceCache.rules.concat(ns); | ||
}); | ||
}).process(selector); | ||
} else { | ||
// Use a simple split function for the namespace | ||
namespaceCache.rules = namespaceCache.rules.concat(selector.split('|')[0]); | ||
} | ||
return; | ||
@@ -135,0 +151,0 @@ } |
{ | ||
"name": "postcss-discard-unused", | ||
"version": "2.2.3", | ||
"version": "4.0.0-rc.0", | ||
"description": "Discard unused counter styles, keyframes and fonts.", | ||
@@ -12,8 +12,3 @@ "main": "dist/index.js", | ||
"scripts": { | ||
"contributorAdd": "all-contributors add", | ||
"contributorGenerate": "all-contributors generate", | ||
"prepublish": "del-cli dist && BABEL_ENV=publish babel src --out-dir dist --ignore /__tests__/", | ||
"pretest": "eslint src", | ||
"test": "ava src/__tests__", | ||
"test-012": "ava src/__tests__" | ||
"prepublish": "cross-env BABEL_ENV=publish babel src --out-dir dist --ignore /__tests__/" | ||
}, | ||
@@ -30,18 +25,6 @@ "keywords": [ | ||
"devDependencies": { | ||
"all-contributors-cli": "^3.0.5", | ||
"ava": "^0.16.0", | ||
"babel-cli": "^6.4.5", | ||
"babel-core": "^6.4.5", | ||
"babel-plugin-add-module-exports": "^0.2.0", | ||
"babel-preset-es2015": "^6.3.13", | ||
"babel-preset-es2015-loose": "^7.0.0", | ||
"babel-preset-stage-0": "^6.3.13", | ||
"babel-register": "^6.9.0", | ||
"del-cli": "^0.2.0", | ||
"eslint": "^3.0.0", | ||
"eslint-config-cssnano": "^3.0.0", | ||
"eslint-plugin-babel": "^3.3.0", | ||
"eslint-plugin-import": "^2.0.1" | ||
"babel-cli": "^6.0.0", | ||
"cross-env": "^3.0.0" | ||
}, | ||
"homepage": "https://github.com/ben-eb/postcss-discard-unused", | ||
"homepage": "https://github.com/ben-eb/cssnano", | ||
"author": { | ||
@@ -52,13 +35,14 @@ "name": "Ben Briggs", | ||
}, | ||
"repository": "ben-eb/postcss-discard-unused", | ||
"repository": "ben-eb/cssnano", | ||
"dependencies": { | ||
"postcss": "^5.0.14", | ||
"postcss": "^6.0.0", | ||
"postcss-selector-parser": "^2.0.0", | ||
"uniqs": "^2.0.0" | ||
}, | ||
"ava": { | ||
"require": "babel-register" | ||
"bugs": { | ||
"url": "https://github.com/ben-eb/cssnano/issues" | ||
}, | ||
"eslintConfig": { | ||
"extends": "cssnano" | ||
"engines": { | ||
"node": ">=4" | ||
} | ||
} |
@@ -1,2 +0,2 @@ | ||
# [postcss][postcss]-discard-unused [![Build Status](https://travis-ci.org/ben-eb/postcss-discard-unused.svg?branch=master)][ci] [![NPM version](https://badge.fury.io/js/postcss-discard-unused.svg)][npm] [![Dependency Status](https://gemnasium.com/ben-eb/postcss-discard-unused.svg)][deps] | ||
# [postcss][postcss]-discard-unused | ||
@@ -68,3 +68,3 @@ > Discard unused counter styles, keyframes and fonts. | ||
*before* this plugin, which will take care of normalising quotes, and | ||
deduplicating. For more examples, see the [tests](test.js). | ||
deduplicating. For more examples, see the [tests](src/__tests__/index.js). | ||
@@ -113,13 +113,10 @@ | ||
## Contributors | ||
## Usage | ||
Thanks goes to these wonderful people ([emoji key](https://github.com/kentcdodds/all-contributors#emoji-key)): | ||
See the [PostCSS documentation](https://github.com/postcss/postcss#usage) for | ||
examples for your environment. | ||
<!-- ALL-CONTRIBUTORS-LIST:START - Do not remove or modify this section --> | ||
| [<img src="https://avatars.githubusercontent.com/u/1282980?v=3" width="100px;"/><br /><sub>Ben Briggs</sub>](http://beneb.info)<br />[💻](https://github.com/ben-eb/postcss-discard-unused/commits?author=ben-eb) [📖](https://github.com/ben-eb/postcss-discard-unused/commits?author=ben-eb) 👀 [⚠️](https://github.com/ben-eb/postcss-discard-unused/commits?author=ben-eb) | [<img src="https://avatars.githubusercontent.com/u/5635476?v=3" width="100px;"/><br /><sub>Bogdan Chadkin</sub>](https://github.com/TrySound)<br />[💻](https://github.com/ben-eb/postcss-discard-unused/commits?author=TrySound) [📖](https://github.com/ben-eb/postcss-discard-unused/commits?author=TrySound) 👀 [⚠️](https://github.com/ben-eb/postcss-discard-unused/commits?author=TrySound) | [<img src="https://avatars.githubusercontent.com/u/770675?v=3" width="100px;"/><br /><sub>Paweł Lesiecki</sub>](https://github.com/plesiecki)<br />[💻](https://github.com/ben-eb/postcss-discard-unused/commits?author=plesiecki) [⚠️](https://github.com/ben-eb/postcss-discard-unused/commits?author=plesiecki) | [<img src="https://avatars.githubusercontent.com/u/197928?v=3" width="100px;"/><br /><sub>Thomas McDonald</sub>](https://github.com/thomas-mcdonald)<br />[💻](https://github.com/ben-eb/postcss-discard-unused/commits?author=thomas-mcdonald) [⚠️](https://github.com/ben-eb/postcss-discard-unused/commits?author=thomas-mcdonald) | | ||
| :---: | :---: | :---: | :---: | | ||
<!-- ALL-CONTRIBUTORS-LIST:END --> | ||
## Contributors | ||
This project follows the [all-contributors] specification. Contributions of | ||
any kind welcome! | ||
See [CONTRIBUTORS.md](https://github.com/ben-eb/cssnano/blob/master/CONTRIBUTORS.md). | ||
@@ -131,7 +128,3 @@ ## License | ||
[all-contributors]: https://github.com/kentcdodds/all-contributors | ||
[ci]: https://travis-ci.org/ben-eb/postcss-discard-unused | ||
[deps]: https://gemnasium.com/ben-eb/postcss-discard-unused | ||
[npm]: http://badge.fury.io/js/postcss-discard-unused | ||
[postcss]: https://github.com/postcss/postcss | ||
[mfv]: https://github.com/trysound/postcss-minify-font-values |
No repository
Supply chain riskPackage does not have a linked source code repository. Without this field, a package will have no reference to the location of the source code use to generate the package.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
No bug tracker
MaintenancePackage does not have a linked bug tracker in package.json.
Found 1 instance in 1 package
No repository
Supply chain riskPackage does not have a linked source code repository. Without this field, a package will have no reference to the location of the source code use to generate the package.
Found 1 instance in 1 package
No website
QualityPackage does not have a website.
Found 1 instance in 1 package
2
152
0
11307
3
128
+ Addedansi-styles@3.2.1(transitive)
+ Addedchalk@2.4.2(transitive)
+ Addedcolor-convert@1.9.3(transitive)
+ Addedcolor-name@1.1.3(transitive)
+ Addedflatten@1.0.3(transitive)
+ Addedhas-flag@3.0.0(transitive)
+ Addedindexes-of@1.0.1(transitive)
+ Addedpostcss@6.0.23(transitive)
+ Addedpostcss-selector-parser@2.2.3(transitive)
+ Addedsource-map@0.6.1(transitive)
+ Addedsupports-color@5.5.0(transitive)
+ Addeduniq@1.0.1(transitive)
- Removedansi-regex@2.1.1(transitive)
- Removedansi-styles@2.2.1(transitive)
- Removedchalk@1.1.3(transitive)
- Removedhas-ansi@2.0.0(transitive)
- Removedhas-flag@1.0.0(transitive)
- Removedjs-base64@2.6.4(transitive)
- Removedpostcss@5.2.18(transitive)
- Removedsource-map@0.5.7(transitive)
- Removedstrip-ansi@3.0.1(transitive)
- Removedsupports-color@2.0.03.2.3(transitive)
Updatedpostcss@^6.0.0