Skip to content

Commit 945d6e3

Browse files
chore: enabled eslint-plugin-n (#5280)
* chore: enabled eslint-plugin-n * Actually included rules, without the override * Revert unrelated formatting changes * fix test/node-unit/cli/options.spec.js tests * Use @rollup/plugin-alias for building node: prefixes
1 parent b720ec1 commit 945d6e3

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

76 files changed

+395
-204
lines changed

bin/mocha.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ if (mochaArgs._) {
7878
}
7979

8080
if (mochaArgs['node-option'] || Object.keys(nodeArgs).length || hasInspect) {
81-
const {spawn} = require('child_process');
81+
const {spawn} = require('node:child_process');
8282
const mochaPath = require.resolve('../lib/cli/cli.js');
8383

8484
const nodeArgv =
@@ -126,7 +126,7 @@ if (mochaArgs['node-option'] || Object.keys(nodeArgs).length || hasInspect) {
126126
// be needed.
127127
if (!args.parallel || args.jobs < 2) {
128128
// win32 does not support SIGTERM, so use next best thing.
129-
if (require('os').platform() === 'win32') {
129+
if (require('node:os').platform() === 'win32') {
130130
proc.kill('SIGKILL');
131131
} else {
132132
// using SIGKILL won't cleanly close the output streams, which can result

docs/_data/files.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
'use strict';
22

3-
const {resolve, relative, dirname} = require('path');
4-
const {promises: fs} = require('fs');
3+
const {resolve, relative, dirname} = require('node:path');
4+
const {promises: fs} = require('node:fs');
55

66
const PROJECT_ROOT_DIR = resolve(__dirname, '..', '..');
77
const FILES = [

docs/_data/supporters.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
#!/usr/bin/env node
2-
31
/**
42
* This script gathers metadata for active supporters of Mocha from OpenCollective's
53
* API by aggregating order ("donation") information.
@@ -17,8 +15,8 @@
1715

1816
'use strict';
1917

20-
const {writeFile, mkdir, rm} = require('fs').promises;
21-
const {resolve} = require('path');
18+
const {writeFile, mkdir, rm} = require('node:fs').promises;
19+
const {resolve} = require('node:path');
2220
const debug = require('debug')('mocha:docs:data:supporters');
2321
const needle = require('needle');
2422
const blocklist = new Set(require('./blocklist.json'));

docs/_data/toc.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
'use strict';
22

33
const markdownToc = require('markdown-toc');
4-
const {readFileSync} = require('fs');
5-
const {resolve} = require('path');
4+
const {readFileSync} = require('node:fs');
5+
const {resolve} = require('node:path');
66

77
const IGNORED_HEADINGS_REGEXP = /Features|Table of Contents|Backers|Sponsors/i;
88
const DOCUMENT_PATH = resolve(__dirname, '..', 'index.md');

docs/_data/usage.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
'use strict';
22

3-
const {stripVTControlCharacters} = require('util');
4-
const {resolve} = require('path');
5-
const {execSync} = require('child_process');
3+
const {stripVTControlCharacters} = require('node:util');
4+
const {resolve} = require('node:path');
5+
const {execSync} = require('node:child_process');
66

77
const executable = require.resolve('../../bin/mocha');
88
const flag = '--help';

eslint.config.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
"use strict";
22

33
const js = require('@eslint/js');
4+
const n = require('eslint-plugin-n');
45
const globals = require('globals');
56

67
const messages = {
@@ -9,6 +10,7 @@ const messages = {
910
};
1011

1112
module.exports = [
13+
n.configs['flat/recommended-script'],
1214
{
1315
...js.configs.recommended,
1416
languageOptions: {
@@ -20,8 +22,13 @@ module.exports = [
2022
sourceType: 'script'
2123
},
2224
rules: {
25+
'n/prefer-node-protocol': 'error',
26+
strict: ['error', 'global'],
27+
2328
'no-var': 'off',
24-
strict: ['error', 'global']
29+
'n/no-process-exit': 'off',
30+
'n/no-unpublished-require': 'off',
31+
'n/no-unsupported-features/node-builtins': 'off',
2532
}
2633
},
2734
{

karma.conf.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,9 @@
2121
*/
2222

2323
'use strict';
24-
const fs = require('fs');
25-
const path = require('path');
26-
const os = require('os');
24+
const fs = require('node:fs');
25+
const path = require('node:path');
26+
const os = require('node:os');
2727
const rollupPlugin = require('./scripts/karma-rollup-plugin');
2828
const BASE_BUNDLE_DIR_PATH = path.join(__dirname, '.karma');
2929
const env = process.env;

lib/cli/cli.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
#!/usr/bin/env node
2-
31
'use strict';
42

53
/**
@@ -13,7 +11,7 @@
1311
const debug = require('debug')('mocha:cli:cli');
1412
const symbols = require('log-symbols');
1513
const yargs = require('yargs');
16-
const path = require('path');
14+
const path = require('node:path');
1715
const {
1816
loadRc,
1917
loadPkgRc,

lib/cli/collect-files.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
'use strict';
22

3-
const fs = require('fs');
4-
const path = require('path');
3+
const fs = require('node:fs');
4+
const path = require('node:path');
55
const ansi = require('ansi-colors');
66
const debug = require('debug')('mocha:cli:run:helpers');
77
const minimatch = require('minimatch');

lib/cli/config.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77
* @module
88
*/
99

10-
const fs = require('fs');
11-
const path = require('path');
10+
const fs = require('node:fs');
11+
const path = require('node:path');
1212
const debug = require('debug')('mocha:cli:config');
1313
const findUp = require('find-up');
1414
const {createUnparsableFileError} = require('../errors');

0 commit comments

Comments
 (0)