Skip to main content

Plugin

Trait Plugin 

Source
pub trait Plugin: Send + Sync {
Show 16 methods // Required method fn name(&self) -> &'static str; // Provided methods fn enablers(&self) -> &'static [&'static str] { ... } fn is_enabled(&self, pkg: &PackageJson, root: &Path) -> bool { ... } fn is_enabled_with_deps(&self, deps: &[String], _root: &Path) -> bool { ... } fn entry_patterns(&self) -> &'static [&'static str] { ... } fn entry_point_role(&self) -> EntryPointRole { ... } fn config_patterns(&self) -> &'static [&'static str] { ... } fn always_used(&self) -> &'static [&'static str] { ... } fn used_exports(&self) -> Vec<(&'static str, &'static [&'static str])> { ... } fn fixture_glob_patterns(&self) -> &'static [&'static str] { ... } fn tooling_dependencies(&self) -> &'static [&'static str] { ... } fn virtual_module_prefixes(&self) -> &'static [&'static str] { ... } fn generated_import_patterns(&self) -> &'static [&'static str] { ... } fn path_aliases(&self, _root: &Path) -> Vec<(&'static str, String)> { ... } fn resolve_config( &self, _config_path: &Path, _source: &str, _root: &Path, ) -> PluginResult { ... } fn package_json_config_key(&self) -> Option<&'static str> { ... }
}
Expand description

A framework/tool plugin that contributes to dead code analysis.

Required Methods§

Source

fn name(&self) -> &'static str

Human-readable plugin name.

Provided Methods§

Source

fn enablers(&self) -> &'static [&'static str]

Package names that activate this plugin when found in package.json. Supports exact matches and prefix patterns (ending with /).

Source

fn is_enabled(&self, pkg: &PackageJson, root: &Path) -> bool

Check if this plugin should be active for the given project. Default implementation checks enablers() against package.json dependencies.

Source

fn is_enabled_with_deps(&self, deps: &[String], _root: &Path) -> bool

Fast variant of is_enabled that accepts a pre-computed deps list. Avoids repeated all_dependency_names() allocation when checking many plugins.

Source

fn entry_patterns(&self) -> &'static [&'static str]

Default glob patterns for entry point files.

Source

fn entry_point_role(&self) -> EntryPointRole

How this plugin’s entry patterns should contribute to coverage reachability.

Support roots keep files alive for dead-code analysis but do not count as runtime or test reachability for static coverage gaps.

Source

fn config_patterns(&self) -> &'static [&'static str]

Glob patterns for config files this plugin can parse.

Source

fn always_used(&self) -> &'static [&'static str]

Files that are always considered “used” when this plugin is active.

Source

fn used_exports(&self) -> Vec<(&'static str, &'static [&'static str])>

Exports that are always considered used for matching file patterns.

Source

fn fixture_glob_patterns(&self) -> &'static [&'static str]

Glob patterns for test fixture files consumed by this framework. These files are implicitly used by the test runner and should not be flagged as unused. Unlike always_used(), this carries semantic intent for reporting purposes.

Source

fn tooling_dependencies(&self) -> &'static [&'static str]

Dependencies that are tooling (used via CLI/config, not source imports). These should not be flagged as unused devDependencies.

Source

fn virtual_module_prefixes(&self) -> &'static [&'static str]

Import prefixes that are virtual modules provided by this framework at build time. Imports matching these prefixes should not be flagged as unlisted dependencies. Each entry is matched as a prefix against the extracted package name (e.g., "@theme/" matches @theme/Layout).

Source

fn generated_import_patterns(&self) -> &'static [&'static str]

Import suffixes for build-time generated relative imports.

Unresolved relative imports whose specifier ends with one of these suffixes will not be flagged as unresolved. For example, SvelteKit generates ./$types imports in route files — returning "/$types" suppresses those.

Source

fn path_aliases(&self, _root: &Path) -> Vec<(&'static str, String)>

Path alias mappings provided by this framework at build time.

Returns a list of (prefix, replacement_dir) tuples. When an import starting with prefix fails to resolve, the resolver will substitute the prefix with replacement_dir (relative to the project root) and retry.

Called once when plugins are activated. The project root is provided so plugins can inspect the filesystem (e.g., Nuxt checks whether app/ exists to determine the srcDir).

Source

fn resolve_config( &self, _config_path: &Path, _source: &str, _root: &Path, ) -> PluginResult

Parse a config file’s AST to discover additional entries, dependencies, etc.

Called for each config file matching config_patterns(). The source code and parsed AST are provided — use config_parser utilities to extract values.

Source

fn package_json_config_key(&self) -> Option<&'static str>

The key name in package.json that holds inline configuration for this tool. When set (e.g., "jest" for the "jest" key in package.json), the plugin system will extract that key’s value and call resolve_config with its JSON content if no standalone config file was found.

Implementors§