We are excited to announce the release of Mago version 0.9.1, which brings significant improvements and new features to both the formatter and linter. This release focuses on enhancing user control, improving code formatting accuracy, and addressing community feedback.
✨ New Features
🚫 @mago-ignore
Comment Support
This release introduces a highly requested feature: the @mago-ignore comment. You can now selectively disable specific linter rules for targeted sections of your code. This provides a flexible way to handle false positives, suppress warnings in specific scenarios, or temporarily bypass certain rules when necessary.
Syntax
@mago-ignore {plugin}/{rule} {description}
:{plugin}/{rule}
: Specifies the linter rule to be ignored (e.g.,strictness/require-return-type
).{description}
(Optional): A brief explanation of why the rule is being ignored. While optional, providing a description is highly recommended for code clarity and maintainability.
Example
/**
* @mago-ignore strictness/require-return-type
*/
function example()
{
// @mago-ignore analysis/undefined-function-or-method
$a = foo();
}
The linter will also intelligently report any @mago-ignore comments that are no longer needed, helping you maintain a clean and relevant set of ignore directives.
This feature was implemented by @azjezz in PR #71, fulfilling a request from @M-arcus in Issue #46.
Ignore comments have been a long-standing community request. This addition empowers users to tailor the linter's strictness to their specific project needs, allowing for more nuanced control over code analysis and improved workflow.
📝 Exclude Files from Formatting
Mago 0.9.1 introduces a new excludes
configuration option for the formatter within your mago.toml
configuration file. This powerful feature enables you to define patterns for files, directories, or glob patterns that should be excluded from formatting operations.
Example:
[format]
excludes = ["**/src/**/*.generated.php"]
Files matching these patterns will be skipped during formatting, ensuring you can maintain control over specific files that should not be automatically formatted while still benefiting from linting and other analysis functionalities.
This feature was implemented in PR #72 by @azjezz, in response to a request from @bendavies in Issue #28.
This enhancement provides greater flexibility in managing your formatting process, allowing you to selectively format your codebase based on project requirements and preferences.
🛠 Bug Fixes
📝 Fix Trailing & Dangling Comments
This release addresses and resolves several bugs within the formatter specifically related to the handling of trailing and dangling comments. These fixes improve the accuracy and reliability of Mago's code formatting, especially in scenarios with complex comment placements within code blocks and after opening tags.
These important fixes are implemented by @azjezz in PR #73.
This ensures that your code is formatted consistently and predictably, even with intricate comment structures, leading to a more polished and professional codebase.
Happy Formatting & Linting!
Full Changelog: 0.9.0...0.9.1