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

postcss-reporter

Package Overview
Dependencies
Maintainers
2
Versions
28
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

postcss-reporter - npm Package Compare versions

Comparing version 7.0.4 to 7.0.5

41

lib/formatter.js
var pico = require('picocolors');
var path = require('path');
var sortBy = require('lodash.sortby');
var firstBy = require('thenby');
var util = require('./util');

@@ -12,2 +12,21 @@

function createSortFunction(positionless, sortByPosition) {
var positionValue = 0
if (positionless === 'any') { positionValue = 1; }
if (positionless === 'first') { positionValue = 2; }
if (positionless === 'last') { positionValue = 0; }
var sortFunction = firstBy((m) => {
if (!m.line) return 1;
return positionValue;
})
if (sortByPosition) {
sortFunction = sortFunction.thenBy('line').thenBy('column');
}
return sortFunction;
}
module.exports = function (opts) {

@@ -21,2 +40,4 @@ var options = opts || {};

var sortFunction = createSortFunction(positionless, sortByPosition);
return function (input) {

@@ -30,19 +51,3 @@ var messages = input.messages.filter(function (message) {

var orderedMessages = sortBy(
messages,
function (m) {
if (!m.line) return 1;
if (positionless === 'any') return 1;
if (positionless === 'first') return 2;
if (positionless === 'last') return 0;
},
function (m) {
if (!sortByPosition) return 1;
return m.line;
},
function (m) {
if (!sortByPosition) return 1;
return m.column;
}
);
var orderedMessages = messages.sort(sortFunction);

@@ -49,0 +54,0 @@ var output = '\n';

var defaultFormatter = require('./formatter');
var pico = require('picocolors');
var util = require('./util');
var groupBy = require('lodash.groupby');
var forOwn = require('lodash.forown');
var difference = require('lodash.difference');

@@ -51,16 +48,26 @@ module.exports = function (opts = {}) {

var sourceGroupedMessages = groupBy(messagesToLog, (message) => {
return util.getLocation(message).file || resultSource;
});
var sourceGroupedMessages = messagesToLog.reduce((grouped, message) => {
const key = util.getLocation(message).file || resultSource;
if (!grouped.hasOwnProperty(key)) {
grouped[key] = [];
}
grouped[key].push(message);
return grouped;
}, {});
var report = '';
forOwn(sourceGroupedMessages, function (messages, source) {
report += formatter({
messages: messages,
source: source,
});
});
for (const source in sourceGroupedMessages) {
if (sourceGroupedMessages.hasOwnProperty(source)) {
report += formatter({
messages: sourceGroupedMessages[source],
source: source,
});
}
}
if (opts.clearReportedMessages) {
result.messages = difference(result.messages, messagesToLog);
result.messages = result.messages.filter(message => !messagesToLog.includes(message));
}

@@ -70,3 +77,3 @@

var messagesToClear = result.messages.filter(pluginFilter);
result.messages = difference(result.messages, messagesToClear);
result.messages = result.messages.filter(message => !messagesToClear.includes(message));
}

@@ -73,0 +80,0 @@

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

var get = require('lodash.get');
exports.getLocation = function (message) {

@@ -11,3 +9,3 @@ var messageNode = message.node;

var messageInput = get(messageNode, 'source.input');
var messageInput = messageNode && messageNode.source && messageNode.source.input;

@@ -14,0 +12,0 @@ if (!messageInput) return location;

{
"name": "postcss-reporter",
"version": "7.0.4",
"version": "7.0.5",
"description": "Log PostCSS messages in the console",

@@ -28,9 +28,5 @@ "main": "index.js",

"dependencies": {
"lodash.difference": "^4.5.0",
"lodash.forown": "^4.4.0",
"lodash.get": "^4.4.2",
"lodash.groupby": "^4.6.0",
"lodash.sortby": "^4.7.0",
"picocolors": "^1.0.0"
"picocolors": "^1.0.0",
"thenby": "^1.3.4"
}
}
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