Skip to content

Commit 9457c42

Browse files
committed
🔨 update regex
1 parent 242358c commit 9457c42

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/commands/highlight-unused-imports.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,13 +43,13 @@ async function unusedImportsActiveFile(editor) {
4343
if (text.includes(solhintRuleString)) return;
4444

4545
const importRegex = /import\s+((?:\{.+?\}\s+from\s+)?(?:\".*?\"|'.*?'));/g;
46-
const imports = text.match(importRegex) || [];
46+
const importStatements = text.match(importRegex) || [];
4747
const unusedImportDecorations = [];
4848

49-
for (const importStatement of imports) {
49+
for (const importStatement of importStatements) {
5050
const imports = extractImports(importStatement);
5151
for (const item of imports) {
52-
const regex = new RegExp(item, 'g');
52+
const regex = new RegExp(`\\b${item}\\b`, 'g');
5353
const itemOccurrencesInImportStatement = (importStatement.replace(/\.sol\b/g, '').match(regex) || []).length;
5454
const totalOccurrencesOfItem = (text.match(new RegExp(`\\b${item}\\b`, 'gi')) || []).length;
5555
if (totalOccurrencesOfItem == itemOccurrencesInImportStatement) {

0 commit comments

Comments
 (0)