Skip to main content

Plugin

Trait Plugin 

Source
pub trait Plugin: Send + Sync {
    // 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 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 resolve_config(
        &self,
        _config_path: &Path,
        _source: &str,
        _root: &Path,
    ) -> PluginResult { ... }
}
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 entry_patterns(&self) -> &'static [&'static str]

Default glob patterns for entry point files.

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 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 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.

Implementors§