Skip to content

Commit eec0340

Browse files
authored
update eslint to 9 (#3658)
* aa * update vite to v5 * aa * fix tests * fix * aa * aa * bump changesets
1 parent 5bc7b84 commit eec0340

File tree

13 files changed

+468
-479
lines changed

13 files changed

+468
-479
lines changed

.eslintrc.js

+17-25
Original file line numberDiff line numberDiff line change
@@ -54,21 +54,14 @@ module.exports = {
5454
extends: [
5555
'eslint:recommended',
5656
'plugin:@typescript-eslint/recommended',
57-
'plugin:import/recommended',
58-
'plugin:import/typescript',
57+
'plugin:import-x/recommended',
58+
'plugin:import-x/typescript',
5959
'plugin:react/recommended',
6060
'plugin:react-hooks/recommended',
6161
'plugin:react/jsx-runtime',
6262
'prettier',
6363
],
64-
plugins: [
65-
'promise',
66-
'sonarjs',
67-
'unicorn',
68-
'@arthurgeron/react-usememo',
69-
'sonar',
70-
'@shopify',
71-
],
64+
plugins: ['promise', 'sonarjs', 'unicorn', 'sonar', '@shopify'],
7265
globals: {
7366
atom: false,
7467
document: false,
@@ -81,10 +74,6 @@ module.exports = {
8174
'@shopify/prefer-early-return': ['error', { maximumStatements: 2 }],
8275
'@shopify/prefer-class-properties': 'off', // enable after https://github.com/Shopify/web-configs/issues/387 will be fixed
8376
'sonarjs/no-inverted-boolean-check': 'error',
84-
'@arthurgeron/react-usememo/require-usememo': [
85-
'error',
86-
{ checkHookCalls: false },
87-
],
8877
// Possible Errors (http://eslint.org/docs/rules/#possible-errors)
8978
'no-console': 'error',
9079
'no-constant-binary-expression': 'error',
@@ -287,9 +276,9 @@ module.exports = {
287276

288277
'sonarjs/no-ignored-return': 'error',
289278
'unicorn/no-array-push-push': 'error',
290-
'import/no-extraneous-dependencies': 'error',
291-
'import/no-duplicates': 'error',
292-
'import/no-named-as-default': 'error',
279+
'import-x/no-extraneous-dependencies': 'error',
280+
'import-x/no-duplicates': 'error',
281+
'import-x/no-named-as-default': 'error',
293282
'prefer-object-spread': 'error',
294283
// React rules
295284
'react/no-unused-state': 'error',
@@ -342,10 +331,15 @@ module.exports = {
342331
'sonar/prefer-promise-shorthand': 'error',
343332
'sonar/no-dead-store': 'error',
344333
'unicorn/prefer-node-protocol': 'error',
345-
'import/no-unresolved': [
334+
'import-x/no-unresolved': [
346335
'error',
347336
{ ignore: ['^node:', '\\.svg\\?react$'] },
348337
],
338+
'no-extra-boolean-cast': [
339+
'error',
340+
{ enforceForInnerExpressions: true },
341+
],
342+
'unicorn/no-length-as-slice-end': 'error',
349343
'unicorn/prefer-string-replace-all': 'error',
350344
'unicorn/no-hex-escape': 'off', // TODO: enable
351345
// doesn't catch a lot of cases; we use ESLint builtin `no-restricted-syntax` to forbid `.keyCode`
@@ -409,7 +403,6 @@ module.exports = {
409403
rules: {
410404
'jest/no-conditional-expect': 'off',
411405
'jest/expect-expect': ['error', { assertFunctionNames: ['expect*'] }],
412-
'@arthurgeron/react-usememo/require-usememo': 'off',
413406
},
414407
},
415408
{
@@ -426,14 +419,14 @@ module.exports = {
426419
'no-console': 'off',
427420
'no-new': 'off',
428421
'no-alert': 'off',
429-
'import/no-unresolved': 'off',
422+
'import-x/no-unresolved': 'off',
430423
},
431424
},
432425
{
433426
// Rule for ignoring imported dependencies from tests files
434427
files: ['**/__tests__/**', 'webpack.config.js', '**/tests/**'],
435428
rules: {
436-
'import/no-extraneous-dependencies': 'off',
429+
'import-x/no-extraneous-dependencies': 'off',
437430
},
438431
},
439432
{
@@ -443,7 +436,7 @@ module.exports = {
443436
'packages/vscode-graphql-execution/**',
444437
],
445438
rules: {
446-
'import/no-unresolved': ['error', { ignore: ['^node:', 'vscode'] }],
439+
'import-x/no-unresolved': ['error', { ignore: ['^node:', 'vscode'] }],
447440
},
448441
},
449442
{
@@ -484,14 +477,13 @@ module.exports = {
484477
// Rules for codeblocks inside Markdown/MDX
485478
files: ['**/*.{md,mdx}/*.{js,jsx,ts,tsx}'],
486479
rules: {
487-
'import/no-extraneous-dependencies': 'off',
480+
'import-x/no-extraneous-dependencies': 'off',
488481
'@typescript-eslint/no-unused-vars': 'off',
489-
'import/no-unresolved': 'off',
482+
'import-x/no-unresolved': 'off',
490483
'no-console': 'off',
491484
'no-undef': 'off',
492485
'react/jsx-no-undef': 'off',
493486
'react-hooks/rules-of-hooks': 'off',
494-
'@arthurgeron/react-usememo/require-usememo': 'off',
495487
'sonar/no-dead-store': 'off',
496488
'@typescript-eslint/no-restricted-imports': 'off',
497489
},

examples/graphiql-webpack/src/index.jsx

-1
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,6 @@ const App = () => {
8484
return (
8585
<GraphiQL
8686
style={style}
87-
// eslint-disable-next-line @arthurgeron/react-usememo/require-usememo
8887
plugins={[serverSelect, explorer, exporter]}
8988
fetcher={fetcher}
9089
shouldPersistHeaders

package.json

+13-14
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@
4848
"dev-graphiql": "yarn workspace graphiql dev",
4949
"e2e": "yarn run e2e:build && yarn workspace graphiql e2e",
5050
"e2e:build": "WEBPACK_SERVE=1 yarn workspace graphiql build-bundles",
51-
"eslint": "NODE_OPTIONS=--max-old-space-size=4096 eslint --max-warnings=0 --ignore-path .gitignore --cache .",
51+
"eslint": "NODE_OPTIONS=--max-old-space-size=4096 ESLINT_USE_FLAT_CONFIG=false eslint --max-warnings=0 --ignore-path .gitignore --cache .",
5252
"format": "yarn eslint --fix && yarn pretty",
5353
"jest": "jest",
5454
"license-check": "jsgl --local packages/*",
@@ -78,7 +78,6 @@
7878
"gen-agenda": "wgutils agenda gen"
7979
},
8080
"dependencies": {
81-
"@arthurgeron/eslint-plugin-react-usememo": "^2.4.0",
8281
"@babel/cli": "^7.21.0",
8382
"@babel/core": "^7.21.0",
8483
"@babel/plugin-proposal-class-properties": "^7.18.6",
@@ -90,8 +89,8 @@
9089
"@babel/preset-react": "^7.18.6",
9190
"@babel/preset-typescript": "^7.21.0",
9291
"@babel/register": "^7.21.0",
93-
"@changesets/changelog-github": "0.4.7",
94-
"@changesets/cli": "2.25.2",
92+
"@changesets/changelog-github": "0.5.0",
93+
"@changesets/cli": "2.27.7",
9594
"@manypkg/get-packages": "^1.1.3",
9695
"@shopify/eslint-plugin": "^45.0.0",
9796
"@strictsoftware/typedoc-plugin-monorepo": "^0.3.1",
@@ -102,25 +101,25 @@
102101
"@types/jest": "^29.5.2",
103102
"@types/node": "^16.18.4",
104103
"@types/ws": "8.2.2",
105-
"@typescript-eslint/eslint-plugin": "^7.14.1",
106-
"@typescript-eslint/parser": "^7.14.1",
104+
"@typescript-eslint/eslint-plugin": "^7.17.0",
105+
"@typescript-eslint/parser": "^7.17.0",
107106
"babel-jest": "^29.4.3",
108107
"concurrently": "^7.0.0",
109108
"copy": "^0.3.2",
110109
"cspell": "^5.15.2",
111-
"eslint": "^8.57.0",
110+
"eslint": "^9.7.0",
112111
"eslint-config-prettier": "^9.1.0",
113112
"eslint-import-resolver-typescript": "^3.6.1",
114-
"eslint-plugin-cypress": "^3.3.0",
115-
"eslint-plugin-import": "^2.29.1",
113+
"eslint-plugin-cypress": "^3.4.0",
114+
"eslint-plugin-import-x": "^3.1.0",
116115
"eslint-plugin-jest": "^28.6.0",
117116
"eslint-plugin-mdx": "^3.1.5",
118-
"eslint-plugin-promise": "^6.4.0",
119-
"eslint-plugin-react": "^7.34.3",
120-
"eslint-plugin-react-hooks": "^4.6.2",
117+
"eslint-plugin-promise": "^7.0.0",
118+
"eslint-plugin-react": "^7.35.0",
119+
"eslint-plugin-react-hooks": "^5.1.0-rc-76002254-20240724",
121120
"eslint-plugin-sonar": "^0.14.1",
122-
"eslint-plugin-sonarjs": "^1.0.3",
123-
"eslint-plugin-unicorn": "^54.0.0",
121+
"eslint-plugin-sonarjs": "^1.0.4",
122+
"eslint-plugin-unicorn": "^55.0.0",
124123
"execa": "^7.1.1",
125124
"fetch-mock": "6.5.2",
126125
"husky": "^4.2.3",

packages/graphiql-plugin-explorer/src/index.tsx

-2
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ const colors = {
3434
atom: 'hsl(var(--color-tertiary))',
3535
};
3636

37-
/* eslint-disable @arthurgeron/react-usememo/require-usememo */
3837
const arrowOpen = (
3938
<ArrowIcon style={{ width: 'var(--px-16)', transform: 'rotate(90deg)' }} />
4039
);
@@ -47,7 +46,6 @@ const checkboxChecked = (
4746
style={{ fill: 'hsl(var(--color-info))', marginRight: 'var(--px-4)' }}
4847
/>
4948
);
50-
/* eslint-enable @arthurgeron/react-usememo/require-usememo */
5149

5250
const styles: Record<string, CSSProperties> = {
5351
buttonStyle: {

packages/graphiql/test/afterDevServer.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// eslint-disable-next-line import/no-extraneous-dependencies
1+
// eslint-disable-next-line import-x/no-extraneous-dependencies
22
const { useServer } = require('graphql-ws/lib/use/ws');
33
const { Server: WebSocketServer } = require('ws');
44
const schema = require('./schema');

packages/graphql-language-service-server/src/parsers/babel.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { BABEL_PLUGINS, PARSER_OPTIONS } from '../constants';
33
import { SourceParser } from './types';
44

55
export const babelParser = (text: string, plugins?: ParserPlugin[]) => {
6-
const babelPlugins = BABEL_PLUGINS.slice(0, BABEL_PLUGINS.length);
6+
const babelPlugins = [...BABEL_PLUGINS];
77
if (plugins) {
88
babelPlugins.push(...plugins);
99
}

packages/monaco-graphql/src/GraphQLWorker.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ export class GraphQLWorker {
135135
return null;
136136
}
137137
const prettierStandalone = await import('prettier/standalone');
138-
// eslint-disable-next-line import/no-unresolved -- should be fixed by pnpm migration (points to @types/prettier rather owns prettier types)
138+
// eslint-disable-next-line import-x/no-unresolved -- should be fixed by pnpm migration (points to @types/prettier rather owns prettier types)
139139
const prettierGraphqlParser = await import('prettier/parser-graphql');
140140

141141
return prettierStandalone.format(document, {

packages/monaco-graphql/vitest.config.mts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// eslint-disable-next-line import/no-unresolved -- todo: try to fix better rather ignoring here?
1+
// eslint-disable-next-line import-x/no-unresolved -- todo: try to fix better rather ignoring here?
22
import { defineConfig } from 'vitest/config';
33

44
export default defineConfig({

packages/vscode-graphql-execution/src/helpers/network.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { gql } from 'graphql-tag';
33
import { fetch } from '@whatwg-node/fetch';
44
import { Agent } from 'node:https';
55
import * as ws from 'ws';
6-
// eslint-disable-next-line import/no-extraneous-dependencies
6+
// eslint-disable-next-line import-x/no-extraneous-dependencies
77
import { pipe, subscribe } from 'wonka';
88

99
import { Endpoint } from './extensions';

packages/vscode-graphql-syntax/vitest.config.mts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// eslint-disable-next-line import/no-unresolved -- fix later
1+
// eslint-disable-next-line import-x/no-unresolved -- fix later
22
import { defineConfig } from 'vitest/config';
33

44
export default defineConfig({

resources/patches/@changesets+assemble-release-plan+5.2.2.patch

-26
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
diff --git a/node_modules/@changesets/assemble-release-plan/dist/changesets-assemble-release-plan.cjs.js b/node_modules/@changesets/assemble-release-plan/dist/changesets-assemble-release-plan.cjs.js
2+
index 60427457c887f2d72168fecec83d79088c68e3a4..07565f3336140470e8ea0d7c1a9b09586f8e946e 100644
3+
--- a/node_modules/@changesets/assemble-release-plan/dist/changesets-assemble-release-plan.cjs.js
4+
+++ b/node_modules/@changesets/assemble-release-plan/dist/changesets-assemble-release-plan.cjs.js
5+
@@ -299,7 +299,7 @@ function shouldBumpMajor({
6+
// we check if it is a peerDependency because if it is, our dependent bump type might need to be major.
7+
return depType === "peerDependencies" && nextRelease.type !== "none" && nextRelease.type !== "patch" && ( // 1. If onlyUpdatePeerDependentsWhenOutOfRange set to true, bump major if the version is leaving the range.
8+
// 2. If onlyUpdatePeerDependentsWhenOutOfRange set to false, bump major regardless whether or not the version is leaving the range.
9+
- !onlyUpdatePeerDependentsWhenOutOfRange || !semverSatisfies__default["default"](incrementVersion(nextRelease, preInfo), versionRange)) && ( // bump major only if the dependent doesn't already has a major release.
10+
+ !onlyUpdatePeerDependentsWhenOutOfRange) && ( // bump major only if the dependent doesn't already has a major release.
11+
!releases.has(dependent) || releases.has(dependent) && releases.get(dependent).type !== "major");
12+
}
13+
14+
@@ -396,7 +396,7 @@ function matchFixedConstraint(releases, packagesByName, config) {
15+
16+
function getPreVersion(version) {
17+
let parsed = semverParse__default["default"](version);
18+
- let preVersion = parsed.prerelease[1] === undefined ? -1 : parsed.prerelease[1];
19+
+ let preVersion = parsed?.prerelease[1] === undefined ? -1 : parsed.prerelease[1];
20+
21+
if (typeof preVersion !== "number") {
22+
throw new errors.InternalError("preVersion is not a number");

0 commit comments

Comments
 (0)