Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

postcss-styl

Package Overview
Dependencies
Maintainers
1
Versions
43
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

postcss-styl - npm Package Compare versions

Comparing version 0.5.2 to 0.5.3

60

lib/stringifier.js

@@ -98,15 +98,57 @@ "use strict"

/**
* Remove commnets on selector
* @param {string} selector
* @returns {string} removed comments
*/
function removeLastCommentsSelector(selector) {
return selector.replace(/\/\/.*$/u, "").replace(/\/\*.*\*\/\s*$/u, "")
}
/**
* Adjust selectors indent
* @param {node} node
* @param {string} selectors
* @param {string} indent
* @returns {string} indented selectors
*/
function adjustSelectorsIndent(node, selectors, indent) {
const lines = toLines(selectors)
return lines
.map((line, index) => {
const trimed = line.trim()
if (!trimed) {
// ignore blank line
return line
}
if (!node.pythonic) {
// If it is not pythonic, adjust the indentation other than comma delimiter.
if (/^,/u.test(trimed)) {
return line
}
const lastLine = lines[index - 1]
if (
lastLine &&
/,$/u.test(removeLastCommentsSelector(lastLine).trim())
) {
return line
}
}
return index === 0
? line.replace(/^\s*/u, "")
: line.replace(/^\s*/u, indent)
})
.join("")
}
module.exports = class StylusStringifier extends Stringifier {
rawValue(node, prop) {
const value = this.rawValuePlain(node, prop)
if (
prop === "selector" &&
node.parent &&
node.parent.pythonic &&
/\r\n|\r|\n/gu.test(value)
) {
if (prop === "selector" && /\r\n|\r|\n/gu.test(value)) {
const indent = this.getIndent(node)
return toLines(value)
.map(line => line.replace(/^\s+/u, indent))
.join("")
return adjustSelectorsIndent(node, value, indent)
}

@@ -113,0 +155,0 @@ return value

2

package.json
{
"name": "postcss-styl",
"version": "0.5.2",
"version": "0.5.3",
"description": "PostCSS parser plugin for converting Stylus syntax to PostCSS AST.",

@@ -5,0 +5,0 @@ "main": "lib/index.js",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc