# yowainwright/es-check architecture

> Architecture diagram of the GitHub repository yowainwright/es-check, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-01-14). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/yowainwright/es-check
- Repository: https://github.com/yowainwright/es-check

## Overview

##### Main Components

a. Core Components:
- CLI Interface
- Configuration Handler
- ES Version Checker
- Feature Detection Engine
- File System Handler
- Reporting System

b. External Dependencies:
- Acorn Parser
- Fast-glob
- Winston Logger
- Commander

**[CLI Input] → [ES Check Core] → [Output/Results]**

- ┌─────────────────┐
- Config Files  │
- (.escheckrc)    │
- ┬────────┘

**┌──────────────┐    ┌──────────────┐    ┌──▼───────────┐**
- CLI Input  │───►│   Commander   │───►│  Config      │
- (ES version,│    │   Interface   │    │  Handler     │
- files)     │    └──────────────┘    └──────┬───────┘
- ┘                                │
- ▼
**┌──────────────┐    ┌──────────────┐    ┌─────────────┐**
- Fast-glob  │◄───│ File System  │◄───│ ES Check    │
- Library    │    │   Handler    │    │   Core      │
- ┬──────┘    └──────────────┘    └─────┬───────┘

- ▼                                      ▼
**┌──────────────┐    ┌──────────────┐    ┌─────────────┐**
- File List   │───►│ Acorn Parser │◄───│  Feature    │
- Detector   │
- ┘    └──────┬───────┘    └─────────────┘

- ▼
- ┌──────────────┐
- Winston    │
- Logger     │
- ┬───────┘

- ▼
- ┌──────────────┐
- Output     │
- (Pass/Fail)  │
- ┘

##### Important Flows to Highlight

a. Configuration Flow:
- CLI arguments processing
- .escheckrc file reading
- Merging of configurations

b. File Processing Flow:
- Glob pattern matching
- File reading
- Syntax checking
- Feature detection (when --checkFeatures flag is used)

c. Validation Flow:
- ES version validation
- Feature compatibility checking
- Error reporting

##### Implementation Details to Note

- Relationship between test files and core functionality
- Modular nature of the feature detection system
- Configuration options (module, allowHashBang, etc.)
- Error handling and reporting paths

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph Input
        CLI[CLI Input]
        ConfigFile[".escheckrc"]:::config
    end

    subgraph Core
        Commander[Commander Interface]
        ConfigHandler[Configuration Handler]:::config
        ESCore[ES Check Core]:::core
        FSHandler[File System Handler]:::utils
        FeatureDetector[Feature Detection Engine]:::feature
    end

    subgraph Dependencies
        FastGlob[Fast-glob Library]
        Acorn[Acorn Parser]
        Winston[Winston Logger]
    end

    subgraph Testing
        TestFramework[Test Framework]
        ES5Tests[ES5 Tests]:::test
        ES6Tests[ES6 Tests]:::test
        ModernTests[Modern ES Tests]:::test
        SpecialTests[Special Cases Tests]:::test
    end

    subgraph Output
        Results[Output Results]
    end

    %% Connections
    CLI --> Commander
    ConfigFile --> ConfigHandler
    Commander --> ConfigHandler
    ConfigHandler --> ESCore
    ESCore --> FSHandler
    FSHandler --> FastGlob
    FastGlob --> ESCore
    ESCore --> FeatureDetector
    FeatureDetector --> Acorn
    ESCore --> Winston
    Winston --> Results

    %% Testing Connections
    TestFramework --> ES5Tests
    TestFramework --> ES6Tests
    TestFramework --> ModernTests
    TestFramework --> SpecialTests

    %% Styling
    classDef core fill:#a8d08d
    classDef config fill:#b4c7e7
    classDef utils fill:#f4b183
    classDef feature fill:#ffd966
    classDef test fill:#c9c9c9

    %% Click Events
    click ESCore "https://github.com/yowainwright/es-check/blob/main/index.js"
    click FeatureDetector "https://github.com/yowainwright/es-check/blob/main/detectFeatures.js"
    click ConfigFile "https://github.com/yowainwright/es-check/blob/main/.escheckrc"
    click FSHandler "https://github.com/yowainwright/es-check/blob/main/utils.js"
    click ES5Tests "https://github.com/yowainwright/es-check/blob/main/tests/es5.js"
    click ES6Tests "https://github.com/yowainwright/es-check/blob/main/tests/es6.js"
    click ModernTests "https://github.com/yowainwright/es-check/blob/main/tests/es7.js"
    click SpecialTests "https://github.com/yowainwright/es-check/blob/main/tests/scripts/hash-bang.js"

    %% Legend
    subgraph Legend
        L1[Core Components]:::core
        L2[Configuration]:::config
        L3[Utilities]:::utils
        L4[Feature Detection]:::feature
        L5[Tests]:::test
    end
```
