Thanks to visit codestin.com
Credit goes to github.com

Skip to content

harshadixit12/yuc

Repository files navigation

YUC

Stands for YAML Unicode Check.

Sketchy unicode characters can hide in plain sight, and can cause unpredictable failures in your declarative configurations. YUC helps you find these.

Install

macOS (Homebrew):

brew tap harshadixit12/yuc --force-auto-update
brew trust --formula harshadixit12/yuc/yuc
brew install yuc

Or install with a single command (platform agnostic):

curl -fsSL https://raw.githubusercontent.com/harshadixit12/yuc/refs/heads/main/install.sh | bash

How to use

yuc myfile.yaml

Use as a Go library

go get github.com/harshadixit12/yuc
import "github.com/harshadixit12/yuc"

cfg := yuc.DefaultConfig()

// Scan files by path
results, err := yuc.Scan([]string{"deploy.yaml", "script.sh"}, cfg)
if err != nil {
    log.Fatal(err)
}

if yuc.HasErrors(results) {
    // handle error-severity issues
}

// Or scan from an io.Reader
res, err := yuc.ScanReader(reader, "filename.txt", cfg)

Each yuc.Result contains yuc.Issue entries:

for _, result := range results {
    for _, issue := range result.Issues {
        fmt.Printf("%s:%d %s\n", result.Filename, issue.Line, issue.Message)
    }
}

To load a config file instead of defaults:

cfg, err := yuc.LoadConfig(".yuc.yaml")

Config file reference

A .yuc.yaml file that exactly mirrors the built-in defaults — every category enabled at its default severity, no custom chars, no allowlist:

categories:
  BIDI_CONTROL:
    severity: error
    enabled: true
  ZERO_WIDTH:
    severity: warn
    enabled: true
  HOMOGLYPH:
    severity: warn
    enabled: true
  LINE_BREAK_CONTROL:
    severity: error
    enabled: true
  TAG_CONFUSION:
    severity: error
    enabled: true
  OVERLONG_SPACE:
    severity: warn
    enabled: true

Downgrade BIDI errors to warnings and disable homoglyph checks:

categories:
  BIDI_CONTROL:
    severity: warn
  HOMOGLYPH:
    enabled: false

Add a custom codepoint and allowlist one:

custom_chars:
  - codepoint: U+FFFD
    name: REPLACEMENT CHARACTER
    severity: warn
    reason: Indicates a decoding error; should not appear in source configs

allowlist:
  - U+FEFF  # permit BOM in this project's files

Combine overrides — strict mode (all categories as errors):

categories:
  ZERO_WIDTH:
    severity: error
  HOMOGLYPH:
    severity: error
  OVERLONG_SPACE:
    severity: error

License

MIT License

Copyright (c) 2026 Harsha Dixit

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

About

Run this on your yaml files to check for rogue unicode characters.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Packages

 
 
 

Contributors