Skip to content

hyperpolymath/fslint-plugin-sdk

fslint-plugin-sdk

Palimpsest

Rust 1.70+ RSR Tier 1

SDK with helper utilities for FSLint plugin development.

1. Overview

This crate provides helper utilities for building plugins for FSLint. It re-exports fslint-plugin-api and adds useful helpers for common plugin operations.

1.1. Features

  • Path utilities - Extension extraction, hidden file detection

  • Metadata helpers - File age, size formatting

  • Common patterns - Predefined patterns for node_modules, images, etc.

  • Context helpers - Simplified access to plugin context

  • Re-exports - Includes all of fslint-plugin-api

2. Installation

Add to your Cargo.toml:

[dependencies]
fslint-plugin-sdk = "0.1"

3. Modules

3.1. path - Path Helpers

use fslint_plugin_sdk::path;

let ext = path::extension(Path::new("file.txt"));  // Some("txt")
let hidden = path::is_hidden(Path::new(".hidden")); // true

3.2. metadata - File Metadata Helpers

use fslint_plugin_sdk::metadata;

let age = metadata::age_in_days(modified_time);
let size = metadata::format_size(1024 * 1024);  // "1.00 MB"

3.3. patterns - Common File Patterns

use fslint_plugin_sdk::patterns::{Patterns, matches};

if matches(path, &Patterns::node_modules()) {
    // Skip node_modules
}

if matches(path, &Patterns::image_files()) {
    // Handle images
}

3.4. context - Plugin Context Helpers

use fslint_plugin_sdk::context;

let rel_path = context::relative_path(&ctx);
let size = context::file_size(&ctx);

4. Example Plugin

use fslint_plugin_sdk::prelude::*;  // Re-exports fslint-plugin-api
use fslint_plugin_sdk::{path, patterns};

pub struct LargeFilePlugin;

impl Plugin for LargeFilePlugin {
    fn metadata() -> PluginMetadata {
        PluginMetadata {
            name: "large-files".into(),
            version: "0.1.0".into(),
            description: "Detect large files".into(),
            author: Some("hyperpolymath".into()),
            enabled_by_default: true,
        }
    }

    fn check(&self, ctx: &PluginContext) -> Result<PluginResult, PluginError> {
        // Skip hidden files
        if path::is_hidden(&ctx.path) {
            return Ok(PluginResult::skipped("large-files"));
        }

        // Check file size
        let size = ctx.metadata.len();
        if size > 10 * 1024 * 1024 {  // 10MB
            return Ok(PluginResult::warning(
                "large-files",
                &format!("Large file: {}", metadata::format_size(size))
            ));
        }

        Ok(PluginResult::inactive("large-files"))
    }
}

6. License

PMPL-1.0 OR PMPL-1.0

See LICENSE-PMPL-1.0 for details.

7. Contributing

Contributions welcome! Please read CONTRIBUTING.md first.

Sponsor this project

Packages

No packages published

Contributors 3

  •  
  •  
  •