Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .vortex/docs/content/development/code-quality/eslint.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ On top of the presets, the configuration sets the following rules:
|-------------------------------|---------|--------------------------------------------------------------------------|
| `prettier/prettier` | Error | Reports every difference from the Prettier formatting. |
| `no-console` | Error | Reports console calls, because they print to every visitor's browser. |
| `no-debugger` | Error | Reports `debugger` statements. |
| `operator-linebreak` | Error | Requires an operator other than `?` or `:` at the end of a wrapped line. |
| `yml/indent` | Error | Requires a 2-space indent in YAML files. |
| `max-nested-callbacks` | Warning | Reports callbacks nested more than 3 levels deep. |
Expand Down
12 changes: 12 additions & 0 deletions .vortex/docs/content/development/code-quality/phpcs.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,10 @@ By default, PHPCS checks against the following standards and sniffs:
- `DrupalPractice` - Drupal best practices
- `Generic.PHP.RequireStrictTypes` - a `declare(strict_types=1);` statement
in every file
- `Drupal.Functions.DiscouragedFunctions` - debug calls, reported as
errors instead of the standard's warnings. The `Drupal` standard lists
the Devel helpers such as `dpm()` and `kint()`, plus `eval()` and
`fnmatch()`. The ruleset adds `var_dump()`, `print_r()` and `dump()`
- `PHPCompatibility` - compatibility with the PHP version in `testVersion`
- `DrevOps` - the DrevOps standard, which requires the following:
- Snake_case names for local variables and parameters
Expand All @@ -96,6 +100,14 @@ By default, PHPCS checks against the following standards and sniffs:
`|` and `&` in union and intersection types, set through its
`withSpacesAroundOperators` property

To forbid another function, add an `<element>` to the `forbiddenFunctions`
property of `Drupal.Functions.DiscouragedFunctions` in `phpcs.xml`. The
property's `extend="true"` attribute keeps the standard's list:

```xml
<element key="debug" value="null"/>
```

The ruleset also adds 3 whitespace sniffs from the standards that ship with
PHPCS and reports them as warnings. They flag a blank line after a
function's opening brace and a blank line before or after a control
Expand Down
1 change: 1 addition & 0 deletions .vortex/docs/cspell.json
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@
"itok",
"jsonpath",
"kcov",
"kint",
"lagooncli",
"lagoonhealthz",
"lando",
Expand Down
2 changes: 2 additions & 0 deletions .vortex/docs/eslint.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ export default defineConfig(
'react/react-in-jsx-scope': 'off',
'react/prop-types': 'off',
'no-unused-vars': ['error', { argsIgnorePattern: '^_' }],
'no-console': ['error', { allow: ['warn', 'error'] }],
'no-debugger': 'error',
'prefer-const': 'error',
'no-var': 'error',
curly: ['error', 'all'],
Expand Down
12 changes: 12 additions & 0 deletions .vortex/installer/phpcs.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,18 @@
</properties>
</rule>

<!-- Fail on debug calls. Add an element to forbid another function. -->
<rule ref="Drupal.Functions.DiscouragedFunctions">
<properties>
<property name="error" value="true"/>
<property name="forbiddenFunctions" type="array" extend="true">
<element key="var_dump" value="null"/>
<element key="print_r" value="null"/>
<element key="dump" value="null"/>
</property>
</properties>
</rule>

<!-- Show sniff codes in all reports -->
<arg value="s"/>
<!-- Show progress of the run. -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ export default defineConfig(
// Kept from the previous ruleset: console calls left in shipped code
// print to every visitor's browser.
'no-console': 'error',
'no-debugger': 'error',
'operator-linebreak': [
'error',
'after',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,30 @@
<ruleset name="custom">
<description>Custom PHPCS Standard, based on Drupal standards.</description>

<arg name="extensions" value="inc,info,install,module,php,profile,test,theme"/>
<arg name="colors"/>
<arg value="sp"/>

<!-- Adjust the number of parallel processes to run based on the number of CPU cores available. -->
<arg name="parallel" value="10"/>

<!-- Lint code against platform version specified in composer.json key "config.platform.php". -->
<config name="testVersion" value="8.4"/>

<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>
<file>scripts</file>

<!-- 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>

<rule ref="Drupal"/>
<rule ref="DrupalPractice"/>
<rule ref="Generic.PHP.RequireStrictTypes" />
Expand All @@ -20,23 +37,6 @@
</properties>
</rule>

<arg name="extensions" value="inc,info,install,module,php,profile,test,theme"/>
<arg name="colors"/>
<arg value="sp"/>

<!-- Adjust the number of parallel processes to run based on the number of CPU cores available. -->
<arg name="parallel" value="10"/>

<!-- Lint code against platform version specified in composer.json key "config.platform.php". -->
<config name="testVersion" value="8.4"/>

<!-- 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>
Expand All @@ -63,4 +63,16 @@
<rule ref="DrupalPractice.General.ClassName.ClassPrefix">
<exclude-pattern>*\/tests\/behat\/bootstrap/*\.php</exclude-pattern>
</rule>

<!-- Fail on debug calls. Add an element to forbid another function. -->
<rule ref="Drupal.Functions.DiscouragedFunctions">
<properties>
<property name="error" value="true"/>
<property name="forbiddenFunctions" type="array" extend="true">
<element key="var_dump" value="null"/>
<element key="print_r" value="null"/>
<element key="dump" value="null"/>
</property>
</properties>
</rule>
</ruleset>
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public function testEnvironmentTypeDetection(array $vars, string $expected_env):

$this->requireSettingsFile();

$this->assertEquals($expected_env, $this->settings['environment'], print_r($vars, TRUE));
$this->assertEquals($expected_env, $this->settings['environment'], var_export($vars, TRUE));
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public function assertArrayContainsString(string $needle, array $haystack): void
return;
}
}
$this->fail(sprintf('Failed asserting that string "%s" is present in array %s.', $needle, print_r($haystack, TRUE)));
$this->fail(sprintf('Failed asserting that string "%s" is present in array %s.', $needle, var_export($haystack, TRUE)));
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ export default defineConfig(
// Kept from the previous ruleset: console calls left in shipped code
// print to every visitor's browser.
'no-console': 'error',
'no-debugger': 'error',
'operator-linebreak': [
'error',
'after',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public function assertArrayContainsString(string $needle, array $haystack): void
return;
}
}
$this->fail(sprintf('Failed asserting that string "%s" is present in array %s.', $needle, print_r($haystack, TRUE)));
$this->fail(sprintf('Failed asserting that string "%s" is present in array %s.', $needle, var_export($haystack, TRUE)));
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ export default defineConfig(
// Kept from the previous ruleset: console calls left in shipped code
// print to every visitor's browser.
'no-console': 'error',
'no-debugger': 'error',
'operator-linebreak': [
'error',
'after',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
@@ -2,10 +2,10 @@
<ruleset name="custom">
<description>Custom PHPCS Standard, based on Drupal standards.</description>
@@ -12,18 +12,18 @@
<!-- Lint code against platform version specified in composer.json key "config.platform.php". -->
<config name="testVersion" value="8.4"/>

- <file>web/modules/custom</file>
- <file>web/themes/custom</file>
Expand All @@ -13,9 +13,6 @@
<file>tests</file>
<file>scripts</file>

@@ -31,10 +31,10 @@
<config name="testVersion" value="8.4"/>

<!-- Exclude theme assets. -->
- <exclude-pattern>web\/themes\/custom\/.*\/build\/.*</exclude-pattern>
- <exclude-pattern>web\/themes\/custom\/.*\/fonts\/.*</exclude-pattern>
Expand All @@ -27,4 +24,4 @@
+ <exclude-pattern>docroot\/themes\/custom\/.*\/node_modules\/.*</exclude-pattern>
<exclude-pattern>*\.min\.*</exclude-pattern>

<!-- Force no empty lines after function opening brace. -->
<rule ref="Drupal"/>
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public function assertArrayContainsString(string $needle, array $haystack): void
return;
}
}
$this->fail(sprintf('Failed asserting that string "%s" is present in array %s.', $needle, print_r($haystack, TRUE)));
$this->fail(sprintf('Failed asserting that string "%s" is present in array %s.', $needle, var_export($haystack, TRUE)));
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ export default defineConfig(
// Kept from the previous ruleset: console calls left in shipped code
// print to every visitor's browser.
'no-console': 'error',
'no-debugger': 'error',
'operator-linebreak': [
'error',
'after',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
@@ -2,10 +2,10 @@
<ruleset name="custom">
<description>Custom PHPCS Standard, based on Drupal standards.</description>
@@ -12,18 +12,18 @@
<!-- Lint code against platform version specified in composer.json key "config.platform.php". -->
<config name="testVersion" value="8.4"/>

- <file>web/modules/custom</file>
- <file>web/themes/custom</file>
Expand All @@ -13,9 +13,6 @@
<file>tests</file>
<file>scripts</file>

@@ -31,10 +31,10 @@
<config name="testVersion" value="8.4"/>

<!-- Exclude theme assets. -->
- <exclude-pattern>web\/themes\/custom\/.*\/build\/.*</exclude-pattern>
- <exclude-pattern>web\/themes\/custom\/.*\/fonts\/.*</exclude-pattern>
Expand All @@ -27,4 +24,4 @@
+ <exclude-pattern>docroot\/themes\/custom\/.*\/node_modules\/.*</exclude-pattern>
<exclude-pattern>*\.min\.*</exclude-pattern>

<!-- Force no empty lines after function opening brace. -->
<rule ref="Drupal"/>
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public function assertArrayContainsString(string $needle, array $haystack): void
return;
}
}
$this->fail(sprintf('Failed asserting that string "%s" is present in array %s.', $needle, print_r($haystack, TRUE)));
$this->fail(sprintf('Failed asserting that string "%s" is present in array %s.', $needle, var_export($haystack, TRUE)));
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ export default defineConfig(
// Kept from the previous ruleset: console calls left in shipped code
// print to every visitor's browser.
'no-console': 'error',
'no-debugger': 'error',
'operator-linebreak': [
'error',
'after',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
@@ -3,7 +3,6 @@
<description>Custom PHPCS Standard, based on Drupal standards.</description>
@@ -13,7 +13,6 @@
<config name="testVersion" value="8.4"/>

<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>
@@ -31,10 +30,6 @@
<config name="testVersion" value="8.4"/>
@@ -20,10 +19,6 @@
<file>scripts</file>

<!-- Exclude theme assets. -->
- <exclude-pattern>web\/themes\/custom\/.*\/build\/.*</exclude-pattern>
Expand All @@ -16,4 +16,4 @@
- <exclude-pattern>web\/themes\/custom\/.*\/node_modules\/.*</exclude-pattern>
<exclude-pattern>*\.min\.*</exclude-pattern>

<!-- Force no empty lines after function opening brace. -->
<rule ref="Drupal"/>
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ export default defineConfig(
// Kept from the previous ruleset: console calls left in shipped code
// print to every visitor's browser.
'no-console': 'error',
'no-debugger': 'error',
'operator-linebreak': [
'error',
'after',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
@@ -3,7 +3,6 @@
<description>Custom PHPCS Standard, based on Drupal standards.</description>
@@ -13,7 +13,6 @@
<config name="testVersion" value="8.4"/>

<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>
@@ -31,10 +30,6 @@
<config name="testVersion" value="8.4"/>
@@ -20,10 +19,6 @@
<file>scripts</file>

<!-- Exclude theme assets. -->
- <exclude-pattern>web\/themes\/custom\/.*\/build\/.*</exclude-pattern>
Expand All @@ -16,4 +16,4 @@
- <exclude-pattern>web\/themes\/custom\/.*\/node_modules\/.*</exclude-pattern>
<exclude-pattern>*\.min\.*</exclude-pattern>

<!-- Force no empty lines after function opening brace. -->
<rule ref="Drupal"/>
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
@@ -3,7 +3,6 @@
<description>Custom PHPCS Standard, based on Drupal standards.</description>
@@ -13,7 +13,6 @@
<config name="testVersion" value="8.4"/>

<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>
@@ -31,10 +30,6 @@
<config name="testVersion" value="8.4"/>
@@ -20,10 +19,6 @@
<file>scripts</file>

<!-- Exclude theme assets. -->
- <exclude-pattern>web\/themes\/custom\/.*\/build\/.*</exclude-pattern>
Expand All @@ -16,4 +16,4 @@
- <exclude-pattern>web\/themes\/custom\/.*\/node_modules\/.*</exclude-pattern>
<exclude-pattern>*\.min\.*</exclude-pattern>

<!-- Force no empty lines after function opening brace. -->
<rule ref="Drupal"/>
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
@@ -59,8 +59,4 @@
@@ -59,11 +59,6 @@
<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>
-
<!-- Fail on debug calls. Add an element to forbid another function. -->
<rule ref="Drupal.Functions.DiscouragedFunctions">
<properties>
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
@@ -59,8 +59,4 @@
@@ -59,11 +59,6 @@
<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>
-
<!-- Fail on debug calls. Add an element to forbid another function. -->
<rule ref="Drupal.Functions.DiscouragedFunctions">
<properties>
Loading
Loading