Skip to content

line_max_width

Cap line length in characters (not bytes — code points). Optional tab_width for tab expansion.

A text file with stray invalid UTF-8 is measured (each invalid byte counts as one column) rather than skipped; binary-looking files are skipped.

OptionTypeRequiredDefaultDescription
max_widthinteger (>= 1)yesMaximum number of Unicode scalar values (chars) allowed per line.

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

A source file with a line past the width limit

Section titled "A source file with a line past the width limit"

The rule fires on this repository:

  • src/
  • src/ok.rs✓
  • src/wide.rs

    ⚠ warning narrow

    2:31 line 2 is 72 chars wide; max is 30

src/ok.rs
fn a() {}
fn b() {}
src/wide.rs
fn x() {}
this line is intentionally way too long to be acceptable under the limit
fn y() {}

With this .alint.yml:

version: 1
rules:
- id: narrow
kind: line_max_width
paths: "src/**/*.rs"
max_width: 30
level: warning

alint check reports:

Terminal window
--- src/wide.rs ----------------------------------------------------------------
! warning narrow
2:31 line 2 is 72 chars wide; max is 30
Summary (1 violation):
! 1 warning
0 passing * 1 failing

Every line stays within the width limit

Section titled "Every line stays within the width limit"

This repository is compliant:

  • src/
  • src/a.rs✓
  • src/b.rs✓
src/a.rs
fn a() {}
fn b() {}
src/b.rs
pub fn c() {}

With this .alint.yml:

version: 1
rules:
- id: narrow
kind: line_max_width
paths: "src/**/*.rs"
max_width: 30
level: warning

alint check reports:

Terminal window
v All 1 rule(s) passed.