Skip to content

Command Reference

The mago lint command is the entry point for all linting-related tasks.

sh
Usage: mago lint [OPTIONS] [PATH]...

Arguments

[PATH]...

Optional. A list of specific files or directories to lint. If you provide paths here, they will be used instead of the paths defined in your mago.toml configuration.


Options

--list-rules

List all enabled linter rules and their descriptions.

--explain <RULE_CODE>

Provide detailed documentation for a specific linter rule (e.g., no-redundant-nullsafe).

-o, --only <RULE_CODE>

Run only a specific, comma-separated list of rules, overriding the configuration file.

-s, --semantics-only

Perform only the parsing and basic semantic checks without running any lint rules.

Auto-Fixing

FlagDescription
--fixAutomatically apply any safe fixes for the issues that are found.
--fixable-onlyFilter the output to show only issues that have an automatic fix available.
--unsafeApply fixes that are marked as "unsafe" and may require manual verification.
--potentially-unsafeApply fixes that are marked as "potentially unsafe".
--format-after-fixAutomatically run the formatter on any files modified by --fix.
-d, --dry-runPreview fixes as a diff without writing any changes to disk.

Reporting

FlagDescription
--sortSort reported issues by level, code, and location.
--reporting-format <FORMAT>Choose the output format (e.g., rich, json, checkstyle). Default: rich.
-m, --minimum-fail-level <LEVEL>Set the minimum issue level (note, help, warning, error) that will cause a failure exit code. Default: error.

Baseline

FlagDescription
--generate-baselineGenerate a baseline file (mago-baseline.php) to ignore all currently existing issues.
--baseline <PATH>Specify a custom path to a baseline file to use for ignoring issues.
--backup-baselineBackup the old baseline file when generating a new one.

-h, --help

Print the help summary for the command.