Skip to content

[0.x] Adds support for specifying custom rules in pint.json #26

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 5 commits into from
Closed

[0.x] Adds support for specifying custom rules in pint.json #26

wants to merge 5 commits into from

Conversation

lukeraymonddowning
Copy link

@lukeraymonddowning lukeraymonddowning commented Jun 23, 2022

Hello there!

It would be nice in Pint if you were able to reference custom fixers for rules that aren't built into the package by default. This PR adds that functionality by allowing a developer to register a fixers array in their pint.json file.

{
    "fixers": [
        "App\\Fixers\\MyFixer"
    ]
}

The fixers array should contain FQCNs of FixerInterface classes. Pint will look these up when building the config, and automatically set them to true in the rules array.

A user may override rules if they wish by specifying the fixer name in the rules config:

{
    "fixers": [
        "App\\Fixers\\MyFixer"
    ],
    "rules": {
        "App/My_Fixer": {
            "some_custom_config": true
        }
    }
}

This allows for passing more specific arguments if the custom rule accepts them.

@lukeraymonddowning lukeraymonddowning changed the title Adds support for specifying custom rules in pint.json [0.x] Adds support for specifying custom rules in pint.json Jun 23, 2022
@lukeraymonddowning lukeraymonddowning marked this pull request as ready for review June 23, 2022 14:39
@Jubeki
Copy link
Contributor

Jubeki commented Jun 23, 2022

I think your custom fixers will not be loaded, because Pint is standalone and should not be loading your composer autoload file. Or am I wrong there?

@lukeraymonddowning
Copy link
Author

Lol @Jubeki good point 😁 Need to think of a way around that. Any suggestions?

@lukeraymonddowning lukeraymonddowning marked this pull request as draft June 23, 2022 15:04
@lukeraymonddowning
Copy link
Author

Converting to draft until I solve the Elephant in the room

@nunomaduro
Copy link
Member

@lukeraymonddowning You may be able to "require" the file. Yet, for now, we plan allow custom rules. Maybe in the future!

@nunomaduro nunomaduro closed this Jun 23, 2022
@dennisprudlo dennisprudlo mentioned this pull request Jun 27, 2022
ablancobarreda added a commit to ablancobarreda/pint that referenced this pull request Jan 5, 2023
@Riley19280 Riley19280 mentioned this pull request Aug 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants