postcss-discard-overridden
Advanced tools
Comparing version 0.1.1 to 4.0.0-nightly.2020.7.24
@@ -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.7.24", | ||
"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": ">=6.9.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). |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
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
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
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
0
5976
4
48
159
2
+ Addedpicocolors@0.2.1(transitive)
+ Addedpostcss@7.0.39(transitive)
+ Addedsource-map@0.6.1(transitive)
- Removedansi-regex@2.1.1(transitive)
- Removedansi-styles@2.2.1(transitive)
- Removedchalk@1.1.3(transitive)
- Removedescape-string-regexp@1.0.5(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@^7.0.16