Skip to content
Open
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
11 changes: 6 additions & 5 deletions standards/Tighten/ruleset.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,13 @@
<description>Tighten PHP CS rules for Laravel</description>

<!-- Ignore normal Laravel files and folders -->
<!-- Dots are escaped because PHPCS converts these patterns to regex by replacing only `*` with `.*`, leaving `.` as the any-char metachar -->
<exclude-pattern>*/cache/*</exclude-pattern>
<exclude-pattern>*/*.js</exclude-pattern>
<exclude-pattern>*/*.css</exclude-pattern>
<exclude-pattern>*/*.xml</exclude-pattern>
<exclude-pattern>*/*.blade.php</exclude-pattern>
<exclude-pattern>*/autoload.php</exclude-pattern>
<exclude-pattern>*/*\.js</exclude-pattern>
<exclude-pattern>*/*\.css</exclude-pattern>
<exclude-pattern>*/*\.xml</exclude-pattern>
<exclude-pattern>*/*\.blade\.php</exclude-pattern>
<exclude-pattern>*/autoload\.php</exclude-pattern>
<exclude-pattern>*/storage/*</exclude-pattern>
<exclude-pattern>*/docs/*</exclude-pattern>
<exclude-pattern>*/vendor/*</exclude-pattern>
Expand Down
16 changes: 16 additions & 0 deletions tests/Feature/LintCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,22 @@
expect($statusCode)->toBe(0);
});

it('lints with PHP_CodeSniffer respecting ruleset exclude-patterns', function () {
[$statusCode, $output] = run('lint', [
'path' => base_path('tests/Fixtures/PhpCodeSnifferRulesetExclusions'),
'--using' => 'phpcs',
]);

expect($statusCode)->toBe(1)
->and($output)
->toContain('Linting using PHP_CodeSniffer')
->toContain('Filename doesn\'t match class name')
->toContain('WrongName')
->toContain('NarrowingFileMustBeLinted')
->not->toContain('AutoloadShouldNotBeLinted')
->not->toContain('BladeShouldNotBeLinted');
});

it('lints with PHP CS Fixer', function () {
[$statusCode, $output] = run('lint', [
'path' => base_path('tests/Fixtures/PhpCsFixerFixableIssues'),
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?php

class WrongName
{
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?php

class BladeShouldNotBeLinted
{
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?php

class NarrowingFileMustBeLinted
{
}
5 changes: 5 additions & 0 deletions tests/Fixtures/PhpCodeSnifferRulesetExclusions/autoload.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?php

class AutoloadShouldNotBeLinted
{
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.foo { color: red; }
1 change: 1 addition & 0 deletions tests/Fixtures/PhpCodeSnifferRulesetExclusions/excluded.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
const x = 1;
2 changes: 2 additions & 0 deletions tests/Fixtures/PhpCodeSnifferRulesetExclusions/excluded.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<?xml version="1.0"?>
<root/>