postcss-prefixer
Advanced tools
Comparing version 2.1.3 to 3.0.0
@@ -1,2 +0,1 @@ | ||
const postcss = require('postcss'); | ||
const Tokenizer = require('css-selector-tokenizer'); | ||
@@ -49,3 +48,3 @@ const { | ||
const prefixer = (options) => (css) => { | ||
const prefixer = (options) => { | ||
const { prefix, ignore } = Object.assign({}, { | ||
@@ -64,14 +63,19 @@ prefix: '', | ||
if (!prefix.length) return; | ||
return { | ||
postcssPlugin: 'postcss-prefixer', | ||
Once(css) { | ||
if (!prefix.length) return; | ||
css.walkRules((rule) => { | ||
const parsed = Tokenizer.parse(rule.selector); | ||
const selector = interateSelectorNodes(parsed, { prefix, ignore }); | ||
css.walkRules((rule) => { | ||
const parsed = Tokenizer.parse(rule.selector); | ||
const selector = interateSelectorNodes(parsed, { prefix, ignore }); | ||
/* eslint no-param-reassign: "off" */ | ||
rule.selector = Tokenizer.stringify(selector); | ||
}); | ||
/* eslint no-param-reassign: "off" */ | ||
rule.selector = Tokenizer.stringify(selector); | ||
}); | ||
}, | ||
}; | ||
}; | ||
prefixer.postcss = true; | ||
module.exports = postcss.plugin('postcss-prefixer', prefixer); | ||
module.exports = prefixer; |
{ | ||
"name": "postcss-prefixer", | ||
"version": "2.1.3", | ||
"version": "3.0.0", | ||
"description": "postcss plugin to prefix all css selector classes and ids", | ||
"main": "lib/prefixer.js", | ||
"engines": { | ||
"node": ">=6.0.0" | ||
"node": "^10 || ^12 || >=14" | ||
}, | ||
"dependencies": { | ||
"css-selector-tokenizer": "^0.7.2", | ||
"postcss": "^5.2.18" | ||
"css-selector-tokenizer": "^0.7.2" | ||
}, | ||
"peerDependencies": { | ||
"postcss": ">= 5.0.0" | ||
"postcss": "^8.0.0" | ||
}, | ||
@@ -22,8 +21,8 @@ "devDependencies": { | ||
"husky": "^4.2.3", | ||
"jest": "^24.9.0" | ||
"jest": "^29.5.0", | ||
"postcss": "^8.4.23" | ||
}, | ||
"scripts": { | ||
"test": "jest", | ||
"test": "jest --coverage", | ||
"test:watch": "jest --watch", | ||
"test:coverage": "jest --coverage", | ||
"lint": "eslint ./lib", | ||
@@ -30,0 +29,0 @@ "prepublish": "npm run lint && npm test" |
# postcss-prefixer | ||
[![Build Status](https://travis-ci.org/marceloucker/postcss-prefixer.svg?branch=master)](https://travis-ci.org/marceloucker/postcss-prefixer) [![dependencies Status](https://david-dm.org/marceloucker/postcss-prefixer/status.svg)](https://david-dm.org/marceloucker/postcss-prefixer) [![devDependencies Status](https://david-dm.org/marceloucker/postcss-prefixer/dev-status.svg)](https://david-dm.org/marceloucker/postcss-prefixer?type=dev) | ||
[![License: MIT](https://img.shields.io/badge/License-MIT-green.svg)](https://opensource.org/licenses/MIT) | ||
@@ -36,3 +35,3 @@ | ||
`npm i -D postcss-prefixer` or `yarn add -D postcss-prefixer` | ||
`npm i -D postcss postcss-prefixer` or `yarn add -D postcss postcss-prefixer` | ||
@@ -39,0 +38,0 @@ create a `postcss.config.js` with: |
@@ -33,13 +33,11 @@ const fs = require('fs'); | ||
test('should throw when passing invalid prefix type', () => { | ||
const results = postcss() | ||
expect(() => postcss() | ||
.use(postcssPrefixer({ prefix: 123, ignore: [] })) | ||
.process(mocks.default.source); | ||
expect(() => results.css).toThrow(); | ||
.process(mocks.default.source)).toThrow(); | ||
}); | ||
test('should throw when passing invalid ignore type', () => { | ||
const results = postcss() | ||
expect(() => postcss() | ||
.use(postcssPrefixer({ prefix: 'prefix-', ignore: '.to-ignore' })) | ||
.process(mocks.default.source); | ||
expect(() => results.css).toThrow(); | ||
.process(mocks.default.source)).toThrow(); | ||
}); | ||
@@ -46,0 +44,0 @@ |
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
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
2
452
0
16066
7
73
+ Addednanoid@3.3.7(transitive)
+ Addedpicocolors@1.1.1(transitive)
+ Addedpostcss@8.4.49(transitive)
+ Addedsource-map-js@1.2.1(transitive)
- Removedpostcss@^5.2.18
- 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)