Comments (3)
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.
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.
Closing this as #148 allows to have custom rulesets :)
from twigcs.
Related Issues (20)
- `UnusedVariable`: Variables defined inside `for` should not be usable outside HOT 1
- Sign PHAR releases HOT 2
- Ability to exclude files (not only dirs) and/or limit sniffing to git diff HOT 1
- Please publish the new release (for symfony 6 use) HOT 2
- Problem when multiple lines HOT 7
- Invalid version value HOT 1
- Support request: How to disable verification of a code fragment? HOT 2
- Support config files with `.php` extension HOT 1
- Spacing of default values in macros HOT 2
- SEVERITY_IGNORE not working
- RegEngine is not happy with breaklines
- Unused variable should not be trigger if the child mutate a parent's variable. HOT 1
- Support for ??? "Empty Coalesce" operator HOT 1
- Variables set and used in loop should not be marked as unused HOT 2
- PHP 8.2 deprecations
- Supporting `createTemplate()`
- Configure cache file location HOT 2
- Avoid useless whitespace control
- Detect Twig depreciations
- PHP 8.3 support HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from twigcs.