Optionalconfig: Partial<MagicStringSelectorConfig>ReadonlycategoryRule category for grouping.
ReadonlydescriptionRule description explaining what it checks.
ReadonlyidUnique rule identifier (scoped to plugin). Format: "plugin-name:rule-name" (e.g., "angular-standalone:component-not-standalone")
ReadonlynameHuman-readable rule name.
ReadonlyseverityRule severity level.
ReadonlytagsTags for filtering and search.
Analyze a source file and return findings.
Analysis context with file, project, and API access
Promise resolving to array of analysis results
Detects magic string selector arguments passed to dynamic component loading methods. Passing a raw string or template literal to methods like
getComponentBySelectororloadComponentcreates fragile implicit contracts that cannot be verified by the TypeScript compiler and break silently when component selectors are renamed.Detection scope:
CallExpressionnodes whose called method name matches a configuredtargetMethodPatternslist (default:'getComponentBySelector','loadComponent',/get.*Component/i).StringLiteral->argumentType: 'string-literal',severity: 'error'NoSubstitutionTemplateLiteral/TemplateExpression->argumentType: 'template-literal',severity: 'error'PropertyAccessExpression(e.g.this.config.selector) ->argumentType: 'config-property',severity: 'warning'; withselectorPropertyNamesonly when the accessed property is one of themSkipped:
.d.tsdeclaration files.Pattern compilation:
targetMethodPatternsare compiled to exact-match regexes ('^' + p + '$'), preventing partial matches such as'load'matching'loadComponentFactory'.RegExpentries are passed through unchanged (they express partial matching explicitly, e.g./get.*Component/i).Example