This crate provides helper utilities for building plugins for FSLint. It re-exports fslint-plugin-api and adds useful helpers for common plugin operations.
use fslint_plugin_sdk::path;
let ext = path::extension(Path::new("file.txt")); // Some("txt")
let hidden = path::is_hidden(Path::new(".hidden")); // trueuse fslint_plugin_sdk::metadata;
let age = metadata::age_in_days(modified_time);
let size = metadata::format_size(1024 * 1024); // "1.00 MB"use fslint_plugin_sdk::patterns::{Patterns, matches};
if matches(path, &Patterns::node_modules()) {
// Skip node_modules
}
if matches(path, &Patterns::image_files()) {
// Handle images
}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"))
}
}-
fslint-plugin-api - Core plugin trait and types
-
file-soup - The main FSLint application
MIT OR Apache-2.0
See LICENSE-MIT for details.
Contributions welcome! Please read CONTRIBUTING.md first.