@@ -31,6 +31,12 @@ module.exports = {
3131 '**/CHANGELOG.md' ,
3232 'functions/*' ,
3333 'packages/vscode-graphql-syntax/tests/__fixtures__/*' ,
34+ // symlinks
35+ 'packages/graphiql-react/__mocks__/monaco-editor.ts' ,
36+ 'packages/graphiql-plugin-doc-explorer/__mocks__/zustand.ts' ,
37+ 'packages/graphiql-plugin-doc-explorer/__mocks__/monaco-editor.ts' ,
38+ 'packages/graphiql-plugin-history/__mocks__/zustand.ts' ,
39+ 'packages/graphiql-plugin-history/__mocks__/monaco-editor.ts' ,
3440 ] ,
3541 overrides : [
3642 {
@@ -57,11 +63,11 @@ module.exports = {
5763 'plugin:import-x/recommended' ,
5864 'plugin:import-x/typescript' ,
5965 'plugin:react/recommended' ,
60- 'plugin:react-hooks/recommended' ,
66+ 'plugin:react-hooks/recommended-legacy ' ,
6167 'plugin:react/jsx-runtime' ,
6268 'prettier' ,
6369 ] ,
64- plugins : [ 'promise' , 'sonarjs' , 'unicorn' , 'sonar' , ' @shopify'] ,
70+ plugins : [ 'promise' , 'sonarjs' , 'unicorn' , '@shopify' ] ,
6571 globals : {
6672 atom : false ,
6773 document : false ,
@@ -129,6 +135,25 @@ module.exports = {
129135 property : 'localStorage' ,
130136 message : 'Use `localStorage` instead' ,
131137 } ,
138+ {
139+ object : 'window' ,
140+ property : 'location' ,
141+ message : 'Use `location` instead' ,
142+ } ,
143+ {
144+ object : 'window' ,
145+ property : 'navigator' ,
146+ message : 'Use `navigator` instead' ,
147+ } ,
148+ {
149+ object : 'window' ,
150+ property : 'getComputedStyle' ,
151+ message : 'Use `getComputedStyle` instead' ,
152+ } ,
153+ {
154+ object : 'self' ,
155+ message : 'Use `globalThis` instead' ,
156+ } ,
132157 ] ,
133158 'no-return-assign' : 'error' ,
134159 'no-return-await' : 'error' ,
@@ -158,7 +183,7 @@ module.exports = {
158183 'init-declarations' : 'off' ,
159184 'no-catch-shadow' : 'error' ,
160185 'no-label-var' : 'error' ,
161- 'no-restricted-globals' : 'off' ,
186+ 'no-restricted-globals' : [ 'error' , 'stop' ] ,
162187 'no-shadow' : 'off' ,
163188 '@typescript-eslint/no-shadow' : 'error' ,
164189 'no-undef-init' : 'off' ,
@@ -167,9 +192,8 @@ module.exports = {
167192 '@typescript-eslint/no-unused-vars' : [
168193 'error' ,
169194 {
170- varsIgnorePattern : '^React$' ,
195+ varsIgnorePattern : '^( React|_)' , // allow underscores in destructuring
171196 argsIgnorePattern : '^_' ,
172- ignoreRestSiblings : true ,
173197 } ,
174198 ] ,
175199
@@ -328,8 +352,9 @@ module.exports = {
328352 '@typescript-eslint/no-unused-expressions' : 'error' ,
329353 'sonarjs/no-small-switch' : 'error' ,
330354 'sonarjs/no-duplicated-branches' : 'error' ,
331- 'sonar/prefer-promise-shorthand' : 'error' ,
332- 'sonar/no-dead-store' : 'error' ,
355+ 'sonarjs/prefer-promise-shorthand' : 'error' ,
356+ 'sonarjs/no-dead-store' : 'error' ,
357+ 'sonarjs/void-use' : 'error' ,
333358 'unicorn/prefer-node-protocol' : 'error' ,
334359 'import-x/no-unresolved' : [
335360 'error' ,
@@ -348,6 +373,8 @@ module.exports = {
348373 ] ,
349374 'unicorn/no-length-as-slice-end' : 'error' ,
350375 'unicorn/prefer-string-replace-all' : 'error' ,
376+ 'unicorn/prefer-array-some' : 'error' ,
377+ // '@typescript-eslint/prefer-for-of': 'error', TODO
351378 'unicorn/no-hex-escape' : 'off' , // TODO: enable
352379 // doesn't catch a lot of cases; we use ESLint builtin `no-restricted-syntax` to forbid `.keyCode`
353380 'unicorn/prefer-keyboard-event-key' : 'off' ,
@@ -356,7 +383,15 @@ module.exports = {
356383 'unicorn/prefer-dom-node-text-content' : 'error' ,
357384 quotes : [ 'error' , 'single' , { avoidEscape : true } ] , // Matches Prettier, but also replaces backticks with single quotes
358385 // TODO: Fix all errors for the following rules included in recommended config
359- '@typescript-eslint/no-var-requires' : 'off' ,
386+ '@typescript-eslint/no-require-imports' : 'off' ,
387+ 'import-x/no-named-as-default-member' : 'off' ,
388+ } ,
389+ } ,
390+ {
391+ files : [ 'packages/{monaco-graphql,graphiql*}/**/*.{ts,tsx,mts,cts}' ] ,
392+ excludedFiles : [ 'packages/graphiql-toolkit/**/*.{ts,tsx}' ] ,
393+ rules : {
394+ '@typescript-eslint/no-unnecessary-condition' : 'error' ,
360395 } ,
361396 } ,
362397 {
@@ -365,13 +400,19 @@ module.exports = {
365400 excludedFiles : [ '**/*.{md,mdx}/*.{ts,tsx}' ] ,
366401 // extends: ['plugin:@typescript-eslint/recommended-type-checked'],
367402 rules : {
403+ // '@typescript-eslint/no-redundant-type-constituents': 'error',
368404 '@typescript-eslint/prefer-optional-chain' : 'error' ,
369405 '@typescript-eslint/no-unnecessary-type-assertion' : 'error' ,
370406 '@typescript-eslint/no-floating-promises' : 'error' ,
371407 '@typescript-eslint/non-nullable-type-assertion-style' : 'error' ,
372408 '@typescript-eslint/consistent-type-assertions' : 'error' ,
373409 '@typescript-eslint/no-duplicate-type-constituents' : 'error' ,
410+ '@typescript-eslint/no-unnecessary-type-conversion' : 'error' ,
411+ // '@typescript-eslint/await-thenable': 'error', // TODO
374412 // TODO: Fix all errors for the following rules included in recommended config
413+ '@typescript-eslint/no-deprecated' : 'off' ,
414+ '@typescript-eslint/no-unsafe-function-type' : 'off' ,
415+
375416 '@typescript-eslint/no-explicit-any' : 'off' ,
376417 '@typescript-eslint/no-non-null-assertion' : 'off' ,
377418 '@typescript-eslint/ban-ts-comment' : 'off' ,
@@ -381,12 +422,35 @@ module.exports = {
381422 '@typescript-eslint/no-namespace' : 'off' ,
382423 } ,
383424 parserOptions : {
384- project : [
385- 'packages/*/tsconfig.json' ,
386- 'examples/*/tsconfig.json' ,
387- 'packages/graphiql/cypress/tsconfig.json' ,
388- 'tsconfig.eslint.json' ,
389- ] ,
425+ projectService : {
426+ allowDefaultProject : [
427+ 'examples/monaco-graphql-react-vite/vite.config.ts' ,
428+ 'packages/{codemirror-graphql,graphiql-toolkit,graphql-language-service-cli,graphql-language-service,monaco-graphql,vscode-graphql-syntax}/vitest.config.mts' ,
429+
430+ 'packages/cm6-graphql/__tests__/test.spec.ts' ,
431+ 'packages/graphiql/cypress.config.ts' ,
432+ 'packages/vscode-graphql-syntax/tests/*.spec.ts' ,
433+ 'packages/graphql-language-service-cli/src/__tests__/*.test.ts' ,
434+ 'packages/monaco-graphql/test/monaco-editor.test.ts' ,
435+
436+ 'packages/codemirror-graphql/setup-files.ts' ,
437+ 'packages/codemirror-graphql/src/__tests__/testSchema.ts' ,
438+ 'packages/codemirror-graphql/src/__tests__/*.test.ts' ,
439+ 'packages/codemirror-graphql/src/{variables,utils,results}/__tests__/*.test.ts' ,
440+
441+ 'packages/graphql-language-service/benchmark/index.ts' ,
442+ 'packages/graphql-language-service/src/{utils,parser,interface}/__tests__/*.test.ts' ,
443+ 'packages/graphql-language-service/src/parser/__tests__/OnlineParserUtils.ts' ,
444+
445+ 'packages/graphql-language-service-server/src/__tests__/*.{spec,test}.ts' ,
446+ 'packages/graphql-language-service-server/src/__tests__/__utils__/utils.ts' ,
447+ 'packages/graphql-language-service-server/src/__tests__/__utils__/MockProject.ts' ,
448+
449+ 'packages/vscode-graphql-syntax/tests/__utilities__/serializer.ts' ,
450+ 'packages/vscode-graphql-syntax/tests/__utilities__/utilities.ts' ,
451+ ] ,
452+ maximumDefaultProjectFileMatchCount_THIS_WILL_SLOW_DOWN_LINTING : 100 ,
453+ } ,
390454 } ,
391455 } ,
392456 // Cypress plugin, global, etc., only for cypress directory
@@ -454,16 +518,15 @@ module.exports = {
454518 } ,
455519 } ,
456520 {
457- // Rule prefer await to then without React packages because it's ugly to have `async IIFE` inside `useEffect`
521+ // Rule to prefer await to then without React packages because it's ugly to have `async IIFE` inside `useEffect`
458522 files : [ 'packages/**' ] ,
459523 excludedFiles : [ 'packages/graphiql/**' , 'packages/graphiql-react/**' ] ,
460524 rules : {
461525 'promise/prefer-await-to-then' : 'error' ,
462526 } ,
463527 } ,
464528 {
465- files : [ 'packages/graphiql-react/**' ] ,
466- plugins : [ 'react-compiler' ] ,
529+ files : [ 'packages/{graphiql-react,graphiql}/**/*.{ts,tsx}' ] ,
467530 rules : {
468531 '@typescript-eslint/no-restricted-imports' : [
469532 'error' ,
@@ -473,7 +536,8 @@ module.exports = {
473536 importNames : [ 'memo' , 'useCallback' , 'useMemo' ] ,
474537 } ,
475538 ] ,
476- 'react-compiler/react-compiler' : 'error' ,
539+ 'react-hooks/react-compiler' : 'error' ,
540+ '@typescript-eslint/no-deprecated' : 'error' ,
477541 } ,
478542 } ,
479543 {
@@ -501,6 +565,12 @@ module.exports = {
501565 'mdx/code-blocks' : true ,
502566 } ,
503567 } ,
568+ {
569+ files : [ '**/*.d.ts' ] ,
570+ rules : {
571+ 'no-var' : 'off' ,
572+ } ,
573+ } ,
504574 {
505575 // ❗ALWAYS LAST
506576 // Rules for codeblocks inside Markdown/MDX
@@ -513,8 +583,9 @@ module.exports = {
513583 'no-undef' : 'off' ,
514584 'react/jsx-no-undef' : 'off' ,
515585 'react-hooks/rules-of-hooks' : 'off' ,
516- 'sonar /no-dead-store' : 'off' ,
586+ 'sonarjs /no-dead-store' : 'off' ,
517587 '@typescript-eslint/no-restricted-imports' : 'off' ,
588+ '@typescript-eslint/no-unnecessary-condition' : 'off' ,
518589 } ,
519590 } ,
520591 ] ,
0 commit comments