Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: enabled eslint-plugin-n #5280

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from
Draft
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
chore: enabled eslint-plugin-n
JoshuaKGoldberg committed Jan 2, 2025
commit 3ae1e8c2b19eb71dafbe0af83f18e4e79d41791c
4 changes: 2 additions & 2 deletions bin/mocha.js
Original file line number Diff line number Diff line change
@@ -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
4 changes: 2 additions & 2 deletions docs/_data/files.js
Original file line number Diff line number Diff line change
@@ -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 = [
4 changes: 2 additions & 2 deletions docs/_data/supporters.js
Original file line number Diff line number Diff line change
@@ -17,8 +17,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'));
4 changes: 2 additions & 2 deletions docs/_data/toc.js
Original file line number Diff line number Diff line change
@@ -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');
6 changes: 3 additions & 3 deletions docs/_data/usage.js
Original file line number Diff line number Diff line change
@@ -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';
3 changes: 3 additions & 0 deletions eslint.config.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"use strict";

const js = require('@eslint/js');
const n = require('eslint-plugin-n')
const globals = require('globals');

const messages = {
@@ -11,6 +12,7 @@ const messages = {
module.exports = [
{
...js.configs.recommended,
...n.configs['flat/recommended-script'],
languageOptions: {
ecmaVersion: 2020,
globals: {
@@ -20,6 +22,7 @@ module.exports = [
sourceType: 'script'
},
rules: {
'n/prefer-node-protocol': 'error',
'no-var': 'off',
strict: ['error', 'global']
}
6 changes: 3 additions & 3 deletions karma.conf.js
Original file line number Diff line number Diff line change
@@ -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;
2 changes: 1 addition & 1 deletion lib/cli/cli.js
Original file line number Diff line number Diff line change
@@ -13,7 +13,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,
4 changes: 2 additions & 2 deletions lib/cli/collect-files.js
Original file line number Diff line number Diff line change
@@ -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');
4 changes: 2 additions & 2 deletions lib/cli/config.js
Original file line number Diff line number Diff line change
@@ -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');
4 changes: 2 additions & 2 deletions lib/cli/init.js
Original file line number Diff line number Diff line change
@@ -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 <path>';

4 changes: 2 additions & 2 deletions lib/cli/lookup-files.js
Original file line number Diff line number Diff line change
@@ -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;
2 changes: 1 addition & 1 deletion lib/cli/options.js
Original file line number Diff line number Diff line change
@@ -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 {
6 changes: 3 additions & 3 deletions lib/cli/run-helpers.js
Original file line number Diff line number Diff line change
@@ -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');
2 changes: 1 addition & 1 deletion lib/cli/watch-run.js
Original file line number Diff line number Diff line change
@@ -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');
2 changes: 1 addition & 1 deletion lib/errors.js
Original file line number Diff line number Diff line change
@@ -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,
2 changes: 1 addition & 1 deletion lib/mocha.js
Original file line number Diff line number Diff line change
@@ -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');
4 changes: 2 additions & 2 deletions lib/nodejs/esm-utils.js
Original file line number Diff line number Diff line change
@@ -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;

4 changes: 2 additions & 2 deletions lib/reporters/json.js
Original file line number Diff line number Diff line change
@@ -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;
2 changes: 1 addition & 1 deletion lib/reporters/tap.js
Original file line number Diff line number Diff line change
@@ -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;
4 changes: 2 additions & 2 deletions lib/reporters/xunit.js
Original file line number Diff line number Diff line change
@@ -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;
2 changes: 1 addition & 1 deletion lib/runnable.js
Original file line number Diff line number Diff line change
@@ -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');
2 changes: 1 addition & 1 deletion lib/runner.js
Original file line number Diff line number Diff line change
@@ -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');
2 changes: 1 addition & 1 deletion lib/suite.js
Original file line number Diff line number Diff line change
@@ -4,7 +4,7 @@
* Module dependencies.
* @private
*/
const {EventEmitter} = require('events');
const {EventEmitter} = require('node:events');
const Hook = require('./hook');
var {
assignNewMochaID,
4 changes: 2 additions & 2 deletions lib/utils.js
Original file line number Diff line number Diff line change
@@ -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__';
Loading