Skip to content

Commit a2218e4

Browse files
authored
Stop using import X = require('…'). (#15659)
1 parent 8fcefef commit a2218e4

File tree

128 files changed

+191
-222
lines changed

Some content is hidden

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

128 files changed

+191
-222
lines changed

babel.config.js

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,6 @@ module.exports = {
1616
exclude: /react-native/,
1717
overrides: [
1818
{
19-
plugins: [
20-
require.resolve(
21-
'./scripts/babel-plugin-jest-replace-ts-require-assignment.js',
22-
),
23-
],
2419
presets: [
2520
[
2621
'@babel/preset-typescript',

e2e/Utils.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import {
1515
sync as spawnSync,
1616
} from 'execa';
1717
import * as fs from 'graceful-fs';
18-
import which = require('which');
18+
import which from 'which';
1919
import type {Config} from '@jest/types';
2020

2121
const dedent = dedentBase.withOptions({escapeSpecialCharacters: true});

e2e/__tests__/jestChangedFiles.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88
import {tmpdir} from 'os';
99
import * as path from 'path';
1010
import * as fs from 'graceful-fs';
11-
import semver = require('semver');
12-
import slash = require('slash');
11+
import * as semver from 'semver';
12+
import slash from 'slash';
1313
import {findRepos, getChangedFilesForRoots} from 'jest-changed-files';
1414
import {
1515
cleanup,

e2e/__tests__/multipleConfigs.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
*/
77

88
import * as path from 'path';
9-
import slash = require('slash');
9+
import slash from 'slash';
1010
import runJest from '../runJest';
1111

1212
const MULTIPLE_CONFIGS_WARNING_TEXT = 'Multiple configurations found';

e2e/__tests__/onlyChanged.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
import {tmpdir} from 'os';
99
import * as path from 'path';
10-
import semver = require('semver');
10+
import * as semver from 'semver';
1111
import {cleanup, run, testIfHg, testIfSl, writeFiles} from '../Utils';
1212
import runJest from '../runJest';
1313

e2e/__tests__/readInitialOptions.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
* This source code is licensed under the MIT license found in the
55
* LICENSE file in the root directory of this source tree.
66
*/
7-
import path = require('path');
8-
import execa = require('execa');
7+
import path from 'path';
8+
import execa from 'execa';
99
import {onNodeVersions} from '@jest/test-utils';
1010
import type {ReadJestConfigOptions, readInitialOptions} from 'jest-config';
1111

e2e/__tests__/workerForceExit.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
import {tmpdir} from 'os';
99
import {resolve} from 'path';
10-
import findProcess = require('find-process');
10+
import findProcess from 'find-process';
1111
import {
1212
cleanup,
1313
generateTestFilesToForceUsingWorkers,

e2e/runJest.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import * as path from 'path';
1010
import {Writable} from 'stream';
1111
import {stripVTControlCharacters as stripAnsi} from 'util';
1212
import dedent from 'dedent';
13-
import execa = require('execa');
13+
import execa from 'execa';
1414
import * as fs from 'graceful-fs';
1515
import {TestPathPatterns} from '@jest/pattern';
1616
import type {FormattedTestResults} from '@jest/test-result';

packages/babel-jest/src/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@ import {
1313
transformSync as babelTransform,
1414
transformAsync as babelTransformAsync,
1515
} from '@babel/core';
16-
import chalk = require('chalk');
16+
import chalk from 'chalk';
1717
import * as fs from 'graceful-fs';
18-
import slash = require('slash');
18+
import slash from 'slash';
1919
import type {
2020
TransformOptions as JestTransformOptions,
2121
SyncTransformer,

packages/create-jest/src/runCreate.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@
66
*/
77

88
import * as path from 'path';
9-
import chalk = require('chalk');
10-
import exit = require('exit-x');
9+
import chalk from 'chalk';
10+
import exit from 'exit-x';
1111
import * as fs from 'graceful-fs';
12-
import prompts = require('prompts');
12+
import prompts from 'prompts';
1313
import {constants} from 'jest-config';
1414
import {clearLine, tryRealpath} from 'jest-util';
1515
import {MalformedPackageJsonError, NotFoundPackageJsonError} from './errors';

packages/jest-changed-files/src/git.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*/
88

99
import * as path from 'path';
10-
import execa = require('execa');
10+
import execa from 'execa';
1111
import type {SCMAdapter} from './types';
1212

1313
const findChangedFilesUsingCommand = async (

packages/jest-changed-files/src/hg.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*/
88

99
import * as path from 'path';
10-
import execa = require('execa');
10+
import execa from 'execa';
1111
import type {SCMAdapter} from './types';
1212

1313
const env = {...process.env, HGPLAIN: '1'};

packages/jest-changed-files/src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
*
77
*/
88

9-
import pLimit = require('p-limit');
9+
import pLimit from 'p-limit';
1010
import {isNonNullable} from 'jest-util';
1111
import git from './git';
1212
import hg from './hg';

packages/jest-changed-files/src/sl.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*/
88

99
import * as path from 'path';
10-
import execa = require('execa');
10+
import execa from 'execa';
1111
import type {SCMAdapter} from './types';
1212

1313
/**

packages/jest-circus/src/__mocks__/testUtils.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
import {sync as spawnSync} from 'execa';
99
import * as fs from 'graceful-fs';
10-
import tempy = require('tempy');
10+
import tempy from 'tempy';
1111

1212
const CIRCUS_PATH = require.resolve('../').replaceAll('\\', '\\\\');
1313
const CIRCUS_RUN_PATH = require.resolve('../run').replaceAll('\\', '\\\\');

packages/jest-circus/src/formatNodeAssertErrors.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
*/
77

88
import {AssertionError} from 'assert';
9-
import chalk = require('chalk');
9+
import chalk from 'chalk';
1010
import type {Circus} from '@jest/types';
1111
import {
1212
type DiffOptions,

packages/jest-circus/src/run.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
*/
77

88
import {AsyncLocalStorage} from 'async_hooks';
9-
import pLimit = require('p-limit');
9+
import pLimit from 'p-limit';
1010
import {jestExpect} from '@jest/expect';
1111
import type {Circus, Global} from '@jest/types';
1212
import {invariant} from 'jest-util';

packages/jest-circus/src/utils.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ import * as path from 'path';
99
import co from 'co';
1010
import dedent from 'dedent';
1111
import isGeneratorFn from 'is-generator-fn';
12-
import slash = require('slash');
13-
import StackUtils = require('stack-utils');
12+
import slash from 'slash';
13+
import StackUtils from 'stack-utils';
1414
import type {Status, TestCaseResult} from '@jest/test-result';
1515
import type {Circus, Global} from '@jest/types';
1616
import {

packages/jest-cli/src/run.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@
66
*/
77

88
import * as path from 'path';
9-
import chalk = require('chalk');
10-
import exit = require('exit-x');
11-
import yargs = require('yargs');
9+
import chalk from 'chalk';
10+
import exit from 'exit-x';
11+
import yargs from 'yargs';
1212
import {getVersion, runCLI} from '@jest/core';
1313
import type {AggregatedResult} from '@jest/test-result';
1414
import type {Config} from '@jest/types';

packages/jest-config/src/Deprecated.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
* LICENSE file in the root directory of this source tree.
66
*/
77

8-
import chalk = require('chalk');
8+
import chalk from 'chalk';
99
import type {DeprecatedOptions} from 'jest-validate';
1010

1111
function formatDeprecation(message: string): string {

packages/jest-config/src/ReporterValidationErrors.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
* LICENSE file in the root directory of this source tree.
66
*/
77

8-
import chalk = require('chalk');
8+
import chalk from 'chalk';
99
import {getType} from '@jest/get-type';
1010
import type {Config} from '@jest/types';
1111
import {ValidationError} from 'jest-validate';

packages/jest-config/src/__tests__/normalize.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
import {createHash} from 'crypto';
1010
import * as path from 'path';
11-
import semver = require('semver');
11+
import * as semver from 'semver';
1212
import type {Config} from '@jest/types';
1313
import {escapeStrForRegex} from 'jest-regex-util';
1414
import Defaults from '../Defaults';

packages/jest-config/src/__tests__/readConfigFileAndSetRootDir.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
* LICENSE file in the root directory of this source tree.
66
*/
77

8-
import path = require('path');
8+
import path from 'path';
99
import * as fs from 'graceful-fs';
1010
import {requireOrImportModule} from 'jest-util';
1111
import readConfigFileAndSetRootDir from '../readConfigFileAndSetRootDir';

packages/jest-config/src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
*/
77

88
import * as path from 'path';
9-
import chalk = require('chalk');
9+
import chalk from 'chalk';
1010
import * as fs from 'graceful-fs';
1111
import type {Config} from '@jest/types';
1212
import {tryRealpath} from 'jest-util';

packages/jest-config/src/normalize.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,11 @@
88
import {createHash} from 'crypto';
99
import {totalmem} from 'os';
1010
import * as path from 'path';
11-
import chalk = require('chalk');
12-
import merge = require('deepmerge');
11+
import chalk from 'chalk';
12+
import merge from 'deepmerge';
1313
import {glob} from 'glob';
1414
import {statSync} from 'graceful-fs';
15-
import micromatch = require('micromatch');
15+
import micromatch from 'micromatch';
1616
import {TestPathPatterns} from '@jest/pattern';
1717
import type {Config} from '@jest/types';
1818
import {replacePathSepForRegex} from 'jest-regex-util';

packages/jest-config/src/readConfigFileAndSetRootDir.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88
import * as path from 'path';
99
import {isNativeError} from 'util/types';
1010
import * as fs from 'graceful-fs';
11-
import parseJson = require('parse-json');
12-
import stripJsonComments = require('strip-json-comments');
11+
import parseJson from 'parse-json';
12+
import stripJsonComments from 'strip-json-comments';
1313
import type {Config} from '@jest/types';
1414
import {extract, parse} from 'jest-docblock';
1515
import {interopRequireDefault, requireOrImportModule} from 'jest-util';

packages/jest-config/src/resolveConfigPath.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@
66
*/
77

88
import * as path from 'path';
9-
import chalk = require('chalk');
9+
import chalk from 'chalk';
1010
import * as fs from 'graceful-fs';
11-
import slash = require('slash');
11+
import slash from 'slash';
1212
import {ValidationError} from 'jest-validate';
1313
import {
1414
JEST_CONFIG_BASE_NAME,

packages/jest-config/src/utils.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
*/
77

88
import * as path from 'path';
9-
import chalk = require('chalk');
9+
import chalk from 'chalk';
1010
import Resolver from 'jest-resolve';
1111
import {ValidationError} from 'jest-validate';
1212

packages/jest-console/src/BufferedConsole.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
import {AssertionError, strict as assert} from 'assert';
99
import {Console} from 'console';
1010
import {type InspectOptions, format, formatWithOptions, inspect} from 'util';
11-
import chalk = require('chalk');
11+
import chalk from 'chalk';
1212
import {ErrorWithStack, formatTime, invariant} from 'jest-util';
1313
import type {
1414
ConsoleBuffer,

packages/jest-console/src/CustomConsole.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import {AssertionError, strict as assert} from 'assert';
99
import {Console} from 'console';
1010
import type {WriteStream} from 'tty';
1111
import {type InspectOptions, format, formatWithOptions, inspect} from 'util';
12-
import chalk = require('chalk');
12+
import chalk from 'chalk';
1313
import {clearLine, formatTime} from 'jest-util';
1414
import type {LogCounters, LogMessage, LogTimers, LogType} from './types';
1515

packages/jest-console/src/__tests__/CustomConsole.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
import {Writable} from 'stream';
99
import type {WriteStream} from 'tty';
10-
import chalk = require('chalk');
10+
import chalk from 'chalk';
1111
import CustomConsole from '../CustomConsole';
1212

1313
describe('CustomConsole', () => {

packages/jest-console/src/__tests__/bufferedConsole.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
* LICENSE file in the root directory of this source tree.
66
*/
77

8-
import chalk = require('chalk');
8+
import chalk from 'chalk';
99
import BufferedConsole from '../BufferedConsole';
1010

1111
describe('CustomConsole', () => {

packages/jest-console/src/getConsoleOutput.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
* LICENSE file in the root directory of this source tree.
66
*/
77

8-
import chalk = require('chalk');
8+
import chalk from 'chalk';
99
import type {Config} from '@jest/types';
1010
import {
1111
type StackTraceConfig,

packages/jest-core/src/FailedTestsInteractiveMode.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
* LICENSE file in the root directory of this source tree.
66
*/
77

8-
import ansiEscapes = require('ansi-escapes');
9-
import chalk = require('chalk');
8+
import ansiEscapes from 'ansi-escapes';
9+
import chalk from 'chalk';
1010
import type {AggregatedResult, AssertionLocation} from '@jest/test-result';
1111
import {pluralize, specialChars} from 'jest-util';
1212
import {KEYS} from 'jest-watcher';

packages/jest-core/src/SearchSource.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
import * as os from 'os';
99
import * as path from 'path';
10-
import micromatch = require('micromatch');
10+
import micromatch from 'micromatch';
1111
import type {TestPathPatternsExecutor} from '@jest/pattern';
1212
import type {Test, TestContext} from '@jest/test-result';
1313
import type {Config} from '@jest/types';

packages/jest-core/src/SnapshotInteractiveMode.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
* LICENSE file in the root directory of this source tree.
66
*/
77

8-
import ansiEscapes = require('ansi-escapes');
9-
import chalk = require('chalk');
8+
import ansiEscapes from 'ansi-escapes';
9+
import chalk from 'chalk';
1010
import type {AggregatedResult, AssertionLocation} from '@jest/test-result';
1111
import {pluralize, specialChars} from 'jest-util';
1212
import {KEYS} from 'jest-watcher';

packages/jest-core/src/TestScheduler.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@
55
* LICENSE file in the root directory of this source tree.
66
*/
77

8-
import chalk = require('chalk');
8+
import chalk from 'chalk';
99
import {GITHUB_ACTIONS} from 'ci-info';
10-
import exit = require('exit-x');
10+
import exit from 'exit-x';
1111
import {
1212
CoverageReporter,
1313
DefaultReporter,

packages/jest-core/src/cli/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77

88
import {performance} from 'perf_hooks';
99
import type {WriteStream} from 'tty';
10-
import chalk = require('chalk');
11-
import exit = require('exit-x');
10+
import chalk from 'chalk';
11+
import exit from 'exit-x';
1212
import * as fs from 'graceful-fs';
1313
import {CustomConsole} from '@jest/console';
1414
import type {AggregatedResult, TestContext} from '@jest/test-result';

packages/jest-core/src/getChangedFilesPromise.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
* LICENSE file in the root directory of this source tree.
66
*/
77

8-
import chalk = require('chalk');
8+
import chalk from 'chalk';
99
import type {Config} from '@jest/types';
1010
import {
1111
type ChangedFilesPromise,

0 commit comments

Comments
 (0)