Skip to content

Commit 5100700

Browse files
authoredApr 14, 2023
[ESLint] enable @typescript-eslint/no-floating-promises, update typescript-eslint to v6 (#3109)
1 parent 2e477eb commit 5100700

File tree

20 files changed

+119
-86
lines changed

20 files changed

+119
-86
lines changed
 

‎.changeset/shaggy-monkeys-bathe.md

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
---
2+
'graphql-language-service-server': patch
3+
'graphql-language-service-cli': patch
4+
'codemirror-graphql': patch
5+
'@graphiql/toolkit': patch
6+
'@graphiql/react': patch
7+
'monaco-graphql': patch
8+
---
9+
10+
enable `no-floating-promises` eslint rule

‎.eslintrc.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,6 @@ module.exports = {
105105
'no-useless-call': 1,
106106
'no-useless-concat': 1,
107107
'no-useless-return': 0,
108-
'no-void': 1,
109108
'@typescript-eslint/prefer-optional-chain': 'error',
110109
'no-warning-comments': 0,
111110
radix: 'error',
@@ -298,8 +297,10 @@ module.exports = {
298297
overrides: [
299298
{
300299
files: ['**/*.{ts,tsx}'],
300+
// extends: ['plugin:@typescript-eslint/recommended-type-checked'],
301301
rules: {
302302
'@typescript-eslint/no-unnecessary-type-assertion': 'error',
303+
'@typescript-eslint/no-floating-promises': 'error',
303304
},
304305
parserOptions: {
305306
project: [

‎examples/monaco-graphql-nextjs/src/components/editor.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ export default function Editor() {
156156
useEffect(() => {
157157
if (!schema && !loading) {
158158
setLoading(true);
159-
getSchema()
159+
void getSchema()
160160
.then(data => {
161161
if (!('data' in data)) {
162162
throw new Error(

‎examples/monaco-graphql-react-vite/src/App.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ export default function App() {
158158
useEffect(() => {
159159
if (!schema && !loading) {
160160
setLoading(true);
161-
getSchema()
161+
void getSchema()
162162
.then(data => {
163163
if (!('data' in data)) {
164164
throw new Error(

‎examples/monaco-graphql-webpack/src/index.ts

+2-4
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,7 @@ const SITE_ID = '46a6b3c8-992f-4623-9a76-f1bd5d40505c';
1313

1414
let monacoGraphQLAPI: MonacoGraphQLAPI | null = null;
1515

16-
(async () => {
17-
await render();
18-
})();
16+
void render();
1917

2018
async function render() {
2119
if (!schemaFetcher.token) {
@@ -314,7 +312,7 @@ export function renderGithubLoginButton() {
314312
if (err) {
315313
console.error('Error authenticating with GitHub:', err);
316314
} else {
317-
schemaFetcher.setApiToken(data.token);
315+
await schemaFetcher.setApiToken(data.token);
318316
await render();
319317
}
320318
},

‎package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -105,8 +105,8 @@
105105
"@types/react": "^17.0.37",
106106
"@types/react-dom": "^17.0.17",
107107
"@types/ws": "^7.4.0",
108-
"@typescript-eslint/eslint-plugin": "^5.54.1",
109-
"@typescript-eslint/parser": "^5.54.1",
108+
"@typescript-eslint/eslint-plugin": "rc-v6",
109+
"@typescript-eslint/parser": "rc-v6",
110110
"aws-serverless-express": "^3.4.0",
111111
"babel-jest": "^29.4.3",
112112
"concurrently": "^7.0.0",

‎packages/codemirror-graphql/src/index.d.ts

-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ declare module 'codemirror' {
1313
hint?: ShowHintOptions['hint'];
1414
}
1515

16-
// eslint-disable-next-line @typescript-eslint/no-empty-interface
1716
interface CodeMirrorHintMap {}
1817

1918
const hint: CodeMirrorHintMap;

‎packages/graphiql-react/src/editor/completion.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ export function onHasCompletion(
2424
explorer: ExplorerContextType | null,
2525
plugin: PluginContextType | null,
2626
callback?: (type: GraphQLNamedType) => void,
27-
) {
28-
importCodeMirror([], { useCommonAddons: false }).then(CodeMirror => {
27+
): void {
28+
void importCodeMirror([], { useCommonAddons: false }).then(CodeMirror => {
2929
let information: HTMLDivElement | null;
3030
let fieldName: HTMLSpanElement | null;
3131
let typeNamePill: HTMLSpanElement | null;

‎packages/graphiql-react/src/editor/header-editor.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ export function useHeaderEditor(
5151
useEffect(() => {
5252
let isActive = true;
5353

54-
importCodeMirror([
54+
void importCodeMirror([
5555
// @ts-expect-error
5656
import('codemirror/mode/javascript/javascript'),
5757
]).then(CodeMirror => {

‎packages/graphiql-react/src/editor/query-editor.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ export function useQueryEditor(
140140
useEffect(() => {
141141
let isActive = true;
142142

143-
importCodeMirror([
143+
void importCodeMirror([
144144
import('codemirror/addon/comment/comment'),
145145
import('codemirror/addon/search/search'),
146146
import('codemirror-graphql/esm/hint'),

‎packages/graphiql-react/src/editor/response-editor.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ export function useResponseEditor(
6262

6363
useEffect(() => {
6464
let isActive = true;
65-
importCodeMirror(
65+
void importCodeMirror(
6666
[
6767
import('codemirror/addon/fold/foldgutter'),
6868
import('codemirror/addon/fold/brace-fold'),

‎packages/graphiql-react/src/editor/variable-editor.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ export function useVariableEditor(
5757
useEffect(() => {
5858
let isActive = true;
5959

60-
importCodeMirror([
60+
void importCodeMirror([
6161
import('codemirror-graphql/esm/variables/hint'),
6262
import('codemirror-graphql/esm/variables/lint'),
6363
import('codemirror-graphql/esm/variables/mode'),

‎packages/graphiql-toolkit/src/async-helpers/index.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ function asyncIterableToPromise<T>(
7070
.then(result => {
7171
resolve(result.value);
7272
// ensure cleanup
73-
iteratorReturn?.();
73+
void iteratorReturn?.();
7474
})
7575
.catch(err => {
7676
reject(err);

‎packages/graphql-language-service-cli/src/cli.ts

+2-4
Original file line numberDiff line numberDiff line change
@@ -126,12 +126,10 @@ if (command === 'server') {
126126
if (argv?.configDir) {
127127
options.configDir = argv.configDir;
128128
}
129-
try {
130-
startServer(options);
131-
} catch (error) {
129+
startServer(options).catch(error => {
132130
const logger = new Logger();
133131
logger.error(String(error));
134-
}
132+
});
135133
} else {
136134
client(command as string, argv as { [key: string]: string });
137135
}

‎packages/graphql-language-service-server/src/GraphQLCache.ts

+6-2
Original file line numberDiff line numberDiff line change
@@ -452,7 +452,11 @@ export class GraphQLCache implements GraphQLCacheInterface {
452452
cache.delete(filePath);
453453
}
454454
} else if (fileAndContent?.queries) {
455-
this.updateFragmentDefinition(rootDir, filePath, fileAndContent.queries);
455+
await this.updateFragmentDefinition(
456+
rootDir,
457+
filePath,
458+
fileAndContent.queries,
459+
);
456460
}
457461
}
458462

@@ -518,7 +522,7 @@ export class GraphQLCache implements GraphQLCacheInterface {
518522
cache.delete(filePath);
519523
}
520524
} else if (fileAndContent?.queries) {
521-
this.updateObjectTypeDefinition(
525+
await this.updateObjectTypeDefinition(
522526
rootDir,
523527
filePath,
524528
fileAndContent.queries,

‎packages/graphql-language-service-server/src/MessageProcessor.ts

+7-7
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ export class MessageProcessor {
143143
}
144144

145145
if (!existsSync(this._tmpDirBase)) {
146-
mkdirp(this._tmpDirBase);
146+
void mkdirp(this._tmpDirBase);
147147
}
148148
}
149149
get connection(): Connection {
@@ -350,7 +350,7 @@ export class MessageProcessor {
350350
uri.match('package.json')?.length && require(uri)?.graphql;
351351
if (hasGraphQLConfigFile || hasPackageGraphQLConfig) {
352352
this._logger.info('updating graphql config');
353-
this._updateGraphQLConfig();
353+
await this._updateGraphQLConfig();
354354
return { uri, diagnostics: [] };
355355
}
356356
// update graphql config only when graphql config is saved!
@@ -703,12 +703,12 @@ export class MessageProcessor {
703703
return { uri, diagnostics };
704704
}
705705
if (change.type === FileChangeTypeKind.Deleted) {
706-
this._graphQLCache.updateFragmentDefinitionCache(
706+
await this._graphQLCache.updateFragmentDefinitionCache(
707707
this._graphQLCache.getGraphQLConfig().dirpath,
708708
change.uri,
709709
false,
710710
);
711-
this._graphQLCache.updateObjectTypeDefinitionCache(
711+
await this._graphQLCache.updateObjectTypeDefinitionCache(
712712
this._graphQLCache.getGraphQLConfig().dirpath,
713713
change.uri,
714714
false,
@@ -924,7 +924,7 @@ export class MessageProcessor {
924924
version = schemaDocument.version++;
925925
}
926926
const schemaText = readFileSync(uri, 'utf8');
927-
this._cacheSchemaText(schemaUri, schemaText, version);
927+
await this._cacheSchemaText(schemaUri, schemaText, version);
928928
}
929929
}
930930
_getTmpProjectPath(
@@ -937,7 +937,7 @@ export class MessageProcessor {
937937
const basePath = path.join(this._tmpDirBase, workspaceName);
938938
let projectTmpPath = path.join(basePath, 'projects', project.name);
939939
if (!existsSync(projectTmpPath)) {
940-
mkdirp(projectTmpPath);
940+
void mkdirp(projectTmpPath);
941941
}
942942
if (appendPath) {
943943
projectTmpPath = path.join(projectTmpPath, appendPath);
@@ -963,7 +963,7 @@ export class MessageProcessor {
963963
);
964964
} else {
965965
try {
966-
this._cacheSchemaFile(uri, project);
966+
await this._cacheSchemaFile(uri, project);
967967
} catch {
968968
// this string may be an SDL string even, how do we even evaluate this?
969969
}

‎packages/graphql-language-service-server/src/startServer.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,7 @@ function reportDiagnostics(
244244
connection: Connection,
245245
) {
246246
if (diagnostics) {
247-
connection.sendNotification(
247+
void connection.sendNotification(
248248
PublishDiagnosticsNotification.type,
249249
diagnostics,
250250
);

‎packages/monaco-graphql/src/initializeMode.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ export function initializeMode(
2828
api = createMonacoGraphQLAPI(LANGUAGE_ID, config);
2929
(<any>languages).graphql = { api };
3030
// export to the global monaco API
31-
getMode().then(mode => mode.setupMode(api));
31+
void getMode().then(mode => mode.setupMode(api));
3232
}
3333

3434
return api;

‎packages/monaco-graphql/src/languageFeatures.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ export class DiagnosticsAdapter {
5656
this._listener[modelUri] = model.onDidChangeContent(() => {
5757
clearTimeout(onChangeTimeout);
5858
onChangeTimeout = setTimeout(() => {
59-
this._doValidate(model.uri, modeId, jsonValidationForModel);
59+
void this._doValidate(model.uri, modeId, jsonValidationForModel);
6060
}, 200);
6161
});
6262
};

0 commit comments

Comments
 (0)
Please sign in to comment.