🚀 Big News:Socket Has Acquired Secure Annex.Learn More
Socket
Book a DemoSign in
Socket

postcss-prefixwrap

Package Overview
Dependencies
Maintainers
1
Versions
84
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

postcss-prefixwrap - npm Package Compare versions

Comparing version
1.29.1
to
1.30.1
+1
-1
build/PostCSSPrefixWrap.js

@@ -49,3 +49,3 @@ "use strict";

// extract their styles.
return cleanSelector.replace(/^(body|html)/, this.prefixSelector);
return cleanSelector.replace(/^(body|html|:root)/, this.prefixSelector);
}

@@ -52,0 +52,0 @@ cssRuleMatchesPrefixSelector(cssRule) {

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const ANY_WHITESPACE_AT_BEGINNING_OR_END = /(^\s*|\s*$)/g;
const IS_ROOT_TAG = /^(body|html).*$/;
const IS_ROOT_TAG = /^(body|html|:root).*$/;
class Selector {

@@ -6,0 +6,0 @@ static isValid(cssSelector) {

@@ -7,2 +7,14 @@ # [PostCSS Prefix Wrap](./README.md) // Changelog

## [1.30.1](https://github.com/dbtedman/postcss-prefixwrap/releases/tag/1.30.1)
### 💡 Features and Improvements
- Snyk + CodeQL SAST
- Switch to PNPM from Yarn
- Introduce Makefile for common commands
### 🐛 Bug Fixes
- `:root` missing from list of root tags
## [1.29.1](https://github.com/dbtedman/postcss-prefixwrap/releases/tag/1.29.1)

@@ -9,0 +21,0 @@

@@ -29,3 +29,3 @@ # [PostCSS Prefix Wrap](./README.md) // Contributing

```shell
yarn format
make format
```

@@ -36,3 +36,3 @@

```shell
yarn lint
make lint
```

@@ -45,3 +45,3 @@

```shell
yarn test
make test
```

@@ -48,0 +48,0 @@

MIT License
Copyright © 2021 [Daniel Tedman](https://danieltedman.com)
Copyright © 2022 [Daniel Tedman](https://danieltedman.com)

@@ -5,0 +5,0 @@ Permission is hereby granted, free of charge, to any person obtaining a copy

{
"name": "postcss-prefixwrap",
"version": "1.29.1",
"version": "1.30.1",
"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.",

@@ -9,6 +9,7 @@ "keywords": [

"nodejs",
"yarn",
"pnpm",
"postcss",
"postcss-plugin",
"typescript"
"typescript",
"yarn"
],

@@ -29,34 +30,36 @@ "homepage": "https://github.com/dbtedman/postcss-prefixwrap#readme",

],
"scripts": {
"build": "tsc --build ./tsconfig.json && rm -rf ./build/{**/*,*}.spec.js && rm -rf ./build/acceptance && rm -rf ./build/integration",
"clean": "rm -rf ./build/",
"format": "sort-package-json && prettier './**/*.{md,yml,yaml,json,ts,js}' --write && yarn eslint --fix . --ext .js,.ts",
"lint": "sort-package-json --check && prettier './**/*.{md,yml,yaml,json,ts,js}' --check && yarn eslint . --ext .js,.ts",
"test": "jest --coverage"
},
"devDependencies": {
"@babel/core": "7.17.9",
"@types/jest": "27.4.1",
"@types/node": "17.0.25",
"@typescript-eslint/eslint-plugin": "5.20.0",
"@typescript-eslint/parser": "5.20.0",
"eslint": "8.14.0",
"@babel/core": "7.18.2",
"@types/jest": "28.1.0",
"@types/node": "17.0.39",
"@typescript-eslint/eslint-plugin": "5.27.0",
"@typescript-eslint/parser": "5.27.0",
"eslint": "8.17.0",
"eslint-config-prettier": "8.5.0",
"eslint-plugin-import": "2.26.0",
"eslint-plugin-jest": "26.1.5",
"eslint-plugin-jest": "26.4.6",
"eslint-plugin-promise": "6.0.0",
"eslint-plugin-security-node": "1.1.1",
"jest": "27.5.1",
"postcss": "8.4.12",
"jest": "28.1.0",
"postcss": "8.4.14",
"postcss-nested": "5.0.6",
"postcss7": "npm:postcss@7.0.34",
"prettier": "2.6.2",
"sort-package-json": "1.55.0",
"ts-jest": "27.1.4",
"ts-node": "10.7.0",
"typescript": "4.6.3"
"sort-package-json": "1.57.0",
"source-map": "0.7.3",
"source-map-js": "1.0.2",
"ts-jest": "28.0.4",
"ts-node": "10.8.1",
"typescript": "4.7.3"
},
"peerDependencies": {
"postcss": "*"
},
"scripts": {
"build": "tsc --build ./tsconfig.json && rm -rf ./build/{**/*,*}.spec.js && rm -rf ./build/acceptance && rm -rf ./build/integration",
"clean": "rm -rf ./build/",
"format": "sort-package-json && prettier './**/*.{md,yml,yaml,json,ts,js}' --write && pnpm eslint --fix . --ext .js,.ts",
"lint": "sort-package-json --check && prettier './**/*.{md,yml,yaml,json,ts,js}' --check && pnpm eslint . --ext .js,.ts",
"test": "jest"
}
}
}
# [PostCSS Prefix Wrap](https://danieltedman.com/my-work/postcss-prefixwrap)
[![CI GitHub Pipeline](https://img.shields.io/github/workflow/status/dbtedman/postcss-prefixwrap/ci?style=for-the-badge&logo=github&label=ci)](https://github.com/dbtedman/postcss-prefixwrap/actions/workflows/ci.yml?query=branch%3Amain)
[![Release GitHub Pipeline](https://img.shields.io/github/workflow/status/dbtedman/postcss-prefixwrap/ci?style=for-the-badge&logo=github&label=release)](https://github.com/dbtedman/postcss-prefixwrap/actions/workflows/release.yml)
[![SAST GitHub Pipeline](https://img.shields.io/github/workflow/status/dbtedman/postcss-prefixwrap/sast?style=for-the-badge&logo=github&label=sast)](https://github.com/dbtedman/postcss-prefixwrap/actions/workflows/sast.yml)
[![Release GitHub Pipeline](https://img.shields.io/github/workflow/status/dbtedman/postcss-prefixwrap/release?style=for-the-badge&logo=github&label=release)](https://github.com/dbtedman/postcss-prefixwrap/actions/workflows/release.yml)
[![NPM Downloads Per Week](https://img.shields.io/npm/dw/postcss-prefixwrap?color=blue&logo=npm&style=for-the-badge)](https://www.npmjs.com/package/postcss-prefixwrap)

@@ -10,6 +11,6 @@

| Supports | Versions |
| :------- | :------------------------- |
| NodeJS | `v12`, `v14`, `v16`, `v17` |
| PostCSS | `v7`, `v8` |
| Supports | Versions |
| :------- | :------------------ |
| NodeJS | `v14`, `v16`, `v17` |
| PostCSS | `v7`, `v8` |

@@ -16,0 +17,0 @@ - [How to use this plugin?](#how-to-use-this-plugin)

"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const indexWrap_1 = __importDefault(require("./indexWrap"));
const postcss8 = __importStar(require("postcss"));
const postcss7 = __importStar(require("postcss7"));
describe("indexWrap", () => {
it("works with PostCSS v8", () => {
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
const plugin = (0, indexWrap_1.default)(postcss8)(".selector", {});
plugin.Once({
walkRules: () => {
// Implementation not important for this test
},
});
expect(plugin).not.toBeNull();
});
it("works with PostCSS v7", () => {
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
const plugin = (0, indexWrap_1.default)(postcss7)(".selector", {});
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
plugin({
walkRules: () => {
// Implementation not important for this test
},
});
expect(plugin).not.toBeNull();
});
});
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const assert_1 = __importDefault(require("assert"));
const postcss_1 = __importDefault(require("postcss"));
const PostCSSPrefixWrap_1 = __importDefault(require("./PostCSSPrefixWrap"));
describe("Plugin", () => {
const prefixSelector = ".my-custom-wrap";
it("Plugin.cssRuleMatchesPrefixSelector() correctly identifies our prefix Selector", () => {
const plugin = new PostCSSPrefixWrap_1.default(prefixSelector);
const cssRule = postcss_1.default.rule({
selector: prefixSelector,
});
assert_1.default.strictEqual(plugin.cssRuleMatchesPrefixSelector(cssRule), true);
});
it("Plugin.cssRuleMatchesPrefixSelector() correctly ignores selector that contains our prefix selector", () => {
const plugin = new PostCSSPrefixWrap_1.default(prefixSelector);
const cssRule = postcss_1.default.rule({
selector: `${prefixSelector}something`,
});
assert_1.default.strictEqual(plugin.cssRuleMatchesPrefixSelector(cssRule), false);
});
it("Plugin.cssRuleMatchesPrefixSelector() correctly ignores another Selector", () => {
const plugin = new PostCSSPrefixWrap_1.default(prefixSelector);
const selector = ".not-my-custom-wrap";
const cssRule = postcss_1.default.rule({
selector: selector,
});
assert_1.default.strictEqual(plugin.cssRuleMatchesPrefixSelector(cssRule), false);
});
it("Plugin.prefixWrapCSSRule() leaves prefix Selector alone", () => {
const plugin = new PostCSSPrefixWrap_1.default(prefixSelector);
const cssRule = postcss_1.default.rule({
selector: prefixSelector,
});
plugin.prefixWrapCSSRule(cssRule);
assert_1.default.strictEqual(cssRule.selector, prefixSelector);
});
it("Plugin.prefixWrapCSSRule() does not change for empty Selector", () => {
const plugin = new PostCSSPrefixWrap_1.default(prefixSelector);
const cssRule = postcss_1.default.rule({
selector: "",
});
plugin.prefixWrapCSSRule(cssRule);
assert_1.default.strictEqual(cssRule.selector, "");
});
it("Plugin.prefixWrapCSSRule() prefixes non root selectors with prefix Selector", () => {
const plugin = new PostCSSPrefixWrap_1.default(prefixSelector);
["div", "p", "h1"].forEach((selector) => {
const parent = postcss_1.default.root();
const cssRule = postcss_1.default.rule({
selector: selector,
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
parent: parent,
});
plugin.prefixWrapCSSRule(cssRule);
assert_1.default.strictEqual(cssRule.selector, `${prefixSelector} ${selector}`);
});
});
it("handles includeFile with whitelist when missing source input data", () => {
const plugin = new PostCSSPrefixWrap_1.default(prefixSelector, {
whitelist: [".something"],
});
assert_1.default.strictEqual(
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
plugin.includeFile({
source: undefined,
}), false);
assert_1.default.strictEqual(plugin.includeFile({
walkRules() {
//
},
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
source: {
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
input: {
file: undefined,
},
},
}), false);
});
it("handles includeFile with blacklist when missing source input data", () => {
const plugin = new PostCSSPrefixWrap_1.default(prefixSelector, {
blacklist: [".something"],
});
assert_1.default.strictEqual(
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
plugin.includeFile({
source: undefined,
}), true);
assert_1.default.strictEqual(plugin.includeFile({
walkRules() {
//
},
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
source: {
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
input: {
file: undefined,
},
},
}), true);
});
});
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const assert_1 = __importDefault(require("assert"));
const Selector_1 = __importDefault(require("./Selector"));
describe("Selector", () => {
it("Selector.isValid() is true for null Selector", () => {
assert_1.default.strictEqual(Selector_1.default.isValid(null), false);
});
it("Selector.clean() removes extra space padding", () => {
assert_1.default.strictEqual(Selector_1.default.clean(" div "), "div");
assert_1.default.strictEqual(Selector_1.default.clean(" div"), "div");
assert_1.default.strictEqual(Selector_1.default.clean("div "), "div");
});
it("Selector.isNotRootTag() is true for root tags", () => {
assert_1.default.strictEqual(Selector_1.default.isNotRootTag("html"), false);
assert_1.default.strictEqual(Selector_1.default.isNotRootTag("body"), false);
});
it("Selector.isNotRootTag() is false for non root tags", () => {
assert_1.default.strictEqual(Selector_1.default.isNotRootTag("div"), true);
assert_1.default.strictEqual(Selector_1.default.isNotRootTag("p"), true);
assert_1.default.strictEqual(Selector_1.default.isNotRootTag("span"), true);
});
});