Skip to content

Commit 1adc40c

Browse files
dimaMachinaTallTed
andauthored
bump eslint, eslint-plugins and fix new warnings (#3896)
* aa * aa * aa * aa * aa * aa * aa * aa * aa * aa * aa * aa * aa * [skip ci] * fix * migrate `graphiql` from `jest` to `vitest` * add .js extension * add .js extension * upd * upd * upd * upd * upd * upd * upd * upd * upd * upd * add * upd * upd * upd * upd * upd * upd * upd * upd * clean up deps * clean up deps * clean up deps * clean up deps * clean up deps * upd * upd * more changes from graphiql v4 * more * fix path isn't exported * fix integration tests * fix e2e * bump * add changeset * remove unneeded beforeDevServer.js * found case which was not optimized * Delete .changeset/sour-onions-rhyme.md * Delete .changeset/silly-nails-double.md * polish graphiql tests setup * polish graphiql tests setup * should be good * prettier * upd * remove `vite-plugin-commonjs` * remove react compiler patch, and use 19.1.0-rc.1 version * remove react compiler patch, and use 19.1.0-rc.1 version * lock update * use requestAnimationFrame instead of setTimeout * use requestAnimationFrame instead of setTimeout * Update packages/graphiql-react/src/editor/hooks.ts Co-authored-by: Ted Thibodeau Jr <[email protected]> * upd * upd * upd * upd * upd * bump eslint, eslint-plugins and fix new warnings * update deps * Update docs/migration/graphiql-2.0.0.md --------- Co-authored-by: Ted Thibodeau Jr <[email protected]>
1 parent cb29e9f commit 1adc40c

File tree

26 files changed

+1557
-665
lines changed

26 files changed

+1557
-665
lines changed

.changeset/eleven-buses-peel.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
---
2+
'graphql-language-service-server': patch
3+
'graphql-language-service': patch
4+
'vscode-graphql-execution': patch
5+
'codemirror-graphql': patch
6+
'@graphiql/toolkit': patch
7+
'@graphiql/react': patch
8+
'monaco-graphql': patch
9+
---
10+
11+
bump eslint, eslint-plugins and fix new warnings

.eslintrc.js

Lines changed: 37 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -167,9 +167,8 @@ module.exports = {
167167
'@typescript-eslint/no-unused-vars': [
168168
'error',
169169
{
170-
varsIgnorePattern: '^React$',
170+
varsIgnorePattern: '^(React|_)', // allow underscores in destructuring
171171
argsIgnorePattern: '^_',
172-
ignoreRestSiblings: true,
173172
},
174173
],
175174

@@ -356,7 +355,8 @@ module.exports = {
356355
'unicorn/prefer-dom-node-text-content': 'error',
357356
quotes: ['error', 'single', { avoidEscape: true }], // Matches Prettier, but also replaces backticks with single quotes
358357
// TODO: Fix all errors for the following rules included in recommended config
359-
'@typescript-eslint/no-var-requires': 'off',
358+
'@typescript-eslint/no-require-imports': 'off',
359+
'import-x/no-named-as-default-member': 'off',
360360
},
361361
},
362362
{
@@ -372,6 +372,9 @@ module.exports = {
372372
'@typescript-eslint/consistent-type-assertions': 'error',
373373
'@typescript-eslint/no-duplicate-type-constituents': 'error',
374374
// TODO: Fix all errors for the following rules included in recommended config
375+
'@typescript-eslint/no-deprecated': 'off',
376+
'@typescript-eslint/no-unsafe-function-type': 'off',
377+
375378
'@typescript-eslint/no-explicit-any': 'off',
376379
'@typescript-eslint/no-non-null-assertion': 'off',
377380
'@typescript-eslint/ban-ts-comment': 'off',
@@ -381,12 +384,37 @@ module.exports = {
381384
'@typescript-eslint/no-namespace': 'off',
382385
},
383386
parserOptions: {
384-
project: [
385-
'packages/*/tsconfig.json',
386-
'examples/*/tsconfig.json',
387-
'packages/graphiql/cypress/tsconfig.json',
388-
'tsconfig.eslint.json',
389-
],
387+
projectService: {
388+
allowDefaultProject: [
389+
'examples/monaco-graphql-react-vite/vite.config.ts',
390+
'packages/*/vitest.config.mts',
391+
'packages/*/vite.config.mts',
392+
393+
'packages/cm6-graphql/__tests__/test.spec.ts',
394+
'packages/graphiql-react/setup-files.ts',
395+
'packages/graphiql/src/GraphiQL.spec.tsx',
396+
'packages/vscode-graphql-syntax/tests/*.spec.ts',
397+
'packages/graphql-language-service-cli/src/__tests__/*.test.ts',
398+
'packages/monaco-graphql/test/monaco-editor.test.ts',
399+
400+
'packages/codemirror-graphql/setup-files.ts',
401+
'packages/codemirror-graphql/src/__tests__/testSchema.ts',
402+
'packages/codemirror-graphql/src/__tests__/*.test.ts',
403+
'packages/codemirror-graphql/src/{variables,utils,results}/__tests__/*.test.ts',
404+
405+
'packages/graphql-language-service/benchmark/index.ts',
406+
'packages/graphql-language-service/src/{utils,parser,interface}/__tests__/*.test.ts',
407+
'packages/graphql-language-service/src/parser/__tests__/OnlineParserUtils.ts',
408+
409+
'packages/graphql-language-service-server/src/__tests__/*.{spec,test}.ts',
410+
'packages/graphql-language-service-server/src/__tests__/__utils__/utils.ts',
411+
'packages/graphql-language-service-server/src/__tests__/__utils__/MockProject.ts',
412+
413+
'packages/vscode-graphql-syntax/tests/__utilities__/serializer.ts',
414+
'packages/vscode-graphql-syntax/tests/__utilities__/utilities.ts',
415+
],
416+
maximumDefaultProjectFileMatchCount_THIS_WILL_SLOW_DOWN_LINTING: 100,
417+
},
390418
},
391419
},
392420
// Cypress plugin, global, etc., only for cypress directory

docs/migration/graphiql-2.0.0.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,11 +103,11 @@ easy access to its props, state and methods by attaching a ref to it like so:
103103
```tsx
104104
import { createGraphiQLFetcher } from '@graphiql/toolkit';
105105
import { GraphiQL } from 'graphiql';
106-
import React from 'react';
106+
import { Component } from 'react';
107107

108108
const fetcher = createGraphiQLFetcher({ url: 'https://my.endpoint' });
109109

110-
class MyComponent extends React.Component {
110+
class MyComponent extends Component {
111111
_graphiql: GraphiQL;
112112

113113
componentDidMount() {

package.json

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -93,35 +93,35 @@
9393
"@changesets/changelog-github": "0.5.0",
9494
"@changesets/cli": "2.27.7",
9595
"@manypkg/get-packages": "^1.1.3",
96-
"@shopify/eslint-plugin": "^45.0.0",
96+
"@shopify/eslint-plugin": "^48.0.2",
9797
"@strictsoftware/typedoc-plugin-monorepo": "^0.3.1",
9898
"@types/codemirror": "^0.0.90",
9999
"@types/express": "^4.17.11",
100100
"@types/fetch-mock": "^7.3.2",
101101
"@types/jest": "^29.5.2",
102102
"@types/node": "^16.18.4",
103103
"@types/ws": "8.2.2",
104-
"@typescript-eslint/eslint-plugin": "^7.17.0",
105-
"@typescript-eslint/parser": "^7.17.0",
104+
"@typescript-eslint/eslint-plugin": "^8.31.0",
105+
"@typescript-eslint/parser": "^8.31.0",
106106
"babel-jest": "^29.4.3",
107107
"babel-plugin-macros": "^3.1.0",
108108
"babel-plugin-transform-import-meta": "^2.2.1",
109109
"concurrently": "^7.0.0",
110110
"copy": "^0.3.2",
111111
"cspell": "^5.15.2",
112-
"eslint": "9.14.0",
113-
"eslint-config-prettier": "^9.1.0",
114-
"eslint-import-resolver-typescript": "^3.6.1",
115-
"eslint-plugin-cypress": "^4.1.0",
116-
"eslint-plugin-import-x": "^3.1.0",
117-
"eslint-plugin-jest": "^28.6.0",
118-
"eslint-plugin-mdx": "^3.1.5",
119-
"eslint-plugin-promise": "^7.0.0",
120-
"eslint-plugin-react": "^7.37.2",
112+
"eslint": "9.25.1",
113+
"eslint-config-prettier": "^10.1.2",
114+
"eslint-import-resolver-typescript": "^4.3.4",
115+
"eslint-plugin-cypress": "^4.3.0",
116+
"eslint-plugin-import-x": "^4.11.0",
117+
"eslint-plugin-jest": "^28.11.0",
118+
"eslint-plugin-mdx": "^3.4.1",
119+
"eslint-plugin-promise": "^7.2.1",
120+
"eslint-plugin-react": "^7.37.5",
121121
"eslint-plugin-react-hooks": "^6.0.0-rc.1",
122122
"eslint-plugin-sonar": "^0.14.1",
123123
"eslint-plugin-sonarjs": "^1.0.4",
124-
"eslint-plugin-unicorn": "^55.0.0",
124+
"eslint-plugin-unicorn": "^56.0.0",
125125
"execa": "^7.1.1",
126126
"identity-obj-proxy": "^3.0.0",
127127
"fetch-mock": "6.5.2",

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

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,5 @@ declare module 'codemirror' {
1313
hint?: ShowHintOptions['hint'];
1414
}
1515

16-
interface CodeMirrorHintMap {}
17-
18-
const hint: CodeMirrorHintMap;
16+
const hint: object;
1917
}

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

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
import { formatError } from '@graphiql/toolkit';
22
import type { Position, Token } from 'codemirror';
3-
import { ComponentType, useEffect, useRef } from 'react';
4-
import ReactDOM from 'react-dom';
3+
import { ComponentType, useEffect, useRef, JSX } from 'react';
4+
// eslint-disable-next-line react/no-deprecated -- We can't refactor to root.unmount() from React 18 because we support React 16/17 too
5+
import { unmountComponentAtNode, render } from 'react-dom';
56
import { useSchemaContext } from '../schema';
67

78
import {
@@ -28,8 +29,7 @@ export type ResponseTooltipType = ComponentType<{
2829

2930
export type UseResponseEditorArgs = CommonEditorProps & {
3031
/**
31-
* Customize the tooltip when hovering over properties in the response
32-
* editor.
32+
* Customize the tooltip when hovering over properties in the response editor.
3333
*/
3434
responseTooltip?: ResponseTooltipType;
3535
};
@@ -52,6 +52,7 @@ function importCodeMirrorImports() {
5252
{ useCommonAddons: false },
5353
);
5454
}
55+
5556
// To make react-compiler happy, otherwise complains about - Hooks may not be referenced as normal values
5657
const _useResponseEditor = useResponseEditor;
5758

@@ -109,15 +110,11 @@ export function useResponseEditor(
109110
<ImagePreview key="image-preview" token={token} />,
110111
);
111112
}
112-
113-
// We can't refactor to root.unmount() from React 18 because we support React 16/17 too
114113
if (!infoElements.length) {
115-
// eslint-disable-next-line react/no-deprecated -- We still support React 16/17
116-
ReactDOM.unmountComponentAtNode(tooltipDiv);
114+
unmountComponentAtNode(tooltipDiv);
117115
return null;
118116
}
119-
// eslint-disable-next-line react/no-deprecated -- We still support React 16/17
120-
ReactDOM.render(infoElements, tooltipDiv);
117+
render(infoElements, tooltipDiv);
121118
return tooltipDiv;
122119
},
123120
);

packages/graphiql-react/src/explorer/components/utils.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import {
66
isListType,
77
isNonNullType,
88
} from 'graphql';
9+
import { JSX } from 'react';
910

1011
export function renderType(
1112
type: GraphQLType,

packages/graphiql-react/src/explorer/context.tsx

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import { useSchemaContext } from '../schema';
1818
import { createContextHook, createNullableContext } from '../utility/context';
1919

2020
export type ExplorerFieldDef =
21-
| GraphQLField<{}, {}, {}>
21+
| GraphQLField<unknown, unknown>
2222
| GraphQLInputField
2323
| GraphQLArgument;
2424

@@ -116,8 +116,10 @@ export function ExplorerContextProvider(props: ExplorerContextProviderProps) {
116116
return oldNavStack;
117117
}
118118
const newNavStack: ExplorerNavStack = [initialNavStackItem];
119-
let lastEntity: GraphQLNamedType | GraphQLField<any, any, any> | null =
120-
null;
119+
let lastEntity:
120+
| GraphQLNamedType
121+
| GraphQLField<unknown, unknown>
122+
| null = null;
121123
for (const item of oldNavStack) {
122124
if (item === initialNavStackItem) {
123125
// No need to copy the initial item

packages/graphiql-react/src/toolbar/button.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { forwardRef, MouseEventHandler, useState } from 'react';
1+
import { forwardRef, MouseEventHandler, useState, JSX } from 'react';
22
import { clsx } from 'clsx';
33
import { Tooltip, UnStyledButton } from '../ui';
44

packages/graphiql-react/src/ui/button-group.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { forwardRef } from 'react';
1+
import { forwardRef, JSX } from 'react';
22
import { clsx } from 'clsx';
33

44
import './button-group.css';

0 commit comments

Comments
 (0)