From deeb467b1b2e8d7d0f2a5b5d5224456e5a233d4b Mon Sep 17 00:00:00 2001 From: Dimitri POSTOLOV Date: Sat, 4 Mar 2023 12:47:58 +0100 Subject: [PATCH] [ESLint] enable `unicorn/prefer-array-flat-map` rule (#3044) * enable `unicorn/prefer-array-flat-map` rule * format --- .eslintrc.js | 1 + packages/graphiql-react/src/execution.tsx | 5 +---- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/.eslintrc.js b/.eslintrc.js index 9c1bc639345..454ad959560 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -253,6 +253,7 @@ module.exports = { 'no-lonely-if': 'error', 'unicorn/no-lonely-if': 'error', 'unicorn/prefer-optional-catch-binding': 'error', + 'unicorn/prefer-array-flat-map': 'error', 'no-unused-expressions': 'off', '@typescript-eslint/no-unused-expressions': 'error', 'sonarjs/no-small-switch': 'error', diff --git a/packages/graphiql-react/src/execution.tsx b/packages/graphiql-react/src/execution.tsx index 950c9c7d22a..6d5ddb114b3 100644 --- a/packages/graphiql-react/src/execution.tsx +++ b/packages/graphiql-react/src/execution.tsx @@ -203,10 +203,7 @@ export function ExecutionContextProvider(props: ExecutionContextProviderProps) { }; const maybeErrors = [ ...(fullResponse?.errors || []), - ...maybeMultipart - .map(i => i.errors) - .flat() - .filter(Boolean), + ...maybeMultipart.flatMap(i => i.errors).filter(Boolean), ]; if (maybeErrors.length) {