postcss-prefixwrap
Advanced tools
Comparing version 1.4.1 to 1.5.0
@@ -5,2 +5,10 @@ # Changelog | ||
## 1.5.0 | ||
### Features and Improvements | ||
- [#41](https://github.com/dbtedman/postcss-prefixwrap/pull/41) - Added ignored selectors list. | ||
- Experiment with better `eslint` / `prettier` integration. | ||
- Package updates; some to fix audit errors, the rest to bring packages up to latest versions. | ||
## 1.4.1 | ||
@@ -7,0 +15,0 @@ |
{ | ||
"name": "postcss-prefixwrap", | ||
"version": "1.4.1", | ||
"version": "1.5.0", | ||
"description": "A PostCSS plugin that is used to wrap css styles with a css selector to constrain their affect on parent elements in a page.", | ||
"main": "./src/main.js", | ||
"scripts": { | ||
"format": "prettier ./**/*.{js,md,yml,yaml,json} --write", | ||
"format": "prettier ./**/*.{md,yml,yaml,json} --write && prettier-eslint ./**/*.js --write", | ||
"test": "npm run test:lint && npm run test:unit && npm run test:integration", | ||
@@ -24,14 +24,16 @@ "test:integration": "npm run test:integration:prep && mocha --colors ./integration", | ||
"devDependencies": { | ||
"@types/mocha": "5.2.5", | ||
"ajv": "6.5.4", | ||
"codecov": "3.2.0", | ||
"@types/mocha": "5.2.6", | ||
"ajv": "6.10.0", | ||
"ajv-keywords": "3.4.0", | ||
"codecov": "3.3.0", | ||
"eslint": "5.16.0", | ||
"fs-extra": "5.0.0", | ||
"gulp": "4.0.0", | ||
"fs-extra": "7.0.1", | ||
"gulp": "4.0.1", | ||
"gulp-postcss": "8.0.0", | ||
"mocha": "4.1.0", | ||
"nyc": "13.3.0", | ||
"postcss": "6.0.14", | ||
"prettier": "1.15.3" | ||
"mocha": "6.1.4", | ||
"nyc": "14.0.0", | ||
"postcss": "7.0.14", | ||
"prettier": "1.17.0", | ||
"prettier-eslint-cli": "4.7.1" | ||
} | ||
} |
@@ -17,2 +17,4 @@ const PostCSS = require("postcss"); | ||
this.prefixSelector = prefixSelector; | ||
this.ignoredSelectors = options !== undefined && options.hasOwnProperty("ignoredSelectors") | ||
? options.ignoredSelectors : []; | ||
} | ||
@@ -31,3 +33,3 @@ | ||
* @param {String} cssSelector | ||
* @param {Rule} cssRule | ||
* @param {postcss.Rule} cssRule | ||
* @returns {null|String} | ||
@@ -47,2 +49,7 @@ */ | ||
// Check for matching ignored selectors | ||
if (this.ignoredSelectors.some(currentValue => cleanSelector.match(currentValue))) { | ||
return cleanSelector; | ||
} | ||
// Anything other than a root tag is always prefixed. | ||
@@ -65,3 +72,3 @@ if (Selector.isRootTag(cleanSelector)) { | ||
/** | ||
* @param {Rule} cssRule | ||
* @param {postcss.Rule} cssRule | ||
*/ | ||
@@ -68,0 +75,0 @@ prefixWrapCSSRule(cssRule) { |
@@ -22,3 +22,3 @@ const ANY_WHITESPACE_AT_BEGINNING_OR_END = /(^\s*|\s*$)/g; | ||
/** | ||
* @param {Rule} cssRule | ||
* @param {postcss.Rule} cssRule | ||
* @returns {Boolean} | ||
@@ -25,0 +25,0 @@ */ |
@@ -1,29 +0,22 @@ | ||
const assert = require("assert"); | ||
const fs = require("fs"); | ||
const postcss = require("postcss"); | ||
const PostCSS = require("postcss"); | ||
const prefixWrap = require("../src/main"); | ||
const PrefixWrap = require("../src/main"); | ||
const PrefixAssert = require("./support/prefix-assert"); | ||
describe("PostCSS Prefix Wrap", () => { | ||
// Generate a postcss instance with our plugin enabled. | ||
const postCSS = postcss([prefixWrap(".my-container")]); | ||
const postCSSSkip = postcss([ | ||
prefixWrap(".my-container", { prefixRootTags: true }) | ||
const postCSS = PostCSS([PrefixWrap(".my-container")]); | ||
const postCSSSkip = PostCSS([ | ||
PrefixWrap(".my-container", { prefixRootTags: true }) | ||
]); | ||
const postCSSIgnore = PostCSS([ | ||
PrefixWrap(".my-container", { | ||
ignoredSelectors: [":root", "#my-id", /^\.some-(.+)$/] | ||
}) | ||
]); | ||
const fixtures = __dirname + "/fixtures"; | ||
function assertActualMatchesExpectedAfterPrefixWrap( | ||
postCSS, | ||
actualPath, | ||
expectedPath | ||
) { | ||
assert.equal( | ||
postCSS.process(fs.readFileSync(actualPath)).css, | ||
fs.readFileSync(expectedPath, "UTF-8") | ||
); | ||
} | ||
describe("Standard Prefixing", () => { | ||
it("adds prefix class for tags", () => { | ||
assertActualMatchesExpectedAfterPrefixWrap( | ||
PrefixAssert.actualMatchesExpectedAfterPrefixWrap( | ||
postCSS, | ||
@@ -36,3 +29,3 @@ fixtures + "/standard-tags-raw.css", | ||
it("adds prefix class for ids", () => { | ||
assertActualMatchesExpectedAfterPrefixWrap( | ||
PrefixAssert.actualMatchesExpectedAfterPrefixWrap( | ||
postCSS, | ||
@@ -45,3 +38,3 @@ fixtures + "/standard-ids-raw.css", | ||
it("adds prefix class for classes", () => { | ||
assertActualMatchesExpectedAfterPrefixWrap( | ||
PrefixAssert.actualMatchesExpectedAfterPrefixWrap( | ||
postCSS, | ||
@@ -54,3 +47,3 @@ fixtures + "/standard-classes-raw.css", | ||
it("adds prefix class for multiple classes", () => { | ||
assertActualMatchesExpectedAfterPrefixWrap( | ||
PrefixAssert.actualMatchesExpectedAfterPrefixWrap( | ||
postCSS, | ||
@@ -65,3 +58,3 @@ fixtures + "/multiple-classes-raw.css", | ||
it("replaces global selectors with prefix", () => { | ||
assertActualMatchesExpectedAfterPrefixWrap( | ||
PrefixAssert.actualMatchesExpectedAfterPrefixWrap( | ||
postCSS, | ||
@@ -76,3 +69,3 @@ fixtures + "/replacement-tags-raw.css", | ||
it("adds prefix to global selectors", () => { | ||
assertActualMatchesExpectedAfterPrefixWrap( | ||
PrefixAssert.actualMatchesExpectedAfterPrefixWrap( | ||
postCSSSkip, | ||
@@ -87,3 +80,3 @@ fixtures + "/leave-body-raw.css", | ||
it("leaves selectors that contain our selector in the left most location", () => { | ||
assertActualMatchesExpectedAfterPrefixWrap( | ||
PrefixAssert.actualMatchesExpectedAfterPrefixWrap( | ||
postCSS, | ||
@@ -98,3 +91,3 @@ fixtures + "/leave-raw.css", | ||
it("ignores empty selectors", () => { | ||
assertActualMatchesExpectedAfterPrefixWrap( | ||
PrefixAssert.actualMatchesExpectedAfterPrefixWrap( | ||
postCSS, | ||
@@ -109,3 +102,3 @@ fixtures + "/empty-selectors-raw.css", | ||
it("ignores selectors that are percentages", () => { | ||
assertActualMatchesExpectedAfterPrefixWrap( | ||
PrefixAssert.actualMatchesExpectedAfterPrefixWrap( | ||
postCSS, | ||
@@ -117,2 +110,12 @@ fixtures + "/keyframes-raw.css", | ||
}); | ||
describe("Ignored Selectors", () => { | ||
it("ignores selectors that are in a ignore list", () => { | ||
PrefixAssert.actualMatchesExpectedAfterPrefixWrap( | ||
postCSSIgnore, | ||
fixtures + "/ignore-selectors.css", | ||
fixtures + "/ignore-selectors-expected.css" | ||
); | ||
}); | ||
}); | ||
}); |
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
29819
42
517
13