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

eslint-plugin-tailwindcss

Package Overview
Dependencies
Maintainers
1
Versions
184
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

eslint-plugin-tailwindcss - npm Package Compare versions

Comparing version 3.17.1 to 3.17.2

74

lib/util/cssFiles.js

@@ -6,5 +6,5 @@ 'use strict';

const postcss = require('postcss');
const removeDuplicatesFromArray = require('./removeDuplicatesFromArray');
const classRegexp = /\.([^\.\,\s\n\:\(\)\[\]\'~\+\>\*\\]*)/gim;
let previousGlobsResults = [];
let lastUpdate = null;

@@ -14,7 +14,2 @@ let classnamesFromFiles = [];

/**
* @type {Map<string, number}
*/
const prevEditedTimestamp = new Map()
/**
* Read CSS files and extract classnames

@@ -27,54 +22,25 @@ * @param {Array} patterns Glob patterns to locate files

const now = new Date().getTime();
const files = fg.sync(patterns, { suppressErrors: true });
const newGlobs = previousGlobsResults.flat().join(',') != files.flat().join(',');
const expired = lastUpdate === null || now - lastUpdate > refreshRate;
if (!expired) {
return classnamesFromFiles;
}
const files = fg.sync(patterns, { suppressErrors: true, stats: true });
lastUpdate = now;
/**
* @type {Set<string}
*/
const detectedClassnames = new Set();
/**
* @type {Set<string>}
*/
const filesSet = new Set();
for (const { path: file, stats } of files) {
filesSet.add(file);
if (!stats) {}
// file is not changed -> we do need to do extra work
else if (prevEditedTimestamp.get(file) === stats.mtimeMs) {
continue;
} else {
prevEditedTimestamp.set(file, stats.mtimeMs);
if (newGlobs || expired) {
previousGlobsResults = files;
lastUpdate = now;
let detectedClassnames = [];
for (const file of files) {
const data = fs.readFileSync(file, 'utf-8');
const root = postcss.parse(data);
root.walkRules((rule) => {
const regexp = /\.([^\.\,\s\n\:\(\)\[\]\'~\+\>\*\\]*)/gim;
const matches = [...rule.selector.matchAll(regexp)];
const classnames = matches.map((arr) => arr[1]);
detectedClassnames.push(...classnames);
});
detectedClassnames = removeDuplicatesFromArray(detectedClassnames);
}
const data = fs.readFileSync(file, 'utf-8');
const root = postcss.parse(data);
root.walkRules((rule) => {
for (const match of rule.selector.matchAll(classRegexp)) {
detectedClassnames.add(match[1]);
}
});
classnamesFromFiles = detectedClassnames;
}
// avoiding memory leak
{
/**
* @type {string[]}
*/
const keysToDelete = []
for (const cachedFilePath of prevEditedTimestamp.keys()) {
if (!filesSet.has(cachedFilePath)) {
keysToDelete.push(cachedFilePath);
}
}
for (const key of keysToDelete) {
prevEditedTimestamp.delete(key);
}
}
classnamesFromFiles = [...detectedClassnames];
return classnamesFromFiles
return classnamesFromFiles;
};
module.exports = generateClassnamesListSync;
{
"name": "eslint-plugin-tailwindcss",
"version": "3.17.1",
"version": "3.17.2",
"description": "Rules enforcing best practices while using Tailwind CSS",

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

@@ -44,3 +44,2 @@ # eslint-plugin-tailwindcss

- perf: [`no-custom-classname` optimization](https://github.com/francoismassart/eslint-plugin-tailwindcss/pull/338) (by [XantreDev](https://github.com/XantreDev) πŸ™)
- fix: [support `tag.div` and `tag(Component)`](https://github.com/francoismassart/eslint-plugin-tailwindcss/pull/302) (by [nihalgonsalves](https://github.com/nihalgonsalves) πŸ™)

@@ -47,0 +46,0 @@ - feat: [**support flat config and ESLint 9**](https://github.com/francoismassart/eslint-plugin-tailwindcss/pull/330) (by [kazupon](https://github.com/kazupon) πŸ™)

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