From 8246d067ed3b23d4656be6d69895f3352370aa00 Mon Sep 17 00:00:00 2001 From: jrfnl Date: Sat, 6 Apr 2024 18:16:21 +0200 Subject: [PATCH] Tests - Generic/ESLint: fix test ESLint has released a new major which no longer supports the `.eslintrc.json` config format by default. To still allow for that format, an `ESLINT_USE_FLAT_CONFIG` environment variable has to be set to `false`. This change is causing the tests for the `Generic.Debug.ESLint` sniff to fail. Setting the environment variable fixes this. This is a test-only change for the following reasons: * If end-users use this sniff, they are responsible for using the correct configuration for the version of ESLint they are using. * The sniff is deprecated and preferably end-users should move away from using the sniff and run the tool directly. * As the sniff is deprecated, no time has been spend to add support for the new ESLint configuration format to the sniff. A simple patch to add this support would be accepted as long as PHPCS 4.0 has not been released yet, but maintainers will not spend time on this as the sniff will be removed sooner rather than later. As an alternative, it was considered to limit the version of `ESLint` being installed in the GH Actions workflow to version 8 of ESlint, but the change as made now is better IMO as it proves that the ESLint sniff does still work on 9, even though only for the old configuration formats. Refs: * https://eslint.org/blog/2024/04/eslint-v9.0.0-released/#flat-config-is-now-the-default-and-has-some-changes * https://eslint.org/docs/latest/use/migrate-to-9.0.0#-new-default-config-format-eslintconfigjs --- src/Standards/Generic/Tests/Debug/ESLintUnitTest.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/Standards/Generic/Tests/Debug/ESLintUnitTest.php b/src/Standards/Generic/Tests/Debug/ESLintUnitTest.php index 824beae4ad..e035c2088c 100644 --- a/src/Standards/Generic/Tests/Debug/ESLintUnitTest.php +++ b/src/Standards/Generic/Tests/Debug/ESLintUnitTest.php @@ -52,6 +52,8 @@ protected function setUpPrerequisites() $cwd = getcwd(); file_put_contents($cwd.'/.eslintrc.json', self::ESLINT_CONFIG); + putenv('ESLINT_USE_FLAT_CONFIG=false'); + }//end setUpPrerequisites()