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
Show file tree
Hide file tree
Changes from all commits
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
4 changes: 2 additions & 2 deletions bin/mocha.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 =
Expand Down Expand Up @@ -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
Expand Down
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 = [
Expand Down
6 changes: 2 additions & 4 deletions docs/_data/supporters.js
Original file line number Diff line number Diff line change
@@ -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.
Expand All @@ -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'));
Expand Down
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');
Expand Down
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';
Expand Down
9 changes: 8 additions & 1 deletion 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 = {
Expand All @@ -9,6 +10,7 @@ const messages = {
};

module.exports = [
n.configs['flat/recommended-script'],
{
...js.configs.recommended,
languageOptions: {
Expand All @@ -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',
}
},
{
Expand Down
6 changes: 3 additions & 3 deletions karma.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
4 changes: 1 addition & 3 deletions lib/cli/cli.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
#!/usr/bin/env node

'use strict';

/**
Expand All @@ -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,
Expand Down
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');
Expand Down
4 changes: 2 additions & 2 deletions lib/cli/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down
4 changes: 2 additions & 2 deletions lib/cli/init.js
Original file line number Diff line number Diff line change
Expand Up @@ -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>';

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

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