ls-lint
ls-lint is an extremely fast file and directory name linter that helps maintain consistent naming conventions across your project. It validates file and directory names against configurable rules to enforce naming patterns, prevent problematic characters, and ensure cross-platform compatibility.
Key Features:
- Lightning Fast Performance: Written in Go for extremely fast scanning of large directory structures and file systems
- Configurable Rules: Flexible YAML configuration supporting regex patterns, case conventions, and custom naming rules
- Cross-Platform Compatibility: Prevents naming conflicts between different operating systems (Windows, macOS, Linux)
- Multiple Naming Conventions: Built-in support for camelCase, PascalCase, snake_case, kebab-case, and custom patterns
- Directory Structure Validation: Enforces consistent naming across both files and directory hierarchies
- Zero Dependencies: Standalone binary with no external dependencies for easy installation and deployment
- Globbing Support: Advanced pattern matching for applying different rules to specific file types or directories
- Team Collaboration: Ensures consistent naming conventions across large development teams and projects
- Error Prevention: Catches naming issues early to prevent problems with case-sensitive filesystems and tools
ls-lint documentation
- Version in MegaLinter: 2.3.1
- Visit Official Web Site
- See Index of problems detected by ls-lint
Configuration in MegaLinter
- Enable ls-lint by adding
REPOSITORY_LS_LINT
in ENABLE_LINTERS variable - Disable ls-lint by adding
REPOSITORY_LS_LINT
in DISABLE_LINTERS variable
Variable | Description | Default value |
---|---|---|
REPOSITORY_LS_LINT_ARGUMENTS | User custom arguments to add in linter CLI call Ex: -s --foo "bar" |
|
REPOSITORY_LS_LINT_COMMAND_REMOVE_ARGUMENTS | User custom arguments to remove from command line before calling the linter Ex: -s --foo "bar" |
|
REPOSITORY_LS_LINT_CLI_LINT_MODE | Override default CLI lint mode ⚠️ As default value is project, overriding might not work - file : Calls the linter for each file- list_of_files : Call the linter with the list of files as argument- project : Call the linter from the root of the project |
project |
REPOSITORY_LS_LINT_PRE_COMMANDS | List of bash commands to run before the linter | None |
REPOSITORY_LS_LINT_POST_COMMANDS | List of bash commands to run after the linter | None |
REPOSITORY_LS_LINT_UNSECURED_ENV_VARIABLES | List of env variables explicitly not filtered before calling REPOSITORY_LS_LINT and its pre/post commands | None |
REPOSITORY_LS_LINT_CONFIG_FILE | ls-lint configuration file nameUse LINTER_DEFAULT to let the linter find it |
.ls-lint.yml |
REPOSITORY_LS_LINT_RULES_PATH | Path where to find linter configuration file | Workspace folder, then MegaLinter default rules |
REPOSITORY_LS_LINT_DISABLE_ERRORS | Run linter but consider errors as warnings | false |
REPOSITORY_LS_LINT_DISABLE_ERRORS_IF_LESS_THAN | Maximum number of errors allowed | 0 |
REPOSITORY_LS_LINT_CLI_EXECUTABLE | Override CLI executable | ['ls-lint'] |
MegaLinter Flavors
This linter is available in the following flavors
Flavor | Description | Embedded linters | Info | |
---|---|---|---|---|
![]() |
all | Default MegaLinter Flavor | 126 | |
c_cpp | Optimized for pure C/C++ projects | 56 | ||
ci_light | Optimized for CI items (Dockerfile, Jenkinsfile, JSON/YAML schemas,XML | 22 | ||
cupcake | MegaLinter for the most commonly used languages | 87 | ||
documentation | MegaLinter for documentation projects | 49 | ||
dotnet | Optimized for C, C++, C# or VB based projects | 64 | ||
dotnetweb | Optimized for C, C++, C# or VB based projects with JS/TS | 73 | ||
go | Optimized for GO based projects | 51 | ||
java | Optimized for JAVA based projects | 54 | ||
javascript | Optimized for JAVASCRIPT or TYPESCRIPT based projects | 59 | ||
php | Optimized for PHP based projects | 54 | ||
python | Optimized for PYTHON based projects | 65 | ||
ruby | Optimized for RUBY based projects | 50 | ||
rust | Optimized for RUST based projects | 50 | ||
salesforce | Optimized for Salesforce based projects | 54 | ||
swift | Optimized for SWIFT based projects | 50 | ||
terraform | Optimized for TERRAFORM based projects | 54 |
Behind the scenes
How are identified applicable files
- Activated only if one of these files is found:
.ls-lint.yml
- If this linter is active, all files will always be linted
How the linting is performed
ls-lint is called once on the whole project directory (project
CLI lint mode)
- filtering can not be done using MegaLinter configuration variables,it must be done using ls-lint configuration or ignore file (if existing)
VALIDATE_ALL_CODEBASE: false
doesn't make ls-lint analyze only updated files
Example calls
ls-lint
ls-lint --workdir src
Help content
ls-lint [options] [file|dir]*
Options:
-config value
ls-lint config file path(s)
-debug
write debug informations to stdout
-error-output-format string
use a specific error output format (text, json) (default "text")
-version
prints version information for ls-lint
-warn
write lint errors to stdout instead of stderr (exit 0)
-workdir string
change working directory before executing the given subcommand (default ".")
Installation on mega-linter Docker image
- Dockerfile commands :
# renovate: datasource=npm depName=@ls-lint/ls-lint
ARG NPM_LS_LINT_LS_LINT_VERSION=2.3.1
- NPM packages (node.js):