Socket
Socket
Sign inDemoInstall

csss

Package Overview
Dependencies
69
Maintainers
1
Versions
22
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.4.5 to 0.4.6

style/dirty.css

109

csss.js

@@ -16,3 +16,4 @@ #!/usr/bin/env node

duplicateSelectors = 0,
mergedSelectors = 0;
mergedSelectors = 0,
consoleOutput;

@@ -33,2 +34,3 @@

duplicateSelectors = 0;
consoleOutput = '';

@@ -44,3 +46,5 @@ csss.getCSSFiles(inputFiles)

} else {
csss.printMultipleSelectors(response[0][0], response[0][1], response[0][2]);
csss.printMultipleSelectors(response[0][0], response[0][1], response[0][2]).then(function (results) {
console.log(results[0]);
});
}

@@ -227,39 +231,17 @@ });

csss.printHead();
var printPromise = promise.map([1], function (map) {
var rules = cssObj.stylesheet.rules,
declarations = {},
i, d, j, sel, media, pos;
csss.printHead();
/* print multiple selectors outside media queries */
for (sel in selectors) {
if (selectors[sel].length > 1) {
console.log((('DUPLICATE: ').bold + sel).red);
declarations = {};
for (i in selectors[sel]) {
d = rules[selectors[sel][i]].declarations;
var rules = cssObj.stylesheet.rules,
declarations = {},
i, d, j, sel, media, pos;
for (j in d) {
if (declarations[d[j].property] == null) {
declarations[d[j].property] = 0;
}
declarations[d[j].property] ++;
}
csss.printMultipleSelectorsLine(rules[selectors[sel][i]].position);
duplicateSelectors++;
}
csss.printSharingProperties(declarations);
}
}
/* print multiple selectors outside media queries */
for (media in mediaSelectors) {
for (sel in mediaSelectors[media]) {
if (mediaSelectors[media][sel].length > 1) {
console.log((('DUPLICATE: ').bold + sel).red + (' @media ' + media).blue);
/* print multiple selectors outside media queries */
for (sel in selectors) {
if (selectors[sel].length > 1) {
consoleOutput += ((('DUPLICATE: ').bold + sel).red) + '\n\r';
declarations = {};
for (i in mediaSelectors[media][sel]) {
pos = mediaSelectors[media][sel][i];
d = rules[pos.media].rules[pos.rule].declarations;
for (i in selectors[sel]) {
d = rules[selectors[sel][i]].declarations;

@@ -273,3 +255,3 @@ for (j in d) {

csss.printMultipleSelectorsLine(rules[pos.media].rules[pos.rule].position);
csss.printMultipleSelectorsLine(rules[selectors[sel][i]].position);
duplicateSelectors++;

@@ -280,7 +262,37 @@ }

}
}
console.log(('\n\rDuplicate selectors: ' + duplicateSelectors + '\n\r').yellow);
csss.printFooter();
/* print multiple selectors outside media queries */
for (media in mediaSelectors) {
for (sel in mediaSelectors[media]) {
if (mediaSelectors[media][sel].length > 1) {
consoleOutput += ((('DUPLICATE: ').bold + sel).red + (' @media ' + media).blue) + '\n\r';
declarations = {};
for (i in mediaSelectors[media][sel]) {
pos = mediaSelectors[media][sel][i];
d = rules[pos.media].rules[pos.rule].declarations;
for (j in d) {
if (declarations[d[j].property] == null) {
declarations[d[j].property] = 0;
}
declarations[d[j].property] ++;
}
csss.printMultipleSelectorsLine(rules[pos.media].rules[pos.rule].position);
duplicateSelectors++;
}
csss.printSharingProperties(declarations);
}
}
}
consoleOutput += (('Duplicate selectors: ' + duplicateSelectors + '\n\r\n\r').yellow);
csss.printFooter();
return consoleOutput;
});
return promise.resolve(printPromise);
},

@@ -299,3 +311,3 @@

}
console.log((' sharing ' + p + ' ' + txt + '\n').green);
consoleOutput += ((' sharing ' + p + ' ' + txt + '\n').green) + '\n\r';
},

@@ -308,5 +320,5 @@

if (inputFiles.length > 1) {
console.log(' ' + info.source + ' > line ' + info.start.line);
consoleOutput += (' ' + info.source + ' > line ' + info.start.line) + '\n\r';
} else {
console.log(' line ' + info.start.line);
consoleOutput += (' line ' + info.start.line) + '\n\r';
}

@@ -316,10 +328,9 @@ },

printHead: function () {
console.log(('CSSS START').rainbow.inverse);
console.log(('\n\rLooking for muliple selectors in').underline);
console.log(inputFiles.toString().replace(/,/g, '\n').blue);
console.log('');
consoleOutput += (('CSSS START\n\r\n\r').rainbow.inverse);
consoleOutput += (('Looking for muliple selectors in\n\r').underline);
consoleOutput += (inputFiles.toString().replace(/,/g, '\n').blue) + '\n\r\n\r';
},
printFooter: function () {
console.log(('CSSS END').rainbow.inverse);
consoleOutput += (('CSSS END').rainbow.inverse);
},

@@ -447,4 +458,4 @@

//program
// .option('-m, --merge <newFileName>', 'merge all duplicate selectors into new file (still WIP!)');
program
.option('-m, --merge <newFileName>', 'merge all duplicate selectors into new file (still WIP!)');

@@ -451,0 +462,0 @@ program

{
"name": "csss",
"version": "0.4.5",
"version": "0.4.6",
"description": "CSSS is a tool that detects multiple CSS selectors from your stylesheets and it works across multiple files.",

@@ -12,3 +12,3 @@ "author": "Anthony Weber",

"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
"test": "mocha"
},

@@ -15,0 +15,0 @@ "keywords": [

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

[![NPM version](https://img.shields.io/npm/v/csss.svg?style=flat)](https://www.npmjs.com/package/csss)
# CSS Shampoo

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

@@ -9,3 +9,3 @@ 'use strict';

csss = require('./../csss.js'),
testFiles = ['./test/test.css'],
testFiles = ['./test/css/test-merge.css'],
mergedCSS, testCSS;

@@ -16,10 +16,10 @@

//get CSS from test input file
//parse it
//search for duplicates
//merge selectors
beforeEach(function () {
//get CSS from test input file
return csss.getCSSFiles(testFiles).then(function (rawCSS) {
//parse it
var parsedCSS = csss.parseCss(rawCSS, testFiles);
//search for duplicates
csss.detectDuplicateSelectors(parsedCSS).then(function (r) {
//merge selectors
csss.mergeCSS(r[0][0], r[0][1], r[0][2]).then(function (m) {

@@ -32,4 +32,4 @@ mergedCSS = css.stringify(m[0]);

//get CSS from result file for comparing
beforeEach(function () {
//get CSS from result file for comparing
return csss.getCSSFiles(['./test/merge-results.css']).then(function (rawCSS) {

@@ -36,0 +36,0 @@ testCSS = css.stringify(csss.parseCss(rawCSS, testFiles));

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc