From c19e539a15b2846954914d831d25806e93a40f3e Mon Sep 17 00:00:00 2001 From: Dimitri POSTOLOV Date: Wed, 14 Jun 2023 21:50:42 +0200 Subject: [PATCH] enable `@typescript-eslint/consistent-type-assertions` --- .eslintrc.js | 1 + packages/monaco-graphql/src/initializeMode.ts | 3 ++- packages/monaco-graphql/src/languageFeatures.ts | 4 ++-- packages/monaco-graphql/src/monaco.contribution.ts | 2 +- 4 files changed, 6 insertions(+), 4 deletions(-) diff --git a/.eslintrc.js b/.eslintrc.js index 5e745e617a9..5badbecb7bb 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -328,6 +328,7 @@ module.exports = { '@typescript-eslint/no-unnecessary-type-assertion': 'error', '@typescript-eslint/no-floating-promises': 'error', '@typescript-eslint/non-nullable-type-assertion-style': 'error', + '@typescript-eslint/consistent-type-assertions': 'error', // TODO: Fix all errors for the following rules included in recommended config '@typescript-eslint/no-explicit-any': 'off', '@typescript-eslint/no-non-null-assertion': 'off', diff --git a/packages/monaco-graphql/src/initializeMode.ts b/packages/monaco-graphql/src/initializeMode.ts index e8424b2bbf0..bb01374578b 100644 --- a/packages/monaco-graphql/src/initializeMode.ts +++ b/packages/monaco-graphql/src/initializeMode.ts @@ -26,7 +26,7 @@ export function initializeMode( ): MonacoGraphQLAPI { if (!api) { api = createMonacoGraphQLAPI(LANGUAGE_ID, config); - (languages).graphql = { api }; + (languages as any).graphql = { api }; // export to the global monaco API // eslint-disable-next-line promise/prefer-await-to-then -- ignore to leave initializeMode sync @@ -35,6 +35,7 @@ export function initializeMode( return api; } + function getMode(): Promise { return import('./graphqlMode'); } diff --git a/packages/monaco-graphql/src/languageFeatures.ts b/packages/monaco-graphql/src/languageFeatures.ts index dea90928fe4..53f78100ffc 100644 --- a/packages/monaco-graphql/src/languageFeatures.ts +++ b/packages/monaco-graphql/src/languageFeatures.ts @@ -298,9 +298,9 @@ export class HoverAdapter implements monaco.languages.HoverProvider { const hoverItem = await worker.doHover(resource.toString(), position); if (hoverItem) { - return { + return { range: hoverItem.range, - contents: [{ value: hoverItem.content }], + contents: [{ value: hoverItem.content as string }], }; } diff --git a/packages/monaco-graphql/src/monaco.contribution.ts b/packages/monaco-graphql/src/monaco.contribution.ts index afd37e15d33..858bbf8b921 100644 --- a/packages/monaco-graphql/src/monaco.contribution.ts +++ b/packages/monaco-graphql/src/monaco.contribution.ts @@ -25,7 +25,7 @@ export { LANGUAGE_ID }; languages.onLanguage(LANGUAGE_ID, () => { const api = initializeMode(); - (languages).graphql = { api }; + (languages as any).graphql = { api }; }); /** * Register the language mode without schema or any settings, so you can configure them asynchronously.