Imported from lucasols/palinter (
AGENTS.md). Install upstream withnpx skills add lucasols/palinter. Copyright stays with the author.
AGENTS.md
This file provides guidance to coding agents when working with code in this repository.
Project Overview
PALinter is a Rust-based architecture linter for projects, primarily focused on TypeScript projects. It validates project structure through YAML configuration files that define rules for files and folders.
Development Commands
Core Development
cargo run- Run the linter with default config (palinter.yaml)cargo run -- --help- Show CLI helpmake test- Run all testscargo clippy- Run linting
Building and Publishing
make build- Build for multiple targets and prepare npm packagemake publish_patch- Patch version bump and publishmake publish_minor- Minor version bump and publish
Test Commands
cargo run -- test-config <test_cases_folder>- Test config against test casescargo run -- circular-deps <file>- Check circular dependenciescargo insta test --unreferenced=delete- Delete unused snapshots
Testing real projects
Real project commands can be configured in makefile.local, use it for testing the linter on actual projects and configurations:
make real_project_test- Run linter on the configured real projectmake real_project_test_allow_warnings- Run linter on the configured real project allowing warningsmake real_project_test_config- Run config tests for the configured real project
Architecture
Core Modules
-
CLI (
cli.rs) - Command-line interface with three main commands:lint(default) - Lint project structurecircular-deps- Check circular dependenciestest-config- Test configuration against test cases
-
Config System:
parse_config_file.rs- Parse YAML config filesinternal_config.rs- Internal config representation with types likeFileExpected,FolderConfig, etc.
-
Folder Analysis (
check_folders/):check_folders.rs- Main folder checking logicchecks.rs- Individual check implementations (file/folder rules)
-
TypeScript Analysis (
analyze_ts_deps/):modules_graph.rs- Build dependency graphscircular_deps.rs- Detect circular dependenciests_checks.rs- TypeScript-specific validationsextract_file_content_imports.rs/extract_file_content_exports.rs- Parse imports/exports
-
File Structure (
load_folder_structure.rs) - Load and represent project file structure
Key Data Structures
Config- Main configuration structureFile/Folder/FolderChild- File system representationFileConditions/FolderConditions- Rule conditionsFileExpect/FolderExpect- Expected behaviorsAnyOr<T>/AnyNoneOr<T>- Flexible condition matching
Configuration System
PALinter uses YAML configuration files (default: palinter.yaml) that define:
- File and folder selection paths
- Conditional rules (
if_file,if_folder) - Expectations (
expectblocks) - TypeScript-specific checks
Example structure:
./:
/folder:
rules:
- if_file: any
expect:
name_case_is: camelCase
Testing
- Snapshot testing using
instacrate - Test cases in
src/test_cases/directory organized by feature - Integration tests in
src/fixtures/for different scenarios - Unit tests embedded in modules
TypeScript Features
Advanced TypeScript analysis capabilities:
- Circular dependency detection
- Import/export validation
- Unused export detection
- Module graph construction
- Pattern matching for file content
Build Configuration
- Clippy configured with
too-many-arguments-threshold = 20 - Rustfmt with
max_width = 85 - Multi-target builds for npm distribution (Linux, macOS, Windows)