Skip to main content

fallow_core/plugins/
mod.rs

1//! Plugin system for framework-aware codebase analysis.
2//!
3//! Plugins read JS, TS and JSON config files with the Oxc parser and walk the
4//! AST. They never run JavaScript. Each plugin implements the [`Plugin`] trait
5//! with static defaults (entry patterns, config file patterns, used exports)
6//! and reads config files for entries, dependencies and setup files.
7
8use std::path::{Path, PathBuf};
9
10use fallow_config::{
11    AutoImportRule, EntryPointRole, JsxImportSourceRule, PackageJson, UsedClassMemberRule,
12};
13use fallow_types::semantic::SemanticFrameworkContract;
14use regex::Regex;
15
16use entry_point_roles::builtin_entry_point_role;
17#[cfg(test)]
18use entry_point_roles::{
19    RUNTIME_ENTRY_POINT_PLUGINS, SUPPORT_ENTRY_POINT_PLUGINS, TEST_ENTRY_POINT_PLUGINS,
20};
21
22/// Whether an entry rule of `result` matches the project-relative `path`, as
23/// entry point discovery compiles and matches the rules.
24#[cfg(test)]
25fn entry_rules_match(result: &PluginResult, path: &str) -> bool {
26    result
27        .entry_patterns
28        .iter()
29        .filter_map(|rule| CompiledPathRule::for_entry_rule(rule, "entry pattern"))
30        .any(|rule| rule.matches(path))
31}
32
33/// Which workspace diagnostic kind a plugin-stage advisory becomes.
34#[derive(Debug, Clone, Copy, PartialEq, Eq)]
35pub enum PluginConfigEffect {
36    /// The plugin could not read the key in full, so part of what it declares
37    /// never reached the analysis.
38    Unreadable,
39    /// The plugin read the key and does not model its effect, so a modeled
40    /// default the run would otherwise have applied stood down.
41    NotModeled,
42}
43
44/// One advisory about a config file a plugin read, before it becomes a
45/// [`fallow_config::WorkspaceDiagnostic`].
46///
47/// A plugin knows the fact (which config file, which key, why) but not the root
48/// the message renders against: in a workspace run its own `root` is the package
49/// root, while the diagnostic's path and message are project-root-relative. The
50/// conversion therefore happens once, where every plugin result has converged on
51/// the project root, and `config_path` is kept ABSOLUTE until then so the
52/// registry's canonical dedupe and the serialized root-relative form both work
53/// from one value (issue #2736).
54#[derive(Debug, Clone, PartialEq, Eq)]
55pub struct PluginConfigDiagnostic {
56    /// Absolute path of the config file that was read.
57    pub config_path: PathBuf,
58    /// The plugin that read it, as it labels itself. Module Federation options
59    /// reach four bundler plugins inline, and each names itself rather than the
60    /// reader, because the config file the user must edit is the bundler's.
61    pub plugin: String,
62    /// The config key the advisory is about (`exposes`, `remotes`,
63    /// `components`, `imports`).
64    pub key: String,
65    /// Why, as a kebab-case token from the resulting kind's open set.
66    pub reason: String,
67    /// Which workspace diagnostic kind this becomes.
68    pub effect: PluginConfigEffect,
69}
70
71impl PluginConfigDiagnostic {
72    /// Build an advisory about a key a plugin could not read in full.
73    pub(super) fn unreadable(
74        config_path: &Path,
75        plugin: &str,
76        key: &str,
77        reason: &'static str,
78    ) -> Self {
79        Self {
80            config_path: config_path.to_path_buf(),
81            plugin: plugin.to_owned(),
82            key: key.to_owned(),
83            reason: reason.to_owned(),
84            effect: PluginConfigEffect::Unreadable,
85        }
86    }
87
88    /// Build an advisory about a key whose effect the plugin does not model.
89    pub(crate) fn not_modeled(
90        config_path: &Path,
91        plugin: &str,
92        key: &str,
93        reason: &'static str,
94    ) -> Self {
95        Self {
96            config_path: config_path.to_path_buf(),
97            plugin: plugin.to_owned(),
98            key: key.to_owned(),
99            reason: reason.to_owned(),
100            effect: PluginConfigEffect::NotModeled,
101        }
102    }
103
104    /// Render this advisory against the PROJECT root, which is the root every
105    /// consumer's paths are relative to.
106    #[must_use]
107    pub fn into_workspace_diagnostic(self, root: &Path) -> fallow_config::WorkspaceDiagnostic {
108        let Self {
109            config_path,
110            plugin,
111            key,
112            reason,
113            effect,
114        } = self;
115        let kind = match effect {
116            PluginConfigEffect::Unreadable => {
117                fallow_config::WorkspaceDiagnosticKind::PluginConfigUnreadable {
118                    plugin,
119                    key,
120                    reason,
121                }
122            }
123            PluginConfigEffect::NotModeled => {
124                fallow_config::WorkspaceDiagnosticKind::PluginEffectNotModeled {
125                    plugin,
126                    key,
127                    reason,
128                }
129            }
130        };
131        fallow_config::WorkspaceDiagnostic::new(root, config_path, kind)
132    }
133}
134
135/// Result of resolving a plugin's config file.
136#[derive(Debug, Default)]
137pub struct PluginResult {
138    /// Additional entry point glob patterns discovered from config.
139    entry_patterns: Vec<PathRule>,
140    /// When true, `entry_patterns` from config replace the plugin's static
141    /// `entry_patterns()` defaults instead of adding to them. Tools like Vitest
142    /// and Jest treat their config's include/testMatch as a replacement for built-in
143    /// defaults, so when the config is explicit the static patterns must be dropped.
144    replace_entry_patterns: bool,
145    /// When true, a replacing config removes only the static defaults, and the
146    /// replacing configs of one plugin run add their patterns together. When
147    /// false, the last replacing config of the plugin wins.
148    accumulate_config_entry_patterns: bool,
149    /// When true, `used_exports` from config replace the plugin's static
150    /// `used_export_rules()` defaults instead of adding to them.
151    replace_used_export_rules: bool,
152    /// Additional export-usage rules discovered from config.
153    used_exports: Vec<UsedExportRule>,
154    /// Exports that the tool reads from the files a config names. These rules
155    /// join the config-file export credit, so they count only under
156    /// `includeEntryExports`. Unlike `used_exports`, they never make an entry
157    /// point reportable when `includeEntryExports` is off.
158    entry_export_credits: Vec<UsedExportRule>,
159    /// Class member rules that should never be flagged as unused. Contributed
160    /// by plugins that know their framework invokes these methods at runtime
161    /// and may scope suppression via `extends` / `implements` constraints when
162    /// the method name is too common to allowlist globally.
163    used_class_members: Vec<UsedClassMemberRule>,
164    /// Dependencies referenced in config files (should not be flagged as unused).
165    referenced_dependencies: Vec<String>,
166    /// Dependencies a config credits only to the package that owns it, keyed
167    /// by the path of that package's `package.json`.
168    package_referenced_dependencies: Vec<(PathBuf, String)>,
169    /// Packages that a config needs installed. See [`RequiredDependency`].
170    required_dependencies: Vec<RequiredDependency>,
171    /// Additional files that are always considered used.
172    always_used_files: Vec<String>,
173    /// Path alias mappings discovered from config (prefix -> replacement directory).
174    path_aliases: Vec<(String, String)>,
175    /// The prefixes of the `path_aliases` that point at a directory that the
176    /// config names. An unresolved import under one of these prefixes reports,
177    /// also when a virtual module prefix of the plugin matches it.
178    checked_alias_prefixes: Vec<String>,
179    /// Setup/helper files referenced from config.
180    setup_files: Vec<PathBuf>,
181    /// Test fixture glob patterns discovered from config.
182    fixture_patterns: Vec<String>,
183    /// Absolute directories to include when resolving SCSS/Sass `@import` and
184    /// `@use` specifiers. Contributed by framework plugins that read their
185    /// tool's equivalent of `includePaths` (e.g. Angular's
186    /// `stylePreprocessorOptions.includePaths` from `angular.json` /
187    /// `project.json`). Bare SCSS specifiers that fail to resolve relative to
188    /// the importing file retry against each include path using the SCSS
189    /// partial / directory-index conventions.
190    scss_include_paths: Vec<PathBuf>,
191    /// URL-to-filesystem static directory mappings discovered from tool config.
192    /// Each tuple is `(absolute_source_dir, normalized_url_mount)`.
193    static_dir_mappings: Vec<(PathBuf, String)>,
194    framework_static_dir_mappings: Vec<(PathBuf, String)>,
195    /// File-scoped dependency providers. Matching imports are considered
196    /// available from the framework runtime and are not unlisted dependencies.
197    provided_dependencies: Vec<ProvidedDependencyRule>,
198    /// Advisories about the config file this result was read from. A plugin
199    /// records the fact here instead of printing it, so it reaches the report
200    /// and every consumer rather than only a stderr line.
201    config_diagnostics: Vec<PluginConfigDiagnostic>,
202    /// Where a Module Federation config exposes a file or declares a remote
203    /// alias, kept so a trace can name the config (issue #2796).
204    federation_sources: Vec<FederationSource>,
205    /// JSX import sources that the config sets for the files it transforms.
206    /// The resolver adds the runtime edge to each matching file without a
207    /// JSX pragma.
208    jsx_import_sources: Vec<JsxImportSourceRule>,
209    /// Runtime packages that the JSX transform of a config imports when the
210    /// config sets no import source. The analysis credits a package only when
211    /// a matching file has JSX and no pragma. These rules never add a graph
212    /// edge.
213    jsx_package_credits: Vec<JsxImportSourceRule>,
214    /// The directories of the tsconfig files that set the JSX runtime of
215    /// TypeScript files, each with the runtime that the tsconfig selects.
216    /// Vite then does not use its own default runtime for the TypeScript
217    /// files below these directories.
218    tsconfig_jsx_dirs: Vec<registry::TsconfigJsxDir>,
219}
220
221/// Match the Module Federation sources of one analysis against the discovered
222/// files, for the trace output.
223///
224/// Only a project with a Federation config pays for the match, and it runs
225/// once per analysis, so a trace reads plain data. A remote that a literal
226/// runtime call (`registerRemotes`, `loadRemote`, `init`, `createInstance`) names traces to the source
227/// file, with the function name as the key.
228#[must_use]
229fn federation_trace_provenance(
230    root: &Path,
231    files: &[crate::discover::DiscoveredFile],
232    sources: &[FederationSource],
233    modules: &[crate::extract::ModuleInfo],
234) -> fallow_types::trace::TraceProvenance {
235    let mut provenance = fallow_types::trace::TraceProvenance::default();
236    push_runtime_remote_sources(&mut provenance, root, files, modules);
237    if sources.is_empty() {
238        return provenance;
239    }
240    let mut exposed = Vec::new();
241    for source in sources {
242        let config = source
243            .config_path
244            .strip_prefix(root)
245            .unwrap_or(&source.config_path)
246            .to_path_buf();
247        let trace_source = fallow_types::trace::TraceSource {
248            kind: "module-federation".to_owned(),
249            plugin: source.plugin.clone(),
250            config,
251            key: source.key.to_owned(),
252        };
253        match &source.target {
254            FederationSourceTarget::Exposed(rule) => {
255                if let Some(compiled) =
256                    CompiledPathRule::for_entry_rule(rule, "Module Federation exposes target")
257                {
258                    exposed.push((compiled, trace_source));
259                }
260            }
261            FederationSourceTarget::Remote(alias) => {
262                provenance.push_dependency(alias.clone(), trace_source);
263            }
264        }
265    }
266    if exposed.is_empty() {
267        return provenance;
268    }
269    for file in files {
270        let Ok(relative) = file.path.strip_prefix(root) else {
271            continue;
272        };
273        let relative_str = relative.to_string_lossy().replace('\\', "/");
274        for (rule, source) in &exposed {
275            if rule.matches(&relative_str) {
276                provenance.push_file(relative.to_path_buf(), source.clone());
277            }
278        }
279    }
280    provenance
281}
282
283/// Export names that frameworks read as configuration, not as code.
284///
285/// A plugin `used_exports` rule can list these names next to real handlers
286/// (Next.js lists `dynamic` next to `GET` and `default`). Only a listed name
287/// with a literal value counts as configuration, so the review brief does not
288/// ask for a test of it. Extend this set when a new plugin adds a
289/// configuration-only export. Never add a name that holds behavior, such as
290/// `generateMetadata`, `loader` or a route handler.
291const CONFIG_ONLY_EXPORT_NAMES: &[&str] = &[
292    "dynamic",
293    "dynamicParams",
294    "revalidate",
295    "fetchCache",
296    "runtime",
297    "preferredRegion",
298    "maxDuration",
299    "prerender",
300    "config",
301    "metadata",
302    "viewport",
303];
304
305/// Record why the unused devDependency check credits each plugin tooling
306/// dependency, so `--trace-dependency` explains the credit instead of calling
307/// the dependency unused.
308fn push_tooling_trace_credits(
309    provenance: &mut fallow_types::trace::TraceProvenance,
310    root: &Path,
311    workspaces: &[fallow_config::WorkspaceInfo],
312    plugin_result: &AggregatedPluginResult,
313) {
314    for entry in &plugin_result.plugin_tooling {
315        let Some(evidence) = entry.evidence(&plugin_result.script_used_packages) else {
316            continue;
317        };
318        let credit = match evidence {
319            PluginToolingEvidence::OwnConfig(config) => fallow_types::trace::ToolingCredit {
320                reason: "plugin-config".to_owned(),
321                plugin: Some(entry.plugin.clone()),
322                config: Some(config.strip_prefix(root).unwrap_or(config).to_path_buf()),
323                reference: None,
324            },
325            PluginToolingEvidence::Reference(name) => fallow_types::trace::ToolingCredit {
326                reason: "plugin-reference".to_owned(),
327                plugin: Some(entry.plugin.clone()),
328                config: None,
329                reference: Some(name.to_owned()),
330            },
331        };
332        for dependency in &entry.dependencies {
333            provenance.push_tooling_credit(dependency.clone(), credit.clone());
334        }
335    }
336    push_types_trace_credits(provenance, plugin_result);
337    push_catalogue_trace_credits(provenance, root, workspaces, plugin_result);
338}
339
340/// Record why the unused devDependency check credits each catalogue entry in
341/// `devDependencies` that the trace would otherwise call unused: a library
342/// entry by name, a command-line tool by its own config file or its
343/// package.json key, and any entry that the same manifest lists in
344/// `peerDependencies`.
345///
346/// The check reads each declaring manifest on its own, so a credit here comes
347/// from a manifest that declares the name. A config in a sibling workspace
348/// gives no credit.
349fn push_catalogue_trace_credits(
350    provenance: &mut fallow_types::trace::TraceProvenance,
351    root: &Path,
352    workspaces: &[fallow_config::WorkspaceInfo],
353    plugin_result: &AggregatedPluginResult,
354) {
355    let manifests = read_trace_manifests(root, workspaces);
356    let mut names: Vec<&String> = plugin_result.dev_dependency_names.iter().collect();
357    names.sort_unstable();
358    for name in names {
359        let declaring: Vec<&(PathBuf, serde_json::Value)> = manifests
360            .iter()
361            .filter(|(_, manifest)| manifest_lists(manifest, "devDependencies", name))
362            .collect();
363        if let Some(credit) = catalogue_credit(name, root, &declaring) {
364            provenance.push_tooling_credit(name.clone(), credit);
365        }
366        if let Some((path, _)) = declaring
367            .iter()
368            .find(|(_, manifest)| manifest_lists(manifest, "peerDependencies", name))
369        {
370            provenance.push_tooling_credit(
371                name.clone(),
372                fallow_types::trace::ToolingCredit {
373                    reason: "own-peer".to_owned(),
374                    plugin: None,
375                    config: Some(path.strip_prefix(root).unwrap_or(path).to_path_buf()),
376                    reference: None,
377                },
378            );
379        }
380    }
381}
382
383/// The root manifest and each workspace manifest, parsed, root first.
384fn read_trace_manifests(
385    root: &Path,
386    workspaces: &[fallow_config::WorkspaceInfo],
387) -> Vec<(PathBuf, serde_json::Value)> {
388    std::iter::once(root)
389        .chain(
390            workspaces
391                .iter()
392                .map(|ws| ws.root.as_path())
393                .filter(|ws_root| *ws_root != root),
394        )
395        .filter_map(|package_root| {
396            let path = package_root.join("package.json");
397            let content = std::fs::read_to_string(&path).ok()?;
398            serde_json::from_str(&content)
399                .ok()
400                .map(|value| (path, value))
401        })
402        .collect()
403}
404
405fn manifest_lists(manifest: &serde_json::Value, section: &str, name: &str) -> bool {
406    manifest
407        .get(section)
408        .and_then(serde_json::Value::as_object)
409        .is_some_and(|deps| deps.contains_key(name))
410}
411
412/// The catalogue credit of `name` from the first declaring manifest that the
413/// unused devDependency check credits.
414fn catalogue_credit(
415    name: &str,
416    root: &Path,
417    declaring: &[&(PathBuf, serde_json::Value)],
418) -> Option<fallow_types::trace::ToolingCredit> {
419    if is_ambient_types_package(name) || types_package_target(name).is_some() {
420        return None;
421    }
422    let Some(patterns) = cli_tooling_config_patterns(name) else {
423        return is_known_tooling_dependency(name).then(|| fallow_types::trace::ToolingCredit {
424            reason: "known-tooling".to_owned(),
425            plugin: None,
426            config: None,
427            reference: None,
428        });
429    };
430    let config = declaring.iter().find_map(|(path, manifest)| {
431        crate::analyze::cli_tool_own_config(name, patterns, root, path, Some(manifest))
432    })?;
433    Some(fallow_types::trace::ToolingCredit {
434        reason: "known-tooling-config".to_owned(),
435        plugin: None,
436        config: Some(config.strip_prefix(root).unwrap_or(&config).to_path_buf()),
437        reference: None,
438    })
439}
440
441/// Record why the unused devDependency check credits each type package in
442/// `devDependencies`: ambient globals, a declared target package, or a
443/// tsconfig `types` entry. A target that the code imports is credited by the trace
444/// itself, which reads the module graph.
445fn push_types_trace_credits(
446    provenance: &mut fallow_types::trace::TraceProvenance,
447    plugin_result: &AggregatedPluginResult,
448) {
449    let declared = plugin_result.dependency_binaries.declared_packages();
450    let mut names: Vec<&String> = plugin_result.dev_dependency_names.iter().collect();
451    names.sort_unstable();
452    for name in names {
453        let credit = if is_ambient_types_package(name) {
454            fallow_types::trace::ToolingCredit {
455                reason: "ambient-types".to_owned(),
456                plugin: None,
457                config: None,
458                reference: None,
459            }
460        } else if let Some(target) = types_package_target(name) {
461            if declared.contains(&target) {
462                fallow_types::trace::ToolingCredit {
463                    reason: "types-target".to_owned(),
464                    plugin: None,
465                    config: None,
466                    reference: Some(target),
467                }
468            } else if plugin_result.referenced_dependencies.contains(name) {
469                fallow_types::trace::ToolingCredit {
470                    reason: "types-config".to_owned(),
471                    plugin: None,
472                    config: None,
473                    reference: None,
474                }
475            } else {
476                continue;
477            }
478        } else {
479            continue;
480        };
481        provenance.push_tooling_credit(name.clone(), credit);
482    }
483}
484
485/// Add a trace source for each remote that a literal runtime call names.
486fn push_runtime_remote_sources(
487    provenance: &mut fallow_types::trace::TraceProvenance,
488    root: &Path,
489    files: &[crate::discover::DiscoveredFile],
490    modules: &[crate::extract::ModuleInfo],
491) {
492    for module in modules {
493        let mut file = None;
494        for fact in module.semantic_facts.iter() {
495            let fallow_types::extract::SemanticFact::FederationRuntimeRemote(fact) = fact else {
496                continue;
497            };
498            let Some(remote) = &fact.remote else {
499                continue;
500            };
501            let Some(path) = file.get_or_insert_with(|| {
502                files.get(module.file_id.0 as usize).map(|file| {
503                    file.path
504                        .strip_prefix(root)
505                        .unwrap_or(&file.path)
506                        .to_path_buf()
507                })
508            }) else {
509                break;
510            };
511            provenance.push_dependency(
512                remote.clone(),
513                fallow_types::trace::TraceSource {
514                    kind: "module-federation".to_owned(),
515                    plugin: "module-federation".to_owned(),
516                    config: path.clone(),
517                    key: fact.call.name().to_owned(),
518                },
519            );
520        }
521    }
522}
523
524impl PluginResult {
525    /// Register `entry` values that a bundler reads relative to the directory
526    /// of its config file. The project root run and the workspace run can read
527    /// the same config, so each value is anchored at the config directory. A
528    /// value with a leading `!` excludes its matches from every other value.
529    fn extend_config_dir_entry_patterns(
530        &mut self,
531        values: Vec<String>,
532        config_path: &Path,
533        root: &Path,
534    ) {
535        let (negated, positive): (Vec<String>, Vec<String>) =
536            values.into_iter().partition(|value| value.starts_with('!'));
537        let excluded: Vec<String> = negated
538            .iter()
539            .filter_map(|value| value.strip_prefix('!'))
540            .filter_map(|value| config_parser::normalize_config_path(value, config_path, root))
541            .collect();
542        self.entry_patterns.extend(
543            positive
544                .iter()
545                .filter_map(|value| config_parser::normalize_config_path(value, config_path, root))
546                .map(|pattern| {
547                    PathRule::new(pattern).with_excluded_globs(excluded.iter().cloned())
548                }),
549        );
550    }
551
552    /// Register an entry pattern whose leading `../` segments are relative to
553    /// the plugin root. The workspace prefix resolves them.
554    fn push_parent_relative_entry_pattern(&mut self, pattern: String) {
555        let mut rule = PathRule::new(pattern);
556        rule.parent_relative = true;
557        self.entry_patterns.push(rule);
558    }
559
560    fn push_entry_pattern(&mut self, pattern: impl Into<String>) {
561        self.entry_patterns
562            .push(PathRule::new(normalize_entry_pattern(pattern.into())));
563    }
564
565    fn extend_entry_patterns<I, S>(&mut self, patterns: I)
566    where
567        I: IntoIterator<Item = S>,
568        S: Into<String>,
569    {
570        self.entry_patterns.extend(
571            patterns
572                .into_iter()
573                .map(|pat| PathRule::new(normalize_entry_pattern(pat.into()))),
574        );
575    }
576
577    /// Route each config value to the surface that can use it: a value naming a
578    /// module request credits its package, every other value becomes an entry
579    /// pattern.
580    ///
581    /// A bundler `entry` accepts a project file and a bare module request such as
582    /// `react-hot-loader/patch` in the same list. A module request names no file,
583    /// so a glob built from it matches nothing while the package still needs
584    /// dependency credit. Module Federation `exposes` targets already split the
585    /// two this way (issue #2706); bundler entries now do too (issue #2739).
586    ///
587    /// `resolve_path` maps a path value to its project-relative form, for
588    /// example against a `context` directory. It runs after the value is
589    /// classified, because a joined path such as `app/main` no longer carries
590    /// the `./` that marks it as a path.
591    fn extend_entry_patterns_or_dependencies<I, S>(
592        &mut self,
593        values: I,
594        resolve_path: impl Fn(String) -> String,
595    ) where
596        I: IntoIterator<Item = S>,
597        S: Into<String>,
598    {
599        for value in values {
600            let value = value.into();
601            if let Some(request) = module_request(&value) {
602                self.referenced_dependencies
603                    .push(crate::resolve::extract_package_name(request));
604                continue;
605            }
606            self.push_entry_path(resolve_path(value));
607        }
608    }
609
610    /// Route each value of a rollup-style `input` to both surfaces when it is
611    /// ambiguous.
612    ///
613    /// Rollup, rolldown and vite resolve an `input` value with no importer: a
614    /// resolve plugin can read it as a module request, and without one it is a
615    /// path relative to the working directory. A value without `./`, `../` or
616    /// `/`, without a source extension and without glob syntax can therefore
617    /// name either one. It keeps the entry pattern, and it credits the package
618    /// unless the value names a file under `root`. A value that names a
619    /// project file is a path, so it must not hide an unused package that has
620    /// the same first segment (issue #2753).
621    fn extend_entry_patterns_and_dependencies<I, S>(&mut self, values: I, root: &Path)
622    where
623        I: IntoIterator<Item = S>,
624        S: Into<String>,
625    {
626        for value in values {
627            let value = value.into();
628            if let Some(request) = module_request(&value)
629                && !names_project_file(root, request)
630            {
631                self.referenced_dependencies
632                    .push(crate::resolve::extract_package_name(request));
633            }
634            self.push_entry_path(value);
635        }
636    }
637
638    /// Register each value as a bundler entry path.
639    fn extend_entry_paths<I, S>(&mut self, values: I)
640    where
641        I: IntoIterator<Item = S>,
642        S: Into<String>,
643    {
644        for value in values {
645            self.push_entry_path(value.into());
646        }
647    }
648
649    /// Register a bundler entry path.
650    ///
651    /// A bundler resolves an entry without a source extension the way it
652    /// resolves an import: first as a file with each extension, then as a
653    /// directory through its index file. `./lib` therefore names
654    /// `lib/index.ts`, and `./src/app` names `src/app.ts`. The value as written
655    /// stays a pattern too, so a file without an extension still matches.
656    fn push_entry_path(&mut self, value: String) {
657        if has_glob_syntax(&value) || has_source_extension(&value) {
658            self.push_entry_pattern(value);
659            return;
660        }
661        let base = value.trim_end_matches('/').to_owned();
662        self.push_entry_pattern(value);
663        self.push_entry_pattern(format!("{base}.{REQUEST_EXTENSIONS}"));
664        self.push_entry_pattern(format!("{base}/index.{REQUEST_EXTENSIONS}"));
665    }
666
667    /// Add a path alias to a directory that the config names. A missing target
668    /// under the alias is an unresolved import, also when a virtual module
669    /// prefix of the plugin matches the specifier.
670    fn push_checked_path_alias(&mut self, prefix: String, replacement: String) {
671        self.checked_alias_prefixes.push(prefix.clone());
672        self.path_aliases.push((prefix, replacement));
673    }
674
675    /// Whether this result contributes nothing, which lets the registry skip a
676    /// config file entirely.
677    ///
678    /// A config that yields only a diagnostic is NOT empty: an unreadable
679    /// `exposes` in a config that declares nothing else is exactly the case the
680    /// advisory exists for, and skipping the result would drop it.
681    #[must_use]
682    const fn is_empty(&self) -> bool {
683        self.config_diagnostics.is_empty()
684            && self.entry_patterns.is_empty()
685            && self.used_exports.is_empty()
686            && self.entry_export_credits.is_empty()
687            && self.used_class_members.is_empty()
688            && self.referenced_dependencies.is_empty()
689            && self.package_referenced_dependencies.is_empty()
690            && self.required_dependencies.is_empty()
691            && self.always_used_files.is_empty()
692            && self.path_aliases.is_empty()
693            && self.setup_files.is_empty()
694            && self.fixture_patterns.is_empty()
695            && self.scss_include_paths.is_empty()
696            && self.static_dir_mappings.is_empty()
697            && self.framework_static_dir_mappings.is_empty()
698            && self.provided_dependencies.is_empty()
699            && self.federation_sources.is_empty()
700            && self.jsx_import_sources.is_empty()
701            && self.jsx_package_credits.is_empty()
702            && self.tsconfig_jsx_dirs.is_empty()
703    }
704}
705
706/// Brace list of the extensions a bundler tries for a request that names no
707/// extension. Entry patterns are plain globs with no extension expansion, so a
708/// bare `src/Button` would match no file.
709const REQUEST_EXTENSIONS: &str = "{ts,tsx,mts,cts,gts,js,jsx,mjs,cjs,gjs,vue,svelte,astro,mdx}";
710
711fn normalize_entry_pattern(pattern: String) -> String {
712    pattern
713        .strip_prefix("./")
714        .map(str::to_owned)
715        .unwrap_or(pattern)
716}
717
718/// A file-pattern rule with optional exclusion globs plus path-level or
719/// segment-level regex filters.
720///
721/// Exclusion regexes are matched against the project-relative path and should be
722/// anchored when generated dynamically so they can be safely workspace-prefixed.
723#[derive(Debug, Clone, Default, PartialEq, Eq, Hash)]
724pub struct PathRule {
725    pub pattern: String,
726    pub exclude_globs: Vec<String>,
727    pub exclude_regexes: Vec<String>,
728    /// Regexes matched against individual path segments. These are not prefixed
729    /// for workspaces because they intentionally operate on segment names rather
730    /// than the full project-relative path.
731    pub exclude_segment_regexes: Vec<String>,
732    /// Whether the leading `../` segments of `pattern` are relative to the
733    /// plugin root, so the workspace prefix resolves them. Only the Module
734    /// Federation reader sets it, for an `exposes` target in a sibling
735    /// workspace. Other plugins emit patterns relative to a config directory,
736    /// such as the Storybook `../src/**`, which must not climb out of the
737    /// workspace.
738    pub parent_relative: bool,
739    /// Whether `pattern` is always relative to the plugin root. The workspace
740    /// prefix then applies also to a pattern that starts with the prefix text,
741    /// such as `docs/js/x.js` in a workspace package named `docs`.
742    pub package_relative: bool,
743}
744
745impl PathRule {
746    #[must_use]
747    pub(crate) fn new(pattern: impl Into<String>) -> Self {
748        Self {
749            pattern: pattern.into(),
750            exclude_globs: Vec::new(),
751            exclude_regexes: Vec::new(),
752            exclude_segment_regexes: Vec::new(),
753            parent_relative: false,
754            package_relative: false,
755        }
756    }
757
758    #[must_use]
759    fn from_static(pattern: &'static str) -> Self {
760        Self::new(pattern)
761    }
762
763    /// A rule for a tool glob with extglob groups, such as `!(*.spec)`. The
764    /// rule matches at least the paths that the tool matches. Each negated
765    /// group becomes an excluded glob.
766    #[must_use]
767    fn from_extglob(pattern: &str) -> Self {
768        let rewritten = fallow_config::extglob::rewrite_include(pattern);
769        Self::new(rewritten.include).with_excluded_globs(rewritten.excludes)
770    }
771
772    /// Exclude the paths of tool globs with extglob groups. An excluded glob
773    /// never removes more paths than the tool does, so a glob with a negated
774    /// group excludes nothing.
775    #[must_use]
776    fn with_excluded_extglobs<I, S>(self, patterns: I) -> Self
777    where
778        I: IntoIterator<Item = S>,
779        S: AsRef<str>,
780    {
781        let excluded: Vec<String> = patterns
782            .into_iter()
783            .filter_map(|pattern| fallow_config::extglob::rewrite_exclude(pattern.as_ref()))
784            .collect();
785        self.with_excluded_globs(excluded)
786    }
787
788    #[must_use]
789    pub(crate) fn with_excluded_globs<I, S>(mut self, patterns: I) -> Self
790    where
791        I: IntoIterator<Item = S>,
792        S: Into<String>,
793    {
794        self.exclude_globs
795            .extend(patterns.into_iter().map(Into::into));
796        self
797    }
798
799    #[must_use]
800    fn with_excluded_regexes<I, S>(mut self, patterns: I) -> Self
801    where
802        I: IntoIterator<Item = S>,
803        S: Into<String>,
804    {
805        self.exclude_regexes
806            .extend(patterns.into_iter().map(Into::into));
807        self
808    }
809
810    #[must_use]
811    fn with_excluded_segment_regexes<I, S>(mut self, patterns: I) -> Self
812    where
813        I: IntoIterator<Item = S>,
814        S: Into<String>,
815    {
816        self.exclude_segment_regexes
817            .extend(patterns.into_iter().map(Into::into));
818        self
819    }
820
821    #[must_use]
822    fn prefixed(&self, ws_prefix: &str) -> Self {
823        let prefix = |pattern: &str| {
824            if self.parent_relative && pattern.starts_with("../") {
825                resolve_parent_relative_pattern(pattern, ws_prefix)
826            } else if self.package_relative {
827                format!("{ws_prefix}/{pattern}")
828            } else {
829                prefix_workspace_pattern(pattern, ws_prefix)
830            }
831        };
832        Self {
833            pattern: prefix(&self.pattern),
834            exclude_globs: self
835                .exclude_globs
836                .iter()
837                .map(|pattern| prefix(pattern))
838                .collect(),
839            exclude_regexes: self
840                .exclude_regexes
841                .iter()
842                .map(|pattern| prefix_workspace_regex(pattern, ws_prefix))
843                .collect(),
844            exclude_segment_regexes: self.exclude_segment_regexes.clone(),
845            parent_relative: false,
846            package_relative: false,
847        }
848    }
849}
850
851/// A file-scoped dependency provider rule contributed by a framework plugin.
852#[derive(Debug, Clone, Default, PartialEq, Eq)]
853pub struct ProvidedDependencyRule {
854    pub(crate) path: PathRule,
855    exact_specifiers: Vec<String>,
856    specifier_prefixes: Vec<String>,
857}
858
859impl ProvidedDependencyRule {
860    #[must_use]
861    fn new(
862        pattern: impl Into<String>,
863        exact_specifiers: impl IntoIterator<Item = impl Into<String>>,
864        specifier_prefixes: impl IntoIterator<Item = impl Into<String>>,
865    ) -> Self {
866        Self {
867            path: PathRule::new(pattern),
868            exact_specifiers: exact_specifiers.into_iter().map(Into::into).collect(),
869            specifier_prefixes: specifier_prefixes.into_iter().map(Into::into).collect(),
870        }
871    }
872
873    #[must_use]
874    fn prefixed(&self, ws_prefix: &str) -> Self {
875        Self {
876            path: self.path.prefixed(ws_prefix),
877            exact_specifiers: self.exact_specifiers.clone(),
878            specifier_prefixes: self.specifier_prefixes.clone(),
879        }
880    }
881
882    #[must_use]
883    pub(crate) fn may_cover_package(&self, package_name: &str) -> bool {
884        self.exact_specifiers
885            .iter()
886            .chain(self.specifier_prefixes.iter())
887            .any(|specifier| crate::resolve::extract_package_name(specifier) == package_name)
888    }
889
890    #[must_use]
891    pub(crate) fn covers_specifier(&self, specifier: &str) -> bool {
892        self.exact_specifiers
893            .iter()
894            .any(|allowed| allowed == specifier)
895            || self
896                .specifier_prefixes
897                .iter()
898                .any(|prefix| specifier.starts_with(prefix))
899    }
900}
901
902/// Compile the include glob of an entry rule. Its `*` stays in one path
903/// segment, and it accepts an empty alternative, such as `{,m}js`, because
904/// the rewrite of an extglob `?(m)` group gives one.
905pub(crate) fn entry_rule_glob(pattern: &str) -> Result<globset::Glob, globset::Error> {
906    globset::GlobBuilder::new(pattern)
907        .literal_separator(true)
908        .empty_alternates(true)
909        .build()
910}
911
912/// A compiled path rule matcher shared by entry-point and used-export matching.
913///
914/// Every glob accepts an empty alternative, such as `{,m}js`, because the
915/// rewrite of an extglob `?(m)` group gives one.
916#[derive(Debug, Clone)]
917pub(crate) struct CompiledPathRule {
918    include: globset::GlobMatcher,
919    exclude_globs: Vec<globset::GlobMatcher>,
920    exclude_regexes: Vec<Regex>,
921    exclude_segment_regexes: Vec<Regex>,
922}
923
924impl CompiledPathRule {
925    pub(crate) fn for_entry_rule(rule: &PathRule, rule_kind: &str) -> Option<Self> {
926        let include = match entry_rule_glob(&rule.pattern) {
927            Ok(glob) => glob.compile_matcher(),
928            Err(err) => {
929                tracing::warn!("invalid {rule_kind} '{}': {err}", rule.pattern);
930                return None;
931            }
932        };
933        Some(Self {
934            include,
935            exclude_globs: compile_excluded_globs(&rule.exclude_globs, rule_kind, &rule.pattern),
936            exclude_regexes: compile_excluded_regexes(
937                &rule.exclude_regexes,
938                rule_kind,
939                &rule.pattern,
940            ),
941            exclude_segment_regexes: compile_excluded_segment_regexes(
942                &rule.exclude_segment_regexes,
943                rule_kind,
944                &rule.pattern,
945            ),
946        })
947    }
948
949    pub(crate) fn for_used_export_rule(rule: &PathRule, rule_kind: &str) -> Option<Self> {
950        Self::for_entry_rule(rule, rule_kind)
951    }
952
953    #[must_use]
954    pub(crate) fn matches(&self, path: &str) -> bool {
955        self.include.is_match(path)
956            && !self.exclude_globs.iter().any(|glob| glob.is_match(path))
957            && !self
958                .exclude_regexes
959                .iter()
960                .any(|regex| regex.is_match(path))
961            && !matches_segment_regex(path, &self.exclude_segment_regexes)
962    }
963}
964
965fn prefix_workspace_pattern(pattern: &str, ws_prefix: &str) -> String {
966    if pattern.starts_with(ws_prefix) || pattern.starts_with('/') {
967        pattern.to_string()
968    } else {
969        format!("{ws_prefix}/{pattern}")
970    }
971}
972
973/// Resolve the leading `../` segments of a parent-relative pattern against the
974/// workspace prefix, so a pattern that names a file in a sibling workspace
975/// matches from the project root. A pattern that climbs past the project root,
976/// or a prefix that is not project-relative, keeps the pattern as written,
977/// which matches no project file.
978fn resolve_parent_relative_pattern(pattern: &str, ws_prefix: &str) -> String {
979    if ws_prefix.starts_with('/') || Path::new(ws_prefix).is_absolute() {
980        return pattern.to_string();
981    }
982    // The workspace prefix comes from a native path, so on Windows its
983    // segments are separated by backslashes.
984    let mut base: Vec<&str> = ws_prefix
985        .split(['/', '\\'])
986        .filter(|segment| !segment.is_empty())
987        .collect();
988    let mut rest = pattern;
989    while let Some(stripped) = rest.strip_prefix("../") {
990        if base.pop().is_none() {
991            return pattern.to_string();
992        }
993        rest = stripped;
994    }
995    if base.is_empty() {
996        rest.to_string()
997    } else {
998        format!("{}/{rest}", base.join("/"))
999    }
1000}
1001
1002fn prefix_workspace_regex(pattern: &str, ws_prefix: &str) -> String {
1003    if let Some(pattern) = pattern.strip_prefix('^') {
1004        format!("^{}/{}", regex::escape(ws_prefix), pattern)
1005    } else {
1006        format!("^{}/(?:{})", regex::escape(ws_prefix), pattern)
1007    }
1008}
1009
1010fn compile_excluded_globs(
1011    patterns: &[String],
1012    rule_kind: &str,
1013    rule_pattern: &str,
1014) -> Vec<globset::GlobMatcher> {
1015    patterns
1016        .iter()
1017        .filter_map(|pattern| {
1018            match globset::GlobBuilder::new(pattern)
1019                .literal_separator(true)
1020                .empty_alternates(true)
1021                .build()
1022            {
1023                Ok(glob) => Some(glob.compile_matcher()),
1024                Err(err) => {
1025                    tracing::warn!(
1026                        "skipping invalid excluded glob '{}' for {} '{}': {err}",
1027                        pattern,
1028                        rule_kind,
1029                        rule_pattern
1030                    );
1031                    None
1032                }
1033            }
1034        })
1035        .collect()
1036}
1037
1038fn compile_excluded_regexes(
1039    patterns: &[String],
1040    rule_kind: &str,
1041    rule_pattern: &str,
1042) -> Vec<Regex> {
1043    patterns
1044        .iter()
1045        .filter_map(|pattern| match Regex::new(pattern) {
1046            Ok(regex) => Some(regex),
1047            Err(err) => {
1048                tracing::warn!(
1049                    "skipping invalid excluded regex '{}' for {} '{}': {err}",
1050                    pattern,
1051                    rule_kind,
1052                    rule_pattern
1053                );
1054                None
1055            }
1056        })
1057        .collect()
1058}
1059
1060fn compile_excluded_segment_regexes(
1061    patterns: &[String],
1062    rule_kind: &str,
1063    rule_pattern: &str,
1064) -> Vec<Regex> {
1065    patterns
1066        .iter()
1067        .filter_map(|pattern| match Regex::new(pattern) {
1068            Ok(regex) => Some(regex),
1069            Err(err) => {
1070                tracing::warn!(
1071                    "skipping invalid excluded segment regex '{}' for {} '{}': {err}",
1072                    pattern,
1073                    rule_kind,
1074                    rule_pattern
1075                );
1076                None
1077            }
1078        })
1079        .collect()
1080}
1081
1082/// Whether a segment of `path` matches one of `regexes`. The path can use the
1083/// native separator: on Windows a caller can pass `src\pages\x.tsx`.
1084fn matches_segment_regex(path: &str, regexes: &[Regex]) -> bool {
1085    path.split(std::path::is_separator)
1086        .any(|segment| regexes.iter().any(|regex| regex.is_match(segment)))
1087}
1088
1089impl From<String> for PathRule {
1090    fn from(pattern: String) -> Self {
1091        Self::new(pattern)
1092    }
1093}
1094
1095impl From<&str> for PathRule {
1096    fn from(pattern: &str) -> Self {
1097        Self::new(pattern)
1098    }
1099}
1100
1101impl std::ops::Deref for PathRule {
1102    type Target = str;
1103
1104    fn deref(&self) -> &Self::Target {
1105        &self.pattern
1106    }
1107}
1108
1109impl PartialEq<&str> for PathRule {
1110    fn eq(&self, other: &&str) -> bool {
1111        self.pattern == *other
1112    }
1113}
1114
1115impl PartialEq<str> for PathRule {
1116    fn eq(&self, other: &str) -> bool {
1117        self.pattern == other
1118    }
1119}
1120
1121impl PartialEq<String> for PathRule {
1122    fn eq(&self, other: &String) -> bool {
1123        &self.pattern == other
1124    }
1125}
1126
1127/// A framework/tool plugin that contributes to dead code analysis.
1128pub trait Plugin: Send + Sync {
1129    /// Human-readable plugin name.
1130    fn name(&self) -> &'static str;
1131
1132    /// Package names that activate this plugin when found in package.json.
1133    /// Supports exact matches and prefix patterns (ending with `/`).
1134    fn enablers(&self) -> &'static [&'static str] {
1135        &[]
1136    }
1137
1138    /// Calls `is_enabled_with_deps`. The registry does not call this method, so do not override it.
1139    fn is_enabled(&self, pkg: &PackageJson, root: &Path) -> bool {
1140        let deps = pkg.all_dependency_names();
1141        self.is_enabled_with_deps(&deps, root)
1142    }
1143
1144    /// Fast variant of `is_enabled` that accepts a pre-computed deps list.
1145    /// Avoids repeated `all_dependency_names()` allocation when checking many plugins.
1146    fn is_enabled_with_deps(&self, deps: &[String], _root: &Path) -> bool {
1147        let enablers = self.enablers();
1148        if enablers.is_empty() {
1149            return false;
1150        }
1151        enablers.iter().any(|enabler| {
1152            if enabler.ends_with('/') {
1153                // Prefix match (e.g., "@storybook/" matches "@storybook/react")
1154                deps.iter().any(|d| d.starts_with(enabler))
1155            } else {
1156                deps.iter().any(|d| d == enabler)
1157            }
1158        })
1159    }
1160
1161    /// Check whether this plugin should be active with source discovery available.
1162    ///
1163    /// Most plugins only need dependency/config activation. Convention-only tools
1164    /// can override this to activate from discovered source filenames without
1165    /// forcing a separate filesystem walk.
1166    ///
1167    /// `candidate_index` is the discovery walk's in-memory listing of source +
1168    /// non-source config-candidate files (`Some` outside production mode, `None`
1169    /// in production). A plugin that activates on a non-source sentinel file
1170    /// (`manifest.json`, `.env.schema`) can consult it to avoid a per-directory
1171    /// filesystem probe; when it is `None`, the plugin falls back to the
1172    /// filesystem.
1173    fn is_enabled_with_files(
1174        &self,
1175        deps: &[String],
1176        root: &Path,
1177        _discovered_files: &[PathBuf],
1178        _candidate_index: Option<&registry::ConfigCandidateIndex>,
1179    ) -> bool {
1180        self.is_enabled_with_deps(deps, root)
1181    }
1182
1183    /// Package-script binary/package names that can activate this plugin.
1184    fn script_enablers(&self) -> &'static [&'static str] {
1185        &[]
1186    }
1187
1188    /// Check whether this plugin should be active from package.json scripts.
1189    fn is_enabled_with_scripts(
1190        &self,
1191        script_packages: &rustc_hash::FxHashSet<String>,
1192        _root: &Path,
1193    ) -> bool {
1194        let enablers = self.script_enablers();
1195        if enablers.is_empty() {
1196            return false;
1197        }
1198        enablers.iter().any(|enabler| {
1199            if enabler.ends_with('/') {
1200                script_packages
1201                    .iter()
1202                    .any(|package| package.starts_with(enabler))
1203            } else {
1204                script_packages.contains(*enabler)
1205            }
1206        })
1207    }
1208
1209    /// Default glob patterns for entry point files.
1210    fn entry_patterns(&self) -> &'static [&'static str] {
1211        &[]
1212    }
1213
1214    /// Entry point rules with optional exclusions.
1215    fn entry_pattern_rules(&self) -> Vec<PathRule> {
1216        self.entry_patterns()
1217            .iter()
1218            .map(|pattern| PathRule::from_static(pattern))
1219            .collect()
1220    }
1221
1222    /// How this plugin's entry patterns should contribute to coverage reachability.
1223    ///
1224    /// `Support` roots keep files alive for dead-code analysis but do not count
1225    /// as runtime or test reachability for static coverage gaps.
1226    fn entry_point_role(&self) -> EntryPointRole {
1227        builtin_entry_point_role(self.name())
1228    }
1229
1230    /// Glob patterns for config files this plugin can parse.
1231    fn config_patterns(&self) -> &'static [&'static str] {
1232        &[]
1233    }
1234
1235    /// Config patterns whose files do not get the `default` export credit.
1236    ///
1237    /// Under `includeEntryExports`, the `default` export of a file that one of
1238    /// [`Self::config_patterns`] matches counts as used, because the tool loads
1239    /// the config file and reads its default export. List a pattern here when
1240    /// the tool reads named exports instead, or when the pattern also matches
1241    /// ordinary source files. Each entry must be identical to an entry of
1242    /// [`Self::config_patterns`].
1243    fn config_default_export_opt_out(&self) -> &'static [&'static str] {
1244        &[]
1245    }
1246
1247    /// Tool config files and the export names that the tool reads from them.
1248    ///
1249    /// Under `includeEntryExports`, these exports of a matching file count as
1250    /// used. `"*"` credits every export. Use this for a config file that is not
1251    /// in [`Self::config_patterns`], or for a tool that reads named exports.
1252    /// Each pattern is anchored: it gets the workspace prefix but no `**/`
1253    /// prefix, so it matches only at the project or workspace package root.
1254    /// This credit never changes the output without `includeEntryExports`.
1255    fn config_file_exports(&self) -> &'static [(&'static str, &'static [&'static str])] {
1256        &[]
1257    }
1258
1259    /// Files that are always considered "used" when this plugin is active.
1260    fn always_used(&self) -> &'static [&'static str] {
1261        &[]
1262    }
1263
1264    /// Exports that are always considered used for matching file patterns.
1265    fn used_exports(&self) -> Vec<(&'static str, &'static [&'static str])> {
1266        vec![]
1267    }
1268
1269    /// Used-export rules with optional exclusions.
1270    fn used_export_rules(&self) -> Vec<UsedExportRule> {
1271        self.used_exports()
1272            .into_iter()
1273            .map(|(pattern, exports)| UsedExportRule::from_static(pattern, exports))
1274            .collect()
1275    }
1276
1277    /// Class member names the framework invokes at runtime. Matching members
1278    /// are skipped during `unused-class-members` analysis. Intended for
1279    /// interface/contract patterns where the library calls methods on consumer
1280    /// classes (e.g. ag-Grid's `agInit`, Web Components' `connectedCallback`).
1281    fn used_class_members(&self) -> &'static [&'static str] {
1282        &[]
1283    }
1284
1285    /// Heritage-scoped class member rules. Each rule applies only to classes
1286    /// matching its `extends` and/or `implements` clause. Used for frameworks
1287    /// where lifecycle members are runtime-invoked only on classes that extend
1288    /// a known base (e.g. Lit's `render`/`updated` on classes extending
1289    /// `LitElement`, native Web Components' `connectedCallback` on classes
1290    /// extending `HTMLElement`). Default: empty. Plugins override when they
1291    /// need scoping; flat names should still come from `used_class_members`.
1292    fn used_class_member_rules(&self) -> Vec<UsedClassMemberRule> {
1293        Vec::new()
1294    }
1295
1296    /// Exact package-backed framework contracts that type-aware analysis may
1297    /// verify for latent class-member candidates.
1298    fn framework_class_member_contracts(&self) -> Vec<SemanticFrameworkContract> {
1299        Vec::new()
1300    }
1301
1302    /// Glob patterns for test fixture files consumed by this framework.
1303    /// These files are implicitly used by the test runner and should not be
1304    /// flagged as unused. Unlike `always_used()`, this carries semantic intent
1305    /// for reporting purposes.
1306    fn fixture_glob_patterns(&self) -> &'static [&'static str] {
1307        &[]
1308    }
1309
1310    /// Hidden directory names that should be traversed when this plugin is active.
1311    ///
1312    /// These are consulted before normal plugin execution because source discovery
1313    /// runs first. Keep entries static and package-convention scoped.
1314    fn discovery_hidden_dirs(&self) -> &'static [&'static str] {
1315        &[]
1316    }
1317
1318    /// Dependencies that are tooling (used via CLI/config, not source imports).
1319    /// These should not be flagged as unused devDependencies.
1320    fn tooling_dependencies(&self) -> &'static [&'static str] {
1321        &[]
1322    }
1323
1324    /// Import prefixes that are virtual modules provided by this framework at build time.
1325    /// Imports matching these prefixes should not be flagged as unlisted dependencies.
1326    /// Each entry is matched as a prefix against the extracted package name
1327    /// (e.g., `"@theme/"` matches `@theme/Layout`).
1328    fn virtual_module_prefixes(&self) -> &'static [&'static str] {
1329        &[]
1330    }
1331
1332    /// Package name suffixes that are virtual modules provided by this framework
1333    /// at build time (e.g., test runner mock conventions).
1334    /// Imports matching these suffixes should not be flagged as unlisted dependencies.
1335    /// Each entry is matched as a suffix against the extracted package name
1336    /// (e.g., `"/__mocks__"` matches `@aws-sdk/__mocks__` and `some-pkg/__mocks__`).
1337    fn virtual_package_suffixes(&self) -> &'static [&'static str] {
1338        &[]
1339    }
1340
1341    /// Import suffixes for build-time generated relative imports.
1342    ///
1343    /// Unresolved relative imports whose specifier ends with one of these suffixes
1344    /// will not be flagged as unresolved. For example, SvelteKit generates
1345    /// `./$types` imports in route files, returning `"/$types"` suppresses those.
1346    fn generated_import_patterns(&self) -> &'static [&'static str] {
1347        &[]
1348    }
1349
1350    /// Import prefixes for generated type-only relative imports.
1351    ///
1352    /// Unresolved type-only imports whose specifier starts with one of these prefixes
1353    /// will not be flagged as unresolved. Runtime imports are still reported.
1354    fn generated_type_import_prefixes(&self) -> &'static [&'static str] {
1355        &[]
1356    }
1357
1358    /// The package that provides this framework's virtual and generated
1359    /// modules, credited as used when a source file imports one.
1360    ///
1361    /// A framework can serve imports that name no npm package (SvelteKit's
1362    /// `$app/state`, `./$types`). The package behind those specifiers would
1363    /// look unused in a project where the plugin found no tooling evidence
1364    /// (its own config file, or a script, CI workflow or git hook calling its
1365    /// tool). Return the providing package name: an import matching
1366    /// [`Self::virtual_module_prefixes`] or [`Self::generated_import_patterns`]
1367    /// in the package where this plugin is active then credits it.
1368    fn virtual_module_package(&self) -> Option<&'static str> {
1369        None
1370    }
1371
1372    /// Path alias mappings provided by this framework at build time.
1373    ///
1374    /// Returns a list of `(prefix, replacement_dir)` tuples. When an import starting
1375    /// with `prefix` fails to resolve, the resolver will substitute the prefix with
1376    /// `replacement_dir` (relative to the project root) and retry.
1377    ///
1378    /// Called once when plugins are activated. The project `root` is provided so
1379    /// plugins can inspect the filesystem (e.g., Nuxt checks whether `app/` exists
1380    /// to determine the `srcDir`).
1381    fn path_aliases(&self, _root: &Path) -> Vec<(&'static str, String)> {
1382        vec![]
1383    }
1384
1385    /// Directories this framework serves at a URL mount by convention, so a
1386    /// root-absolute reference in ANY HTML document in the project names a file
1387    /// inside one.
1388    ///
1389    /// Called once when plugins are activated, with the project `root`, so a
1390    /// plugin can require the directory to exist before claiming it.
1391    ///
1392    /// Distinct from the config-file mounts a tool declares from
1393    /// `resolve_config` (Storybook `staticDirs`), which stay scoped to that
1394    /// tool's own documents. A convention here describes how the whole project
1395    /// is served, so it is not scoped that way.
1396    fn static_dir_mappings(&self, _root: &Path) -> Vec<(std::path::PathBuf, String)> {
1397        vec![]
1398    }
1399
1400    /// Convention-based auto-imports provided by this framework.
1401    ///
1402    /// Returns the names this framework exposes to user code by filesystem
1403    /// convention with no explicit `import` statement (e.g. Nuxt `components/`
1404    /// resolved by `<Card001 />` template tags), each mapped to the source file
1405    /// providing the export. When a file references one of these names without an
1406    /// import, the resolver synthesizes a graph edge to `source`.
1407    ///
1408    /// Called once when plugins are activated. The project `root` is provided so
1409    /// plugins can scan the convention directories on the filesystem. The table is
1410    /// a function of which files exist on disk, so it is rebuilt every run and is
1411    /// never folded into per-file extraction caching. See issue #704.
1412    ///
1413    /// A rule with an empty `scope` is visible to the files under `root` only.
1414    /// A plugin can set `scope` itself to make a rule visible to more roots.
1415    /// After the plugin runs, a shared step links a Nuxt app and each layer
1416    /// outside it in both directions. See issue #2752.
1417    fn auto_imports(&self, _root: &Path) -> Vec<AutoImportRule> {
1418        Vec::new()
1419    }
1420
1421    /// File-scoped dependency providers contributed by this framework.
1422    fn provided_dependencies(&self) -> Vec<ProvidedDependencyRule> {
1423        Vec::new()
1424    }
1425
1426    /// Check whether parsed package.json metadata activates this plugin.
1427    fn is_enabled_with_package_json(&self, _pkg: &PackageJson, _root: &Path) -> bool {
1428        false
1429    }
1430
1431    /// Resolve parsed package.json metadata into dynamic plugin facts.
1432    fn resolve_package_json(&self, _pkg: &PackageJson, _root: &Path) -> PluginResult {
1433        PluginResult::default()
1434    }
1435
1436    /// Dependencies referenced by the package's own package.json metadata.
1437    ///
1438    /// Unlike config-derived dependencies, these credits apply only to the
1439    /// package.json that produced them.
1440    fn package_json_referenced_dependencies(
1441        &self,
1442        _pkg: &PackageJson,
1443        _root: &Path,
1444    ) -> Vec<String> {
1445        Vec::new()
1446    }
1447
1448    /// Parse a config file's AST to discover additional entries, dependencies, etc.
1449    ///
1450    /// Called for each config file matching `config_patterns()`. The source code
1451    /// and parsed AST are provided, use [`config_parser`] utilities to extract values.
1452    fn resolve_config(&self, _config_path: &Path, _source: &str, _root: &Path) -> PluginResult {
1453        PluginResult::default()
1454    }
1455
1456    /// Parse a config file with the project root known.
1457    ///
1458    /// `root` is the package root that [`Plugin::resolve_config`] receives. In
1459    /// a workspace run it is the workspace package directory. `project_root`
1460    /// is the analysis root. A plugin that reads more files from paths that
1461    /// the config names must keep each read inside `project_root`, because the
1462    /// config comes from the analyzed repository. The default ignores
1463    /// `project_root`.
1464    fn resolve_config_in_project(
1465        &self,
1466        config_path: &Path,
1467        source: &str,
1468        root: &Path,
1469        _project_root: &Path,
1470    ) -> PluginResult {
1471        self.resolve_config(config_path, source, root)
1472    }
1473
1474    /// Parse a config file that a package script passes with `--config` or
1475    /// `-c`. The script runs the tool in `root`, also for a config in a
1476    /// subdirectory. The default is [`Plugin::resolve_config_in_project`].
1477    fn resolve_script_config(
1478        &self,
1479        config_path: &Path,
1480        source: &str,
1481        root: &Path,
1482        project_root: &Path,
1483    ) -> PluginResult {
1484        self.resolve_config_in_project(config_path, source, root, project_root)
1485    }
1486
1487    /// Binaries whose `--config` / `-c` argument in a package script names a
1488    /// config file of this plugin.
1489    ///
1490    /// A script such as `vitest run --config vitest.e2e.config.ts` points the
1491    /// tool at a file that no `config_patterns()` entry matches. The plugin
1492    /// system sends that file to `resolve_config` and credits its default
1493    /// export as used.
1494    fn script_config_binaries(&self) -> &'static [&'static str] {
1495        &[]
1496    }
1497
1498    /// The package.json key that holds the inline config of this tool, such as
1499    /// `"jest"`, and that [`fallow_config::INLINE_TOOL_CONFIG_KEYS`] lists. When a
1500    /// package has no config file of the tool, `resolve_config_in_project` gets it.
1501    fn package_json_config_key(&self) -> Option<&'static str> {
1502        None
1503    }
1504}
1505
1506/// Macro to eliminate boilerplate in plugin implementations.
1507///
1508/// Generates a struct and a `Plugin` trait impl with the standard static methods
1509/// (`name`, `enablers`, `entry_patterns`, `config_patterns`, `always_used`, `tooling_dependencies`,
1510/// `fixture_glob_patterns`, `virtual_module_prefixes`, `virtual_package_suffixes`,
1511/// `generated_type_import_prefixes`, `used_exports`).
1512///
1513/// For plugins that need custom `resolve_config()` or `is_enabled()`, keep those as
1514/// manual `impl Plugin for ...` blocks instead of using this macro.
1515///
1516/// # Usage
1517///
1518/// ```ignore
1519/// // Simple plugin (most common):
1520/// define_plugin! {
1521///     struct VitePlugin => "vite",
1522///     enablers: ENABLERS,
1523///     entry_patterns: ENTRY_PATTERNS,
1524///     config_patterns: CONFIG_PATTERNS,
1525///     always_used: ALWAYS_USED,
1526///     tooling_dependencies: TOOLING_DEPENDENCIES,
1527/// }
1528///
1529/// // Plugin with used_exports:
1530/// define_plugin! {
1531///     struct RemixPlugin => "remix",
1532///     enablers: ENABLERS,
1533///     entry_patterns: ENTRY_PATTERNS,
1534///     always_used: ALWAYS_USED,
1535///     tooling_dependencies: TOOLING_DEPENDENCIES,
1536///     used_exports: [("app/routes/**/*.{ts,tsx}", ROUTE_EXPORTS)],
1537/// }
1538///
1539/// // Plugin with imports-only resolve_config (extracts imports from config as deps):
1540/// define_plugin! {
1541///     struct CypressPlugin => "cypress",
1542///     enablers: ENABLERS,
1543///     entry_patterns: ENTRY_PATTERNS,
1544///     config_patterns: CONFIG_PATTERNS,
1545///     always_used: ALWAYS_USED,
1546///     tooling_dependencies: TOOLING_DEPENDENCIES,
1547///     resolve_config: imports_only,
1548/// }
1549///
1550/// // Plugin with custom resolve_config body:
1551/// define_plugin! {
1552///     struct RollupPlugin => "rollup",
1553///     enablers: ENABLERS,
1554///     config_patterns: CONFIG_PATTERNS,
1555///     always_used: ALWAYS_USED,
1556///     tooling_dependencies: TOOLING_DEPENDENCIES,
1557///     resolve_config(config_path, source, _root) {
1558///         let mut result = PluginResult::default();
1559///         // custom config parsing...
1560///         result
1561///     }
1562/// }
1563/// ```
1564///
1565/// All fields except `struct` and `enablers` are optional and default to `&[]` / `vec![]`.
1566macro_rules! define_plugin {
1567    (
1568        struct $name:ident => $display:expr,
1569        enablers: $enablers:expr
1570        $(, entry_patterns: $entry:expr)?
1571        $(, config_patterns: $config:expr)?
1572        $(, config_default_export_opt_out: $config_opt_out:expr)?
1573        $(, config_file_exports: $config_exports:expr)?
1574        $(, always_used: $always:expr)?
1575        $(, tooling_dependencies: $tooling:expr)?
1576        $(, fixture_glob_patterns: $fixtures:expr)?
1577        $(, discovery_hidden_dirs: $hidden_dirs:expr)?
1578        $(, virtual_module_prefixes: $virtual:expr)?
1579        $(, virtual_package_suffixes: $virtual_suffixes:expr)?
1580        $(, generated_type_import_prefixes: $generated_type_prefixes:expr)?
1581        $(, provided_dependencies: $provided_dependencies:expr)?
1582        $(, used_exports: [$( ($pat:expr, $exports:expr) ),* $(,)?])?
1583        , resolve_config: imports_only
1584        $(,)?
1585    ) => {
1586        pub struct $name;
1587
1588        impl Plugin for $name {
1589            fn name(&self) -> &'static str {
1590                $display
1591            }
1592
1593            fn enablers(&self) -> &'static [&'static str] {
1594                $enablers
1595            }
1596
1597            $( fn entry_patterns(&self) -> &'static [&'static str] { $entry } )?
1598            $( fn config_patterns(&self) -> &'static [&'static str] { $config } )?
1599            $( fn config_default_export_opt_out(&self) -> &'static [&'static str] { $config_opt_out } )?
1600            $( fn config_file_exports(&self) -> &'static [(&'static str, &'static [&'static str])] { $config_exports } )?
1601            $( fn always_used(&self) -> &'static [&'static str] { $always } )?
1602            $( fn tooling_dependencies(&self) -> &'static [&'static str] { $tooling } )?
1603            $( fn fixture_glob_patterns(&self) -> &'static [&'static str] { $fixtures } )?
1604            $( fn discovery_hidden_dirs(&self) -> &'static [&'static str] { $hidden_dirs } )?
1605            $( fn virtual_module_prefixes(&self) -> &'static [&'static str] { $virtual } )?
1606            $( fn virtual_package_suffixes(&self) -> &'static [&'static str] { $virtual_suffixes } )?
1607            $( fn generated_type_import_prefixes(&self) -> &'static [&'static str] { $generated_type_prefixes } )?
1608            $( fn provided_dependencies(&self) -> Vec<ProvidedDependencyRule> { $provided_dependencies } )?
1609
1610            $(
1611                fn used_exports(&self) -> Vec<(&'static str, &'static [&'static str])> {
1612                    vec![$( ($pat, $exports) ),*]
1613                }
1614            )?
1615
1616            fn resolve_config(
1617                &self,
1618                config_path: &std::path::Path,
1619                source: &str,
1620                _root: &std::path::Path,
1621            ) -> PluginResult {
1622                let mut result = PluginResult::default();
1623                crate::plugins::add_import_referenced_dependencies(
1624                    &mut result,
1625                    source,
1626                    config_path,
1627                );
1628                result
1629            }
1630        }
1631    };
1632
1633    (
1634        struct $name:ident => $display:expr,
1635        enablers: $enablers:expr
1636        $(, entry_patterns: $entry:expr)?
1637        $(, config_patterns: $config:expr)?
1638        $(, config_default_export_opt_out: $config_opt_out:expr)?
1639        $(, config_file_exports: $config_exports:expr)?
1640        $(, always_used: $always:expr)?
1641        $(, tooling_dependencies: $tooling:expr)?
1642        $(, fixture_glob_patterns: $fixtures:expr)?
1643        $(, discovery_hidden_dirs: $hidden_dirs:expr)?
1644        $(, virtual_module_prefixes: $virtual:expr)?
1645        $(, virtual_package_suffixes: $virtual_suffixes:expr)?
1646        $(, generated_type_import_prefixes: $generated_type_prefixes:expr)?
1647        $(, provided_dependencies: $provided_dependencies:expr)?
1648        $(, package_json_config_key: $pkg_key:expr)?
1649        $(, script_config_binaries: $script_binaries:expr)?
1650        $(, used_exports: [$( ($pat:expr, $exports:expr) ),* $(,)?])?
1651        , resolve_config($cp:ident, $src:ident, $root:ident) $body:block
1652        $(, resolve_config_in_project($pcp:ident, $psrc:ident, $proot:ident, $pproj:ident) $pbody:block)?
1653        $(,)?
1654    ) => {
1655        pub struct $name;
1656
1657        impl Plugin for $name {
1658            fn name(&self) -> &'static str {
1659                $display
1660            }
1661
1662            fn enablers(&self) -> &'static [&'static str] {
1663                $enablers
1664            }
1665
1666            $( fn entry_patterns(&self) -> &'static [&'static str] { $entry } )?
1667            $( fn config_patterns(&self) -> &'static [&'static str] { $config } )?
1668            $( fn config_default_export_opt_out(&self) -> &'static [&'static str] { $config_opt_out } )?
1669            $( fn config_file_exports(&self) -> &'static [(&'static str, &'static [&'static str])] { $config_exports } )?
1670            $( fn always_used(&self) -> &'static [&'static str] { $always } )?
1671            $( fn tooling_dependencies(&self) -> &'static [&'static str] { $tooling } )?
1672            $( fn fixture_glob_patterns(&self) -> &'static [&'static str] { $fixtures } )?
1673            $( fn discovery_hidden_dirs(&self) -> &'static [&'static str] { $hidden_dirs } )?
1674            $( fn virtual_module_prefixes(&self) -> &'static [&'static str] { $virtual } )?
1675            $( fn virtual_package_suffixes(&self) -> &'static [&'static str] { $virtual_suffixes } )?
1676            $( fn generated_type_import_prefixes(&self) -> &'static [&'static str] { $generated_type_prefixes } )?
1677            $( fn provided_dependencies(&self) -> Vec<ProvidedDependencyRule> { $provided_dependencies } )?
1678
1679            $(
1680                fn package_json_config_key(&self) -> Option<&'static str> {
1681                    Some($pkg_key)
1682                }
1683            )?
1684
1685            $(
1686                fn used_exports(&self) -> Vec<(&'static str, &'static [&'static str])> {
1687                    vec![$( ($pat, $exports) ),*]
1688                }
1689            )?
1690
1691            $( fn script_config_binaries(&self) -> &'static [&'static str] { $script_binaries } )?
1692
1693            fn resolve_config(
1694                &self,
1695                $cp: &std::path::Path,
1696                $src: &str,
1697                $root: &std::path::Path,
1698            ) -> PluginResult
1699            $body
1700
1701            $(
1702                fn resolve_config_in_project(
1703                    &self,
1704                    $pcp: &std::path::Path,
1705                    $psrc: &str,
1706                    $proot: &std::path::Path,
1707                    $pproj: &std::path::Path,
1708                ) -> PluginResult
1709                $pbody
1710            )?
1711        }
1712    };
1713
1714    (
1715        struct $name:ident => $display:expr,
1716        enablers: $enablers:expr
1717        $(, entry_patterns: $entry:expr)?
1718        $(, config_patterns: $config:expr)?
1719        $(, config_default_export_opt_out: $config_opt_out:expr)?
1720        $(, config_file_exports: $config_exports:expr)?
1721        $(, always_used: $always:expr)?
1722        $(, tooling_dependencies: $tooling:expr)?
1723        $(, fixture_glob_patterns: $fixtures:expr)?
1724        $(, discovery_hidden_dirs: $hidden_dirs:expr)?
1725        $(, virtual_module_prefixes: $virtual:expr)?
1726        $(, virtual_package_suffixes: $virtual_suffixes:expr)?
1727        $(, generated_type_import_prefixes: $generated_type_prefixes:expr)?
1728        $(, provided_dependencies: $provided_dependencies:expr)?
1729        $(, package_json_config_key: $pkg_key:expr)?
1730        $(, used_exports: [$( ($pat:expr, $exports:expr) ),* $(,)?])?
1731        $(,)?
1732    ) => {
1733        pub struct $name;
1734
1735        impl Plugin for $name {
1736            fn name(&self) -> &'static str {
1737                $display
1738            }
1739
1740            fn enablers(&self) -> &'static [&'static str] {
1741                $enablers
1742            }
1743
1744            $( fn entry_patterns(&self) -> &'static [&'static str] { $entry } )?
1745            $( fn config_patterns(&self) -> &'static [&'static str] { $config } )?
1746            $( fn config_default_export_opt_out(&self) -> &'static [&'static str] { $config_opt_out } )?
1747            $( fn config_file_exports(&self) -> &'static [(&'static str, &'static [&'static str])] { $config_exports } )?
1748            $( fn always_used(&self) -> &'static [&'static str] { $always } )?
1749            $( fn tooling_dependencies(&self) -> &'static [&'static str] { $tooling } )?
1750            $( fn fixture_glob_patterns(&self) -> &'static [&'static str] { $fixtures } )?
1751            $( fn discovery_hidden_dirs(&self) -> &'static [&'static str] { $hidden_dirs } )?
1752            $( fn virtual_module_prefixes(&self) -> &'static [&'static str] { $virtual } )?
1753            $( fn virtual_package_suffixes(&self) -> &'static [&'static str] { $virtual_suffixes } )?
1754            $( fn generated_type_import_prefixes(&self) -> &'static [&'static str] { $generated_type_prefixes } )?
1755            $( fn provided_dependencies(&self) -> Vec<ProvidedDependencyRule> { $provided_dependencies } )?
1756
1757            $(
1758                fn package_json_config_key(&self) -> Option<&'static str> {
1759                    Some($pkg_key)
1760                }
1761            )?
1762
1763            $(
1764                fn used_exports(&self) -> Vec<(&'static str, &'static [&'static str])> {
1765                    vec![$( ($pat, $exports) ),*]
1766                }
1767            )?
1768        }
1769    };
1770}
1771
1772mod config_dependencies;
1773pub mod config_parser;
1774mod config_value_credits;
1775mod federation_source;
1776use config_value_credits::{
1777    canonical_test_environment, credit_config_value, credit_environment_optional_peers,
1778};
1779mod flue;
1780mod jasmine;
1781mod manifest;
1782mod module_request;
1783use module_request::{has_glob_syntax, has_source_extension, module_request, names_project_file};
1784pub mod manifest_entries;
1785mod mise;
1786mod osls;
1787mod path_rule_index;
1788mod project_glob;
1789mod railway;
1790pub mod registry;
1791mod rstest;
1792mod serverless_framework;
1793mod textlint;
1794mod tooling;
1795pub(crate) mod trace_provenance;
1796mod used_export_names;
1797mod used_export_rule;
1798
1799pub use config_dependencies::RequiredDependency;
1800use config_dependencies::add_import_referenced_dependencies;
1801pub use federation_source::{FederationSource, FederationSourceTarget};
1802pub(crate) use module_federation::runtime_remotes;
1803pub(crate) use path_rule_index::PathRuleIndex;
1804pub(crate) use registry::module_specifiers;
1805pub use registry::{
1806    AggregatedPluginResult, CheckedAliasPrefix, PluginRegistry, PluginToolingDependencies,
1807    PluginToolingEvidence, VirtualModuleMatch, VirtualModuleProviderRule,
1808};
1809pub use tooling::types_package_target;
1810pub(crate) use tooling::{
1811    cli_tooling_config_patterns, is_ambient_types_package, is_known_tooling_dependency,
1812};
1813pub use trace_provenance::ExportCredits;
1814pub use used_export_names::UsedExportNames;
1815pub(crate) use used_export_rule::{ConfigExportCredit, is_export_ignored};
1816pub use used_export_rule::{PluginUsedExportRule, UsedExportRule};
1817
1818mod adonis;
1819mod ag_ui;
1820mod alchemy;
1821mod alias_replacement;
1822mod angular;
1823mod astro;
1824mod ava;
1825mod babel;
1826mod biome;
1827mod browser_extension;
1828mod bun;
1829mod c8;
1830mod capacitor;
1831mod changesets;
1832mod coderabbit;
1833mod commit_and_tag_version;
1834mod commitizen;
1835mod commitlint;
1836mod content_collections;
1837mod contentlayer;
1838mod convex;
1839mod cspell;
1840mod cucumber;
1841mod cypress;
1842mod danger;
1843mod deno;
1844mod dependency_cruiser;
1845mod docusaurus;
1846mod dotenv;
1847mod drizzle;
1848mod dumi;
1849mod egg;
1850mod electron;
1851mod ember;
1852mod entry_point_roles;
1853mod eslint;
1854mod eve;
1855mod expo;
1856mod expo_packages;
1857mod expo_router;
1858mod extends_walk;
1859mod firebase;
1860mod fumadocs;
1861mod gatsby;
1862mod github_action;
1863mod gnome_shell_extension;
1864mod graphql_codegen;
1865mod graphql_config;
1866mod gulp;
1867mod hardhat;
1868mod husky;
1869mod i18next;
1870mod ionic;
1871mod jest;
1872mod k6;
1873mod karma;
1874mod kibana;
1875mod knex;
1876mod kysely;
1877mod lefthook;
1878mod lexical;
1879mod lint_staged;
1880mod lit;
1881mod markdownlint;
1882mod mintlify;
1883mod mkdocs;
1884mod mocha;
1885mod module_federation;
1886mod msw;
1887mod n8n;
1888mod napi_rs;
1889mod nest_commander;
1890mod nestjs;
1891mod nestjs_trpc;
1892mod next_intl;
1893mod nextjs;
1894mod nitro;
1895mod nodemon;
1896pub(crate) mod nuxt;
1897mod nx;
1898mod nyc;
1899mod obsidian;
1900mod openapi_ts;
1901mod opencode;
1902mod opennext_cloudflare;
1903mod opentelemetry;
1904mod oxfmt;
1905mod oxlint;
1906mod pandacss;
1907mod parcel;
1908mod pinia;
1909mod pkg_utils;
1910mod playwright;
1911mod plop;
1912mod pm2;
1913mod pnpm;
1914mod postcss;
1915mod prettier;
1916mod prisma;
1917mod qwik;
1918mod react_compiler;
1919mod react_native;
1920pub(crate) mod react_router;
1921mod redwoodsdk;
1922mod relay;
1923mod release_it;
1924mod remark;
1925mod remix;
1926mod rolldown;
1927mod rollup;
1928mod rsbuild;
1929mod rspack;
1930mod rspress;
1931mod sanity;
1932mod semantic_release;
1933mod sentry;
1934mod simple_git_hooks;
1935mod size_limit;
1936mod solid_start;
1937mod storybook;
1938mod stryker;
1939mod stylelint;
1940mod supabase;
1941mod sveltekit;
1942mod svgo;
1943mod svgr;
1944mod swc;
1945mod syncpack;
1946mod tailwind;
1947mod tanstack_router;
1948mod tap;
1949mod test_alias;
1950#[cfg(test)]
1951mod tests;
1952mod tsd;
1953mod tsdown;
1954mod tsup;
1955mod turborepo;
1956mod typedoc;
1957mod typeorm;
1958mod typescript;
1959mod typescript_content_mapper;
1960mod unocss;
1961pub(crate) mod unplugin_icons;
1962mod varlock;
1963mod velite;
1964mod vercel;
1965mod vite;
1966mod vite_plugin_pages;
1967pub(crate) mod vite_plus;
1968mod vite_pwa_assets_generator;
1969mod vitepress;
1970mod vitest;
1971mod vscode;
1972mod waku;
1973mod webdriverio;
1974mod webpack;
1975mod wrangler;
1976mod wuchale;
1977mod wxt;