From 3ead715375aa0a471be25a3ee55fb4b908dadebc Mon Sep 17 00:00:00 2001 From: Guido Gasper Date: Tue, 20 Aug 2019 21:31:46 +0300 Subject: [PATCH] Fix regex. Previously it wrongfully matched variables even if their name just started with another variable's name. --- index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.js b/index.js index 799d29e..efdc41a 100644 --- a/index.js +++ b/index.js @@ -52,7 +52,7 @@ function findUnusedVars(strDir, opts) { // Store unused vars from all files and loop through each variable const unusedVars = variables.filter(variable => { - const re = new RegExp(regExpQuote(variable), 'g'); + const re = new RegExp(`(${regExpQuote(variable)})\\b(?!-)`, 'g'); return sassFilesString.match(re).length === 1; });