From 8725d1b6b686139286cf05dec6a84d89942128ba Mon Sep 17 00:00:00 2001 From: Dimitri POSTOLOV Date: Fri, 3 Feb 2023 14:17:47 +0100 Subject: [PATCH] =?UTF-8?q?=F0=9F=9B=A0=EF=B8=8F=20ESLint:=20enable=20`uni?= =?UTF-8?q?corn/prefer-node-protocol`=20rule=20(#2940)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * enable `unicorn/prefer-node-protocol` rule * use `"@types/node": "^16.18.4"` since github ci is use node v16 * fix unit tests * fix * rebase --- .changeset/tasty-pigs-care.md | 12 ++++++++++++ .eslintrc.js | 4 +++- .../monaco-graphql-webpack/webpack.config.js | 2 +- jest.config.base.js | 2 +- package.json | 2 +- packages/cm6-graphql/__tests__/test.spec.ts | 6 +++--- .../src/__tests__/lint-test.ts | 4 ++-- .../src/__tests__/mode-test.ts | 4 ++-- packages/graphiql/package.json | 2 +- packages/graphiql/resources/webpack.config.js | 2 +- packages/graphiql/test/beforeDevServer.js | 2 +- packages/graphiql/test/e2e-server.js | 2 +- .../graphql-language-service-cli/src/client.ts | 6 +++--- .../src/GraphQLCache.ts | 2 +- .../src/Logger.ts | 8 ++++---- .../src/MessageProcessor.ts | 8 ++++---- .../__tests__/GraphQLLanguageService-test.ts | 2 +- .../src/__tests__/Logger-test.ts | 2 +- .../src/__tests__/MessageProcessor-test.ts | 18 +++++++++++------- .../src/__tests__/findGraphQLTags-test.ts | 2 +- .../src/parseDocument.ts | 2 +- .../src/startServer.ts | 2 +- .../benchmark/index.ts | 4 ++-- .../getAutocompleteSuggestions-test.ts | 4 ++-- .../interface/__tests__/getDiagnostics-test.ts | 4 ++-- .../__tests__/getHoverInformation-test.ts | 4 ++-- .../__tests__/getVariablesJSONSchema.spec.ts | 4 ++-- .../__tests__/validateWithCustomRules-test.ts | 4 ++-- packages/vscode-graphql-execution/package.json | 2 +- .../src/helpers/network.ts | 2 +- packages/vscode-graphql/src/extension.ts | 2 +- resources/runTests.js | 2 +- resources/webpack.config.js | 2 +- scripts/buildFlow.js | 4 ++-- scripts/pretty.js | 6 +++--- scripts/renameFileExtensions.js | 6 +++--- scripts/set-resolution.js | 4 ++-- scripts/util.js | 4 ++-- yarn.lock | 15 +++++---------- 39 files changed, 91 insertions(+), 78 deletions(-) create mode 100644 .changeset/tasty-pigs-care.md diff --git a/.changeset/tasty-pigs-care.md b/.changeset/tasty-pigs-care.md new file mode 100644 index 00000000000..7d313354615 --- /dev/null +++ b/.changeset/tasty-pigs-care.md @@ -0,0 +1,12 @@ +--- +'cm6-graphql': patch +'codemirror-graphql': patch +'graphiql': patch +'graphql-language-service': patch +'graphql-language-service-cli': patch +'graphql-language-service-server': patch +'vscode-graphql': patch +'vscode-graphql-execution': patch +--- + +enable `unicorn/prefer-node-protocol` rule diff --git a/.eslintrc.js b/.eslintrc.js index 4caef755595..2863e7bc28c 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -276,6 +276,8 @@ module.exports = { '@typescript-eslint/no-unused-expressions': 'error', 'sonarjs/no-small-switch': 'error', 'sonarjs/no-duplicated-branches': 'error', + 'unicorn/prefer-node-protocol': 'error', + 'import/no-unresolved': ['error', { ignore: ['^node:'] }], }, plugins: ['@typescript-eslint', 'promise', 'sonarjs', 'unicorn'], @@ -344,7 +346,7 @@ module.exports = { 'packages/vscode-graphql-execution/**', ], rules: { - 'import/no-unresolved': ['error', { ignore: ['vscode'] }], + 'import/no-unresolved': ['error', { ignore: ['^node:', 'vscode'] }], }, }, ], diff --git a/examples/monaco-graphql-webpack/webpack.config.js b/examples/monaco-graphql-webpack/webpack.config.js index 81adb0c885d..34a55208e58 100644 --- a/examples/monaco-graphql-webpack/webpack.config.js +++ b/examples/monaco-graphql-webpack/webpack.config.js @@ -1,4 +1,4 @@ -const path = require('path'); +const path = require('node:path'); const HtmlWebpackPlugin = require('html-webpack-plugin'); const { BundleAnalyzerPlugin } = require('webpack-bundle-analyzer'); diff --git a/jest.config.base.js b/jest.config.base.js index eb2972a5d01..eeade539686 100644 --- a/jest.config.base.js +++ b/jest.config.base.js @@ -1,4 +1,4 @@ -const path = require('path'); +const path = require('node:path'); module.exports = (dir, env = 'jsdom') => { const package = require(`${dir}/package.json`); diff --git a/package.json b/package.json index 06f7b2fb049..b71568af18b 100644 --- a/package.json +++ b/package.json @@ -99,7 +99,7 @@ "@types/express": "^4.17.11", "@types/fetch-mock": "^7.3.2", "@types/jest": "^26.0.22", - "@types/node": "^14.14.22", + "@types/node": "^16.18.4", "@types/prettier": "^2.7.0", "@types/react": "^17.0.37", "@types/react-dom": "^17.0.17", diff --git a/packages/cm6-graphql/__tests__/test.spec.ts b/packages/cm6-graphql/__tests__/test.spec.ts index 6dfd9e34066..1facef1c521 100644 --- a/packages/cm6-graphql/__tests__/test.spec.ts +++ b/packages/cm6-graphql/__tests__/test.spec.ts @@ -1,8 +1,8 @@ import { graphqlLanguage } from '../dist/index.js'; import { fileTests } from '@lezer/generator/dist/test'; -import * as fs from 'fs'; -import * as path from 'path'; +import * as fs from 'node:fs'; +import * as path from 'node:path'; // because of the babel transformations, __dirname is the package root (cm6-graphql) const caseDir = path.resolve(path.dirname(__dirname), '__tests__'); @@ -23,7 +23,7 @@ describe('codemirror 6 language', () => { try { run(graphqlLanguage.parser); } catch (err) { - require('console').log(name, err); + require('node:console').log(name, err); throw err; } }); diff --git a/packages/codemirror-graphql/src/__tests__/lint-test.ts b/packages/codemirror-graphql/src/__tests__/lint-test.ts index fd608521e1f..f948000fae3 100644 --- a/packages/codemirror-graphql/src/__tests__/lint-test.ts +++ b/packages/codemirror-graphql/src/__tests__/lint-test.ts @@ -9,8 +9,8 @@ import CodeMirror from 'codemirror'; import 'codemirror/addon/lint/lint'; -import { readFileSync } from 'fs'; -import { join } from 'path'; +import { readFileSync } from 'node:fs'; +import { join } from 'node:path'; import { GraphQLError, OperationDefinitionNode } from 'graphql'; import '../lint'; import '../mode'; diff --git a/packages/codemirror-graphql/src/__tests__/mode-test.ts b/packages/codemirror-graphql/src/__tests__/mode-test.ts index 4757be0abd4..2cd16ecaff3 100644 --- a/packages/codemirror-graphql/src/__tests__/mode-test.ts +++ b/packages/codemirror-graphql/src/__tests__/mode-test.ts @@ -9,8 +9,8 @@ import CodeMirror from 'codemirror'; import 'codemirror/addon/runmode/runmode'; -import { readFileSync } from 'fs'; -import { join } from 'path'; +import { readFileSync } from 'node:fs'; +import { join } from 'node:path'; import '../mode'; describe('graphql-mode', () => { diff --git a/packages/graphiql/package.json b/packages/graphiql/package.json index 78c06a929c0..e6069054c1e 100644 --- a/packages/graphiql/package.json +++ b/packages/graphiql/package.json @@ -67,7 +67,7 @@ "@testing-library/react": "12.1.5", "@types/codemirror": "^5.60.5", "@types/markdown-it": "^12.2.3", - "@types/node": "^14.14.22", + "@types/node": "^16.18.4", "@types/testing-library__jest-dom": "5.14.5", "babel-loader": "^8.1.0", "babel-plugin-macros": "^2.8.0", diff --git a/packages/graphiql/resources/webpack.config.js b/packages/graphiql/resources/webpack.config.js index 95ec2e220b8..1e2ad729515 100644 --- a/packages/graphiql/resources/webpack.config.js +++ b/packages/graphiql/resources/webpack.config.js @@ -1,4 +1,4 @@ -const path = require('path'); +const path = require('node:path'); const webpack = require('webpack'); const HtmlWebpackPlugin = require('html-webpack-plugin'); diff --git a/packages/graphiql/test/beforeDevServer.js b/packages/graphiql/test/beforeDevServer.js index 0b4e0bd2c8a..0cc336c8348 100644 --- a/packages/graphiql/test/beforeDevServer.js +++ b/packages/graphiql/test/beforeDevServer.js @@ -6,7 +6,7 @@ */ const express = require('express'); -const path = require('path'); +const path = require('node:path'); const { graphqlHTTP } = require('express-graphql'); const schema = require('./schema'); const { schema: badSchema } = require('./bad-schema'); diff --git a/packages/graphiql/test/e2e-server.js b/packages/graphiql/test/e2e-server.js index 221b0dd63ce..e54ce410ddd 100644 --- a/packages/graphiql/test/e2e-server.js +++ b/packages/graphiql/test/e2e-server.js @@ -7,7 +7,7 @@ /* eslint-disable no-console */ const express = require('express'); -const path = require('path'); +const path = require('node:path'); const { graphqlHTTP } = require('express-graphql'); const { GraphQLError } = require('graphql'); const schema = require('./schema'); diff --git a/packages/graphql-language-service-cli/src/client.ts b/packages/graphql-language-service-cli/src/client.ts index 2b61b9bb93d..6b60f47c618 100644 --- a/packages/graphql-language-service-cli/src/client.ts +++ b/packages/graphql-language-service-cli/src/client.ts @@ -9,8 +9,8 @@ import { GraphQLSchema, buildSchema, buildClientSchema } from 'graphql'; -import invariant from 'assert'; -import fs from 'fs'; +import invariant from 'node:assert'; +import fs from 'node:fs'; import { getAutocompleteSuggestions, getDiagnostics, @@ -18,7 +18,7 @@ import { Position, } from 'graphql-language-service'; -import path from 'path'; +import path from 'node:path'; import type { CompletionItem, Diagnostic } from 'graphql-language-service'; diff --git a/packages/graphql-language-service-server/src/GraphQLCache.ts b/packages/graphql-language-service-server/src/GraphQLCache.ts index f8cdbbafe76..975fd56c376 100644 --- a/packages/graphql-language-service-server/src/GraphQLCache.ts +++ b/packages/graphql-language-service-server/src/GraphQLCache.ts @@ -18,7 +18,7 @@ import type { Uri, } from 'graphql-language-service'; -import * as fs from 'fs'; +import * as fs from 'node:fs'; import { GraphQLSchema, Kind, extendSchema, parse, visit } from 'graphql'; import nullthrows from 'nullthrows'; diff --git a/packages/graphql-language-service-server/src/Logger.ts b/packages/graphql-language-service-server/src/Logger.ts index de2451ae853..01ca1a9293f 100644 --- a/packages/graphql-language-service-server/src/Logger.ts +++ b/packages/graphql-language-service-server/src/Logger.ts @@ -10,10 +10,10 @@ import { Logger as VSCodeLogger } from 'vscode-jsonrpc'; import { DiagnosticSeverity } from 'vscode-languageserver'; -import * as fs from 'fs'; -import * as os from 'os'; -import { join } from 'path'; -import { Socket } from 'net'; +import * as fs from 'node:fs'; +import * as os from 'node:os'; +import { join } from 'node:path'; +import { Socket } from 'node:net'; import { DIAGNOSTIC_SEVERITY, diff --git a/packages/graphql-language-service-server/src/MessageProcessor.ts b/packages/graphql-language-service-server/src/MessageProcessor.ts index 09caa9deec9..61d6068297d 100644 --- a/packages/graphql-language-service-server/src/MessageProcessor.ts +++ b/packages/graphql-language-service-server/src/MessageProcessor.ts @@ -8,8 +8,8 @@ */ import mkdirp from 'mkdirp'; -import { readFileSync, existsSync, writeFileSync, writeFile } from 'fs'; -import * as path from 'path'; +import { readFileSync, existsSync, writeFileSync, writeFile } from 'node:fs'; +import * as path from 'node:path'; import glob from 'fast-glob'; import { URI } from 'vscode-uri'; import { @@ -61,7 +61,7 @@ import { parseDocument, DEFAULT_SUPPORTED_EXTENSIONS } from './parseDocument'; import { Logger } from './Logger'; import { printSchema, visit, parse, FragmentDefinitionNode } from 'graphql'; -import { tmpdir } from 'os'; +import { tmpdir } from 'node:os'; import { ConfigEmptyError, ConfigInvalidError, @@ -71,7 +71,7 @@ import { ProjectNotFoundError, } from 'graphql-config'; import type { LoadConfigOptions } from './types'; -import { promisify } from 'util'; +import { promisify } from 'node:util'; const writeFileAsync = promisify(writeFile); diff --git a/packages/graphql-language-service-server/src/__tests__/GraphQLLanguageService-test.ts b/packages/graphql-language-service-server/src/__tests__/GraphQLLanguageService-test.ts index 33691d551e2..844fc1b31a0 100644 --- a/packages/graphql-language-service-server/src/__tests__/GraphQLLanguageService-test.ts +++ b/packages/graphql-language-service-server/src/__tests__/GraphQLLanguageService-test.ts @@ -7,7 +7,7 @@ * */ -import { join } from 'path'; +import { join } from 'node:path'; import { GraphQLConfig } from 'graphql-config'; import { GraphQLLanguageService } from '../GraphQLLanguageService'; diff --git a/packages/graphql-language-service-server/src/__tests__/Logger-test.ts b/packages/graphql-language-service-server/src/__tests__/Logger-test.ts index 8b4ea289692..3cfa3a89ee6 100644 --- a/packages/graphql-language-service-server/src/__tests__/Logger-test.ts +++ b/packages/graphql-language-service-server/src/__tests__/Logger-test.ts @@ -7,7 +7,7 @@ * */ -import { tmpdir } from 'os'; +import { tmpdir } from 'node:os'; import { Logger } from '../Logger'; describe('Logger', () => { diff --git a/packages/graphql-language-service-server/src/__tests__/MessageProcessor-test.ts b/packages/graphql-language-service-server/src/__tests__/MessageProcessor-test.ts index 7a7b0890c8a..3e95f7c7946 100644 --- a/packages/graphql-language-service-server/src/__tests__/MessageProcessor-test.ts +++ b/packages/graphql-language-service-server/src/__tests__/MessageProcessor-test.ts @@ -6,7 +6,7 @@ * LICENSE file in the root directory of this source tree. * */ -import { tmpdir } from 'os'; +import { tmpdir } from 'node:os'; import { SymbolKind } from 'vscode-languageserver'; import { FileChangeType } from 'vscode-languageserver-protocol'; import { Position, Range } from 'graphql-language-service'; @@ -23,9 +23,9 @@ import { loadConfig } from 'graphql-config'; import type { DefinitionQueryResult, Outline } from 'graphql-language-service'; import { Logger } from '../Logger'; -import { pathToFileURL } from 'url'; +import { pathToFileURL } from 'node:url'; -jest.mock('fs', () => ({ +jest.mock('node:fs', () => ({ ...jest.requireActual('fs'), readFileSync: jest.fn(jest.requireActual('fs').readFileSync), })); @@ -316,7 +316,8 @@ describe('MessageProcessor', () => { }); describe('handleDidOpenOrSaveNotification', () => { - const mockReadFileSync: jest.Mock = jest.requireMock('fs').readFileSync; + const mockReadFileSync: jest.Mock = + jest.requireMock('node:fs').readFileSync; beforeEach(() => { mockReadFileSync.mockReturnValue(''); @@ -718,7 +719,8 @@ query Test { }); describe('handleWatchedFilesChangedNotification', () => { - const mockReadFileSync: jest.Mock = jest.requireMock('fs').readFileSync; + const mockReadFileSync: jest.Mock = + jest.requireMock('node:fs').readFileSync; beforeEach(() => { mockReadFileSync.mockReturnValue(''); @@ -740,7 +742,8 @@ query Test { }); describe('handleWatchedFilesChangedNotification without graphql config', () => { - const mockReadFileSync: jest.Mock = jest.requireMock('fs').readFileSync; + const mockReadFileSync: jest.Mock = + jest.requireMock('node:fs').readFileSync; beforeEach(() => { mockReadFileSync.mockReturnValue(''); @@ -763,7 +766,8 @@ query Test { }); describe('handleDidChangedNotification without graphql config', () => { - const mockReadFileSync: jest.Mock = jest.requireMock('fs').readFileSync; + const mockReadFileSync: jest.Mock = + jest.requireMock('node:fs').readFileSync; beforeEach(() => { mockReadFileSync.mockReturnValue(''); diff --git a/packages/graphql-language-service-server/src/__tests__/findGraphQLTags-test.ts b/packages/graphql-language-service-server/src/__tests__/findGraphQLTags-test.ts index 247d501b78c..48bd37be429 100644 --- a/packages/graphql-language-service-server/src/__tests__/findGraphQLTags-test.ts +++ b/packages/graphql-language-service-server/src/__tests__/findGraphQLTags-test.ts @@ -6,7 +6,7 @@ * LICENSE file in the root directory of this source tree. * */ -import { tmpdir } from 'os'; +import { tmpdir } from 'node:os'; import { findGraphQLTags as baseFindGraphQLTags } from '../findGraphQLTags'; diff --git a/packages/graphql-language-service-server/src/parseDocument.ts b/packages/graphql-language-service-server/src/parseDocument.ts index a251a3478d8..e92beb2c7cc 100644 --- a/packages/graphql-language-service-server/src/parseDocument.ts +++ b/packages/graphql-language-service-server/src/parseDocument.ts @@ -1,4 +1,4 @@ -import { extname } from 'path'; +import { extname } from 'node:path'; import type { CachedContent } from 'graphql-language-service'; import { Range, Position } from 'graphql-language-service'; diff --git a/packages/graphql-language-service-server/src/startServer.ts b/packages/graphql-language-service-server/src/startServer.ts index f0866432b0b..81070f06b23 100644 --- a/packages/graphql-language-service-server/src/startServer.ts +++ b/packages/graphql-language-service-server/src/startServer.ts @@ -6,7 +6,7 @@ * LICENSE file in the root directory of this source tree. * */ -import * as net from 'net'; +import * as net from 'node:net'; import { MessageProcessor } from './MessageProcessor'; import { GraphQLConfig, GraphQLExtensionDeclaration } from 'graphql-config'; import { diff --git a/packages/graphql-language-service/benchmark/index.ts b/packages/graphql-language-service/benchmark/index.ts index 177ec578147..857f6b76dbd 100644 --- a/packages/graphql-language-service/benchmark/index.ts +++ b/packages/graphql-language-service/benchmark/index.ts @@ -1,6 +1,6 @@ /* eslint-disable no-console */ -import fs from 'fs'; -import path from 'path'; +import fs from 'node:fs'; +import path from 'node:path'; import Benchmark from 'benchmark'; import { parse } from 'graphql'; import { onlineParser, CharacterStream } from '../src'; diff --git a/packages/graphql-language-service/src/interface/__tests__/getAutocompleteSuggestions-test.ts b/packages/graphql-language-service/src/interface/__tests__/getAutocompleteSuggestions-test.ts index 81f6f0737e9..edffd58c9c8 100644 --- a/packages/graphql-language-service/src/interface/__tests__/getAutocompleteSuggestions-test.ts +++ b/packages/graphql-language-service/src/interface/__tests__/getAutocompleteSuggestions-test.ts @@ -12,7 +12,7 @@ import { CompletionItem, } from 'graphql-language-service'; -import fs from 'fs'; +import fs from 'node:fs'; import { buildSchema, FragmentDefinitionNode, @@ -21,7 +21,7 @@ import { version as graphQLVersion, } from 'graphql'; import { Position } from '../../utils'; -import path from 'path'; +import path from 'node:path'; import { getAutocompleteSuggestions } from '../getAutocompleteSuggestions'; diff --git a/packages/graphql-language-service/src/interface/__tests__/getDiagnostics-test.ts b/packages/graphql-language-service/src/interface/__tests__/getDiagnostics-test.ts index 74af7ef65ef..854c0b0ea6d 100644 --- a/packages/graphql-language-service/src/interface/__tests__/getDiagnostics-test.ts +++ b/packages/graphql-language-service/src/interface/__tests__/getDiagnostics-test.ts @@ -8,7 +8,7 @@ * @flow */ -import fs from 'fs'; +import fs from 'node:fs'; import { buildSchema, parse, @@ -18,7 +18,7 @@ import { ASTVisitor, FragmentDefinitionNode, } from 'graphql'; -import path from 'path'; +import path from 'node:path'; import { getDiagnostics, diff --git a/packages/graphql-language-service/src/interface/__tests__/getHoverInformation-test.ts b/packages/graphql-language-service/src/interface/__tests__/getHoverInformation-test.ts index 755a82242b0..745abc789a7 100644 --- a/packages/graphql-language-service/src/interface/__tests__/getHoverInformation-test.ts +++ b/packages/graphql-language-service/src/interface/__tests__/getHoverInformation-test.ts @@ -10,10 +10,10 @@ import { Hover } from 'vscode-languageserver-types'; -import fs from 'fs'; +import fs from 'node:fs'; import { buildSchema, GraphQLSchema } from 'graphql'; import { Position } from 'graphql-language-service'; -import path from 'path'; +import path from 'node:path'; import { getHoverInformation } from '../getHoverInformation'; diff --git a/packages/graphql-language-service/src/utils/__tests__/getVariablesJSONSchema.spec.ts b/packages/graphql-language-service/src/utils/__tests__/getVariablesJSONSchema.spec.ts index 1e429f1216e..7dbe14c4fcf 100644 --- a/packages/graphql-language-service/src/utils/__tests__/getVariablesJSONSchema.spec.ts +++ b/packages/graphql-language-service/src/utils/__tests__/getVariablesJSONSchema.spec.ts @@ -6,10 +6,10 @@ * LICENSE file in the root directory of this source tree. */ -import { readFileSync } from 'fs'; +import { readFileSync } from 'node:fs'; import { buildSchema, GraphQLSchema, parse } from 'graphql'; -import { join } from 'path'; +import { join } from 'node:path'; import { collectVariables } from '../collectVariables'; import { getVariablesJSONSchema } from '../getVariablesJSONSchema'; diff --git a/packages/graphql-language-service/src/utils/__tests__/validateWithCustomRules-test.ts b/packages/graphql-language-service/src/utils/__tests__/validateWithCustomRules-test.ts index ec4d018c6e9..6ba7de8002b 100644 --- a/packages/graphql-language-service/src/utils/__tests__/validateWithCustomRules-test.ts +++ b/packages/graphql-language-service/src/utils/__tests__/validateWithCustomRules-test.ts @@ -6,7 +6,7 @@ * LICENSE file in the root directory of this source tree. */ -import { readFileSync } from 'fs'; +import { readFileSync } from 'node:fs'; import { GraphQLError, buildSchema, @@ -15,7 +15,7 @@ import { ValidationContext, ArgumentNode, } from 'graphql'; -import { join } from 'path'; +import { join } from 'node:path'; import { validateWithCustomRules } from '../validateWithCustomRules'; diff --git a/packages/vscode-graphql-execution/package.json b/packages/vscode-graphql-execution/package.json index 1b1d63bf601..710bffe59af 100644 --- a/packages/vscode-graphql-execution/package.json +++ b/packages/vscode-graphql-execution/package.json @@ -94,7 +94,7 @@ "@types/capitalize": "2.0.0", "@types/dotenv": "8.2.0", "@types/mocha": "5.2.7", - "@types/node": "16.11.26", + "@types/node": "^16.18.4", "@types/node-fetch": "3.0.3", "@types/vscode": "1.62.0", "@types/ws": "8.2.2", diff --git a/packages/vscode-graphql-execution/src/helpers/network.ts b/packages/vscode-graphql-execution/src/helpers/network.ts index 900dbc1eded..762cabd2ff4 100644 --- a/packages/vscode-graphql-execution/src/helpers/network.ts +++ b/packages/vscode-graphql-execution/src/helpers/network.ts @@ -1,7 +1,7 @@ import { visit, OperationTypeNode, GraphQLError } from 'graphql'; import { gql } from 'graphql-tag'; import { fetch } from '@whatwg-node/fetch'; -import { Agent } from 'https'; +import { Agent } from 'node:https'; import * as ws from 'ws'; // eslint-disable-next-line import/no-extraneous-dependencies import { pipe, subscribe } from 'wonka'; diff --git a/packages/vscode-graphql/src/extension.ts b/packages/vscode-graphql/src/extension.ts index 2c705ecbbd6..2cc717aff5c 100644 --- a/packages/vscode-graphql/src/extension.ts +++ b/packages/vscode-graphql/src/extension.ts @@ -14,7 +14,7 @@ import { LanguageClient, } from 'vscode-languageclient/node'; -import * as path from 'path'; +import * as path from 'node:path'; import { createStatusBar, initStatusBar } from './apis/statusBar'; let client: LanguageClient; diff --git a/resources/runTests.js b/resources/runTests.js index 4cf42c5c484..0d0cd7029b2 100644 --- a/resources/runTests.js +++ b/resources/runTests.js @@ -7,7 +7,7 @@ */ 'use strict'; -const path = require('path'); +const path = require('node:path'); const { exec } = require('./util'); exec( diff --git a/resources/webpack.config.js b/resources/webpack.config.js index 472393091d3..408981e286e 100644 --- a/resources/webpack.config.js +++ b/resources/webpack.config.js @@ -1,5 +1,5 @@ const HtmlWebpackPlugin = require('html-webpack-plugin'); -const path = require('path'); +const path = require('node:path'); const isDev = process.env.NODE_ENV === 'development'; module.exports = { diff --git a/scripts/buildFlow.js b/scripts/buildFlow.js index 8af5110fc18..4513fca2780 100644 --- a/scripts/buildFlow.js +++ b/scripts/buildFlow.js @@ -8,8 +8,8 @@ 'use strict'; -const { readdirSync } = require('fs'); -const { join } = require('path'); +const { readdirSync } = require('node:fs'); +const { join } = require('node:path'); const { cp } = require('./util'); // Non-recursively copy src/*.js to dist/*.js.flow: diff --git a/scripts/pretty.js b/scripts/pretty.js index ba0299fa20b..a9f77324f2e 100755 --- a/scripts/pretty.js +++ b/scripts/pretty.js @@ -7,9 +7,9 @@ * LICENSE file in the root directory of this source tree. */ -const { spawnSync } = require('child_process'); -const { join } = require('path'); -const os = require('os'); +const { spawnSync } = require('node:child_process'); +const { join } = require('node:path'); +const os = require('node:os'); const INVERSE = '\x1b[7m'; const RESET = '\x1b[0m'; diff --git a/scripts/renameFileExtensions.js b/scripts/renameFileExtensions.js index c2a885e0777..f3a6116e30e 100644 --- a/scripts/renameFileExtensions.js +++ b/scripts/renameFileExtensions.js @@ -1,8 +1,8 @@ const copy = require('copy'); -const path = require('path'); -const fs = require('fs'); +const path = require('node:path'); +const fs = require('node:fs'); const mkdirp = require('mkdirp'); -const crypto = require('crypto'); +const crypto = require('node:crypto'); const rimraf = require('rimraf'); const [, , src, dest, destExtension] = process.argv; diff --git a/scripts/set-resolution.js b/scripts/set-resolution.js index 5da70683e08..d68d796fb6b 100644 --- a/scripts/set-resolution.js +++ b/scripts/set-resolution.js @@ -1,5 +1,5 @@ -const { readFile, writeFile } = require('fs/promises'); -const path = require('path'); +const { readFile, writeFile } = require('node:fs/promises'); +const path = require('node:path'); async function setResolution() { const [, , tag] = process.argv; diff --git a/scripts/util.js b/scripts/util.js index 77cdc5eedb4..f66bee9576a 100644 --- a/scripts/util.js +++ b/scripts/util.js @@ -9,8 +9,8 @@ 'use strict'; -const { execFileSync } = require('child_process'); -const { createReadStream, createWriteStream } = require('fs'); +const { execFileSync } = require('node:child_process'); +const { createReadStream, createWriteStream } = require('node:fs'); function cp(source, destination) { createReadStream(source).pipe(createWriteStream(destination)); diff --git a/yarn.lock b/yarn.lock index c70d70c4136..8f5e182006a 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3580,26 +3580,21 @@ resolved "https://registry.yarnpkg.com/@types/node/-/node-14.14.37.tgz#a3dd8da4eb84a996c36e331df98d82abd76b516e" integrity sha512-XYmBiy+ohOR4Lh5jE379fV2IU+6Jn4g5qASinhitfyO71b/sCo6MKsMLF5tc7Zf2CE8hViVQyYSobJNke8OvUw== -"@types/node@16.11.26": - version "16.11.26" - resolved "https://registry.yarnpkg.com/@types/node/-/node-16.11.26.tgz#63d204d136c9916fb4dcd1b50f9740fe86884e47" - integrity sha512-GZ7bu5A6+4DtG7q9GsoHXy3ALcgeIHP4NnL0Vv2wu0uUB/yQex26v0tf6/na1mm0+bS9Uw+0DFex7aaKr2qawQ== - "@types/node@^12.7.1": version "12.20.7" resolved "https://registry.yarnpkg.com/@types/node/-/node-12.20.7.tgz#1cb61fd0c85cb87e728c43107b5fd82b69bc9ef8" integrity sha512-gWL8VUkg8VRaCAUgG9WmhefMqHmMblxe2rVpMF86nZY/+ZysU+BkAp+3cz03AixWDSSz0ks5WX59yAhv/cDwFA== -"@types/node@^14.14.22": - version "14.14.22" - resolved "https://registry.yarnpkg.com/@types/node/-/node-14.14.22.tgz#0d29f382472c4ccf3bd96ff0ce47daf5b7b84b18" - integrity sha512-g+f/qj/cNcqKkc3tFqlXOYjrmZA+jNBiDzbP3kH+B+otKFqAdPgVTGP1IeKRdMml/aE69as5S4FqtxAbl+LaMw== - "@types/node@^16.11.7": version "16.11.46" resolved "https://registry.yarnpkg.com/@types/node/-/node-16.11.46.tgz#26047602eefa47b36759d9ebb1b55ad08ce97a73" integrity sha512-x+sfpb2dMrhCQPL4NAGs64Z9hh0t72aP0dg+PuZidmPr/0Gj5ELQTjD/t46dq3DF/8ZvSHOaIyDIbAsdPshyVQ== +"@types/node@^16.18.4": + version "16.18.4" + resolved "https://registry.yarnpkg.com/@types/node/-/node-16.18.4.tgz#712ba61b4caf091fc6490301b1888356638c17bd" + integrity sha512-9qGjJ5GyShZjUfx2ArBIGM+xExdfLvvaCyQR0t6yRXKPcWCVYF/WemtX/uIU3r7FYECXRXkIiw2Vnhn6y8d+pw== + "@types/normalize-package-data@^2.4.0": version "2.4.0" resolved "https://registry.yarnpkg.com/@types/normalize-package-data/-/normalize-package-data-2.4.0.tgz#e486d0d97396d79beedd0a6e33f4534ff6b4973e"