Code Monkey home page Code Monkey logo

Comments (3)

OwlyCode avatar OwlyCode commented on June 2, 2024

Hello Toni,

It's an interesting topic and I would be thrilled to support your initiative! I never faced until now the opportunity to add a completely new ruleset. My current take on this would be to create a new repository, like toniperic/twigcs-<ruleset name> that contains the ruleset declaration and its custom rules. I see many advantages on this approach :

  • This would allow creators to maintain their own ruleset independently, without needing an approval and/or a merge from us.
  • This would allow creators to track the popularity of their rulesets on packagist.
  • This would prevent to have a lot of rulesets to maintain along twigcs. (they would upgrade asynchronously, and by the hand of their own maintainers)

But there would be work to do on twigcs itself too. At the moment using a custom ruleset only works if twigcs and the ruleset share the same autoloader (that means they are both in the dev-dependencies of the project). I would like to improve this in the future so you can use a ruleset from anywhere on your computer with both installations methods (phar or composer dev-dependency). I'm open to suggestions on that point as I have not started thinking on the technical details of this (autoloading? and where to store the configuration (if any)?).

For the functional testing part, we could create classes to help you do that on your repo. Like Symfony having a KernelTestCase and a CommandTester class. For instance :

use FriendsOfTwig\Twigcs\RulesetTestCase;

class FunctionalTest extends RulesetTestCase
{
    public function testMyRules()
    {
        $this->assertTwigcsValidFiles(__DIR__ . '/../data/corpus');
        $this->assertTwigcsValid('{{ foo }}');
        $this->assertTwigcsInvalid('{{ foo  }}', 'Hey there is an extra space here!', 'error', [1, 7]);
    }
}

What do you think about this ?

from twigcs.

toniperic avatar toniperic commented on June 2, 2024

Hey Tristan, sorry for the late reply.

That sounds good, thanks for the advice.

Regarding the autoloading part - that's not something I've tackled yet as my ruleset and TwigCS do share the same autoloader, so I don't have any suggestions at the moment, sorry. I'll for sure get back to you if something pops up.

As for the testing utilities - that could be a nice enhancement, yeah. Anything that would streamline testing definitely has a thumbs up from me.

from twigcs.

OwlyCode avatar OwlyCode commented on June 2, 2024

Closing this as #148 allows to have custom rulesets :)

from twigcs.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.