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).
Same binary policy as no_bidi_controls: a binary-looking file is scanned only when it is valid UTF-8 (so a NUL byte cannot hide a character), invalid-UTF-8 binaries are skipped, and a finding in a binary-looking file is reported but not auto-fixed.
Options
Section titled "Options"This rule takes no kind-specific options.
Plus the common paths, level, id, when, and expect_matches fields. This table is generated from the JSON Schema; option types and defaults are authoritative.
Example
Section titled "Example"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
✗ error no-zwsp
1:11 zero-width character U+200B at line 1 col 11
pub fn normal() {}pub fn sec<U+200B>ret() {}With this .alint.yml:
version: 1rules: - id: no-zwsp kind: no_zero_width_chars paths: "src/**/*.rs" level: erroralint check reports:
--- 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 failingA 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✓
pub fn ok2() {}<U+FEFF>pub fn ok() {}With this .alint.yml:
version: 1rules: - id: no-zwsp kind: no_zero_width_chars paths: "src/**/*.rs" level: erroralint check reports:
v All 1 rule(s) passed.