File length linter for any language — single native binary, zero runtime deps
Project description
open-harness-linelens
File length linter for any language. Reports files that exceed a configured line limit. Single native binary, zero runtime dependencies.
Part of the open-harness monorepo. Español abajo.
Same tool, other ecosystems: also available on npm (
@open_harness/linelens) and on Packagist (open-harness/linelens). Identical binary, identical config; pick the registry that matches your stack.
Install
pip install open-harness-linelens
pip picks the right native wheel for your platform automatically (Linux x86_64, macOS arm64, macOS x86_64, Windows x86_64). Each wheel embeds the Go binary — no runtime deps.
Usage
linelens check # scan current directory
linelens check --fail # exit 1 on violations (CI / git hooks)
linelens check --dir ./src # scan a specific directory
linelens check --max 200 # override the line limit
linelens check --no-color # plain output for logs
linelens init # generate a default linelens.json
linelens version # print version
Configuration
Place a linelens.json at the repo root:
{
"default": { "maxLines": 100 },
"rules": [
{ "pattern": "**/*_test.go", "maxLines": 300 },
{ "pattern": "**/*.spec.*", "maxLines": 300 },
{ "pattern": "**/migrations/**", "skip": true }
],
"exclude": ["node_modules", "vendor", ".git", "dist"]
}
Pattern semantics follow .gitignore style. The first matching rules entry wins; if no rule matches, default.maxLines applies.
Alternative: configure inside pyproject.toml or the dedicated linelens.json
If you prefer not to keep a separate linelens.json, add a linelens key in your package.json with the same shape:
{
"name": "my-project",
"linelens": {
"default": { "maxLines": 100 },
"rules": [{ "pattern": "**/*_test.go", "maxLines": 300 }],
"exclude": ["node_modules", "dist"]
}
}
Precedence: --config <path> > linelens.json > package.json key > built-in defaults. CLI flags (--max, --no-color, etc.) always win.
Integrations
# Husky pre-commit
linelens check --fail
# lefthook.yml
pre-commit:
commands:
linelens:
run: linelens check --fail --no-color
# GitHub Actions
- name: Run linelens
run: npx @open_harness/linelens check --fail
Why a line limit?
Large files concentrate too many responsibilities and become hard to read, test, and refactor. A soft cap (e.g. 100 lines, with exceptions for tests) keeps modules focused and forces responsibility-split decisions early — when they are cheap.
Exit codes
| Code | Meaning |
|---|---|
0 |
No violations (or --fail not passed) |
1 |
Violations found and --fail was passed, or config error |
Español
Linter de longitud de archivos, agnóstico al lenguaje. Reporta los archivos que superan un límite de líneas configurable. Un solo binario nativo, cero dependencias en tiempo de ejecución.
Parte del monorepo open-harness.
Instalación
pip install open-harness-linelens
pip elige automáticamente la wheel nativa correcta para tu plataforma (Linux x86_64, macOS arm64, macOS x86_64, Windows x86_64). Cada wheel embebe el binario Go — sin deps en runtime.
Uso
linelens check # escanea el directorio actual
linelens check --fail # exit 1 si hay violaciones (CI / git hooks)
linelens check --dir ./src # escanea un directorio específico
linelens check --max 200 # sobrescribe el límite de líneas
linelens check --no-color # salida sin colores
linelens init # genera un linelens.json por defecto
linelens version # imprime la versión
Configuración
Colocá un linelens.json en la raíz del repo. Ver ejemplo arriba. La semántica de patrones sigue el estilo .gitignore. La primera regla coincidente en rules gana; si ninguna coincide, aplica default.maxLines.
Alternativa: configurar dentro de pyproject.toml o linelens.json
Si preferís no tener un linelens.json separado, agregá una key linelens en tu package.json con la misma forma del archivo dedicado. Precedencia: --config <path> > linelens.json > key en package.json > defaults del binario. Los flags CLI (--max, --no-color, etc.) siempre ganan.
Integraciones
Mismos snippets que arriba — sirven con Husky (.husky/pre-commit), lefthook (lefthook.yml) o GitHub Actions.
Por qué un límite de líneas
Los archivos grandes concentran demasiadas responsabilidades y son difíciles de leer, testear y refactorizar. Un tope blando (por ejemplo 100 líneas, con excepciones para tests) mantiene los módulos enfocados y obliga a tomar decisiones de partición temprano — cuando son baratas.
Códigos de salida
| Código | Significado |
|---|---|
0 |
Sin violaciones (o no se pasó --fail) |
1 |
Hubo violaciones con --fail, o error de configuración |
License
MIT — see the main repository.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
Built Distributions
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file open_harness_linelens-0.2.1-py3-none-win_amd64.whl.
File metadata
- Download URL: open_harness_linelens-0.2.1-py3-none-win_amd64.whl
- Upload date:
- Size: 1.7 MB
- Tags: Python 3, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
47ca3e9630d2a4afc0352c39c7a287ab0dc1fadcda3d968d8a58eb6c6e6999e4
|
|
| MD5 |
5da3a143f3e8aa04f1112c6e0f88c6ac
|
|
| BLAKE2b-256 |
9b26f7b7ce4697384a12dc1f08f6e21a15f647a16277c2323874fb80d169c1be
|
File details
Details for the file open_harness_linelens-0.2.1-py3-none-manylinux2014_x86_64.whl.
File metadata
- Download URL: open_harness_linelens-0.2.1-py3-none-manylinux2014_x86_64.whl
- Upload date:
- Size: 837.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6fb39e7ee361673c6b9fc5b98428aa6e061dd031a08d38bb53e50056ff1d10aa
|
|
| MD5 |
b72ae6a98d01c26b6b71217330769ef2
|
|
| BLAKE2b-256 |
abbabccfa187583578f3b922f66bc31f08267666b467fe785f9d8658fa937cb9
|
File details
Details for the file open_harness_linelens-0.2.1-py3-none-macosx_11_0_arm64.whl.
File metadata
- Download URL: open_harness_linelens-0.2.1-py3-none-macosx_11_0_arm64.whl
- Upload date:
- Size: 806.8 kB
- Tags: Python 3, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0aed5d51951f6b7c6fe2e685748c452e98686ee2f25c33698e07b6e37e27d07d
|
|
| MD5 |
958151edb42f1a5c45eb6257309c1396
|
|
| BLAKE2b-256 |
b2bae56da70173a8414bf202c3d0628682bbf63d3ef75e44209808d3839210d9
|
File details
Details for the file open_harness_linelens-0.2.1-py3-none-macosx_10_9_x86_64.whl.
File metadata
- Download URL: open_harness_linelens-0.2.1-py3-none-macosx_10_9_x86_64.whl
- Upload date:
- Size: 850.5 kB
- Tags: Python 3, macOS 10.9+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a27bef1bb3186f7ee6f46efea0e733bcc89f53621727838d007cc0ef5c998413
|
|
| MD5 |
b1cde4664ff197b16dabf6d0546eebc4
|
|
| BLAKE2b-256 |
04bbd15c3fcca99f94d288a945c86b2eabe3784f996f54ea4b30aa64b15474a2
|