Skip to content

Commit fdec377

Browse files
authored
update eslint plugins and fix errors (#3637)
* update eslint * yarn dedup * more lint * update eslint-plugin-react * more update eslint * more lint fixes * more lint fixes * more fixes * more fixes * add changeset * yarn dedup * fix build * fix tests * rollback yarn lock changes * polish * cypress works * remove resolutions
1 parent ef57ce5 commit fdec377

File tree

20 files changed

+2012
-4514
lines changed

20 files changed

+2012
-4514
lines changed

.changeset/gold-numbers-crash.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
---
2+
"codemirror-graphql": patch
3+
"@graphiql/react": patch
4+
"graphql-language-service": patch
5+
"graphql-language-service-server": patch
6+
"monaco-graphql": patch
7+
---
8+
9+
update eslint plugins and fix errors

.eslintrc.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,6 @@ module.exports = {
144144
'no-useless-call': 'error',
145145
'no-useless-concat': 'error',
146146
'no-useless-return': 'off',
147-
'@typescript-eslint/prefer-optional-chain': 'error',
148147
'no-warning-comments': 'off',
149148
radix: 'error',
150149
'require-await': 'off',
@@ -355,6 +354,7 @@ module.exports = {
355354
excludedFiles: ['**/*.{md,mdx}/*.{ts,tsx}'],
356355
// extends: ['plugin:@typescript-eslint/recommended-type-checked'],
357356
rules: {
357+
'@typescript-eslint/prefer-optional-chain': 'error',
358358
'@typescript-eslint/no-unnecessary-type-assertion': 'error',
359359
'@typescript-eslint/no-floating-promises': 'error',
360360
'@typescript-eslint/non-nullable-type-assertion-style': 'error',

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ async function render() {
3737
.getElementById('toolbar')
3838
?.setAttribute('style', 'display: inline-flex');
3939

40-
const toolbar = document.getElementById('toolbar')!;
40+
const toolbar = document.getElementById('toolbar');
4141
const editors = createEditors();
4242
const {
4343
operationModel,

package.json

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -79,10 +79,12 @@
7979
"wsrun:noexamples": "wsrun --exclude-missing --exclude example-monaco-graphql-react-vite --exclude example-monaco-graphql-nextjs --exclude example-monaco-graphql-webpack --exclude example-graphiql-webpack"
8080
},
8181
"dependencies": {
82-
"@arthurgeron/eslint-plugin-react-usememo": "^1.1.4",
82+
"@arthurgeron/eslint-plugin-react-usememo": "^2.4.0",
8383
"@babel/cli": "^7.21.0",
8484
"@babel/core": "^7.21.0",
8585
"@babel/plugin-proposal-class-properties": "^7.18.6",
86+
"@babel/plugin-proposal-nullish-coalescing-operator": "^7.18.6",
87+
"@babel/plugin-proposal-optional-chaining": "^7.21.0",
8688
"@babel/plugin-syntax-dynamic-import": "^7.8.3",
8789
"@babel/polyfill": "^7.12.1",
8890
"@babel/preset-env": "^7.20.2",
@@ -92,7 +94,7 @@
9294
"@changesets/changelog-github": "0.4.7",
9395
"@changesets/cli": "2.25.2",
9496
"@manypkg/get-packages": "^1.1.3",
95-
"@shopify/eslint-plugin": "^42.1.0",
97+
"@shopify/eslint-plugin": "^45.0.0",
9698
"@strictsoftware/typedoc-plugin-monorepo": "^0.3.1",
9799
"@testing-library/jest-dom": "5.16.5",
98100
"@types/codemirror": "^0.0.90",
@@ -101,25 +103,25 @@
101103
"@types/jest": "^29.5.2",
102104
"@types/node": "^16.18.4",
103105
"@types/ws": "8.2.2",
104-
"@typescript-eslint/eslint-plugin": "6.0.0-alpha.159",
105-
"@typescript-eslint/parser": "6.0.0-alpha.159",
106+
"@typescript-eslint/eslint-plugin": "^7.14.1",
107+
"@typescript-eslint/parser": "^7.14.1",
106108
"babel-jest": "^29.4.3",
107109
"concurrently": "^7.0.0",
108110
"copy": "^0.3.2",
109111
"cspell": "^5.15.2",
110-
"eslint": "^8.43.0",
112+
"eslint": "^8.57.0",
111113
"eslint-config-prettier": "^9.1.0",
112-
"eslint-import-resolver-typescript": "^3.5.5",
113-
"eslint-plugin-cypress": "^2.13.3",
114-
"eslint-plugin-import": "^2.27.5",
115-
"eslint-plugin-jest": "^27.2.2",
116-
"eslint-plugin-mdx": "^2.1.0",
117-
"eslint-plugin-promise": "^6.1.1",
118-
"eslint-plugin-react": "^7.32.2",
119-
"eslint-plugin-react-hooks": "^4.6.0",
120-
"eslint-plugin-sonar": "^0.12.0",
121-
"eslint-plugin-sonarjs": "^0.19.0",
122-
"eslint-plugin-unicorn": "^47.0.0",
114+
"eslint-import-resolver-typescript": "^3.6.1",
115+
"eslint-plugin-cypress": "^3.3.0",
116+
"eslint-plugin-import": "^2.29.1",
117+
"eslint-plugin-jest": "^28.6.0",
118+
"eslint-plugin-mdx": "^3.1.5",
119+
"eslint-plugin-promise": "^6.4.0",
120+
"eslint-plugin-react": "^7.34.3",
121+
"eslint-plugin-react-hooks": "^4.6.2",
122+
"eslint-plugin-sonar": "^0.14.1",
123+
"eslint-plugin-sonarjs": "^1.0.3",
124+
"eslint-plugin-unicorn": "^54.0.0",
123125
"execa": "^7.1.1",
124126
"fetch-mock": "6.5.2",
125127
"husky": "^4.2.3",

packages/codemirror-graphql/src/info.ts

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -98,11 +98,7 @@ CodeMirror.registerHelper(
9898
renderDescription(into, options, typeInfo.argDef);
9999
return into;
100100
}
101-
if (
102-
kind === 'EnumValue' &&
103-
typeInfo.enumValue &&
104-
typeInfo.enumValue.description
105-
) {
101+
if (kind === 'EnumValue' && typeInfo.enumValue?.description) {
106102
const header = document.createElement('div');
107103
header.className = 'CodeMirror-info-header';
108104
renderEnumValue(header, typeInfo, options);

packages/codemirror-graphql/src/utils/jump-addon.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -121,9 +121,7 @@ function onKeyDown(cm: CodeMirror.Editor, event: KeyboardEvent) {
121121
}
122122

123123
const isMac =
124-
typeof navigator !== 'undefined' &&
125-
navigator &&
126-
navigator.appVersion.includes('Mac');
124+
typeof navigator !== 'undefined' && navigator?.appVersion.includes('Mac');
127125

128126
function isJumpModifier(key: string) {
129127
return key === (isMac ? 'Meta' : 'Control');

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,9 +105,11 @@ export function useResponseEditor(
105105

106106
// We can't refactor to root.unmount() from React 18 because we support React 16/17 too
107107
if (!infoElements.length) {
108+
// eslint-disable-next-line react/no-deprecated -- We still support React 16/17
108109
ReactDOM.unmountComponentAtNode(tooltipDiv);
109110
return null;
110111
}
112+
// eslint-disable-next-line react/no-deprecated -- We still support React 16/17
111113
ReactDOM.render(infoElements, tooltipDiv);
112114
return tooltipDiv;
113115
},

packages/graphiql/test/e2e-server.js

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
*/
77

88
/* eslint-disable no-console */
9+
const { createServer } = require('node:http');
910
const express = require('express');
1011
const path = require('node:path');
1112
const { createHandler } = require('graphql-http/lib/use/express');
@@ -17,13 +18,7 @@ const WebSocketsServer = require('./afterDevServer');
1718

1819
// Server
1920
app.post('/graphql', createHandler({ schema }));
20-
21-
app.get(
22-
'/graphql',
23-
createHandler({
24-
schema,
25-
}),
26-
);
21+
app.get('/graphql', createHandler({ schema }));
2722

2823
app.post('/bad/graphql', (_req, res, next) => {
2924
res.json({ data: badSchema });
@@ -44,7 +39,8 @@ app.use(express.static(path.resolve(__dirname, '../')));
4439
app.use('index.html', express.static(path.resolve(__dirname, '../dev.html')));
4540

4641
// messy but it allows close
47-
const server = require('node:http').createServer(app);
42+
const server = createServer(app);
43+
4844
server.listen(process.env.PORT || 3100, function () {
4945
const { port } = this.address();
5046

@@ -58,7 +54,5 @@ server.listen(process.env.PORT || 3100, function () {
5854
process.exit();
5955
});
6056
});
61-
const wsServer = WebSocketsServer();
6257

63-
module.exports.server = server;
64-
module.exports.wsServer = wsServer;
58+
WebSocketsServer();

packages/graphql-language-service-server/src/GraphQLLanguageService.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -201,8 +201,6 @@ export class GraphQLLanguageService {
201201
typeof extensions.customValidationRules === 'function'
202202
) {
203203
customRules = extensions.customValidationRules(this._graphQLConfig);
204-
205-
/* eslint-enable no-implicit-coercion */
206204
}
207205
const schema = await this._graphQLCache.getSchema(
208206
projectName,

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

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1010,9 +1010,7 @@ export class MessageProcessor {
10101010
symbols.push(...docSymbols);
10111011
}),
10121012
);
1013-
return symbols.filter(
1014-
symbol => symbol?.name && symbol.name.includes(params.query),
1015-
);
1013+
return symbols.filter(symbol => symbol?.name?.includes(params.query));
10161014
}
10171015

10181016
return [];
@@ -1358,7 +1356,6 @@ export class MessageProcessor {
13581356
const cachedDocument = this._textDocumentCache.get(uri);
13591357
if (
13601358
cachedDocument &&
1361-
textDocument &&
13621359
textDocument?.version &&
13631360
cachedDocument.version < textDocument.version
13641361
) {

0 commit comments

Comments
 (0)