From 25909b0d9e9fa4b2fbb02457647cd01f3b50d229 Mon Sep 17 00:00:00 2001
From: demonicattack <160151261+demonicattack@users.noreply.github.com>
Date: Tue, 19 Nov 2024 22:01:43 +0400
Subject: [PATCH] fix(linter): move eslint-config-prettier to the end for
 proper override (#28503)
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

There is a conflict between ESLint and Prettier rules, which causes
incorrect formatting behavior.

Reordering the config so that `eslint-config-prettier` is applied last
ensures proper rule overrides and resolves conflicts with Prettier.

---------

Co-authored-by: Leosvel PĂ©rez Espinosa <leosvel.perez.espinosa@gmail.com>
---
 packages/eslint-plugin/src/flat-configs/javascript.ts | 7 +++++--
 packages/eslint-plugin/src/flat-configs/typescript.ts | 7 +++++--
 2 files changed, 10 insertions(+), 4 deletions(-)

diff --git a/packages/eslint-plugin/src/flat-configs/javascript.ts b/packages/eslint-plugin/src/flat-configs/javascript.ts
index 281a7e2402f63..aad10376c9603 100644
--- a/packages/eslint-plugin/src/flat-configs/javascript.ts
+++ b/packages/eslint-plugin/src/flat-configs/javascript.ts
@@ -27,7 +27,6 @@ export default tseslint.config(
     files: ['**/*.js', '**/*.jsx'],
     extends: [eslint.configs.recommended, ...tseslint.configs.recommended],
   },
-  ...(isPrettierAvailable ? [require('eslint-config-prettier')] : []),
   {
     languageOptions: {
       parser: tseslint.parser,
@@ -80,5 +79,9 @@ export default tseslint.config(
        */
       '@typescript-eslint/no-require-imports': 'off',
     },
-  }
+  },
+  /**
+   * We include it last so it overrides the conflicting rules from the configuration blocks above.
+   */
+  ...(isPrettierAvailable ? [require('eslint-config-prettier')] : [])
 );
diff --git a/packages/eslint-plugin/src/flat-configs/typescript.ts b/packages/eslint-plugin/src/flat-configs/typescript.ts
index d32b685cdc529..58dc9e06b5c64 100644
--- a/packages/eslint-plugin/src/flat-configs/typescript.ts
+++ b/packages/eslint-plugin/src/flat-configs/typescript.ts
@@ -18,7 +18,6 @@ export default tseslint.config(
     files: ['**/*.ts', '**/*.tsx'],
     extends: [eslint.configs.recommended, ...tseslint.configs.recommended],
   },
-  ...(isPrettierAvailable ? [require('eslint-config-prettier')] : []),
   {
     plugins: { '@typescript-eslint': tseslint.plugin },
     languageOptions: {
@@ -64,5 +63,9 @@ export default tseslint.config(
        */
       '@typescript-eslint/no-require-imports': 'off',
     },
-  }
+  },
+  /**
+   * We include it last so it overrides the conflicting rules from the configuration blocks above.
+   */
+  ...(isPrettierAvailable ? [require('eslint-config-prettier')] : [])
 );