Socket
Socket
Sign inDemoInstall

postcss-discard-overridden

Package Overview
Dependencies
3
Maintainers
7
Versions
36
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.1.1 to 4.0.0-nightly.2020.1.9

80

dist/index.js

@@ -1,57 +0,61 @@

'use strict';
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
value: true
});
exports.default = void 0;
var _postcss = require('postcss');
var _postcss = _interopRequireDefault(require("postcss"));
var _postcss2 = _interopRequireDefault(_postcss);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var OVERRIDABLE_RULES = ['keyframes', 'counter-style'];
var SCOPE_RULES = ['media', 'supports'];
const OVERRIDABLE_RULES = ['keyframes', 'counter-style'];
const SCOPE_RULES = ['media', 'supports'];
function isOverridable(name) {
return OVERRIDABLE_RULES.indexOf(_postcss2.default.vendor.unprefixed(name)) !== -1;
return ~OVERRIDABLE_RULES.indexOf(_postcss.default.vendor.unprefixed(name.toLowerCase()));
}
function isScope(name) {
return SCOPE_RULES.indexOf(_postcss2.default.vendor.unprefixed(name)) !== -1;
return ~SCOPE_RULES.indexOf(_postcss.default.vendor.unprefixed(name.toLowerCase()));
}
function getScope(node) {
var current = node.parent;
var chain = [node.name, node.params];
do {
if (current.type === 'atrule' && isScope(current.name)) {
chain.unshift(current.name + ' ' + current.params);
}
current = current.parent;
} while (current);
return chain.join('|');
let current = node.parent;
const chain = [node.name.toLowerCase(), node.params];
do {
if (current.type === 'atrule' && isScope(current.name)) {
chain.unshift(current.name + ' ' + current.params);
}
current = current.parent;
} while (current);
return chain.join('|');
}
exports.default = _postcss2.default.plugin('postcss-discard-overridden', function () {
return function (css) {
var cache = {};
var rules = [];
css.walkAtRules(function (rule) {
if (rule.type === 'atrule' && isOverridable(rule.name)) {
var scope = getScope(rule);
cache[scope] = rule;
rules.push({
node: rule,
scope: scope
});
}
var _default = _postcss.default.plugin('postcss-discard-overridden', () => {
return css => {
const cache = {};
const rules = [];
css.walkAtRules(node => {
if (isOverridable(node.name)) {
const scope = getScope(node);
cache[scope] = node;
rules.push({
node,
scope
});
rules.forEach(function (rule) {
if (cache[rule.scope] !== rule.node) {
rule.node.remove();
}
});
};
}
});
rules.forEach(rule => {
if (cache[rule.scope] !== rule.node) {
rule.node.remove();
}
});
};
});
module.exports = exports['default'];
exports.default = _default;
module.exports = exports.default;
{
"name": "postcss-discard-overridden",
"version": "0.1.1",
"version": "4.0.0-nightly.2020.1.9",
"description": "PostCSS plugin to discard overridden @keyframes or @counter-style.",
"main": "dist/index.js",
"files": [
"LICENSE",
"dist"
],
"keywords": [

@@ -16,30 +20,18 @@ "postcss",

"license": "MIT",
"repository": "Justineo/postcss-discard-overridden",
"repository": "cssnano/cssnano",
"bugs": {
"url": "https://github.com/Justineo/postcss-discard-overridden/issues"
"url": "https://github.com/cssnano/cssnano/issues"
},
"homepage": "https://github.com/Justineo/postcss-discard-overridden",
"homepage": "https://github.com/cssnano/cssnano",
"dependencies": {
"postcss": "^5.0.16"
"postcss": "^7.0.16"
},
"devDependencies": {
"ava": "^0.14.0",
"babel-cli": "^6.7.7",
"babel-plugin-add-module-exports": "^0.1.4",
"babel-preset-es2015": "^6.6.0",
"babel-register": "^6.7.2",
"eslint": "^2.1.0",
"eslint-config-postcss": "^2.0.0"
},
"scripts": {
"test": "ava && eslint *.js"
"prebuild": "",
"build": "cross-env BABEL_ENV=publish babel src --config-file ../../babel.config.js --out-dir dist --ignore \"**/__tests__/\"",
"prepublish": ""
},
"eslintConfig": {
"extends": "eslint-config-postcss/es5"
},
"ava": {
"require": [
"babel-register"
]
"engines": {
"node": ">=10.13.0"
}
}
}

@@ -1,2 +0,2 @@

# PostCSS Discard Overridden [![Build Status][ci-img]][ci]
# PostCSS Discard Overridden

@@ -8,4 +8,2 @@ [PostCSS] plugin to discard overridden `@keyframes` or `@counter-style`.

[PostCSS]: https://github.com/postcss/postcss
[ci-img]: https://travis-ci.org/Justineo/postcss-discard-overridden.svg
[ci]: https://travis-ci.org/Justineo/postcss-discard-overridden

@@ -156,6 +154,7 @@ ```css

```js
postcss([ require('postcss-discard-overridden') ])
```
See the [PostCSS documentation](https://github.com/postcss/postcss#usage) for
examples for your environment.
See [PostCSS] docs for examples for your environment.
## Contributors
See [CONTRIBUTORS.md](https://github.com/cssnano/cssnano/blob/master/CONTRIBUTORS.md).
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc