8000 Support custom rules by dennisprudlo · Pull Request #55 · laravel/pint · GitHub
[go: up one dir, main page]

Skip to content

Conversation

dennisprudlo
Copy link

Hey pinters,

I wanted to use a linter since forever, however wasn't really satisfied with PHP-CS-Fixer as a standalone package. I wouldn't be able to use it out of the box either way because I use a unique – malicious gossip has it that it's a weird – coding style.

// psr 12
public function foo(): array
{
    $this->bar();

    // this returns something
    return array_map(fn($value) => ucwords($value), ['one', 'two', 'three']);
}
// my weird style
public function foo () : array {
    $this->bar();

    //
    // this returns something
    return array_map(fn ($value) => ucwords($value), [ 'one', 'two', 'three' ]);
}

Anyway, now with pint I just got to implement a linter. This PR is my attempt to implement custom rules, so I can start writing my own and use them with pint.

The configuration now accepts a new property where the fixers FQCN and the name of the rule can be specified:

{
    "custom": {
        "\\ACMECorp\\Fixers\\MyCustomFixer": "ACMECorp/my_custom_rule"
    }
}

The key is the FQCN to the fixer class and the value is the rule name which should be used for the configuration. I added two tests:

  1. Check if the custom property can be read by the ConfigurationJsonRepository
  2. Check if a custom fixer is being applied when specified. (The actual fixer is nonsense, but we know that the fixer is being applied)

I don't know if custom rules are even a desired feature for pint and if this gets closed I will still be waiting excitedly for custom rules. However, I'd love to hear some thoughts on this. 🙃

@dennisprudlo
Copy link
Author

Just saw the custom rule PR #26. Don't know why I didn't see it before 😅 I'm outta here 👋🏼

@dennisprudlo dennisprudlo deleted the support-custom-rules branch July 19, 2022 09:04
@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.

1 participant

0