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

classless-js

Package Overview
Dependencies
Maintainers
1
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

classless-js - npm Package Compare versions

Comparing version 0.1.5 to 0.1.6

test/tmp.txt

30

bin/getCSSElems.js
const glob = require('glob');
const request = require('sync-request');
const fs = require('fs');
function getClassesAndIds(stylesheet) {
const classes = [];
const ids = [];
const elemArray = [];
let temp;
// Get the classes
temp = stylesheet.match(/\.\D\w+/g);
// Get the classes and id's
temp = stylesheet.match(/[\.|#]\w+([-]?(-|--)?\w+((-|--)\w+)?)?/g);
if (temp) {
classes.push.apply(classes, temp);
elemArray.push.apply(elemArray, temp);
}
// Get the IDs
temp = stylesheet.match(/\#\D\w+/g);
if (temp) {
ids.push.apply(ids, temp);
}
// Combine classes and ID's and filter for unique ones
const filteredElems = classes.concat(ids)
.filter((v, i, a) => a.indexOf(v) === i);
const filteredElems = elemArray.filter((v, i, a) => a.indexOf(v) === i);
// Return all of the unique elements
// console.log(filteredElems);
return filteredElems;
}
function getAllCSSElems(cssFilePath) {
function getAllCSSElems(cssPathInput) {
//If the CSS file is a url, read the URL and get classes + ids
if (cssFilePath.includes('http')) {
let cssText = getCSSTextFromURL(cssFilePath);
if (cssPathInput.includes('http')) {
let cssText = getCSSTextFromURL(cssPathInput);
return (getClassesAndIds(cssText));

@@ -41,3 +33,5 @@ }

let eachCSSElemArray = [];
const files = new glob(cssFilePath, {sync: true});
const files = new glob(cssPathInput, {sync: true});
const cssFilePath = cssPathInput.substr(0, cssPathInput.indexOf(','));
// console.log(cssFilePath);

@@ -44,0 +38,0 @@ files.forEach(file => {

18

bin/HTMLUtils.js

@@ -27,9 +27,15 @@ const glob = require('glob');

substring.forEach(item => {
// get all id elements and add '#' to all Elem list
if (elem.startsWith("id")) {
allElems.push('#' + item);
// This is for frameworks
if (item.includes("{") || item.includes("}") || item.includes("(") || item.includes(")") || item.includes("/")) {
console.log(item);
return
} else {
// get all id elements and add '#' to all Elem list
if (elem.startsWith("id")) {
allElems.push('#' + item);
// get all class elements and add '.' to all Elem list
} else {
allElems.push('.' + item)
// get all class elements and add '.' to all Elem list
} else {
allElems.push('.' + item)
}
}

@@ -36,0 +42,0 @@ })

@@ -23,2 +23,10 @@ #!/usr/bin/env node

fs.writeFile('tmp.txt', cssElemArray, function(err) {
if(err) {
return console.log(err);
}
console.log("The file was saved!");
});
// get all of the HTML elements used

@@ -25,0 +33,0 @@ const totalHTMLElemArray = htmlUtils.getAllHTMLElems(htmlFilePath);

{
"name": "classless-js",
"version": "0.1.5",
"version": "0.1.6",
"description": "Enforce and question your design system by checking your classes against an approved class list",

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

@@ -30,1 +30,2 @@ # Classless.js

- CSS as local or URL link
- Ember plugin

Sorry, the diff of this file is not supported yet

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