Description
By default, Pattern Lab is pretty opinionated about the folder structure for source/_patterns
folder. This can lead to issues when packaging components in a way Pattern Lab doesn't expect.
For example:
source/_patterns/atoms/
button/
button.twig
js/
index.js
sass/
button.scss
tests/
test.js
Leads to several undesired component sub types getting created when Pattern Lab is compiled:
ATOMS / BUTTON / JS
ATOMS / BUTTON / SASS
ATOMS / BUTTON / TESTS
When what we really want is just the:
ATOMS / BUTTON component.
Here's a list of the default rules provided by Pattern Lab:
PatternLab\PatternData\Rules\DocumentationRule
PatternLab\PatternData\Rules\PatternInfoListItemsRule
PatternLab\PatternData\Rules\PatternInfoRule
PatternLab\PatternData\Rules\PatternRule
PatternLab\PatternData\Rules\PatternSubtypeRule
PatternLab\PatternData\Rules\PatternTypeRule
PatternLab\PatternData\Rules\PseudoPatternRule
The use of these rules is currently hard coded in:
https://github.com/drupal-pattern-lab/patternlab-php-core/blob/master/src/PatternLab/PatternData.php#L393
I would propose allowing this to be configured in config/config.yml
:
twigTagExt: tag.php
twigTestExt: test.php
enabledPatternRules:
- PatternLab\PatternData\Rules\DocumentationRule
- PatternLab\PatternData\Rules\PatternInfoListItemsRule
- PatternLab\PatternData\Rules\PatternInfoRule
- PatternLab\PatternData\Rules\PatternRule
- CustomRules\PatternSubtypeFilterRule
- PatternLab\PatternData\Rules\PatternTypeRule
- PatternLab\PatternData\Rules\PseudoPatternRule
...
This would prevent users from having to perform hacky file system magic (currently we do this with a gulp task creating symlinks galore) in order to get their existing component libraries running in Pattern Lab.