pub trait Plugin: Send + Sync {
Show 13 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 config_patterns(&self) -> &'static [&'static str] { ... }
fn always_used(&self) -> &'static [&'static str] { ... }
fn used_exports(&self) -> Vec<(&'static str, &'static [&'static str])> { ... }
fn tooling_dependencies(&self) -> &'static [&'static str] { ... }
fn virtual_module_prefixes(&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§
Provided Methods§
Sourcefn enablers(&self) -> &'static [&'static str]
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 /).
Sourcefn is_enabled(&self, pkg: &PackageJson, root: &Path) -> bool
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.
Sourcefn is_enabled_with_deps(&self, deps: &[String], _root: &Path) -> bool
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.
Sourcefn entry_patterns(&self) -> &'static [&'static str]
fn entry_patterns(&self) -> &'static [&'static str]
Default glob patterns for entry point files.
Sourcefn config_patterns(&self) -> &'static [&'static str]
fn config_patterns(&self) -> &'static [&'static str]
Glob patterns for config files this plugin can parse.
Sourcefn always_used(&self) -> &'static [&'static str]
fn always_used(&self) -> &'static [&'static str]
Files that are always considered “used” when this plugin is active.
Sourcefn used_exports(&self) -> Vec<(&'static str, &'static [&'static str])>
fn used_exports(&self) -> Vec<(&'static str, &'static [&'static str])>
Exports that are always considered used for matching file patterns.
Sourcefn tooling_dependencies(&self) -> &'static [&'static str]
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.
Sourcefn virtual_module_prefixes(&self) -> &'static [&'static str]
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).
Sourcefn path_aliases(&self, _root: &Path) -> Vec<(&'static str, String)>
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).
Sourcefn resolve_config(
&self,
_config_path: &Path,
_source: &str,
_root: &Path,
) -> PluginResult
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.
Sourcefn package_json_config_key(&self) -> Option<&'static str>
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.