Skip to content

no_zero_width_chars

Flag body-internal zero-width characters (U+200B, U+200C, U+200D, and non-leading U+FEFF). A leading U+FEFF is no_bom’s concern.

As of v0.14 the detection set also covers U+2060 (word joiner) and U+180E (Mongolian vowel separator).


This rule takes no kind-specific options.

Plus the common paths, level, id, and when fields. This table is generated from the JSON Schema; option types and defaults are authoritative.

An identifier with a hidden zero-width space

Section titled “An identifier with a hidden zero-width space”

The rule fires on this repository:

src/
src/clean.rs
src/obfuscated.rs
src/clean.rs
pub fn normal() {}
src/obfuscated.rs
pub fn sec<U+200B>ret() {}

With this .alint.yml:

version: 1
rules:
- id: no-zwsp
kind: no_zero_width_chars
paths: "src/**/*.rs"
level: error

alint check reports:

Terminal window
--- src/obfuscated.rs ----------------------------------------------------------
x error no-zwsp
1:11 zero-width character U+200B at line 1 col 11
Summary (1 violation):
x 1 error
0 passing * 1 failing

A file whose only zero-width codepoint is an allowed leading BOM

Section titled “A file whose only zero-width codepoint is an allowed leading BOM”

This repository is compliant:

src/
src/clean.rs
src/with_bom.rs
src/clean.rs
pub fn ok2() {}
src/with_bom.rs
<U+FEFF>pub fn ok() {}

With this .alint.yml:

version: 1
rules:
- id: no-zwsp
kind: no_zero_width_chars
paths: "src/**/*.rs"
level: error

alint check reports:

Terminal window
v All 1 rule(s) passed.