From 66b45be3ce0e2af33fe6f1fef7c490db76e4aec2 Mon Sep 17 00:00:00 2001
From: Benjamin Franzke <ben@bnf.dev>
Date: Tue, 5 Sep 2023 10:14:10 +0200
Subject: [PATCH] [TASK] Allow eslint execution from root folder

With #101782 eslint project configuration was overwritten
to use a custom path.
eslint read the relative project configuration based
on the current execution folder instead of relative
to the eslintrc file.
This worked as long as eslint was executed from the
Build/ folder (execution folder == eslintrc folder).

As some tools execute eslint from the git root directory,
the configuration is now adapted to always resolve the
tsconfig file name as an absolute path based on the
configurations directory name.

Also overrideConfigFile is removed from Gruntfile.js
as .eslintrc.[json|js] is read by default and no
override is needed.

Resolves: #101846
Related: #101782
Releases: main, 12.4
Change-Id: I58a6322a74d388efb0da28d1d8e7375f491c7aea
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/80841
Reviewed-by: Benjamin Franzke <ben@bnf.dev>
Tested-by: Benjamin Franzke <ben@bnf.dev>
Tested-by: core-ci <typo3@b13.com>
---
 .editorconfig                          | 5 -----
 Build/{.eslintrc.json => .eslintrc.js} | 6 ++++--
 Build/Gruntfile.js                     | 3 +--
 3 files changed, 5 insertions(+), 9 deletions(-)
 rename Build/{.eslintrc.json => .eslintrc.js} (96%)

diff --git a/.editorconfig b/.editorconfig
index 4229670aa303..293886f83b3b 100644
--- a/.editorconfig
+++ b/.editorconfig
@@ -38,11 +38,6 @@ indent_size = 2
 indent_size = 2
 indent_style = tab
 
-#.eslintrc.json
-[.eslintrc.json]
-indent_size = 2
-indent_style = space
-
 # stylelint
 [.stylelintrc]
 indent_size = 2
diff --git a/Build/.eslintrc.json b/Build/.eslintrc.js
similarity index 96%
rename from Build/.eslintrc.json
rename to Build/.eslintrc.js
index b8bbb2649c8e..877fa17eb608 100644
--- a/Build/.eslintrc.json
+++ b/Build/.eslintrc.js
@@ -1,4 +1,6 @@
-{
+const path = require('path');
+
+module.exports = {
   "root": true,
   "env": {
     "browser": true,
@@ -6,7 +8,7 @@
   },
   "parser": "@typescript-eslint/parser",
   "parserOptions": {
-    "project": ["./tsconfig.eslint.json"]
+    "project": [path.resolve(__dirname, "./tsconfig.eslint.json")]
   },
   "plugins": [
     "@typescript-eslint",
diff --git a/Build/Gruntfile.js b/Build/Gruntfile.js
index 75c02f3934ef..0ace49d151a5 100644
--- a/Build/Gruntfile.js
+++ b/Build/Gruntfile.js
@@ -275,8 +275,7 @@ module.exports = function (grunt) {
     eslint: {
       options: {
         cache: true,
-        cacheLocation: './.cache/eslintcache/',
-        overrideConfigFile: '.eslintrc.json'
+        cacheLocation: './.cache/eslintcache/'
       },
       files: {
         src: [
-- 
GitLab