Socket
Socket
Sign inDemoInstall

postcss-less

Package Overview
Dependencies
Maintainers
1
Versions
46
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

postcss-less - npm Package Compare versions

Comparing version 5.0.0 to 6.0.0

49

lib/index.js

@@ -0,1 +1,3 @@

/* eslint-disable import/no-extraneous-dependencies */
const Input = require('postcss/lib/input');

@@ -13,2 +15,49 @@

// To handle double-slash comments (`//`) we end up creating a new tokenizer
// in certain cases (see `lib/nodes/inline-comment.js`). However, this means
// that any following node in the AST will have incorrect start/end positions
// on the `source` property. To fix that, we'll walk the AST and compute
// updated positions for all nodes.
parser.root.walk((node) => {
const offset = input.css.lastIndexOf(node.source.input.css);
if (offset === 0) {
// Short circuit - this node was processed with the original tokenizer
// and should therefore have correct position information.
return;
}
// This ensures that the chunk of source we're processing corresponds
// strictly to a terminal substring of the input CSS. This should always
// be the case, but if it ever isn't, we prefer to fail instead of
// producing potentially invalid output.
// istanbul ignore next
if (offset + node.source.input.css.length !== input.css.length) {
throw new Error('Invalid state detected in postcss-less');
}
const newStartOffset = offset + node.source.start.offset;
const newStartPosition = input.fromOffset(offset + node.source.start.offset);
// eslint-disable-next-line no-param-reassign
node.source.start = {
offset: newStartOffset,
line: newStartPosition.line,
column: newStartPosition.col
};
// Not all nodes have an `end` property.
if (node.source.end) {
const newEndOffset = offset + node.source.end.offset;
const newEndPosition = input.fromOffset(offset + node.source.end.offset);
// eslint-disable-next-line no-param-reassign
node.source.end = {
offset: newEndOffset,
line: newEndPosition.line,
column: newEndPosition.col
};
}
});
return parser.root;

@@ -15,0 +64,0 @@ },

2

lib/LessParser.js

@@ -1,2 +0,2 @@

/* eslint no-param-reassign: off */
/* eslint-disable import/no-extraneous-dependencies, no-param-reassign */

@@ -3,0 +3,0 @@ const Comment = require('postcss/lib/comment');

@@ -0,1 +1,3 @@

/* eslint-disable import/no-extraneous-dependencies */
const Stringifier = require('postcss/lib/stringifier');

@@ -2,0 +4,0 @@

@@ -1,2 +0,2 @@

/* eslint no-param-reassign: off */
/* eslint-disable import/no-extraneous-dependencies, no-param-reassign */

@@ -3,0 +3,0 @@ const tokenize = require('postcss/lib/tokenize');

@@ -1,2 +0,2 @@

/* eslint-disable no-param-reassign */
/* eslint-disable import/no-extraneous-dependencies, no-param-reassign */

@@ -11,3 +11,3 @@ const tokenizer = require('postcss/lib/tokenize');

const bits = [];
let last;
let endOffset;
let remainingInput;

@@ -24,3 +24,8 @@

remainingInput = token[1].substring(token[1].indexOf('\n'));
remainingInput += this.input.css.valueOf().substring(this.tokenizer.position());
const untokenizedRemainingInput = this.input.css
.valueOf()
.substring(this.tokenizer.position());
remainingInput += untokenizedRemainingInput;
endOffset = token[3] + untokenizedRemainingInput.length - remainingInput.length;
} else {

@@ -34,7 +39,8 @@ // If the tokenizer went to the next line go back

bits.push(token[1]);
last = token;
// eslint-disable-next-line prefer-destructuring
endOffset = token[2];
token = this.tokenizer.nextToken({ ignoreUnclosed: true });
}
const newToken = ['comment', bits.join(''), first[2], last[2]];
const newToken = ['comment', bits.join(''), first[2], endOffset];
this.inlineComment(newToken);

@@ -41,0 +47,0 @@

{
"name": "postcss-less",
"version": "5.0.0",
"version": "6.0.0",
"description": "LESS parser for PostCSS",

@@ -49,2 +49,5 @@ "license": "MIT",

},
"peerDependencies": {
"postcss": "^8.3.5"
},
"keywords": [

@@ -51,0 +54,0 @@ "css",

@@ -12,3 +12,3 @@ [tests]: https://img.shields.io/circleci/project/github/shellscape/postcss-less.svg

[PostCSS-SCSS]: https://github.com/postcss/postcss-scss
[LESS]: http://lesless.org
[LESS]: https://lesscss.org/
[Autoprefixer]: https://github.com/postcss/autoprefixer

@@ -15,0 +15,0 @@ [Stylelint]: http://stylelint.io/

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