diff --git a/bin/mocha.js b/bin/mocha.js index fb58e65fcd..8970d1bdd6 100644 --- a/bin/mocha.js +++ b/bin/mocha.js @@ -78,7 +78,7 @@ if (mochaArgs._) { } if (mochaArgs['node-option'] || Object.keys(nodeArgs).length || hasInspect) { - const {spawn} = require('child_process'); + const {spawn} = require('node:child_process'); const mochaPath = require.resolve('../lib/cli/cli.js'); const nodeArgv = @@ -126,7 +126,7 @@ if (mochaArgs['node-option'] || Object.keys(nodeArgs).length || hasInspect) { // be needed. if (!args.parallel || args.jobs < 2) { // win32 does not support SIGTERM, so use next best thing. - if (require('os').platform() === 'win32') { + if (require('node:os').platform() === 'win32') { proc.kill('SIGKILL'); } else { // using SIGKILL won't cleanly close the output streams, which can result diff --git a/docs/_data/files.js b/docs/_data/files.js index 908fae8a34..0435ffcef8 100644 --- a/docs/_data/files.js +++ b/docs/_data/files.js @@ -1,7 +1,7 @@ 'use strict'; -const {resolve, relative, dirname} = require('path'); -const {promises: fs} = require('fs'); +const {resolve, relative, dirname} = require('node:path'); +const {promises: fs} = require('node:fs'); const PROJECT_ROOT_DIR = resolve(__dirname, '..', '..'); const FILES = [ diff --git a/docs/_data/supporters.js b/docs/_data/supporters.js index 21d950d1d3..e8c11c268d 100755 --- a/docs/_data/supporters.js +++ b/docs/_data/supporters.js @@ -1,5 +1,3 @@ -#!/usr/bin/env node - /** * This script gathers metadata for active supporters of Mocha from OpenCollective's * API by aggregating order ("donation") information. @@ -17,8 +15,8 @@ 'use strict'; -const {writeFile, mkdir, rm} = require('fs').promises; -const {resolve} = require('path'); +const {writeFile, mkdir, rm} = require('node:fs').promises; +const {resolve} = require('node:path'); const debug = require('debug')('mocha:docs:data:supporters'); const needle = require('needle'); const blocklist = new Set(require('./blocklist.json')); diff --git a/docs/_data/toc.js b/docs/_data/toc.js index 9937c6fc10..11763d1686 100644 --- a/docs/_data/toc.js +++ b/docs/_data/toc.js @@ -1,8 +1,8 @@ 'use strict'; const markdownToc = require('markdown-toc'); -const {readFileSync} = require('fs'); -const {resolve} = require('path'); +const {readFileSync} = require('node:fs'); +const {resolve} = require('node:path'); const IGNORED_HEADINGS_REGEXP = /Features|Table of Contents|Backers|Sponsors/i; const DOCUMENT_PATH = resolve(__dirname, '..', 'index.md'); diff --git a/docs/_data/usage.js b/docs/_data/usage.js index bffff31362..84bcbb85be 100644 --- a/docs/_data/usage.js +++ b/docs/_data/usage.js @@ -1,8 +1,8 @@ 'use strict'; -const {stripVTControlCharacters} = require('util'); -const {resolve} = require('path'); -const {execSync} = require('child_process'); +const {stripVTControlCharacters} = require('node:util'); +const {resolve} = require('node:path'); +const {execSync} = require('node:child_process'); const executable = require.resolve('../../bin/mocha'); const flag = '--help'; diff --git a/eslint.config.js b/eslint.config.js index 4448037012..9d1481fc02 100644 --- a/eslint.config.js +++ b/eslint.config.js @@ -1,6 +1,7 @@ "use strict"; const js = require('@eslint/js'); +const n = require('eslint-plugin-n'); const globals = require('globals'); const messages = { @@ -9,6 +10,7 @@ const messages = { }; module.exports = [ + n.configs['flat/recommended-script'], { ...js.configs.recommended, languageOptions: { @@ -20,8 +22,13 @@ module.exports = [ sourceType: 'script' }, rules: { + 'n/prefer-node-protocol': 'error', + strict: ['error', 'global'], + 'no-var': 'off', - strict: ['error', 'global'] + 'n/no-process-exit': 'off', + 'n/no-unpublished-require': 'off', + 'n/no-unsupported-features/node-builtins': 'off', } }, { diff --git a/karma.conf.js b/karma.conf.js index d577bfd394..93704e04cb 100644 --- a/karma.conf.js +++ b/karma.conf.js @@ -21,9 +21,9 @@ */ 'use strict'; -const fs = require('fs'); -const path = require('path'); -const os = require('os'); +const fs = require('node:fs'); +const path = require('node:path'); +const os = require('node:os'); const rollupPlugin = require('./scripts/karma-rollup-plugin'); const BASE_BUNDLE_DIR_PATH = path.join(__dirname, '.karma'); const env = process.env; diff --git a/lib/cli/cli.js b/lib/cli/cli.js index f333dbffee..9b0d2ec024 100755 --- a/lib/cli/cli.js +++ b/lib/cli/cli.js @@ -1,5 +1,3 @@ -#!/usr/bin/env node - 'use strict'; /** @@ -13,7 +11,7 @@ const debug = require('debug')('mocha:cli:cli'); const symbols = require('log-symbols'); const yargs = require('yargs'); -const path = require('path'); +const path = require('node:path'); const { loadRc, loadPkgRc, diff --git a/lib/cli/collect-files.js b/lib/cli/collect-files.js index 73f5d2e95a..14503c0431 100644 --- a/lib/cli/collect-files.js +++ b/lib/cli/collect-files.js @@ -1,7 +1,7 @@ 'use strict'; -const fs = require('fs'); -const path = require('path'); +const fs = require('node:fs'); +const path = require('node:path'); const ansi = require('ansi-colors'); const debug = require('debug')('mocha:cli:run:helpers'); const minimatch = require('minimatch'); diff --git a/lib/cli/config.js b/lib/cli/config.js index ac719833cf..9f9dfdbb31 100644 --- a/lib/cli/config.js +++ b/lib/cli/config.js @@ -7,8 +7,8 @@ * @module */ -const fs = require('fs'); -const path = require('path'); +const fs = require('node:fs'); +const path = require('node:path'); const debug = require('debug')('mocha:cli:config'); const findUp = require('find-up'); const {createUnparsableFileError} = require('../errors'); diff --git a/lib/cli/init.js b/lib/cli/init.js index 3847aff86c..c892d30876 100644 --- a/lib/cli/init.js +++ b/lib/cli/init.js @@ -7,8 +7,8 @@ * @module */ -const fs = require('fs'); -const path = require('path'); +const fs = require('node:fs'); +const path = require('node:path'); exports.command = 'init '; diff --git a/lib/cli/lookup-files.js b/lib/cli/lookup-files.js index a587cf974c..f5ad0ca844 100644 --- a/lib/cli/lookup-files.js +++ b/lib/cli/lookup-files.js @@ -5,8 +5,8 @@ * @private */ -var fs = require('fs'); -var path = require('path'); +var fs = require('node:fs'); +var path = require('node:path'); var glob = require('glob'); var errors = require('../errors'); var createNoFilesMatchPatternError = errors.createNoFilesMatchPatternError; diff --git a/lib/cli/options.js b/lib/cli/options.js index 09351957b4..825d535db4 100644 --- a/lib/cli/options.js +++ b/lib/cli/options.js @@ -7,7 +7,7 @@ * @private */ -const fs = require('fs'); +const fs = require('node:fs'); const ansi = require('ansi-colors'); const yargsParser = require('yargs-parser'); const { diff --git a/lib/cli/run-helpers.js b/lib/cli/run-helpers.js index ec65829f14..440965df31 100644 --- a/lib/cli/run-helpers.js +++ b/lib/cli/run-helpers.js @@ -7,13 +7,13 @@ * @private */ -const fs = require('fs'); -const path = require('path'); +const fs = require('node:fs'); +const path = require('node:path'); const ansi = require('ansi-colors'); const debug = require('debug')('mocha:cli:run:helpers'); const {watchRun, watchParallelRun} = require('./watch-run'); const collectFiles = require('./collect-files'); -const {format} = require('util'); +const {format} = require('node:util'); const {createInvalidLegacyPluginError} = require('../errors'); const {requireOrImport} = require('../nodejs/esm-utils'); const PluginLoader = require('../plugin-loader'); diff --git a/lib/cli/watch-run.js b/lib/cli/watch-run.js index 6d5c6c26a7..9334341182 100644 --- a/lib/cli/watch-run.js +++ b/lib/cli/watch-run.js @@ -2,7 +2,7 @@ const logSymbols = require('log-symbols'); const debug = require('debug')('mocha:cli:watch'); -const path = require('path'); +const path = require('node:path'); const chokidar = require('chokidar'); const Context = require('../context'); const collectFiles = require('./collect-files'); diff --git a/lib/errors.js b/lib/errors.js index bcc7291c99..f68511e702 100644 --- a/lib/errors.js +++ b/lib/errors.js @@ -1,6 +1,6 @@ 'use strict'; -const {format} = require('util'); +const {format} = require('node:util'); /** * Contains error codes, factory functions to create throwable error objects, diff --git a/lib/mocha.js b/lib/mocha.js index 56061a2f09..374f7b1d25 100644 --- a/lib/mocha.js +++ b/lib/mocha.js @@ -7,7 +7,7 @@ */ var escapeRe = require('escape-string-regexp'); -var path = require('path'); +var path = require('node:path'); var builtinReporters = require('./reporters'); var utils = require('./utils'); var mocharc = require('./mocharc.json'); diff --git a/lib/nodejs/esm-utils.js b/lib/nodejs/esm-utils.js index 5318099365..539d4aa124 100644 --- a/lib/nodejs/esm-utils.js +++ b/lib/nodejs/esm-utils.js @@ -1,5 +1,5 @@ -const path = require('path'); -const url = require('url'); +const path = require('node:path'); +const url = require('node:url'); const forward = x => x; diff --git a/lib/reporters/json.js b/lib/reporters/json.js index 6194d8747d..5d39f9c589 100644 --- a/lib/reporters/json.js +++ b/lib/reporters/json.js @@ -7,8 +7,8 @@ */ var Base = require('./base'); -var fs = require('fs'); -var path = require('path'); +var fs = require('node:fs'); +var path = require('node:path'); const createUnsupportedError = require('../errors').createUnsupportedError; const utils = require('../utils'); var constants = require('../runner').constants; diff --git a/lib/reporters/tap.js b/lib/reporters/tap.js index 37fa8b57a0..5898949efd 100644 --- a/lib/reporters/tap.js +++ b/lib/reporters/tap.js @@ -6,7 +6,7 @@ * Module dependencies. */ -var util = require('util'); +var util = require('node:util'); var Base = require('./base'); var constants = require('../runner').constants; var EVENT_TEST_PASS = constants.EVENT_TEST_PASS; diff --git a/lib/reporters/xunit.js b/lib/reporters/xunit.js index 4e6fe2bcf9..b24aa06b32 100644 --- a/lib/reporters/xunit.js +++ b/lib/reporters/xunit.js @@ -8,8 +8,8 @@ var Base = require('./base'); var utils = require('../utils'); -var fs = require('fs'); -var path = require('path'); +var fs = require('node:fs'); +var path = require('node:path'); var errors = require('../errors'); var createUnsupportedError = errors.createUnsupportedError; var constants = require('../runner').constants; diff --git a/lib/runnable.js b/lib/runnable.js index 98327bf5d9..0e5b25256f 100644 --- a/lib/runnable.js +++ b/lib/runnable.js @@ -1,6 +1,6 @@ 'use strict'; -var EventEmitter = require('events').EventEmitter; +var EventEmitter = require('node:events').EventEmitter; var Pending = require('./pending'); var debug = require('debug')('mocha:runnable'); var milliseconds = require('ms'); diff --git a/lib/runner.js b/lib/runner.js index ad31843444..7795129710 100644 --- a/lib/runner.js +++ b/lib/runner.js @@ -4,7 +4,7 @@ * Module dependencies. * @private */ -var EventEmitter = require('events').EventEmitter; +var EventEmitter = require('node:events').EventEmitter; var Pending = require('./pending'); var utils = require('./utils'); var debug = require('debug')('mocha:runner'); diff --git a/lib/suite.js b/lib/suite.js index bce00731ec..7a695fc4e2 100644 --- a/lib/suite.js +++ b/lib/suite.js @@ -4,7 +4,7 @@ * Module dependencies. * @private */ -const {EventEmitter} = require('events'); +const {EventEmitter} = require('node:events'); const Hook = require('./hook'); var { assignNewMochaID, diff --git a/lib/utils.js b/lib/utils.js index 89b21a32d6..f5cf48493f 100644 --- a/lib/utils.js +++ b/lib/utils.js @@ -8,8 +8,8 @@ /** * Module dependencies. */ -var path = require('path'); -var util = require('util'); +var path = require('node:path'); +var util = require('node:util'); var he = require('he'); const MOCHA_ID_PROP_NAME = '__mocha_id__'; diff --git a/package-lock.json b/package-lock.json index 2e89d24349..732a53b714 100644 --- a/package-lock.json +++ b/package-lock.json @@ -47,6 +47,7 @@ "coffeescript": "^2.6.1", "cross-env": "^7.0.2", "eslint": "^8.56.0", + "eslint-plugin-n": "^17.15.1", "fail-on-errors-webpack-plugin": "^3.0.0", "fs-extra": "^10.0.0", "globals": "^13.24.0", @@ -696,34 +697,30 @@ } }, "node_modules/@eslint-community/eslint-utils": { - "version": "4.2.0", - "resolved": "https://registry.npmjs.org/@eslint-community/eslint-utils/-/eslint-utils-4.2.0.tgz", - "integrity": "sha512-gB8T4H4DEfX2IV9zGDJPOBgP1e/DbfCPDTtEqUMckpvzS1OYtva8JdFYBqMwYk7xAQ429WGF/UPqn8uQ//h2vQ==", + "version": "4.4.1", + "resolved": "https://registry.npmjs.org/@eslint-community/eslint-utils/-/eslint-utils-4.4.1.tgz", + "integrity": "sha512-s3O3waFUrMV8P/XaF/+ZTp1X9XBZW1a4B97ZnjQF2KYWaFD2A8KyFBsrsfSjEmjn3RGWAIuvlneuZm3CUK3jbA==", "dev": true, + "license": "MIT", "dependencies": { - "eslint-visitor-keys": "^3.3.0" + "eslint-visitor-keys": "^3.4.3" }, "engines": { "node": "^12.22.0 || ^14.17.0 || >=16.0.0" }, + "funding": { + "url": "https://opencollective.com/eslint" + }, "peerDependencies": { "eslint": "^6.0.0 || ^7.0.0 || >=8.0.0" } }, - "node_modules/@eslint-community/eslint-utils/node_modules/eslint-visitor-keys": { - "version": "3.3.0", - "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-3.3.0.tgz", - "integrity": "sha512-mQ+suqKJVyeuwGYHAdjMFqjCyfl8+Ldnxuyp3ldiMBFKkvytrXUZWaiPCEav8qDHKty44bD+qV1IP4T+w+xXRA==", - "dev": true, - "engines": { - "node": "^12.22.0 || ^14.17.0 || >=16.0.0" - } - }, "node_modules/@eslint-community/regexpp": { - "version": "4.10.0", - "resolved": "https://registry.npmjs.org/@eslint-community/regexpp/-/regexpp-4.10.0.tgz", - "integrity": "sha512-Cu96Sd2By9mCNTx2iyKOmq10v22jUVQv0lQnlGNy16oE9589yE+QADPbrMGCkA51cKZSg3Pu/aTJVTGfL/qjUA==", + "version": "4.12.1", + "resolved": "https://registry.npmjs.org/@eslint-community/regexpp/-/regexpp-4.12.1.tgz", + "integrity": "sha512-CCZCDJuduB9OUkFkY2IgppNZMi2lBQgD2qzwXkEia16cge2pijY/aXi96CJMquDMn3nJdlPV1A5KrJEXwfLNzQ==", "dev": true, + "license": "MIT", "engines": { "node": "^12.0.0 || ^14.0.0 || >=16.0.0" } @@ -5668,10 +5665,11 @@ } }, "node_modules/enhanced-resolve": { - "version": "5.12.0", - "resolved": "https://registry.npmjs.org/enhanced-resolve/-/enhanced-resolve-5.12.0.tgz", - "integrity": "sha512-QHTXI/sZQmko1cbDoNAa3mJ5qhWUUNAq3vR0/YiD379fWQrcfuoX1+HW2S0MTt7XmoPLapdaDKUtelUSPic7hQ==", + "version": "5.18.0", + "resolved": "https://registry.npmjs.org/enhanced-resolve/-/enhanced-resolve-5.18.0.tgz", + "integrity": "sha512-0/r0MySGYG8YqlayBZ6MuCfECmHFdJ5qyPh8s8wa5Hnm6SaFLSK1VYCbj+NKp090Nm1caZhD+QTnmxO7esYGyQ==", "dev": true, + "license": "MIT", "dependencies": { "graceful-fs": "^4.2.4", "tapable": "^2.2.0" @@ -5811,6 +5809,99 @@ "url": "https://opencollective.com/eslint" } }, + "node_modules/eslint-compat-utils": { + "version": "0.5.1", + "resolved": "https://registry.npmjs.org/eslint-compat-utils/-/eslint-compat-utils-0.5.1.tgz", + "integrity": "sha512-3z3vFexKIEnjHE3zCMRo6fn/e44U7T1khUjg+Hp0ZQMCigh28rALD0nPFBcGZuiLC5rLZa2ubQHDRln09JfU2Q==", + "dev": true, + "license": "MIT", + "dependencies": { + "semver": "^7.5.4" + }, + "engines": { + "node": ">=12" + }, + "peerDependencies": { + "eslint": ">=6.0.0" + } + }, + "node_modules/eslint-plugin-es-x": { + "version": "7.8.0", + "resolved": "https://registry.npmjs.org/eslint-plugin-es-x/-/eslint-plugin-es-x-7.8.0.tgz", + "integrity": "sha512-7Ds8+wAAoV3T+LAKeu39Y5BzXCrGKrcISfgKEqTS4BDN8SFEDQd0S43jiQ8vIa3wUKD07qitZdfzlenSi8/0qQ==", + "dev": true, + "funding": [ + "https://github.com/sponsors/ota-meshi", + "https://opencollective.com/eslint" + ], + "license": "MIT", + "dependencies": { + "@eslint-community/eslint-utils": "^4.1.2", + "@eslint-community/regexpp": "^4.11.0", + "eslint-compat-utils": "^0.5.1" + }, + "engines": { + "node": "^14.18.0 || >=16.0.0" + }, + "peerDependencies": { + "eslint": ">=8" + } + }, + "node_modules/eslint-plugin-n": { + "version": "17.15.1", + "resolved": "https://registry.npmjs.org/eslint-plugin-n/-/eslint-plugin-n-17.15.1.tgz", + "integrity": "sha512-KFw7x02hZZkBdbZEFQduRGH4VkIH4MW97ClsbAM4Y4E6KguBJWGfWG1P4HEIpZk2bkoWf0bojpnjNAhYQP8beA==", + "dev": true, + "license": "MIT", + "dependencies": { + "@eslint-community/eslint-utils": "^4.4.1", + "enhanced-resolve": "^5.17.1", + "eslint-plugin-es-x": "^7.8.0", + "get-tsconfig": "^4.8.1", + "globals": "^15.11.0", + "ignore": "^5.3.2", + "minimatch": "^9.0.5", + "semver": "^7.6.3" + }, + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + }, + "funding": { + "url": "https://opencollective.com/eslint" + }, + "peerDependencies": { + "eslint": ">=8.23.0" + } + }, + "node_modules/eslint-plugin-n/node_modules/globals": { + "version": "15.14.0", + "resolved": "https://registry.npmjs.org/globals/-/globals-15.14.0.tgz", + "integrity": "sha512-OkToC372DtlQeje9/zHIo5CT8lRP/FUgEOKBEhU4e0abL7J7CD24fD9ohiLN5hagG/kWCYj4K5oaxxtj2Z0Dig==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=18" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/eslint-plugin-n/node_modules/minimatch": { + "version": "9.0.5", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-9.0.5.tgz", + "integrity": "sha512-G6T0ZX48xgozx7587koeX9Ys2NYy6Gmv//P89sEte9V9whIapMNF4idKxnW2QtCcLiTWlb/wfCabAtAFWhhBow==", + "dev": true, + "license": "ISC", + "dependencies": { + "brace-expansion": "^2.0.1" + }, + "engines": { + "node": ">=16 || 14 >=14.17" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, "node_modules/eslint-scope": { "version": "5.1.1", "resolved": "https://registry.npmjs.org/eslint-scope/-/eslint-scope-5.1.1.tgz", @@ -5833,6 +5924,19 @@ "node": ">=4.0" } }, + "node_modules/eslint-visitor-keys": { + "version": "3.4.3", + "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-3.4.3.tgz", + "integrity": "sha512-wpc+LXeiyiisxPlEkUzU6svyS1frIO3Mgxj1fdy7Pm8Ygzguax2N3Fa/D/ag1WqbOprdI+uY6wMUl8/a2G+iag==", + "dev": true, + "license": "Apache-2.0", + "engines": { + "node": "^12.22.0 || ^14.17.0 || >=16.0.0" + }, + "funding": { + "url": "https://opencollective.com/eslint" + } + }, "node_modules/eslint/node_modules/brace-expansion": { "version": "1.1.11", "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", @@ -5859,18 +5963,6 @@ "url": "https://opencollective.com/eslint" } }, - "node_modules/eslint/node_modules/eslint-visitor-keys": { - "version": "3.4.3", - "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-3.4.3.tgz", - "integrity": "sha512-wpc+LXeiyiisxPlEkUzU6svyS1frIO3Mgxj1fdy7Pm8Ygzguax2N3Fa/D/ag1WqbOprdI+uY6wMUl8/a2G+iag==", - "dev": true, - "engines": { - "node": "^12.22.0 || ^14.17.0 || >=16.0.0" - }, - "funding": { - "url": "https://opencollective.com/eslint" - } - }, "node_modules/eslint/node_modules/glob-parent": { "version": "6.0.2", "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-6.0.2.tgz", @@ -5929,18 +6021,6 @@ "url": "https://opencollective.com/eslint" } }, - "node_modules/espree/node_modules/eslint-visitor-keys": { - "version": "3.4.3", - "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-3.4.3.tgz", - "integrity": "sha512-wpc+LXeiyiisxPlEkUzU6svyS1frIO3Mgxj1fdy7Pm8Ygzguax2N3Fa/D/ag1WqbOprdI+uY6wMUl8/a2G+iag==", - "dev": true, - "engines": { - "node": "^12.22.0 || ^14.17.0 || >=16.0.0" - }, - "funding": { - "url": "https://opencollective.com/eslint" - } - }, "node_modules/esprima": { "version": "4.0.1", "resolved": "https://registry.npmjs.org/esprima/-/esprima-4.0.1.tgz", @@ -6786,6 +6866,19 @@ "node": ">=0.10.0" } }, + "node_modules/get-tsconfig": { + "version": "4.8.1", + "resolved": "https://registry.npmjs.org/get-tsconfig/-/get-tsconfig-4.8.1.tgz", + "integrity": "sha512-k9PN+cFBmaLWtVz29SkUoqU5O0slLuHJXt/2P+tMVFT+phsSGXGkp9t3rQIqdz0e+06EHNGs3oM6ZX1s2zHxRg==", + "dev": true, + "license": "MIT", + "dependencies": { + "resolve-pkg-maps": "^1.0.0" + }, + "funding": { + "url": "https://github.com/privatenumber/get-tsconfig?sponsor=1" + } + }, "node_modules/glob": { "version": "10.4.5", "resolved": "https://registry.npmjs.org/glob/-/glob-10.4.5.tgz", @@ -7538,10 +7631,11 @@ ] }, "node_modules/ignore": { - "version": "5.2.4", - "resolved": "https://registry.npmjs.org/ignore/-/ignore-5.2.4.tgz", - "integrity": "sha512-MAb38BcSbH0eHNBxn7ql2NH/kX33OkB3lZ1BNdh7ENeRChHTYsTvWrMubiIAMNS2llXEEgZ1MUOBtXChP3kaFQ==", + "version": "5.3.2", + "resolved": "https://registry.npmjs.org/ignore/-/ignore-5.3.2.tgz", + "integrity": "sha512-hsBTNUqQTDwkWtcdYI2i06Y/nUBEsNEDJKjWdigLvegy8kDuJAS8uRlpkkcQpyEXL0Z/pjDy5HBmMjRCJ2gq+g==", "dev": true, + "license": "MIT", "engines": { "node": ">= 4" } @@ -13027,6 +13121,16 @@ "node": ">=4" } }, + "node_modules/resolve-pkg-maps": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/resolve-pkg-maps/-/resolve-pkg-maps-1.0.0.tgz", + "integrity": "sha512-seS2Tj26TBVOC2NIc2rOe2y2ZO7efxITtLZcGSOnHHNOQ7CkiUBfw0Iw2ck6xkIhPwLhKNLS8BO+hEpngQlqzw==", + "dev": true, + "license": "MIT", + "funding": { + "url": "https://github.com/privatenumber/resolve-pkg-maps?sponsor=1" + } + }, "node_modules/resp-modifier": { "version": "6.0.2", "resolved": "https://registry.npmjs.org/resp-modifier/-/resp-modifier-6.0.2.tgz", @@ -16660,26 +16764,18 @@ "dev": true }, "@eslint-community/eslint-utils": { - "version": "4.2.0", - "resolved": "https://registry.npmjs.org/@eslint-community/eslint-utils/-/eslint-utils-4.2.0.tgz", - "integrity": "sha512-gB8T4H4DEfX2IV9zGDJPOBgP1e/DbfCPDTtEqUMckpvzS1OYtva8JdFYBqMwYk7xAQ429WGF/UPqn8uQ//h2vQ==", + "version": "4.4.1", + "resolved": "https://registry.npmjs.org/@eslint-community/eslint-utils/-/eslint-utils-4.4.1.tgz", + "integrity": "sha512-s3O3waFUrMV8P/XaF/+ZTp1X9XBZW1a4B97ZnjQF2KYWaFD2A8KyFBsrsfSjEmjn3RGWAIuvlneuZm3CUK3jbA==", "dev": true, "requires": { - "eslint-visitor-keys": "^3.3.0" - }, - "dependencies": { - "eslint-visitor-keys": { - "version": "3.3.0", - "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-3.3.0.tgz", - "integrity": "sha512-mQ+suqKJVyeuwGYHAdjMFqjCyfl8+Ldnxuyp3ldiMBFKkvytrXUZWaiPCEav8qDHKty44bD+qV1IP4T+w+xXRA==", - "dev": true - } + "eslint-visitor-keys": "^3.4.3" } }, "@eslint-community/regexpp": { - "version": "4.10.0", - "resolved": "https://registry.npmjs.org/@eslint-community/regexpp/-/regexpp-4.10.0.tgz", - "integrity": "sha512-Cu96Sd2By9mCNTx2iyKOmq10v22jUVQv0lQnlGNy16oE9589yE+QADPbrMGCkA51cKZSg3Pu/aTJVTGfL/qjUA==", + "version": "4.12.1", + "resolved": "https://registry.npmjs.org/@eslint-community/regexpp/-/regexpp-4.12.1.tgz", + "integrity": "sha512-CCZCDJuduB9OUkFkY2IgppNZMi2lBQgD2qzwXkEia16cge2pijY/aXi96CJMquDMn3nJdlPV1A5KrJEXwfLNzQ==", "dev": true }, "@eslint/eslintrc": { @@ -20629,9 +20725,9 @@ "dev": true }, "enhanced-resolve": { - "version": "5.12.0", - "resolved": "https://registry.npmjs.org/enhanced-resolve/-/enhanced-resolve-5.12.0.tgz", - "integrity": "sha512-QHTXI/sZQmko1cbDoNAa3mJ5qhWUUNAq3vR0/YiD379fWQrcfuoX1+HW2S0MTt7XmoPLapdaDKUtelUSPic7hQ==", + "version": "5.18.0", + "resolved": "https://registry.npmjs.org/enhanced-resolve/-/enhanced-resolve-5.18.0.tgz", + "integrity": "sha512-0/r0MySGYG8YqlayBZ6MuCfECmHFdJ5qyPh8s8wa5Hnm6SaFLSK1VYCbj+NKp090Nm1caZhD+QTnmxO7esYGyQ==", "dev": true, "requires": { "graceful-fs": "^4.2.4", @@ -20759,12 +20855,6 @@ "estraverse": "^5.2.0" } }, - "eslint-visitor-keys": { - "version": "3.4.3", - "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-3.4.3.tgz", - "integrity": "sha512-wpc+LXeiyiisxPlEkUzU6svyS1frIO3Mgxj1fdy7Pm8Ygzguax2N3Fa/D/ag1WqbOprdI+uY6wMUl8/a2G+iag==", - "dev": true - }, "glob-parent": { "version": "6.0.2", "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-6.0.2.tgz", @@ -20799,6 +20889,59 @@ } } }, + "eslint-compat-utils": { + "version": "0.5.1", + "resolved": "https://registry.npmjs.org/eslint-compat-utils/-/eslint-compat-utils-0.5.1.tgz", + "integrity": "sha512-3z3vFexKIEnjHE3zCMRo6fn/e44U7T1khUjg+Hp0ZQMCigh28rALD0nPFBcGZuiLC5rLZa2ubQHDRln09JfU2Q==", + "dev": true, + "requires": { + "semver": "^7.5.4" + } + }, + "eslint-plugin-es-x": { + "version": "7.8.0", + "resolved": "https://registry.npmjs.org/eslint-plugin-es-x/-/eslint-plugin-es-x-7.8.0.tgz", + "integrity": "sha512-7Ds8+wAAoV3T+LAKeu39Y5BzXCrGKrcISfgKEqTS4BDN8SFEDQd0S43jiQ8vIa3wUKD07qitZdfzlenSi8/0qQ==", + "dev": true, + "requires": { + "@eslint-community/eslint-utils": "^4.1.2", + "@eslint-community/regexpp": "^4.11.0", + "eslint-compat-utils": "^0.5.1" + } + }, + "eslint-plugin-n": { + "version": "17.15.1", + "resolved": "https://registry.npmjs.org/eslint-plugin-n/-/eslint-plugin-n-17.15.1.tgz", + "integrity": "sha512-KFw7x02hZZkBdbZEFQduRGH4VkIH4MW97ClsbAM4Y4E6KguBJWGfWG1P4HEIpZk2bkoWf0bojpnjNAhYQP8beA==", + "dev": true, + "requires": { + "@eslint-community/eslint-utils": "^4.4.1", + "enhanced-resolve": "^5.17.1", + "eslint-plugin-es-x": "^7.8.0", + "get-tsconfig": "^4.8.1", + "globals": "^15.11.0", + "ignore": "^5.3.2", + "minimatch": "^9.0.5", + "semver": "^7.6.3" + }, + "dependencies": { + "globals": { + "version": "15.14.0", + "resolved": "https://registry.npmjs.org/globals/-/globals-15.14.0.tgz", + "integrity": "sha512-OkToC372DtlQeje9/zHIo5CT8lRP/FUgEOKBEhU4e0abL7J7CD24fD9ohiLN5hagG/kWCYj4K5oaxxtj2Z0Dig==", + "dev": true + }, + "minimatch": { + "version": "9.0.5", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-9.0.5.tgz", + "integrity": "sha512-G6T0ZX48xgozx7587koeX9Ys2NYy6Gmv//P89sEte9V9whIapMNF4idKxnW2QtCcLiTWlb/wfCabAtAFWhhBow==", + "dev": true, + "requires": { + "brace-expansion": "^2.0.1" + } + } + } + }, "eslint-scope": { "version": "5.1.1", "resolved": "https://registry.npmjs.org/eslint-scope/-/eslint-scope-5.1.1.tgz", @@ -20817,6 +20960,12 @@ } } }, + "eslint-visitor-keys": { + "version": "3.4.3", + "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-3.4.3.tgz", + "integrity": "sha512-wpc+LXeiyiisxPlEkUzU6svyS1frIO3Mgxj1fdy7Pm8Ygzguax2N3Fa/D/ag1WqbOprdI+uY6wMUl8/a2G+iag==", + "dev": true + }, "espree": { "version": "9.6.1", "resolved": "https://registry.npmjs.org/espree/-/espree-9.6.1.tgz", @@ -20826,14 +20975,6 @@ "acorn": "^8.9.0", "acorn-jsx": "^5.3.2", "eslint-visitor-keys": "^3.4.1" - }, - "dependencies": { - "eslint-visitor-keys": { - "version": "3.4.3", - "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-3.4.3.tgz", - "integrity": "sha512-wpc+LXeiyiisxPlEkUzU6svyS1frIO3Mgxj1fdy7Pm8Ygzguax2N3Fa/D/ag1WqbOprdI+uY6wMUl8/a2G+iag==", - "dev": true - } } }, "esprima": { @@ -21468,6 +21609,15 @@ "pinkie-promise": "^2.0.0" } }, + "get-tsconfig": { + "version": "4.8.1", + "resolved": "https://registry.npmjs.org/get-tsconfig/-/get-tsconfig-4.8.1.tgz", + "integrity": "sha512-k9PN+cFBmaLWtVz29SkUoqU5O0slLuHJXt/2P+tMVFT+phsSGXGkp9t3rQIqdz0e+06EHNGs3oM6ZX1s2zHxRg==", + "dev": true, + "requires": { + "resolve-pkg-maps": "^1.0.0" + } + }, "glob": { "version": "10.4.5", "resolved": "https://registry.npmjs.org/glob/-/glob-10.4.5.tgz", @@ -22019,9 +22169,9 @@ "dev": true }, "ignore": { - "version": "5.2.4", - "resolved": "https://registry.npmjs.org/ignore/-/ignore-5.2.4.tgz", - "integrity": "sha512-MAb38BcSbH0eHNBxn7ql2NH/kX33OkB3lZ1BNdh7ENeRChHTYsTvWrMubiIAMNS2llXEEgZ1MUOBtXChP3kaFQ==", + "version": "5.3.2", + "resolved": "https://registry.npmjs.org/ignore/-/ignore-5.3.2.tgz", + "integrity": "sha512-hsBTNUqQTDwkWtcdYI2i06Y/nUBEsNEDJKjWdigLvegy8kDuJAS8uRlpkkcQpyEXL0Z/pjDy5HBmMjRCJ2gq+g==", "dev": true }, "immutable": { @@ -26138,6 +26288,12 @@ "integrity": "sha512-pb/MYmXstAkysRFx8piNI1tGFNQIFA3vkE3Gq4EuA1dF6gHp/+vgZqsCGJapvy8N3Q+4o7FwvquPJcnZ7RYy4g==", "dev": true }, + "resolve-pkg-maps": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/resolve-pkg-maps/-/resolve-pkg-maps-1.0.0.tgz", + "integrity": "sha512-seS2Tj26TBVOC2NIc2rOe2y2ZO7efxITtLZcGSOnHHNOQ7CkiUBfw0Iw2ck6xkIhPwLhKNLS8BO+hEpngQlqzw==", + "dev": true + }, "resp-modifier": { "version": "6.0.2", "resolved": "https://registry.npmjs.org/resp-modifier/-/resp-modifier-6.0.2.tgz", diff --git a/package.json b/package.json index 7d0d4364a5..c6eca45ed8 100644 --- a/package.json +++ b/package.json @@ -128,6 +128,7 @@ "coffeescript": "^2.6.1", "cross-env": "^7.0.2", "eslint": "^8.56.0", + "eslint-plugin-n": "^17.15.1", "fail-on-errors-webpack-plugin": "^3.0.0", "fs-extra": "^10.0.0", "globals": "^13.24.0", diff --git a/scripts/karma-rollup-plugin.js b/scripts/karma-rollup-plugin.js index bd009f2aed..7fac34adb7 100644 --- a/scripts/karma-rollup-plugin.js +++ b/scripts/karma-rollup-plugin.js @@ -29,10 +29,10 @@ * been modified heavily to simplify and support rollup instead of browserify. */ -const os = require('os'); -const fs = require('fs'); -const path = require('path'); -const {randomUUID} = require('crypto'); +const os = require('node:os'); +const fs = require('node:fs'); +const path = require('node:path'); +const {randomUUID} = require('node:crypto'); const rollup = require('rollup'); const minimatch = require('minimatch'); const loadConfigFile = require('rollup/dist/loadConfigFile.js'); diff --git a/scripts/linkify-changelog.mjs b/scripts/linkify-changelog.mjs index 207511c403..dc87a680fe 100644 --- a/scripts/linkify-changelog.mjs +++ b/scripts/linkify-changelog.mjs @@ -2,7 +2,7 @@ * Linkify CHANGELOG.md */ -import {readFileSync, writeFileSync} from 'fs'; +import {readFileSync, writeFileSync} from 'node:fs'; import {remark} from 'remark'; import remarkGithub from 'remark-github'; import remarkInlineLinks from 'remark-inline-links'; diff --git a/scripts/update-authors.js b/scripts/update-authors.js index a21cea8801..ed5ff524b3 100755 --- a/scripts/update-authors.js +++ b/scripts/update-authors.js @@ -1,12 +1,11 @@ -#!/usr/bin/env node // original comes from https://github.com/nodejs/node/blob/master/tools/update-authors.js // Usage: tools/update-author.js [--dry] // Passing --dry will redirect output to stdout rather than write to 'AUTHORS'. 'use strict'; -const {spawn} = require('child_process'); -const fs = require('fs'); -const readline = require('readline'); +const {spawn} = require('node:child_process'); +const fs = require('node:fs'); +const readline = require('node:readline'); const log = spawn( 'git', diff --git a/test/browser-specific/fixtures/webpack/webpack.config.js b/test/browser-specific/fixtures/webpack/webpack.config.js index 052b97b778..2ea596fd8b 100644 --- a/test/browser-specific/fixtures/webpack/webpack.config.js +++ b/test/browser-specific/fixtures/webpack/webpack.config.js @@ -1,8 +1,8 @@ 'use strict'; const FailOnErrorsPlugin = require('fail-on-errors-webpack-plugin'); -const {tmpdir} = require('os'); -const {join} = require('path'); +const {tmpdir} = require('node:os'); +const {join} = require('node:path'); const outputPath = join(tmpdir(), 'mocha-test-webpack'); diff --git a/test/integration/color.spec.js b/test/integration/color.spec.js index d21a0073b6..d713b35c92 100644 --- a/test/integration/color.spec.js +++ b/test/integration/color.spec.js @@ -1,7 +1,7 @@ 'use strict'; -var childProcess = require('child_process'); -var path = require('path'); +var childProcess = require('node:child_process'); +var path = require('node:path'); describe('mocha binary', function () { it('should not output colors to pipe', function (done) { diff --git a/test/integration/compiler-globbing.spec.js b/test/integration/compiler-globbing.spec.js index e3c5857042..8d272b9409 100644 --- a/test/integration/compiler-globbing.spec.js +++ b/test/integration/compiler-globbing.spec.js @@ -1,7 +1,7 @@ 'use strict'; -var exec = require('child_process').exec; -var path = require('path'); +var exec = require('node:child_process').exec; +var path = require('node:path'); describe('globbing like --compilers', function () { it('should find a file of each type', function (done) { diff --git a/test/integration/config.spec.js b/test/integration/config.spec.js index 7009a89044..8f259059d5 100644 --- a/test/integration/config.spec.js +++ b/test/integration/config.spec.js @@ -3,8 +3,8 @@ // This is not a "functional" test; we aren't invoking the mocha executable. // Instead we just avoid test doubles. -var fs = require('fs'); -var path = require('path'); +var fs = require('node:fs'); +var path = require('node:path'); var loadConfig = require('../../lib/cli/config').loadConfig; describe('config', function () { diff --git a/test/integration/deprecate.spec.js b/test/integration/deprecate.spec.js index 4d83ebe3b4..52e231ac92 100644 --- a/test/integration/deprecate.spec.js +++ b/test/integration/deprecate.spec.js @@ -1,6 +1,6 @@ 'use strict'; -var assert = require('assert'); +var assert = require('node:assert'); var run = require('./helpers').runMocha; var args = []; diff --git a/test/integration/diffs.spec.js b/test/integration/diffs.spec.js index 26c4882d10..0224715acc 100644 --- a/test/integration/diffs.spec.js +++ b/test/integration/diffs.spec.js @@ -2,8 +2,8 @@ var helpers = require('./helpers'); var run = helpers.runMocha; -var fs = require('fs'); -var path = require('path'); +var fs = require('node:fs'); +var path = require('node:path'); /** * Returns an array of diffs corresponding to exceptions thrown from specs, diff --git a/test/integration/esm.spec.js b/test/integration/esm.spec.js index 3209a2ce38..ecce7033a9 100644 --- a/test/integration/esm.spec.js +++ b/test/integration/esm.spec.js @@ -1,5 +1,5 @@ 'use strict'; -var path = require('path'); +var path = require('node:path'); const {runMochaJSON: run, runMochaAsync} = require('./helpers'); var args = []; diff --git a/test/integration/file-utils.spec.js b/test/integration/file-utils.spec.js index 7672e7c420..67ca1be424 100644 --- a/test/integration/file-utils.spec.js +++ b/test/integration/file-utils.spec.js @@ -1,8 +1,8 @@ 'use strict'; const lookupFiles = require('../../lib/cli/lookup-files'); -const {existsSync, symlinkSync, renameSync} = require('fs'); -const path = require('path'); +const {existsSync, symlinkSync, renameSync} = require('node:fs'); +const path = require('node:path'); const {touchFile, createTempDir} = require('./helpers'); const SYMLINK_SUPPORT = process.platform !== 'win32'; diff --git a/test/integration/glob.spec.js b/test/integration/glob.spec.js index 3533e35a4c..f3fdedcd85 100644 --- a/test/integration/glob.spec.js +++ b/test/integration/glob.spec.js @@ -1,7 +1,7 @@ 'use strict'; -var exec = require('child_process').exec; -var path = require('path'); +var exec = require('node:child_process').exec; +var path = require('node:path'); var node = '"' + process.execPath + '"'; diff --git a/test/integration/helpers.js b/test/integration/helpers.js index 61c6ec01ca..6348403502 100644 --- a/test/integration/helpers.js +++ b/test/integration/helpers.js @@ -1,10 +1,10 @@ 'use strict'; const escapeRegExp = require('escape-string-regexp'); -const os = require('os'); +const os = require('node:os'); const fs = require('fs-extra'); -const {format} = require('util'); -const path = require('path'); +const {format} = require('node:util'); +const path = require('node:path'); const Base = require('../../lib/reporters/base'); const debug = require('debug')('mocha:test:integration:helpers'); @@ -323,7 +323,7 @@ function createSubprocess(args, done, opts = {}) { */ let mocha; if (opts.fork) { - const {fork} = require('child_process'); + const {fork} = require('node:child_process'); // to use ipc, we need a fourth item in `stdio` array. // opts.stdio is usually an array of length 3, but it could be smaller // (pad with `null`) @@ -333,7 +333,7 @@ function createSubprocess(args, done, opts = {}) { debug('forking: %s', args.join(' ')); mocha = fork(args[0], args.slice(1), opts); } else { - const {spawn} = require('child_process'); + const {spawn} = require('node:child_process'); debug('spawning: %s', [process.execPath].concat(args).join(' ')); mocha = spawn(process.execPath, args, opts); } diff --git a/test/integration/hooks.spec.js b/test/integration/hooks.spec.js index 7f345e6274..af01093d4e 100644 --- a/test/integration/hooks.spec.js +++ b/test/integration/hooks.spec.js @@ -1,6 +1,6 @@ 'use strict'; -var assert = require('assert'); +var assert = require('node:assert'); var runMocha = require('./helpers').runMocha; var runMochaJSON = require('./helpers').runMochaJSON; var SPLIT_DOT_REPORTER_REGEXP = require('./helpers').SPLIT_DOT_REPORTER_REGEXP; diff --git a/test/integration/init.spec.js b/test/integration/init.spec.js index d19f42a0b4..68361b35fa 100644 --- a/test/integration/init.spec.js +++ b/test/integration/init.spec.js @@ -1,10 +1,10 @@ 'use strict'; -var fs = require('fs'); +var fs = require('node:fs'); var rimraf = require('rimraf'); var invokeMocha = require('./helpers').invokeMocha; -var path = require('path'); -var os = require('os'); +var path = require('node:path'); +var os = require('node:os'); describe('init command', function () { var tmpdir; diff --git a/test/integration/only.spec.js b/test/integration/only.spec.js index fb3aa78f57..f7a317a054 100644 --- a/test/integration/only.spec.js +++ b/test/integration/only.spec.js @@ -1,7 +1,7 @@ 'use strict'; var run = require('./helpers').runMochaJSON; -var assert = require('assert'); +var assert = require('node:assert'); describe('.only()', function () { describe('bdd', function () { diff --git a/test/integration/options/allowUncaught.spec.js b/test/integration/options/allowUncaught.spec.js index 518dd32994..782355f4fb 100644 --- a/test/integration/options/allowUncaught.spec.js +++ b/test/integration/options/allowUncaught.spec.js @@ -1,6 +1,6 @@ 'use strict'; -var path = require('path').posix; +var path = require('node:path').posix; var helpers = require('../helpers'); var runMocha = helpers.runMocha; var runMochaJSON = helpers.runMochaJSON; diff --git a/test/integration/options/asyncOnly.spec.js b/test/integration/options/asyncOnly.spec.js index 6d23308654..e9b8dab318 100644 --- a/test/integration/options/asyncOnly.spec.js +++ b/test/integration/options/asyncOnly.spec.js @@ -1,6 +1,6 @@ 'use strict'; -var path = require('path').posix; +var path = require('node:path').posix; var helpers = require('../helpers'); var runMochaJSON = helpers.runMochaJSON; diff --git a/test/integration/options/bail.spec.js b/test/integration/options/bail.spec.js index f55177bed5..9d1ae49046 100644 --- a/test/integration/options/bail.spec.js +++ b/test/integration/options/bail.spec.js @@ -1,6 +1,6 @@ 'use strict'; -var path = require('path').posix; +var path = require('node:path').posix; var helpers = require('../helpers'); var runMochaJSON = helpers.runMochaJSON; diff --git a/test/integration/options/delay.spec.js b/test/integration/options/delay.spec.js index dc4c284079..c1da3afa02 100644 --- a/test/integration/options/delay.spec.js +++ b/test/integration/options/delay.spec.js @@ -1,6 +1,6 @@ 'use strict'; -var path = require('path').posix; +var path = require('node:path').posix; var helpers = require('../helpers'); var runMochaJSON = helpers.runMochaJSON; diff --git a/test/integration/options/dryRun.spec.js b/test/integration/options/dryRun.spec.js index 45eeabee8f..759cc0bc27 100644 --- a/test/integration/options/dryRun.spec.js +++ b/test/integration/options/dryRun.spec.js @@ -1,6 +1,6 @@ 'use strict'; -var path = require('path').posix; +var path = require('node:path').posix; var helpers = require('../helpers'); var runMochaJSON = helpers.runMochaJSON; diff --git a/test/integration/options/file.spec.js b/test/integration/options/file.spec.js index 259ce4782e..77b1b09d9b 100644 --- a/test/integration/options/file.spec.js +++ b/test/integration/options/file.spec.js @@ -1,6 +1,6 @@ 'use strict'; -var path = require('path').posix; +var path = require('node:path').posix; const { runMochaJSON, resolveFixturePath: resolvePath, diff --git a/test/integration/options/forbidOnly.spec.js b/test/integration/options/forbidOnly.spec.js index 81dbde2dcd..7f988c14e9 100644 --- a/test/integration/options/forbidOnly.spec.js +++ b/test/integration/options/forbidOnly.spec.js @@ -1,6 +1,6 @@ 'use strict'; -var path = require('path').posix; +var path = require('node:path').posix; var helpers = require('../helpers'); var runMocha = helpers.runMocha; var runMochaJSON = helpers.runMochaJSON; diff --git a/test/integration/options/forbidPending.spec.js b/test/integration/options/forbidPending.spec.js index d507204401..dbe9848a7a 100644 --- a/test/integration/options/forbidPending.spec.js +++ b/test/integration/options/forbidPending.spec.js @@ -1,6 +1,6 @@ 'use strict'; -var path = require('path').posix; +var path = require('node:path').posix; var helpers = require('../helpers'); var runMocha = helpers.runMocha; var runMochaJSON = helpers.runMochaJSON; diff --git a/test/integration/options/ignore.spec.js b/test/integration/options/ignore.spec.js index 2818fe0996..9c982f60fb 100644 --- a/test/integration/options/ignore.spec.js +++ b/test/integration/options/ignore.spec.js @@ -1,6 +1,6 @@ 'use strict'; -var path = require('path').posix; +var path = require('node:path').posix; var helpers = require('../helpers'); var runMochaJSON = helpers.runMochaJSON; var resolvePath = helpers.resolveFixturePath; diff --git a/test/integration/options/reporter-option.spec.js b/test/integration/options/reporter-option.spec.js index 5f7b6ba35e..513d8e030f 100644 --- a/test/integration/options/reporter-option.spec.js +++ b/test/integration/options/reporter-option.spec.js @@ -1,7 +1,7 @@ 'use strict'; var runMocha = require('../helpers').runMocha; -var path = require('path'); +var path = require('node:path'); describe('--reporter-option', function () { describe('when given options w/ invalid format', function () { diff --git a/test/integration/options/retries.spec.js b/test/integration/options/retries.spec.js index dd22375fba..c08d0c03c7 100644 --- a/test/integration/options/retries.spec.js +++ b/test/integration/options/retries.spec.js @@ -1,6 +1,6 @@ 'use strict'; -var path = require('path').posix; +var path = require('node:path').posix; var helpers = require('../helpers'); var runMochaJSON = helpers.runMochaJSON; diff --git a/test/integration/options/sort.spec.js b/test/integration/options/sort.spec.js index 4f739488bf..8e34f9068d 100644 --- a/test/integration/options/sort.spec.js +++ b/test/integration/options/sort.spec.js @@ -1,6 +1,6 @@ 'use strict'; -var path = require('path').posix; +var path = require('node:path').posix; var helpers = require('../helpers'); var runMochaJSON = helpers.runMochaJSON; diff --git a/test/integration/options/watch.spec.js b/test/integration/options/watch.spec.js index 957b4938c3..79d9ceb9e9 100644 --- a/test/integration/options/watch.spec.js +++ b/test/integration/options/watch.spec.js @@ -1,7 +1,7 @@ 'use strict'; const fs = require('fs-extra'); -const path = require('path'); +const path = require('node:path'); const { copyFixture, runMochaWatchJSONAsync, diff --git a/test/integration/parallel.spec.js b/test/integration/parallel.spec.js index ed65650046..51cde34a4b 100644 --- a/test/integration/parallel.spec.js +++ b/test/integration/parallel.spec.js @@ -1,6 +1,6 @@ 'use strict'; -const assert = require('assert'); +const assert = require('node:assert'); const {runMochaJSONAsync} = require('./helpers'); describe('parallel run', () => { diff --git a/test/integration/pending.spec.js b/test/integration/pending.spec.js index 01b280cdb0..921c39c6e6 100644 --- a/test/integration/pending.spec.js +++ b/test/integration/pending.spec.js @@ -1,6 +1,6 @@ 'use strict'; -var assert = require('assert'); +var assert = require('node:assert'); var helpers = require('./helpers'); var run = helpers.runMochaJSON; var invokeNode = helpers.invokeNode; diff --git a/test/integration/plugins/global-fixtures.spec.js b/test/integration/plugins/global-fixtures.spec.js index b136dbbd1d..eecd2978bd 100644 --- a/test/integration/plugins/global-fixtures.spec.js +++ b/test/integration/plugins/global-fixtures.spec.js @@ -1,6 +1,6 @@ 'use strict'; -const path = require('path'); +const path = require('node:path'); const { touchFile, runMochaAsync, diff --git a/test/integration/reporters.spec.js b/test/integration/reporters.spec.js index 9285dfe80c..1343b58c6a 100644 --- a/test/integration/reporters.spec.js +++ b/test/integration/reporters.spec.js @@ -1,9 +1,9 @@ 'use strict'; -var os = require('os'); -var fs = require('fs'); -var crypto = require('crypto'); -var path = require('path'); +var os = require('node:os'); +var fs = require('node:fs'); +var crypto = require('node:crypto'); +var path = require('node:path'); var run = require('./helpers').runMocha; describe('reporters', function () { diff --git a/test/integration/retries.spec.js b/test/integration/retries.spec.js index a9cb46a42c..d9388829f3 100644 --- a/test/integration/retries.spec.js +++ b/test/integration/retries.spec.js @@ -1,6 +1,6 @@ 'use strict'; -var assert = require('assert'); +var assert = require('node:assert'); var helpers = require('./helpers'); var runJSON = helpers.runMochaJSON; var args = []; diff --git a/test/integration/timeout.spec.js b/test/integration/timeout.spec.js index 066c1bcdba..6c33fa428d 100644 --- a/test/integration/timeout.spec.js +++ b/test/integration/timeout.spec.js @@ -1,6 +1,6 @@ 'use strict'; -var assert = require('assert'); +var assert = require('node:assert'); var run = require('./helpers').runMochaJSON; var args = []; diff --git a/test/node-unit/esm-utils.spec.js b/test/node-unit/esm-utils.spec.js index 8880b5bceb..184756eb5d 100644 --- a/test/node-unit/esm-utils.spec.js +++ b/test/node-unit/esm-utils.spec.js @@ -2,7 +2,7 @@ const esmUtils = require('../../lib/nodejs/esm-utils'); const sinon = require('sinon'); -const url = require('url'); +const url = require('node:url'); describe('esm-utils', function () { beforeEach(function () { diff --git a/test/node-unit/mocha.spec.js b/test/node-unit/mocha.spec.js index 78991657e2..b64885696d 100644 --- a/test/node-unit/mocha.spec.js +++ b/test/node-unit/mocha.spec.js @@ -1,9 +1,9 @@ 'use strict'; -const path = require('path'); +const path = require('node:path'); const rewiremock = require('rewiremock/node'); const sinon = require('sinon'); -const {EventEmitter} = require('events'); +const {EventEmitter} = require('node:events'); const DUMB_FIXTURE_PATH = require.resolve('./fixtures/dumb-module.fixture.js'); const DUMBER_FIXTURE_PATH = require.resolve( diff --git a/test/node-unit/reporters/parallel-buffered.spec.js b/test/node-unit/reporters/parallel-buffered.spec.js index 24a70dd625..1ed6ee1fd4 100644 --- a/test/node-unit/reporters/parallel-buffered.spec.js +++ b/test/node-unit/reporters/parallel-buffered.spec.js @@ -18,7 +18,7 @@ const { EVENT_HOOK_END, EVENT_RUN_END } = require('../../../lib/runner').constants; -const {EventEmitter} = require('events'); +const {EventEmitter} = require('node:events'); const sinon = require('sinon'); const rewiremock = require('rewiremock/node'); diff --git a/test/node-unit/stack-trace-filter.spec.js b/test/node-unit/stack-trace-filter.spec.js index 12fc937b62..a139c701da 100644 --- a/test/node-unit/stack-trace-filter.spec.js +++ b/test/node-unit/stack-trace-filter.spec.js @@ -1,6 +1,6 @@ 'use strict'; -var path = require('path'); +var path = require('node:path'); var utils = require('../../lib/utils'); describe('stackTraceFilter()', function () { diff --git a/test/only/bdd-require.spec.js b/test/only/bdd-require.spec.js index ca6c6be4a1..68213e9d3f 100644 --- a/test/only/bdd-require.spec.js +++ b/test/only/bdd-require.spec.js @@ -12,7 +12,7 @@ describe('it.only via require("mocha")', function () { }); describe('nested within a describe/context', function () { it.only('should run all enclosing beforeEach hooks', function () { - require('assert').strictEqual(this.didRunBeforeEach, true); + require('node:assert').strictEqual(this.didRunBeforeEach, true); }); }); }); diff --git a/test/reporters/base.spec.js b/test/reporters/base.spec.js index 84778f3693..ce7fa678cc 100644 --- a/test/reporters/base.spec.js +++ b/test/reporters/base.spec.js @@ -1,6 +1,6 @@ 'use strict'; -var assert = require('assert'); +var assert = require('node:assert'); var chai = require('chai'); var sinon = require('sinon'); var helpers = require('./helpers'); diff --git a/test/reporters/json.spec.js b/test/reporters/json.spec.js index f1f1f87922..823bd692d4 100644 --- a/test/reporters/json.spec.js +++ b/test/reporters/json.spec.js @@ -1,6 +1,6 @@ 'use strict'; -var fs = require('fs'); +var fs = require('node:fs'); var sinon = require('sinon'); var JSONReporter = require('../../lib/reporters/json'); var utils = require('../../lib/utils'); diff --git a/test/reporters/xunit.spec.js b/test/reporters/xunit.spec.js index 4e98cf6002..d167daae29 100644 --- a/test/reporters/xunit.spec.js +++ b/test/reporters/xunit.spec.js @@ -1,8 +1,8 @@ 'use strict'; -var EventEmitter = require('events').EventEmitter; -var fs = require('fs'); -var path = require('path'); +var EventEmitter = require('node:events').EventEmitter; +var fs = require('node:fs'); +var path = require('node:path'); var sinon = require('sinon'); var createStatsCollector = require('../../lib/stats-collector'); var events = require('../../').Runner.constants; diff --git a/test/smoke/smoke.spec.js b/test/smoke/smoke.spec.js index 8f91f2f6fe..c5ad721a4b 100644 --- a/test/smoke/smoke.spec.js +++ b/test/smoke/smoke.spec.js @@ -6,7 +6,7 @@ // in `devDependencies` or otherwise in the wrong place. // It does not ensure that all files are present in the published package! -var assert = require('assert'); +var assert = require('node:assert'); describe('a production installation of Mocha', function () { it('should be able to execute a test', function () { diff --git a/test/unit/mocha.spec.js b/test/unit/mocha.spec.js index e0f603574e..15abd66cd5 100644 --- a/test/unit/mocha.spec.js +++ b/test/unit/mocha.spec.js @@ -1,7 +1,7 @@ 'use strict'; var sinon = require('sinon'); -var EventEmitter = require('events').EventEmitter; +var EventEmitter = require('node:events').EventEmitter; var Mocha = require('../../lib/mocha'); var utils = require('../../lib/utils'); const errors = require('../../lib/errors'); diff --git a/test/unit/required-tokens.spec.js b/test/unit/required-tokens.spec.js index 836e664d4d..ba2ee95dc2 100644 --- a/test/unit/required-tokens.spec.js +++ b/test/unit/required-tokens.spec.js @@ -1,6 +1,6 @@ 'use strict'; -const assert = require('assert'); +const assert = require('node:assert'); const {describe, it} = require('../..'); describe('using imported "describe"', function () { diff --git a/test/unit/runner.spec.js b/test/unit/runner.spec.js index 66ca6a0532..3bd22b5036 100644 --- a/test/unit/runner.spec.js +++ b/test/unit/runner.spec.js @@ -1,6 +1,6 @@ 'use strict'; -const path = require('path'); +const path = require('node:path'); const sinon = require('sinon'); const Mocha = require('../../lib/mocha'); const Pending = require('../../lib/pending');