From 9564a2a054ebeb602a56d2aaba261d7d3cd568d8 Mon Sep 17 00:00:00 2001 From: Dimitri POSTOLOV Date: Sat, 1 Apr 2023 01:37:44 +0200 Subject: [PATCH] fix --- .eslintrc.js | 2 +- packages/cm6-graphql/src/state.ts | 12 ++++-------- packages/graphiql-react/src/editor/context.tsx | 2 +- packages/graphiql-react/src/execution.tsx | 2 +- packages/graphiql/src/components/GraphiQL.tsx | 2 +- .../graphql-language-service-server/src/Logger.ts | 2 +- .../vscode-graphql-execution/src/helpers/source.ts | 2 +- 7 files changed, 10 insertions(+), 14 deletions(-) diff --git a/.eslintrc.js b/.eslintrc.js index 22f1d3fdd68..2e5097099ab 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -116,7 +116,7 @@ module.exports = { 'sonarjs/no-identical-functions': 'error', 'sonarjs/no-unused-collection': 'error', 'sonarjs/no-extra-arguments': 'error', - + 'unicorn/no-useless-undefined': 'error', // Strict Mode (http://eslint.org/docs/rules/#strict-mode) strict: 0, diff --git a/packages/cm6-graphql/src/state.ts b/packages/cm6-graphql/src/state.ts index 4b2c6ef3c29..5851715454b 100644 --- a/packages/cm6-graphql/src/state.ts +++ b/packages/cm6-graphql/src/state.ts @@ -4,10 +4,8 @@ import { GraphQLSchema } from 'graphql'; import { GqlExtensionsOptions } from './interfaces'; const schemaEffect = StateEffect.define(); -const schemaStateField = StateField.define({ - create() { - return undefined; - }, +const schemaStateField = StateField.define({ + create() {}, update(schema, tr) { for (const e of tr.effects) { if (e.is(schemaEffect)) { @@ -20,10 +18,8 @@ const schemaStateField = StateField.define({ }); const optionsEffect = StateEffect.define(); -const optionsStateField = StateField.define({ - create() { - return undefined; - }, +const optionsStateField = StateField.define({ + create() {}, update(opts, tr) { for (const e of tr.effects) { if (e.is(optionsEffect)) { diff --git a/packages/graphiql-react/src/editor/context.tsx b/packages/graphiql-react/src/editor/context.tsx index 3441de7179b..2854fa5062d 100644 --- a/packages/graphiql-react/src/editor/context.tsx +++ b/packages/graphiql-react/src/editor/context.tsx @@ -343,7 +343,7 @@ export function EditorContextProvider(props: EditorContextProviderProps) { [storage, tabState, headerEditor], ); - const lastShouldPersistHeadersProp = useRef(undefined); + const lastShouldPersistHeadersProp = useRef(); useEffect(() => { const propValue = Boolean(props.shouldPersistHeaders); if (lastShouldPersistHeadersProp.current !== propValue) { diff --git a/packages/graphiql-react/src/execution.tsx b/packages/graphiql-react/src/execution.tsx index da38cbf8bd6..d66b4eea78b 100644 --- a/packages/graphiql-react/src/execution.tsx +++ b/packages/graphiql-react/src/execution.tsx @@ -344,7 +344,7 @@ function tryParseJsonObject({ errorMessageParse: string; errorMessageType: string; }) { - let parsed: Record | undefined = undefined; + let parsed: Record | undefined; try { parsed = json && json.trim() !== '' ? JSON.parse(json) : undefined; } catch (error) { diff --git a/packages/graphiql/src/components/GraphiQL.tsx b/packages/graphiql/src/components/GraphiQL.tsx index fcaf397c1cd..0db2be31ca8 100644 --- a/packages/graphiql/src/components/GraphiQL.tsx +++ b/packages/graphiql/src/components/GraphiQL.tsx @@ -249,7 +249,7 @@ export function GraphiQLInterface(props: GraphiQLInterfaceProps) { props.defaultEditorToolsVisibility === 'variables' || props.defaultEditorToolsVisibility === 'headers' ) { - return undefined; + return; } if (typeof props.defaultEditorToolsVisibility === 'boolean') { diff --git a/packages/graphql-language-service-server/src/Logger.ts b/packages/graphql-language-service-server/src/Logger.ts index 01ca1a9293f..6f1506c7991 100644 --- a/packages/graphql-language-service-server/src/Logger.ts +++ b/packages/graphql-language-service-server/src/Logger.ts @@ -63,7 +63,7 @@ export class Logger implements VSCodeLogger { } _log(message: string, severityKey: SeverityEnum): void { - const timestamp = new Date().toLocaleString(undefined); + const timestamp = new Date().toLocaleString(); const severity = DIAGNOSTIC_SEVERITY[severityKey]; const { pid } = process; diff --git a/packages/vscode-graphql-execution/src/helpers/source.ts b/packages/vscode-graphql-execution/src/helpers/source.ts index f7999e397ef..41e704ebf2e 100644 --- a/packages/vscode-graphql-execution/src/helpers/source.ts +++ b/packages/vscode-graphql-execution/src/helpers/source.ts @@ -82,7 +82,7 @@ export class SourceHelper { JSON.parse(value); return null; } catch { - return undefined; + return; } } } catch {