Research
Security News
Malicious npm Packages Inject SSH Backdoors via Typosquatted Libraries
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
postcss-namespace
Advanced tools
PostCSS plugin that prefix a namespace to a selector
npm i postcss-namespace
Write @prefix
atrule to your css file.
(e.g. input.css)
.outside {}
@prefix block not(.not-target, /ignore/);
.box {}
.inner .target {}
.inner .not-target {}
.inner .ignore-1 {}
.inner .ignore-2,
.inner .target {}
@prefix ;
.box {}
@prefix block2;
.box {}
&:hover {}
[href^="https"][target="_blank"] {}
@media screen and (min-width: 768px) {
#media {}
#media #inner,
.media .inner.box {}
}
Use this plugin in PostCSS (e.g.)
const fs = require('fs');
const postcss = require('postcss');
const namespace = require('postcss-namespace');
const css = fs.readFileSync('./sample.css', 'utf-8');
// or postcss([namespace.bem])
postcss([namespace({token: '__'})])
.process(css)
.then(result => console.log(result.css));
Will get output
like following CSS
.outside {}
.block__box {}
.block__inner .block__target {}
.block__inner .not-target {}
.block__inner .ignore-1 {}
.block__inner .ignore-2,
.block__inner .block__target {}
.box {}
.block2__box {}
&:hover {}
[href^="https"][target="_blank"] {}
@media screen and (min-width: 768px) {
#block2__media {}
#block2__media #block2__inner,
.block2__media .block2__inner.block2__box {}
}
not
(string|regexp)...namespace.bem
namespace({token: '__'})
token
namespace({token: '__'})
-
by default1 Close this
git clone git@github.com:totora0155/postcss-namespace.git
2 Change directory
cd postcss-namespace
3 Install modules
npm install
4 Run to script
cd examples && node postcss.js
version | log |
---|---|
1.1.0 | Add bem function. (Alias {token: '__'} ) |
1.0.1 | Fix node.nodes |
1.0.0 | Rewrite with es2015 & Add not func in AtRule |
0.2.5 | Bug fix for :nth* selector & Revert v0.2.2 |
0.2.4 | Bug fix for pseudo selector |
0.2.3 | Bug fix (Tag not output after atrule) |
0.2.2 | Fix, occured error to postcss-selector-not syntax |
0.2.0 | Change at-rule keyword to @prefix from @namespace #1 |
FAQs
PostCSS plugin that prefix a namespace to a selector
The npm package postcss-namespace receives a total of 304 weekly downloads. As such, postcss-namespace popularity was classified as not popular.
We found that postcss-namespace demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.