phpcs on windows throws on every file following error: End of line character is invalid; expected "\n" but found "\r\n"
rakoitde opened this issue · comments
Actual behavior
phpcs on windows throws on every file following error: End of line character is invalid; expected "\n" but found "\r\n"
FILE: ...\MAMP\htdocs\api-client-php\tests\Idoit\APIClient\SubnetTest.php
----------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
----------------------------------------------------------------------
1 | ERROR | [x] End of line character is invalid; expected "\n" but
| | found "\r\n"
----------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
----------------------------------------------------------------------
Found this Issue:
squizlabs/PHP_CodeSniffer#2554
Steps to resolve the behavior
I'm not firm with phpcs, so I can't judge if my successful test can be a solution!
-
create ruleset.xlm from following link
https://raw.githubusercontent.com/squizlabs/PHP_CodeSniffer/master/src/Standards/PSR2/ruleset.xml -
Change eolChar from "\n" to "\r\n"
<rule ref="Generic.Files.LineEndings">
<properties>
<property name="eolChar" value="\r\n"/>
</properties>
</rule>
- comment excludes
<!-- checked by PSR2.Classes.ClassDeclaration -->
<!-- <rule ref="Squiz.Functions.MultiLineFunctionDeclaration"/> -->
- add script in composer.json
"phpcs-win": "./vendor/bin/phpcs --standard=ruleset.xml --extensions=php src/ tests/",
- Test works fine
composer phpcs-win
Environment
Windows