Skip to content

Commit 8c193bc

Browse files
committed
Add checks for hard-to-see characters.
1 parent 62715cf commit 8c193bc

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

style-check/src/main.rs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ fn check_directory(dir: &Path, bad: &mut bool) -> Result<(), Box<dyn Error>> {
5151
if contents.contains("#![feature") {
5252
style_error!(bad, path, "#![feature] attributes are not allowed");
5353
}
54-
if contents.contains('\r') {
54+
if !cfg!(windows) && contents.contains('\r') {
5555
style_error!(
5656
bad,
5757
path,
@@ -64,6 +64,15 @@ fn check_directory(dir: &Path, bad: &mut bool) -> Result<(), Box<dyn Error>> {
6464
if !contents.ends_with('\n') {
6565
style_error!(bad, path, "file must end with a newline");
6666
}
67+
if contents.contains('\u{2013}') {
68+
style_error!(bad, path, "en-dash not allowed, use two dashes like --");
69+
}
70+
if contents.contains('\u{2014}') {
71+
style_error!(bad, path, "em-dash not allowed, use three dashes like ---");
72+
}
73+
if contents.contains('\u{a0}') {
74+
style_error!(bad, path, "don't use 0xa0 no-break-space, use &nbsp; instead");
75+
}
6776
for line in contents.lines() {
6877
if line.ends_with(' ') {
6978
style_error!(bad, path, "lines must not end with spaces");

0 commit comments

Comments
 (0)