postcss-discard-empty
Advanced tools
Comparing version
{ | ||
"name": "postcss-discard-empty", | ||
"version": "5.0.3", | ||
"version": "5.1.0", | ||
"description": "Discard empty rules and values with PostCSS.", | ||
"main": "src/index.js", | ||
"types": "types/index.d.ts", | ||
"files": [ | ||
"src", | ||
"LICENSE-MIT" | ||
"LICENSE-MIT", | ||
"types" | ||
], | ||
@@ -10,0 +12,0 @@ "keywords": [ |
'use strict'; | ||
const plugin = 'postcss-discard-empty'; | ||
/** | ||
* @param {import('postcss').Root} css | ||
* @param {import('postcss').Result} result | ||
* @return {void} | ||
*/ | ||
function discardAndReport(css, result) { | ||
/** | ||
* @param {import('postcss').AnyNode} node | ||
* @return {void} | ||
*/ | ||
function discardEmpty(node) { | ||
const { type, nodes: sub, params } = node; | ||
const { type } = node; | ||
/** @type {(import('postcss').ChildNode | import('postcss').ChildProps)[] | undefined} */ | ||
const sub = /** @type {any} */ (node).nodes; | ||
if (sub) { | ||
node.each(discardEmpty); | ||
/** @type {import('postcss').Container} */ (node).each(discardEmpty); | ||
} | ||
@@ -16,3 +25,6 @@ | ||
(sub && !sub.length) || | ||
(type === 'atrule' && ((!sub && !params) || (!params && !sub.length))) | ||
(type === 'atrule' && | ||
((!sub && !node.params) || | ||
(!node.params && | ||
!(/** @type {import('postcss').ChildNode[]}*/ (sub).length)))) | ||
) { | ||
@@ -32,2 +44,6 @@ node.remove(); | ||
/** | ||
* @type {import('postcss').PluginCreator<void>} | ||
* @return {import('postcss').Plugin} | ||
*/ | ||
function pluginCreator() { | ||
@@ -34,0 +50,0 @@ return { |
5023
19.48%5
25%61
79.41%