diff --git a/build/.eslintrc.json b/build/.eslintrc.json new file mode 100644 index 0000000000..dc7dde78dc --- /dev/null +++ b/build/.eslintrc.json @@ -0,0 +1,8 @@ +{ + "plugins": [ + "unicorn" + ], + "rules": { + "unicorn/prefer-node-protocol": "error" + } +} diff --git a/build/webpack/webpack.config.base.js b/build/webpack/webpack.config.base.js index 7afe880258..bd4ca38e02 100644 --- a/build/webpack/webpack.config.base.js +++ b/build/webpack/webpack.config.base.js @@ -1,5 +1,5 @@ -const fs = require('fs'); -const path = require('path'); +const fs = require('node:fs'); +const path = require('node:path'); const webpack = require('webpack'); const TerserPlugin = require('terser-webpack-plugin'); const WrapperPlugin = require('wrapper-webpack-plugin'); diff --git a/script/.eslintrc.json b/script/.eslintrc.json new file mode 100644 index 0000000000..dc7dde78dc --- /dev/null +++ b/script/.eslintrc.json @@ -0,0 +1,8 @@ +{ + "plugins": [ + "unicorn" + ], + "rules": { + "unicorn/prefer-node-protocol": "error" + } +} diff --git a/script/check-patch-diff.ts b/script/check-patch-diff.ts index 8b2bccc26d..b48a5bf914 100644 --- a/script/check-patch-diff.ts +++ b/script/check-patch-diff.ts @@ -1,5 +1,5 @@ -import { spawnSync } from 'child_process'; -import * as path from 'path'; +import { spawnSync } from 'node:child_process'; +import * as path from 'node:path'; const srcPath = path.resolve(__dirname, '..', '..', '..'); const patchExportFnPath = path.resolve(__dirname, 'export_all_patches.py'); diff --git a/script/check-symlinks.js b/script/check-symlinks.js index c68e2ac27e..19c9626025 100644 --- a/script/check-symlinks.js +++ b/script/check-symlinks.js @@ -1,5 +1,5 @@ -const fs = require('fs'); -const path = require('path'); +const fs = require('node:fs'); +const path = require('node:path'); const utils = require('./lib/utils'); const branding = require('../shell/app/BRANDING.json'); diff --git a/script/codesign/gen-trust.ts b/script/codesign/gen-trust.ts index 3f39f0e74b..941db3c865 100644 --- a/script/codesign/gen-trust.ts +++ b/script/codesign/gen-trust.ts @@ -1,6 +1,6 @@ -import * as cp from 'child_process'; -import * as fs from 'fs'; -import * as path from 'path'; +import * as cp from 'node:child_process'; +import * as fs from 'node:fs'; +import * as path from 'node:path'; const certificatePath = process.argv[2]; const outPath = process.argv[3]; diff --git a/script/create-api-json.js b/script/create-api-json.js index 00a70355c3..4f3b5ecfc2 100644 --- a/script/create-api-json.js +++ b/script/create-api-json.js @@ -1,6 +1,6 @@ const { parseDocs } = require('@electron/docs-parser'); -const fs = require('fs'); -const path = require('path'); +const fs = require('node:fs'); +const path = require('node:path'); const { getElectronVersion } = require('./lib/get-version'); diff --git a/script/download-circleci-artifacts.js b/script/download-circleci-artifacts.js index 118dd4a447..c0593fa01a 100644 --- a/script/download-circleci-artifacts.js +++ b/script/download-circleci-artifacts.js @@ -1,8 +1,8 @@ const args = require('minimist')(process.argv.slice(2)); -const fs = require('fs'); +const fs = require('node:fs'); const got = require('got'); -const stream = require('stream'); -const { promisify } = require('util'); +const stream = require('node:stream'); +const { promisify } = require('node:util'); const pipeline = promisify(stream.pipeline); diff --git a/script/gen-filenames.ts b/script/gen-filenames.ts index 3e1f41bcc8..b281ea78ef 100644 --- a/script/gen-filenames.ts +++ b/script/gen-filenames.ts @@ -1,7 +1,7 @@ -import * as cp from 'child_process'; +import * as cp from 'node:child_process'; import * as fs from 'fs-extra'; -import * as os from 'os'; -import * as path from 'path'; +import * as os from 'node:os'; +import * as path from 'node:path'; const rootPath = path.resolve(__dirname, '..'); const gniPath = path.resolve(__dirname, '../filenames.auto.gni'); diff --git a/script/gen-hunspell-filenames.js b/script/gen-hunspell-filenames.js index 4e9b9d2a01..336cefec8c 100644 --- a/script/gen-hunspell-filenames.js +++ b/script/gen-hunspell-filenames.js @@ -1,5 +1,5 @@ -const fs = require('fs'); -const path = require('path'); +const fs = require('node:fs'); +const path = require('node:path'); const check = process.argv.includes('--check'); diff --git a/script/gen-libc++-filenames.js b/script/gen-libc++-filenames.js index 0d083c4ea2..c6fbe3347a 100644 --- a/script/gen-libc++-filenames.js +++ b/script/gen-libc++-filenames.js @@ -1,5 +1,5 @@ -const fs = require('fs'); -const path = require('path'); +const fs = require('node:fs'); +const path = require('node:path'); const check = process.argv.includes('--check'); diff --git a/script/generate-deps-hash.js b/script/generate-deps-hash.js index ca22e23ad6..9161da0d6e 100644 --- a/script/generate-deps-hash.js +++ b/script/generate-deps-hash.js @@ -1,6 +1,6 @@ -const crypto = require('crypto'); -const fs = require('fs'); -const path = require('path'); +const crypto = require('node:crypto'); +const fs = require('node:fs'); +const path = require('node:path'); // Fallback to blow away old cache keys const FALLBACK_HASH_VERSION = 3; diff --git a/script/generate-version-json.js b/script/generate-version-json.js index 8a981f8173..76dd8c8049 100644 --- a/script/generate-version-json.js +++ b/script/generate-version-json.js @@ -1,5 +1,5 @@ -const fs = require('fs'); -const path = require('path'); +const fs = require('node:fs'); +const path = require('node:path'); const semver = require('semver'); const outputPath = process.argv[2]; diff --git a/script/gn-asar-hash.js b/script/gn-asar-hash.js index 8aa78c9a3d..ad341cb2cd 100644 --- a/script/gn-asar-hash.js +++ b/script/gn-asar-hash.js @@ -1,6 +1,6 @@ const asar = require('@electron/asar'); -const crypto = require('crypto'); -const fs = require('fs'); +const crypto = require('node:crypto'); +const fs = require('node:fs'); const archive = process.argv[2]; const hashFile = process.argv[3]; diff --git a/script/gn-asar.js b/script/gn-asar.js index 57ef6a8110..f7dd9db2db 100644 --- a/script/gn-asar.js +++ b/script/gn-asar.js @@ -1,8 +1,8 @@ const asar = require('@electron/asar'); -const assert = require('assert'); +const assert = require('node:assert'); const fs = require('fs-extra'); -const os = require('os'); -const path = require('path'); +const os = require('node:os'); +const path = require('node:path'); const getArgGroup = (name) => { const group = []; diff --git a/script/gn-check.js b/script/gn-check.js index 12dca3651e..54ba2b5b7d 100644 --- a/script/gn-check.js +++ b/script/gn-check.js @@ -4,8 +4,8 @@ Usage: $ node ./script/gn-check.js [--outDir=dirName] */ -const cp = require('child_process'); -const path = require('path'); +const cp = require('node:child_process'); +const path = require('node:path'); const args = require('minimist')(process.argv.slice(2), { string: ['outDir'] }); const { getOutDir } = require('./lib/utils'); diff --git a/script/gn-plist-but-with-hashes.js b/script/gn-plist-but-with-hashes.js index 16ee734ef9..4eec9581f9 100644 --- a/script/gn-plist-but-with-hashes.js +++ b/script/gn-plist-but-with-hashes.js @@ -1,4 +1,4 @@ -const fs = require('fs'); +const fs = require('node:fs'); const [,, plistPath, outputPath, ...keySet] = process.argv; diff --git a/script/lib/azput.js b/script/lib/azput.js index 6abd0220db..2c0dab15d4 100644 --- a/script/lib/azput.js +++ b/script/lib/azput.js @@ -1,7 +1,7 @@ /* eslint-disable camelcase */ const { BlobServiceClient } = require('@azure/storage-blob'); -const fs = require('fs'); -const path = require('path'); +const fs = require('node:fs'); +const path = require('node:path'); const blobServiceClient = BlobServiceClient.fromConnectionString(process.env.ELECTRON_ARTIFACTS_BLOB_STORAGE); diff --git a/script/lib/get-version.js b/script/lib/get-version.js index 45a120482b..3e1cc62acc 100644 --- a/script/lib/get-version.js +++ b/script/lib/get-version.js @@ -1,5 +1,5 @@ -const { spawnSync } = require('child_process'); -const path = require('path'); +const { spawnSync } = require('node:child_process'); +const path = require('node:path'); module.exports.getElectronVersion = () => { // Find the nearest tag to the current HEAD diff --git a/script/lib/utils.js b/script/lib/utils.js index 03ac37b649..7e1db46881 100644 --- a/script/lib/utils.js +++ b/script/lib/utils.js @@ -1,8 +1,8 @@ const { GitProcess } = require('dugite'); -const fs = require('fs'); +const fs = require('node:fs'); const klaw = require('klaw'); -const os = require('os'); -const path = require('path'); +const os = require('node:os'); +const path = require('node:path'); const ELECTRON_DIR = path.resolve(__dirname, '..', '..'); const SRC_DIR = path.resolve(ELECTRON_DIR, '..'); diff --git a/script/lint.js b/script/lint.js index 7b6405a4bd..e3508bbb74 100755 --- a/script/lint.js +++ b/script/lint.js @@ -1,12 +1,12 @@ #!/usr/bin/env node -const crypto = require('crypto'); +const crypto = require('node:crypto'); const { GitProcess } = require('dugite'); -const childProcess = require('child_process'); +const childProcess = require('node:child_process'); const { ESLint } = require('eslint'); -const fs = require('fs'); +const fs = require('node:fs'); const minimist = require('minimist'); -const path = require('path'); +const path = require('node:path'); const { chunkFilenames, findMatchingFiles } = require('./lib/utils'); diff --git a/script/nan-spec-runner.js b/script/nan-spec-runner.js index 85aebb15f6..2889f3290b 100644 --- a/script/nan-spec-runner.js +++ b/script/nan-spec-runner.js @@ -1,6 +1,6 @@ -const cp = require('child_process'); -const fs = require('fs'); -const path = require('path'); +const cp = require('node:child_process'); +const fs = require('node:fs'); +const path = require('node:path'); const BASE = path.resolve(__dirname, '../..'); const NAN_DIR = path.resolve(BASE, 'third_party', 'nan'); diff --git a/script/node-spec-runner.js b/script/node-spec-runner.js index f365886b0a..3d904e9a66 100644 --- a/script/node-spec-runner.js +++ b/script/node-spec-runner.js @@ -1,6 +1,6 @@ -const cp = require('child_process'); -const fs = require('fs'); -const path = require('path'); +const cp = require('node:child_process'); +const fs = require('node:fs'); +const path = require('node:path'); const args = require('minimist')(process.argv.slice(2), { boolean: ['default', 'validateDisabled'], diff --git a/script/prepare-appveyor.js b/script/prepare-appveyor.js index 0e15e4eaec..a08ce66e3f 100644 --- a/script/prepare-appveyor.js +++ b/script/prepare-appveyor.js @@ -1,9 +1,9 @@ if (!process.env.CI) require('dotenv-safe').load(); -const assert = require('assert'); -const fs = require('fs'); +const assert = require('node:assert'); +const fs = require('node:fs'); const got = require('got'); -const path = require('path'); +const path = require('node:path'); const { handleGitCall, ELECTRON_DIR } = require('./lib/utils.js'); const { Octokit } = require('@octokit/rest'); const octokit = new Octokit(); diff --git a/script/push-patch.js b/script/push-patch.js index 8f7bc86326..78595bc6e6 100644 --- a/script/push-patch.js +++ b/script/push-patch.js @@ -1,5 +1,5 @@ const { appCredentialsFromString, getTokenForRepo } = require('@electron/github-app-auth'); -const cp = require('child_process'); +const cp = require('node:child_process'); if (!process.env.CIRCLE_BRANCH) { console.error('Not building for a specific branch, can\'t autopush a patch'); diff --git a/script/release/ci-release-build.js b/script/release/ci-release-build.js index e79dfc9627..8d455c1a5e 100644 --- a/script/release/ci-release-build.js +++ b/script/release/ci-release-build.js @@ -1,6 +1,6 @@ if (!process.env.CI) require('dotenv-safe').load(); -const assert = require('assert'); +const assert = require('node:assert'); const got = require('got'); const { Octokit } = require('@octokit/rest'); diff --git a/script/release/get-url-hash.js b/script/release/get-url-hash.js index ae91fac30e..a4c0966559 100644 --- a/script/release/get-url-hash.js +++ b/script/release/get-url-hash.js @@ -1,5 +1,5 @@ const got = require('got'); -const url = require('url'); +const url = require('node:url'); module.exports = async function getUrlHash (targetUrl, algorithm = 'sha256', attempts = 3) { const options = { diff --git a/script/release/notes/index.js b/script/release/notes/index.js index 567135faf8..6dc5454a8f 100755 --- a/script/release/notes/index.js +++ b/script/release/notes/index.js @@ -2,7 +2,7 @@ const { GitProcess } = require('dugite'); const minimist = require('minimist'); -const path = require('path'); +const path = require('node:path'); const semver = require('semver'); const { ELECTRON_DIR } = require('../../lib/utils'); diff --git a/script/release/notes/notes.js b/script/release/notes/notes.js index 7bc3d525d7..1aee04b7ec 100644 --- a/script/release/notes/notes.js +++ b/script/release/notes/notes.js @@ -2,8 +2,8 @@ 'use strict'; -const fs = require('fs'); -const path = require('path'); +const fs = require('node:fs'); +const path = require('node:path'); const { GitProcess } = require('dugite'); diff --git a/script/release/prepare-release.js b/script/release/prepare-release.js index be9c430849..e38f93746e 100755 --- a/script/release/prepare-release.js +++ b/script/release/prepare-release.js @@ -6,11 +6,11 @@ const args = require('minimist')(process.argv.slice(2), { }); const ciReleaseBuild = require('./ci-release-build'); const { Octokit } = require('@octokit/rest'); -const { execSync } = require('child_process'); +const { execSync } = require('node:child_process'); const { GitProcess } = require('dugite'); -const path = require('path'); -const readline = require('readline'); +const path = require('node:path'); +const readline = require('node:readline'); const releaseNotesGenerator = require('./notes/index.js'); const { getCurrentBranch, ELECTRON_DIR } = require('../lib/utils.js'); const bumpType = args._[0]; diff --git a/script/release/publish-to-npm.js b/script/release/publish-to-npm.js index dbf15a9f03..e74cc280c9 100644 --- a/script/release/publish-to-npm.js +++ b/script/release/publish-to-npm.js @@ -1,7 +1,7 @@ const temp = require('temp'); -const fs = require('fs'); -const path = require('path'); -const childProcess = require('child_process'); +const fs = require('node:fs'); +const path = require('node:path'); +const childProcess = require('node:child_process'); const got = require('got'); const semver = require('semver'); diff --git a/script/release/release-artifact-cleanup.js b/script/release/release-artifact-cleanup.js index 0079696c3a..3565125408 100755 --- a/script/release/release-artifact-cleanup.js +++ b/script/release/release-artifact-cleanup.js @@ -5,7 +5,7 @@ const args = require('minimist')(process.argv.slice(2), { string: ['tag', 'releaseID'], default: { releaseID: '' } }); -const { execSync } = require('child_process'); +const { execSync } = require('node:child_process'); const { GitProcess } = require('dugite'); const { getCurrentBranch, ELECTRON_DIR } = require('../lib/utils.js'); const { Octokit } = require('@octokit/rest'); diff --git a/script/release/release.js b/script/release/release.js index b12da0f029..e25cc60286 100755 --- a/script/release/release.js +++ b/script/release/release.js @@ -9,13 +9,13 @@ const args = require('minimist')(process.argv.slice(2), { ], default: { verboseNugget: false } }); -const fs = require('fs'); -const { execSync } = require('child_process'); +const fs = require('node:fs'); +const { execSync } = require('node:child_process'); const got = require('got'); -const path = require('path'); +const path = require('node:path'); const semver = require('semver'); const temp = require('temp').track(); -const { URL } = require('url'); +const { URL } = require('node:url'); const { BlobServiceClient } = require('@azure/storage-blob'); const { Octokit } = require('@octokit/rest'); diff --git a/script/release/uploaders/upload-to-github.ts b/script/release/uploaders/upload-to-github.ts index c998e2f42e..218e369fee 100644 --- a/script/release/uploaders/upload-to-github.ts +++ b/script/release/uploaders/upload-to-github.ts @@ -1,5 +1,5 @@ import { Octokit } from '@octokit/rest'; -import * as fs from 'fs'; +import * as fs from 'node:fs'; const octokit = new Octokit({ auth: process.env.ELECTRON_GITHUB_TOKEN diff --git a/script/release/version-utils.js b/script/release/version-utils.js index 85e8f8f15a..d50fdedaa0 100644 --- a/script/release/version-utils.js +++ b/script/release/version-utils.js @@ -1,8 +1,8 @@ -const path = require('path'); -const fs = require('fs'); +const path = require('node:path'); +const fs = require('node:fs'); const semver = require('semver'); const { GitProcess } = require('dugite'); -const { promisify } = require('util'); +const { promisify } = require('node:util'); const { ELECTRON_DIR } = require('../lib/utils'); diff --git a/script/run-clang-tidy.ts b/script/run-clang-tidy.ts index ab1aa5eba5..6a5ba9c2c7 100644 --- a/script/run-clang-tidy.ts +++ b/script/run-clang-tidy.ts @@ -1,8 +1,8 @@ -import * as childProcess from 'child_process'; -import * as fs from 'fs'; +import * as childProcess from 'node:child_process'; +import * as fs from 'node:fs'; import * as minimist from 'minimist'; -import * as os from 'os'; -import * as path from 'path'; +import * as os from 'node:os'; +import * as path from 'node:path'; import * as streamChain from 'stream-chain'; import * as streamJson from 'stream-json'; import { ignore as streamJsonIgnore } from 'stream-json/filters/Ignore'; diff --git a/script/run-if-exists.js b/script/run-if-exists.js index 93e2252fc9..9ffe732bc6 100644 --- a/script/run-if-exists.js +++ b/script/run-if-exists.js @@ -1,5 +1,5 @@ -const cp = require('child_process'); -const fs = require('fs'); +const cp = require('node:child_process'); +const fs = require('node:fs'); const checkPath = process.argv[2]; const command = process.argv.slice(3); diff --git a/script/spec-runner.js b/script/spec-runner.js index 1b828713f0..f8a32423b7 100755 --- a/script/spec-runner.js +++ b/script/spec-runner.js @@ -1,12 +1,12 @@ #!/usr/bin/env node const { ElectronVersions, Installer } = require('@electron/fiddle-core'); -const childProcess = require('child_process'); -const crypto = require('crypto'); +const childProcess = require('node:child_process'); +const crypto = require('node:crypto'); const fs = require('fs-extra'); const { hashElement } = require('folder-hash'); -const os = require('os'); -const path = require('path'); +const os = require('node:os'); +const path = require('node:path'); const unknownFlags = []; require('colors'); diff --git a/script/start.js b/script/start.js index 94ecfeac87..6c081a0ccd 100644 --- a/script/start.js +++ b/script/start.js @@ -1,4 +1,4 @@ -const cp = require('child_process'); +const cp = require('node:child_process'); const utils = require('./lib/utils'); const electronPath = utils.getAbsoluteElectronExec(); diff --git a/script/yarn.js b/script/yarn.js index 353a183244..3638802ccd 100644 --- a/script/yarn.js +++ b/script/yarn.js @@ -1,6 +1,6 @@ -const cp = require('child_process'); -const fs = require('fs'); -const path = require('path'); +const cp = require('node:child_process'); +const fs = require('node:fs'); +const path = require('node:path'); const YARN_VERSION = /'yarn_version': '(.+?)'/.exec(fs.readFileSync(path.resolve(__dirname, '../DEPS'), 'utf8'))[1]; const NPX_CMD = process.platform === 'win32' ? 'npx.cmd' : 'npx';