-
Notifications
You must be signed in to change notification settings - Fork 941
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
Adding a phpcs.xml file #227
Comments
+1 We can use core's ruleset as a starting point: https://github.com/drupal/drupal/blob/8.4.x/core/phpcs.xml.dist |
Since this projects provides tooling via If we decide to do so, we would need to:
|
Config for core development contains a lot of core-specific rules that are not useful for consumer sites. Here is an example of the config file that can be used in this project (taken from 🌀Vortex Drupal project template and currently used on consumer sites): <?xml version="1.0"?>
<ruleset name="custom">
<description>Custom PHPCS Standard, based on Drupal standards.</description>
<file>web/modules/custom</file>
<file>web/themes/custom</file>
<file>web/sites/default/settings.php</file>
<file>web/sites/default/includes</file>
<file>tests</file>
<rule ref="Drupal"/>
<rule ref="DrupalPractice"/>
<rule ref="Generic.PHP.RequireStrictTypes" />
<rule ref="Generic.Debug.ESLint"/>
<rule ref="PHPCompatibility"/>
<arg name="extensions" value="inc,info,install,module,php,profile,test,theme,js,css"/>
<arg name="colors"/>
<arg value="sp"/>
<arg name="parallel" value="75"/>
<!-- Lint code against platform version specified in composer.json key "config.platform.php". -->
<config name="testVersion" value="8.3"/>
<!-- Exclude theme assets. -->
<exclude-pattern>web\/themes\/custom\/.*\/build\/.*</exclude-pattern>
<exclude-pattern>web\/themes\/custom\/.*\/fonts\/.*</exclude-pattern>
<exclude-pattern>web\/themes\/custom\/.*\/images\/.*</exclude-pattern>
<exclude-pattern>web\/themes\/custom\/.*\/node_modules\/.*</exclude-pattern>
<exclude-pattern>*\.min\.*</exclude-pattern>
<!-- Force no empty lines after function opening brace. -->
<rule ref="Squiz.WhiteSpace.FunctionOpeningBraceSpace">
<type>warning</type>
</rule>
<!-- Force no empty lines before control structure closing. -->
<rule ref="Squiz.WhiteSpace.ControlStructureSpacing.SpacingBeforeClose">
<type>warning</type>
</rule>
<!-- Force no empty lines after control structure closing. -->
<rule ref="Squiz.WhiteSpace.ControlStructureSpacing.LineAfterClose">
<type>warning</type>
</rule>
<!-- Allow long array lines in tests. -->
<rule ref="Drupal.Arrays.Array.LongLineDeclaration">
<exclude-pattern>*.Test\.php</exclude-pattern>
<exclude-pattern>*.TestCase\.php</exclude-pattern>
<exclude-pattern>*.test</exclude-pattern>
</rule>
<!-- Ignore prefixing of class names with project name in Behat tests. -->
<rule ref="DrupalPractice.General.ClassName.ClassPrefix">
<exclude-pattern>*\/tests\/behat\/bootstrap/*\.php</exclude-pattern>
</rule>
</ruleset>
|
It would be kind of nice to ship with a phpcs.xml file. Ideally this would be default at least have the rules be available in core by default, and point to just code running in modules/custom, themes/custom
The text was updated successfully, but these errors were encountered: