Skip to content

regex pattern for dependency check #124

@HeikoGr

Description

@HeikoGr

The dependency checker also includes false positives from comment lines:

https://github.com/MagicMirrorOrg/MagicMirror-3rd-Party-Modules/blob/4ee0d8b12a1c1dd04b7ed1e78635857872e05486/scripts/check-modules/dependency-usage.js#L37C1-L42C4

this should be better (proposal by github copilot - needs to be testet)

const DEPENDENCY_CAPTURE_PATTERNS = Object.freeze([
// CommonJS require - with const/let/var declaration
/^(?!\s*//)(?!\s*/*)(?!\s**)\s*(?:const|let|var)\s+.=\srequire\s*(\s*"'["']\s*)/gmu,

// ES6 from import - ONLY with import/export keyword
/^(?!\s*//)(?!\s*/*)(?!\s**)\s*(?:import|export)\s+.*\bfrom\s+"'["']/gmu,

// ES6 side-effect import
/^(?!\s*//)(?!\s*/*)(?!\s**)\s*import\s+"'["']/gmu,

// Dynamic import
/^(?!\s*//)(?!\s*/*)(?!\s**)\s*.import\s(\s*"'["']\s*)/gmu
]);

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions