eslint-plugin-tailwindcss
Advanced tools
Comparing version 1.13.2 to 1.13.3
@@ -6,7 +6,18 @@ 'use strict'; | ||
const REFRESH_RATE = 1000; | ||
const CHECK_REFRESH_RATE = 1000; | ||
let previousConfig = null; | ||
let lastUpdate = null; | ||
let lastCheck = null; | ||
let mergedConfig = null; | ||
let lastModifiedDate = null; | ||
/** | ||
* @see https://stackoverflow.com/questions/9210542/node-js-require-cache-possible-to-invalidate | ||
* @param {string} module The path to the module | ||
* @returns the module's export | ||
*/ | ||
function requireUncached(module) { | ||
delete require.cache[require.resolve(module)]; | ||
return require(module); | ||
} | ||
function loadConfig(config) { | ||
@@ -16,4 +27,16 @@ let loadedConfig = null; | ||
const resolved = path.resolve(); | ||
const resolvedPath = resolved + '/' + config; | ||
try { | ||
loadedConfig = require(resolved + '/' + config); | ||
fs.stat(resolvedPath, (err, stats) => { | ||
if (err) { | ||
loadedConfig = {}; | ||
return; | ||
} | ||
if (lastModifiedDate !== stats.mtime) { | ||
lastModifiedDate = stats.mtime; | ||
loadedConfig = requireUncached(resolvedPath); | ||
} else { | ||
loadedConfig = null; | ||
} | ||
}); | ||
} catch (err) { | ||
@@ -46,8 +69,11 @@ loadedConfig = {}; | ||
const newConfig = convertConfigToString(twConfig) !== convertConfigToString(previousConfig); | ||
const expired = now - lastUpdate > REFRESH_RATE; | ||
const expired = now - lastCheck > CHECK_REFRESH_RATE; | ||
if (newConfig || expired) { | ||
previousConfig = twConfig; | ||
lastUpdate = now; | ||
lastCheck = now; | ||
const userConfig = loadConfig(twConfig); | ||
mergedConfig = resolveConfig(userConfig); | ||
// userConfig is null when config file was not modified | ||
if (userConfig !== null) { | ||
mergedConfig = resolveConfig(userConfig); | ||
} | ||
} | ||
@@ -54,0 +80,0 @@ return mergedConfig; |
{ | ||
"name": "eslint-plugin-tailwindcss", | ||
"version": "1.13.2", | ||
"version": "1.13.3", | ||
"description": "Rules enforcing best practices while using Tailwind CSS", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
71196
2213
6