chore: use consistent type imports (#14662)

This commit is contained in:
Simen Bekkhus 2023-10-30 13:37:25 +01:00 committed by GitHub
parent 79a4ff4985
commit 5ce83ac4bc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
103 changed files with 294 additions and 240 deletions

View File

@ -46,6 +46,11 @@ module.exports = {
rules: {
'@typescript-eslint/array-type': ['error', {default: 'generic'}],
'@typescript-eslint/ban-types': 'error',
'@typescript-eslint/consistent-type-imports': [
'error',
{fixStyle: 'inline-type-imports', disallowTypeAnnotations: false},
],
'@typescript-eslint/no-import-type-side-effects': 'error',
'@typescript-eslint/no-inferrable-types': 'error',
'@typescript-eslint/no-unused-vars': [
'error',
@ -278,6 +283,16 @@ module.exports = {
'no-restricted-imports': 'off',
},
},
{
files: ['examples/angular/**/*'],
rules: {
// Angular DI for some reason doesn't work with type imports
'@typescript-eslint/consistent-type-imports': [
'error',
{prefer: 'no-type-imports', disallowTypeAnnotations: false},
],
},
},
{
files: 'packages/**/*.ts',
rules: {
@ -416,6 +431,7 @@ module.exports = {
'handle-callback-err': 'off',
'id-length': 'off',
'id-match': 'off',
'import/no-duplicates': 'error',
'import/no-extraneous-dependencies': [
'error',
{

View File

@ -736,7 +736,7 @@ export function setDateNow(now: number): jest.Spied<typeof Date.now> {
```
```ts
import {afterEach, expect, jest, test} from '@jest/globals';
import {afterEach, expect, type jest, test} from '@jest/globals';
import {setDateNow} from './__utils__/setDateNow';
let spiedDateNow: jest.Spied<typeof Date.now> | undefined = undefined;

View File

@ -9,9 +9,9 @@ import * as path from 'path';
import * as util from 'util';
import dedent from 'dedent';
import {
ExecaSyncError,
SyncOptions as ExecaSyncOptions,
ExecaSyncReturnValue,
type ExecaSyncError,
type SyncOptions as ExecaSyncOptions,
type ExecaSyncReturnValue,
sync as spawnSync,
} from 'execa';
import * as fs from 'graceful-fs';

View File

@ -5,7 +5,7 @@
* LICENSE file in the root directory of this source tree.
*/
import runJest, {RunJestResult} from '../runJest';
import runJest, {type RunJestResult} from '../runJest';
const getLog = (result: RunJestResult) => result.stdout.split('\n')[1].trim();

View File

@ -8,7 +8,7 @@
import * as path from 'path';
import {skipSuiteOnJasmine} from '@jest/test-utils';
import {extractSummary} from '../Utils';
import runJest, {RunJestResult} from '../runJest';
import runJest, {type RunJestResult} from '../runJest';
skipSuiteOnJasmine();

View File

@ -7,8 +7,8 @@
import {resolve} from 'path';
import run, {
RunJestJsonResult,
RunJestResult,
type RunJestJsonResult,
type RunJestResult,
json as runWithJson,
} from '../runJest';

View File

@ -8,7 +8,7 @@
import {tmpdir} from 'os';
import * as path from 'path';
import {
PackageJson,
type PackageJson,
cleanup,
createEmptyPackage,
runYarnInstall,

View File

@ -6,7 +6,7 @@
*
*/
/* eslint-disable no-duplicate-imports */
/* eslint-disable no-duplicate-imports, import/no-duplicates */
import {jest} from '@jest/globals';
import {jest as aliasedJest} from '@jest/globals';
import * as JestGlobals from '@jest/globals';

View File

@ -18,9 +18,11 @@ import staticImportedStatefulFromCjs from '../fromCjs.mjs';
import {double} from '../index';
import defaultFromCjs, {half, namedFunction} from '../namedExport.cjs';
import {bag} from '../namespaceExport.js';
/* eslint-disable import/no-duplicates */
import staticImportedStateful from '../stateful.mjs';
import staticImportedStatefulWithQuery from '../stateful.mjs?query=1';
import staticImportedStatefulWithAnotherQuery from '../stateful.mjs?query=2';
/* eslint-enable */
test('should have correct import.meta', () => {
expect(typeof require).toBe('undefined');

View File

@ -6,7 +6,11 @@
*/
import pLimit from 'p-limit';
import {Test, TestResult, createEmptyTestResult} from '@jest/test-result';
import {
type Test,
type TestResult,
createEmptyTestResult,
} from '@jest/test-result';
import type {Config} from '@jest/types';
import type {
OnTestFailure,

View File

@ -5,7 +5,7 @@
* LICENSE file in the root directory of this source tree.
*/
import {SnapshotResolver} from 'jest-snapshot';
import type {SnapshotResolver} from 'jest-snapshot';
const snapshotResolver: SnapshotResolver = {
resolveSnapshotPath: (testPath, snapshotExtension) =>

View File

@ -4,10 +4,10 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
import {JestEnvironment} from '@jest/environment';
import {TestResult, createEmptyTestResult} from '@jest/test-result';
import {Config} from '@jest/types';
import Runtime from 'jest-runtime';
import type {JestEnvironment} from '@jest/environment';
import {type TestResult, createEmptyTestResult} from '@jest/test-result';
import type {Config} from '@jest/types';
import type Runtime from 'jest-runtime';
export default async function testRunner(
globalConfig: Config.GlobalConfig,

View File

@ -1,4 +1,4 @@
import Memory from './Memory';
import type Memory from './Memory';
import sub from './sub';
import sum from './sum';

View File

@ -8,8 +8,8 @@
import {createHash} from 'crypto';
import * as path from 'path';
import {
PartialConfig,
TransformOptions,
type PartialConfig,
type TransformOptions,
transformSync as babelTransform,
transformAsync as babelTransformAsync,
} from '@babel/core';

View File

@ -10,17 +10,17 @@ import type {PluginObj} from '@babel/core';
import {statement} from '@babel/template';
import type {NodePath} from '@babel/traverse';
import {
BlockStatement,
CallExpression,
Expression,
Identifier,
ImportDeclaration,
MemberExpression,
Node,
Program,
Super,
VariableDeclaration,
VariableDeclarator,
type BlockStatement,
type CallExpression,
type Expression,
type Identifier,
type ImportDeclaration,
type MemberExpression,
type Node,
type Program,
type Super,
type VariableDeclaration,
type VariableDeclarator,
callExpression,
emptyStatement,
isIdentifier,

View File

@ -8,12 +8,12 @@
import {expectAssignable, expectError, expectType} from 'tsd-lite';
import type {EqualsFunction} from '@jest/expect-utils';
import {
MatcherContext,
MatcherFunction,
MatcherFunctionWithContext,
Matchers,
Tester,
TesterContext,
type MatcherContext,
type MatcherFunction,
type MatcherFunctionWithContext,
type Matchers,
type Tester,
type TesterContext,
expect,
} from 'expect';
import type * as jestMatcherUtils from 'jest-matcher-utils';

View File

@ -6,7 +6,7 @@
*
*/
import {Tester, equals} from '@jest/expect-utils';
import {type Tester, equals} from '@jest/expect-utils';
import jestExpect from '../';
// Test test file demonstrates and tests the capability of recursive custom

View File

@ -23,7 +23,7 @@ import {getType, isPrimitive} from 'jest-get-type';
import {
DIM_COLOR,
EXPECTED_COLOR,
MatcherHintOptions,
type MatcherHintOptions,
RECEIVED_COLOR,
SUGGEST_TO_CONTAIN_EQUAL,
ensureExpectedIsNonNegativeInteger,

View File

@ -10,7 +10,7 @@ import {getType, isPrimitive} from 'jest-get-type';
import {
DIM_COLOR,
EXPECTED_COLOR,
MatcherHintOptions,
type MatcherHintOptions,
RECEIVED_COLOR,
diff,
ensureExpectedIsNonNegativeInteger,

View File

@ -11,7 +11,7 @@
import {isError} from '@jest/expect-utils';
import {
EXPECTED_COLOR,
MatcherHintOptions,
type MatcherHintOptions,
RECEIVED_COLOR,
matcherErrorMessage,
matcherHint,

View File

@ -8,7 +8,7 @@
import type {EqualsFunction, Tester} from '@jest/expect-utils';
import type * as jestMatcherUtils from 'jest-matcher-utils';
import {INTERNAL_MATCHER_FLAG} from './jestMatchersObject';
import type {INTERNAL_MATCHER_FLAG} from './jestMatchersObject';
export type SyncExpectationResult = {
pass: boolean;

View File

@ -9,7 +9,7 @@ import {AssertionError} from 'assert';
import chalk = require('chalk');
import type {Circus} from '@jest/types';
import {
DiffOptions,
type DiffOptions,
diff,
printExpected,
printReceived,

View File

@ -7,12 +7,12 @@
import type * as Process from 'process';
import type {JestEnvironment} from '@jest/environment';
import {JestExpect, jestExpect} from '@jest/expect';
import {type JestExpect, jestExpect} from '@jest/expect';
import {
AssertionResult,
Status,
TestFileEvent,
TestResult,
type AssertionResult,
type Status,
type TestFileEvent,
type TestResult,
createEmptyTestResult,
} from '@jest/test-result';
import type {Circus, Config, Global} from '@jest/types';

View File

@ -10,7 +10,10 @@ import pLimit = require('p-limit');
import {jestExpect} from '@jest/expect';
import type {Circus, Global} from '@jest/types';
import {invariant} from 'jest-util';
import shuffleArray, {RandomNumberGenerator, rngBuilder} from './shuffleArray';
import shuffleArray, {
type RandomNumberGenerator,
rngBuilder,
} from './shuffleArray';
import {dispatch, getState} from './state';
import {RETRY_TIMES} from './types';
import {

View File

@ -13,7 +13,7 @@ import type {Config} from '@jest/types';
import {escapeStrForRegex} from 'jest-regex-util';
import Defaults from '../Defaults';
import {DEFAULT_JS_PATTERN} from '../constants';
import normalize, {AllOptions} from '../normalize';
import normalize, {type AllOptions} from '../normalize';
const DEFAULT_CSS_PATTERN = '\\.(css)$';

View File

@ -7,7 +7,7 @@
import {AssertionError, strict as assert} from 'assert';
import {Console} from 'console';
import {InspectOptions, format, formatWithOptions, inspect} from 'util';
import {type InspectOptions, format, formatWithOptions, inspect} from 'util';
import chalk = require('chalk');
import {ErrorWithStack, formatTime, invariant} from 'jest-util';
import type {

View File

@ -8,7 +8,7 @@
import {AssertionError, strict as assert} from 'assert';
import {Console} from 'console';
import type {WriteStream} from 'tty';
import {InspectOptions, format, formatWithOptions, inspect} from 'util';
import {type InspectOptions, format, formatWithOptions, inspect} from 'util';
import chalk = require('chalk');
import {clearLine, formatTime} from 'jest-util';
import type {LogCounters, LogMessage, LogTimers, LogType} from './types';

View File

@ -8,8 +8,8 @@
import chalk = require('chalk');
import type {Config} from '@jest/types';
import {
StackTraceConfig,
StackTraceOptions,
type StackTraceConfig,
type StackTraceOptions,
formatStackTrace,
} from 'jest-message-util';
import type {ConsoleBuffer} from './types';

View File

@ -7,8 +7,8 @@
import {
PatternPrompt,
Prompt,
ScrollOptions,
type Prompt,
type ScrollOptions,
printPatternCaret,
printRestoredPatternCaret,
} from 'jest-watcher';

View File

@ -7,8 +7,8 @@
import {
PatternPrompt,
Prompt,
ScrollOptions,
type Prompt,
type ScrollOptions,
printPatternCaret,
printRestoredPatternCaret,
} from 'jest-watcher';

View File

@ -12,20 +12,20 @@ import {
CoverageReporter,
DefaultReporter,
GitHubActionsReporter,
BaseReporter as JestReporter,
type BaseReporter as JestReporter,
NotifyReporter,
Reporter,
ReporterContext,
type Reporter,
type ReporterContext,
SummaryReporter,
SummaryReporterOptions,
type SummaryReporterOptions,
VerboseReporter,
} from '@jest/reporters';
import {
AggregatedResult,
SerializableError,
Test,
TestContext,
TestResult,
type AggregatedResult,
type SerializableError,
type Test,
type TestContext,
type TestResult,
addResult,
buildFailureTestResult,
makeEmptyAggregatedTestResult,

View File

@ -7,7 +7,10 @@
import chalk = require('chalk');
import type {Config} from '@jest/types';
import {ChangedFilesPromise, getChangedFilesForRoots} from 'jest-changed-files';
import {
type ChangedFilesPromise,
getChangedFilesForRoots,
} from 'jest-changed-files';
import {formatExecError} from 'jest-message-util';
export default function getChangedFilesPromise(

View File

@ -9,9 +9,9 @@ import type {AggregatedResult, AssertionLocation} from '@jest/test-result';
import type {Config} from '@jest/types';
import {
BaseWatchPlugin,
JestHookSubscriber,
UpdateConfigCallback,
UsageData,
type JestHookSubscriber,
type UpdateConfigCallback,
type UsageData,
} from 'jest-watcher';
import FailedTestsInteractiveMode from '../FailedTestsInteractiveMode';

View File

@ -6,7 +6,7 @@
*/
import type {ReadStream, WriteStream} from 'tty';
import {BaseWatchPlugin, UsageData} from 'jest-watcher';
import {BaseWatchPlugin, type UsageData} from 'jest-watcher';
class QuitPlugin extends BaseWatchPlugin {
isInternal: true;

View File

@ -10,8 +10,8 @@ import type {Config} from '@jest/types';
import {
BaseWatchPlugin,
Prompt,
UpdateConfigCallback,
UsageData,
type UpdateConfigCallback,
type UsageData,
} from 'jest-watcher';
import TestNamePatternPrompt from '../TestNamePatternPrompt';
import activeFilters from '../lib/activeFiltersMessage';

View File

@ -10,8 +10,8 @@ import type {Config} from '@jest/types';
import {
BaseWatchPlugin,
Prompt,
UpdateConfigCallback,
UsageData,
type UpdateConfigCallback,
type UsageData,
} from 'jest-watcher';
import TestPathPatternPrompt from '../TestPathPatternPrompt';
import activeFilters from '../lib/activeFiltersMessage';

View File

@ -9,9 +9,9 @@ import type {ReadStream, WriteStream} from 'tty';
import type {Config} from '@jest/types';
import {
BaseWatchPlugin,
JestHookSubscriber,
UpdateConfigCallback,
UsageData,
type JestHookSubscriber,
type UpdateConfigCallback,
type UsageData,
} from 'jest-watcher';
class UpdateSnapshotsPlugin extends BaseWatchPlugin {

View File

@ -9,7 +9,11 @@
import type {AggregatedResult, AssertionLocation} from '@jest/test-result';
import type {Config} from '@jest/types';
import {BaseWatchPlugin, JestHookSubscriber, UsageData} from 'jest-watcher';
import {
BaseWatchPlugin,
type JestHookSubscriber,
type UsageData,
} from 'jest-watcher';
import SnapshotInteractiveMode from '../SnapshotInteractiveMode';
class UpdateSnapshotInteractivePlugin extends BaseWatchPlugin {

View File

@ -13,10 +13,10 @@ import exit = require('exit');
import * as fs from 'graceful-fs';
import {CustomConsole} from '@jest/console';
import {
AggregatedResult,
Test,
TestContext,
TestResultsProcessor,
type AggregatedResult,
type Test,
type TestContext,
type TestResultsProcessor,
formatTestResults,
makeEmptyAggregatedTestResult,
} from '@jest/test-result';
@ -25,11 +25,13 @@ import type {Config} from '@jest/types';
import type {ChangedFiles, ChangedFilesPromise} from 'jest-changed-files';
import Resolver from 'jest-resolve';
import {requireOrImportModule, tryRealpath} from 'jest-util';
import {JestHook, JestHookEmitter, TestWatcher} from 'jest-watcher';
import {JestHook, type JestHookEmitter, type TestWatcher} from 'jest-watcher';
import type FailedTestsCache from './FailedTestsCache';
import SearchSource from './SearchSource';
import {TestSchedulerContext, createTestScheduler} from './TestScheduler';
import collectNodeHandles, {HandleCollectionResult} from './collectHandles';
import {type TestSchedulerContext, createTestScheduler} from './TestScheduler';
import collectNodeHandles, {
type HandleCollectionResult,
} from './collectHandles';
import getNoTestsFoundMessage from './getNoTestsFoundMessage';
import runGlobalHook from './runGlobalHook';
import type {Filter, TestRunData} from './types';

View File

@ -24,12 +24,12 @@ import {
} from 'jest-util';
import {ValidationError} from 'jest-validate';
import {
AllowedConfigOptions,
type AllowedConfigOptions,
JestHook,
KEYS,
TestWatcher,
WatchPlugin,
WatchPluginClass,
type WatchPlugin,
type WatchPluginClass,
} from 'jest-watcher';
import FailedTestsCache from './FailedTestsCache';
import SearchSource from './SearchSource';

View File

@ -8,7 +8,7 @@
import chalk = require('chalk');
import {getType} from 'jest-get-type';
import {
PrettyFormatOptions,
type PrettyFormatOptions,
format as prettyFormat,
plugins as prettyFormatPlugins,
} from 'pretty-format';

View File

@ -5,7 +5,12 @@
* LICENSE file in the root directory of this source tree.
*/
import {DIFF_DELETE, DIFF_EQUAL, DIFF_INSERT, Diff} from './cleanupSemantic';
import {
DIFF_DELETE,
DIFF_EQUAL,
DIFF_INSERT,
type Diff,
} from './cleanupSemantic';
import type {DiffOptionsColor, DiffOptionsNormalized} from './types';
const formatTrailingSpaces = (

View File

@ -5,7 +5,7 @@
* LICENSE file in the root directory of this source tree.
*/
import {DIFF_EQUAL, Diff, cleanupSemantic} from './cleanupSemantic';
import {DIFF_EQUAL, type Diff, cleanupSemantic} from './cleanupSemantic';
import {diffLinesUnified, printDiffLines} from './diffLines';
import diffStrings from './diffStrings';
import getAlignedDiffs from './getAlignedDiffs';

View File

@ -10,7 +10,7 @@ import * as util from 'util';
import type {Global} from '@jest/types';
import {format as pretty} from 'pretty-format';
import type {EachTests} from '../bind';
import {Templates, interpolateVariables} from './interpolation';
import {type Templates, interpolateVariables} from './interpolation';
const SUPPORTED_PLACEHOLDERS = /%[sdifjoOp#]/g;
const PRETTY_PLACEHOLDER = '%p';

View File

@ -9,9 +9,9 @@
import type {Global} from '@jest/types';
import type {EachTests} from '../bind';
import {
Headings,
Template,
Templates,
type Headings,
type Template,
type Templates,
interpolateVariables,
} from './interpolation';

View File

@ -5,7 +5,7 @@
* LICENSE file in the root directory of this source tree.
*/
import {Context, createContext, runInContext} from 'vm';
import {type Context, createContext, runInContext} from 'vm';
import type {
EnvironmentContext,
JestEnvironment,

View File

@ -8,7 +8,7 @@
/* eslint-disable local/prefer-spread-eventually */
import {promisify} from 'util';
import {StackTraceConfig, formatStackTrace} from 'jest-message-util';
import {type StackTraceConfig, formatStackTrace} from 'jest-message-util';
import type {
FunctionLike,
Mock,

View File

@ -6,10 +6,10 @@
*/
import {
FakeTimerWithContext,
FakeMethod as FakeableAPI,
InstalledClock,
FakeTimerInstallOpts as SinonFakeTimersConfig,
type FakeTimerWithContext,
type FakeMethod as FakeableAPI,
type InstalledClock,
type FakeTimerInstallOpts as SinonFakeTimersConfig,
withGlobal,
} from '@sinonjs/fake-timers';
import type {Config} from '@jest/types';

View File

@ -10,11 +10,11 @@ import {EventEmitter} from 'events';
import {tmpdir} from 'os';
import * as path from 'path';
import {deserialize, serialize} from 'v8';
import {Stats, readFileSync, writeFileSync} from 'graceful-fs';
import {type Stats, readFileSync, writeFileSync} from 'graceful-fs';
import type {Config} from '@jest/types';
import {escapePathForRegex} from 'jest-regex-util';
import {invariant, requireOrImportModule} from 'jest-util';
import {JestWorkerFarm, Worker} from 'jest-worker';
import {type JestWorkerFarm, Worker} from 'jest-worker';
import HasteFS from './HasteFS';
import HasteModuleMap from './ModuleMap';
import H from './constants';

View File

@ -8,7 +8,7 @@
import {EventEmitter} from 'events';
import * as path from 'path';
import anymatch, {Matcher} from 'anymatch';
import anymatch, {type Matcher} from 'anymatch';
import * as fs from 'graceful-fs';
import micromatch = require('micromatch');
// @ts-expect-error no types

View File

@ -6,7 +6,7 @@
*
*/
import Suite, {Attributes} from '../jasmine/Suite';
import Suite, {type Attributes} from '../jasmine/Suite';
describe('Suite', () => {
let suite: Suite;

View File

@ -6,7 +6,7 @@
*
*/
import queueRunner, {Options, QueueableFn} from '../queueRunner';
import queueRunner, {type Options, type QueueableFn} from '../queueRunner';
describe('queueRunner', () => {
it('runs every function in the queue.', async () => {

View File

@ -7,7 +7,7 @@
import chalk = require('chalk');
import {
DiffOptions,
type DiffOptions,
diff,
printExpected,
printReceived,

View File

@ -36,10 +36,10 @@ import {ErrorWithStack, convertDescriptorToString, isPromise} from 'jest-util';
import assertionErrorMessage from '../assertionErrorMessage';
import isError from '../isError';
import queueRunner, {
Options as QueueRunnerOptions,
QueueableFn,
type Options as QueueRunnerOptions,
type QueueableFn,
} from '../queueRunner';
import treeProcessor, {TreeNode} from '../treeProcessor';
import treeProcessor, {type TreeNode} from '../treeProcessor';
import type {
AssertionErrorWithStack,
Jasmine,

View File

@ -37,7 +37,7 @@ import {convertDescriptorToString} from 'jest-util';
import ExpectationFailed from '../ExpectationFailed';
import assertionErrorMessage from '../assertionErrorMessage';
import expectationResultFactory, {
Options as ExpectationResultFactoryOptions,
type Options as ExpectationResultFactoryOptions,
} from '../expectationResultFactory';
import type {QueueableFn, default as queueRunner} from '../queueRunner';
import type {AssertionErrorWithStack} from '../types';

View File

@ -31,7 +31,7 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
/* eslint-disable sort-keys, local/prefer-rest-params-eventually */
import type {Spy} from '../types';
import CallTracker, {Context} from './CallTracker';
import CallTracker, {type Context} from './CallTracker';
import SpyStrategy from './SpyStrategy';
interface Fn extends Record<string, unknown> {

View File

@ -6,8 +6,8 @@
*/
import {
AssertionResult,
TestResult,
type AssertionResult,
type TestResult,
createEmptyTestResult,
} from '@jest/test-result';
import type {Config} from '@jest/types';

View File

@ -10,7 +10,7 @@ import chalk = require('chalk');
import {alignedAnsiStyleSerializer} from '@jest/test-utils';
import {format as prettyFormat} from 'pretty-format';
import {
MatcherHintOptions,
type MatcherHintOptions,
diff,
ensureNoExpected,
ensureNumbers,

View File

@ -12,8 +12,8 @@ import {
DIFF_DELETE,
DIFF_EQUAL,
DIFF_INSERT,
Diff,
DiffOptions as ImportDiffOptions,
type Diff,
type DiffOptions as ImportDiffOptions,
diff as diffDefault,
diffStringsRaw,
diffStringsUnified,

View File

@ -6,7 +6,7 @@
*/
import {expectType} from 'tsd-lite';
import {MockMetadata, Mocked, ModuleMocker} from 'jest-mock';
import {type MockMetadata, type Mocked, ModuleMocker} from 'jest-mock';
class ExampleClass {
memberA: Array<number>;

View File

@ -14,12 +14,12 @@ import {
expectType,
} from 'tsd-lite';
import {
Mock,
Replaced,
SpiedClass,
SpiedFunction,
SpiedGetter,
SpiedSetter,
type Mock,
type Replaced,
type SpiedClass,
type SpiedFunction,
type SpiedGetter,
type SpiedSetter,
fn,
replaceProperty,
spyOn,

View File

@ -9,7 +9,7 @@
/* eslint-disable local/ban-types-eventually, local/prefer-rest-params-eventually */
import * as util from 'util';
import {Context, createContext, runInContext, runInNewContext} from 'vm';
import {type Context, createContext, runInContext, runInNewContext} from 'vm';
import {ModuleMocker, fn, mocked, spyOn} from '../';
describe('moduleMocker', () => {

View File

@ -7,11 +7,11 @@
import {expectError, expectType} from 'tsd-lite';
import {
AggregatedResult,
Config,
SnapshotSummary,
SummaryOptions,
TestResult,
type AggregatedResult,
type Config,
type SnapshotSummary,
type SummaryOptions,
type TestResult,
utils,
} from '@jest/reporters';

View File

@ -26,7 +26,7 @@ import type {
} from '@jest/test-result';
import type {Config} from '@jest/types';
import {clearLine, isInteractive} from 'jest-util';
import {JestWorkerFarm, Worker} from 'jest-worker';
import {type JestWorkerFarm, Worker} from 'jest-worker';
import BaseReporter from './BaseReporter';
import getWatermarks from './getWatermarks';
import type {ReporterContext} from './types';

View File

@ -9,7 +9,7 @@ import exit = require('exit');
import * as fs from 'graceful-fs';
import type {Config} from '@jest/types';
import generateEmptyCoverage, {
CoverageWorkerResult,
type CoverageWorkerResult,
} from './generateEmptyCoverage';
import type {ReporterContext} from './types';

View File

@ -7,7 +7,7 @@
import type {V8Coverage} from 'collect-v8-coverage';
import * as fs from 'graceful-fs';
import {FileCoverage, createFileCoverage} from 'istanbul-lib-coverage';
import {type FileCoverage, createFileCoverage} from 'istanbul-lib-coverage';
import {readInitialCoverage} from 'istanbul-lib-instrument';
import {createScriptTransformer, shouldInstrument} from '@jest/transform';
import type {Config} from '@jest/types';

View File

@ -8,7 +8,7 @@
import * as path from 'path';
import type {IHasteFS} from 'jest-haste-map';
import type {ResolveModuleConfig, default as Resolver} from 'jest-resolve';
import {SnapshotResolver, isSnapshotPath} from 'jest-snapshot';
import {type SnapshotResolver, isSnapshotPath} from 'jest-snapshot';
export type ResolvedModule = {
file: string;

View File

@ -9,10 +9,10 @@
import * as path from 'path';
import * as fs from 'graceful-fs';
import {sync as resolveSync} from 'resolve';
import {IModuleMap, ModuleMap} from 'jest-haste-map';
import {type IModuleMap, ModuleMap} from 'jest-haste-map';
import userResolver from '../__mocks__/userResolver';
import userResolverAsync from '../__mocks__/userResolverAsync';
import defaultResolver, {PackageFilter} from '../defaultResolver';
import defaultResolver, {type PackageFilter} from '../defaultResolver';
import nodeModulesPaths from '../nodeModulesPaths';
import Resolver from '../resolver';
import type {ResolverConfig} from '../types';

View File

@ -7,7 +7,10 @@
import {dirname, isAbsolute, resolve as pathResolve} from 'path';
import pnpResolver from 'jest-pnp-resolver';
import {SyncOpts as UpstreamResolveOptions, sync as resolveSync} from 'resolve';
import {
type SyncOpts as UpstreamResolveOptions,
sync as resolveSync,
} from 'resolve';
import * as resolve from 'resolve.exports';
import {
findClosestPackageJson,

View File

@ -14,9 +14,9 @@ import type {IModuleMap} from 'jest-haste-map';
import {tryRealpath} from 'jest-util';
import ModuleNotFoundError from './ModuleNotFoundError';
import defaultResolver, {
AsyncResolver,
Resolver as ResolverInterface,
SyncResolver,
type AsyncResolver,
type Resolver as ResolverInterface,
type SyncResolver,
} from './defaultResolver';
import {clearFsCache} from './fileWalkers';
import isBuiltinModule from './isBuiltinModule';

View File

@ -8,19 +8,19 @@
import {expectType} from 'tsd-lite';
import {
CallbackTestRunner,
CallbackTestRunnerInterface,
Config,
type CallbackTestRunnerInterface,
type Config,
EmittingTestRunner,
EmittingTestRunnerInterface,
OnTestFailure,
OnTestStart,
OnTestSuccess,
Test,
TestEvents,
TestRunnerContext,
TestRunnerOptions,
TestWatcher,
UnsubscribeFn,
type EmittingTestRunnerInterface,
type OnTestFailure,
type OnTestStart,
type OnTestSuccess,
type Test,
type TestEvents,
type TestRunnerContext,
type TestRunnerOptions,
type TestWatcher,
type UnsubscribeFn,
} from 'jest-runner';
const globalConfig = {} as Config.GlobalConfig;

View File

@ -16,10 +16,18 @@ import type {
} from '@jest/test-result';
import {deepCyclicCopy} from 'jest-util';
import type {TestWatcher} from 'jest-watcher';
import {JestWorkerFarm, PromiseWithCustomMessage, Worker} from 'jest-worker';
import {
type JestWorkerFarm,
type PromiseWithCustomMessage,
Worker,
} from 'jest-worker';
import runTest from './runTest';
import type {SerializableResolver} from './testWorker';
import {EmittingTestRunner, TestRunnerOptions, UnsubscribeFn} from './types';
import {
EmittingTestRunner,
type TestRunnerOptions,
type UnsubscribeFn,
} from './types';
export type {Test, TestEvents} from '@jest/test-result';
export type {Config} from '@jest/types';

View File

@ -12,8 +12,8 @@ import sourcemapSupport = require('source-map-support');
import {
BufferedConsole,
CustomConsole,
LogMessage,
LogType,
type LogMessage,
type LogType,
NullConsole,
getConsoleOutput,
} from '@jest/console';
@ -24,6 +24,7 @@ import type {Config} from '@jest/types';
import * as docblock from 'jest-docblock';
import LeakDetector from 'jest-leak-detector';
import {formatExecError} from 'jest-message-util';
// eslint-disable-next-line @typescript-eslint/consistent-type-imports
import Resolver, {resolveTestEnvironment} from 'jest-resolve';
import type RuntimeClass from 'jest-runtime';
import {ErrorWithStack, interopRequireDefault, setGlobal} from 'jest-util';

View File

@ -13,7 +13,7 @@ import type {
TestResult,
} from '@jest/test-result';
import type {Config} from '@jest/types';
import HasteMap, {SerializableModuleMap} from 'jest-haste-map';
import HasteMap, {type SerializableModuleMap} from 'jest-haste-map';
import {separateMessageFromStack} from 'jest-message-util';
import type Resolver from 'jest-resolve';
import Runtime from 'jest-runtime';

View File

@ -14,12 +14,12 @@ import {
SourceTextModule,
// @ts-expect-error: experimental, not added to the types
SyntheticModule,
Context as VMContext,
type Context as VMContext,
// @ts-expect-error: experimental, not added to the types
Module as VMModule,
type Module as VMModule,
} from 'vm';
import {parse as parseCjs} from 'cjs-module-lexer';
import {CoverageInstrumenter, V8Coverage} from 'collect-v8-coverage';
import {CoverageInstrumenter, type V8Coverage} from 'collect-v8-coverage';
import * as fs from 'graceful-fs';
import slash = require('slash');
import stripBOM = require('strip-bom');
@ -39,19 +39,19 @@ import type {
V8CoverageResult,
} from '@jest/test-result';
import {
CallerTransformOptions,
ScriptTransformer,
ShouldInstrumentOptions,
TransformationOptions,
type CallerTransformOptions,
type ScriptTransformer,
type ShouldInstrumentOptions,
type TransformationOptions,
handlePotentialSyntaxError,
shouldInstrument,
} from '@jest/transform';
import type {Config, Global} from '@jest/types';
import HasteMap, {IHasteMap, IModuleMap} from 'jest-haste-map';
import HasteMap, {type IHasteMap, type IModuleMap} from 'jest-haste-map';
import {formatStackTrace, separateMessageFromStack} from 'jest-message-util';
import type {MockMetadata, ModuleMocker} from 'jest-mock';
import {escapePathForRegex} from 'jest-regex-util';
import Resolver, {ResolveModuleConfig} from 'jest-resolve';
import Resolver, {type ResolveModuleConfig} from 'jest-resolve';
import {EXTENSION as SnapshotExtension} from 'jest-snapshot';
import {
createDirectory,

View File

@ -5,7 +5,7 @@
* LICENSE file in the root directory of this source tree.
*/
import {Static, Type} from '@sinclair/typebox';
import {type Static, Type} from '@sinclair/typebox';
const RawSnapshotFormat = Type.Partial(
Type.Object({

View File

@ -8,8 +8,8 @@
import {expectError, expectType} from 'tsd-lite';
import type {ExpectationResult} from 'expect';
import {
Context,
SnapshotState,
type Context,
type SnapshotState,
toMatchInlineSnapshot,
toMatchSnapshot,
toThrowErrorMatchingInlineSnapshot,

View File

@ -7,7 +7,10 @@
import * as path from 'path';
import {makeProjectConfig} from '@jest/test-utils';
import {SnapshotResolver, buildSnapshotResolver} from '../SnapshotResolver';
import {
type SnapshotResolver,
buildSnapshotResolver,
} from '../SnapshotResolver';
describe('defaults', () => {
let snapshotResolver: SnapshotResolver;

View File

@ -11,7 +11,7 @@ import chalk = require('chalk');
import type {SyncExpectationResult} from 'expect';
import format from 'pretty-format';
import {
Context,
type Context,
toMatchInlineSnapshot,
toMatchSnapshot,
toThrowErrorMatchingInlineSnapshot,

View File

@ -12,14 +12,14 @@ import type {MatcherFunctionWithContext} from 'expect';
import {
BOLD_WEIGHT,
EXPECTED_COLOR,
MatcherHintOptions,
type MatcherHintOptions,
RECEIVED_COLOR,
matcherErrorMessage,
matcherHint,
printWithType,
stringify,
} from 'jest-matcher-utils';
import {EXTENSION, SnapshotResolver} from './SnapshotResolver';
import {EXTENSION, type SnapshotResolver} from './SnapshotResolver';
import {
PROPERTIES_ARG,
SNAPSHOT_ARG,

View File

@ -6,8 +6,8 @@
*/
import {
Plugin as PrettyFormatPlugin,
Plugins as PrettyFormatPlugins,
type Plugin as PrettyFormatPlugin,
type Plugins as PrettyFormatPlugins,
plugins as prettyFormatPlugins,
} from 'pretty-format';
import jestMockSerializer from './mockSerializer';

View File

@ -11,8 +11,8 @@ import {
DIFF_DELETE,
DIFF_EQUAL,
DIFF_INSERT,
Diff,
DiffOptionsColor,
type Diff,
type DiffOptionsColor,
diffLinesUnified,
diffLinesUnified2,
diffStringsRaw,
@ -23,7 +23,7 @@ import {
BOLD_WEIGHT,
EXPECTED_COLOR,
INVERTED_COLOR,
MatcherHintOptions,
type MatcherHintOptions,
RECEIVED_COLOR,
getLabelPrinter,
matcherHint,

View File

@ -19,7 +19,7 @@ import * as fs from 'graceful-fs';
import naturalCompare = require('natural-compare');
import type {Config} from '@jest/types';
import {
OptionsReceived as PrettyFormatOptions,
type OptionsReceived as PrettyFormatOptions,
format as prettyFormat,
} from 'pretty-format';
import {getSerializers} from './plugins';

View File

@ -20,7 +20,7 @@ Another use-case for `@types/jest` is a typed Jest config as those types are not
```ts
// jest.config.ts
import {Config} from '@jest/types';
import type {Config} from '@jest/types';
const config: Config.InitialOptions = {
// some typed config

View File

@ -8,17 +8,17 @@
import FifoQueue from './FifoQueue';
import {
CHILD_MESSAGE_CALL,
ChildMessage,
OnCustomMessage,
OnEnd,
OnStart,
PromiseWithCustomMessage,
QueueChildMessage,
TaskQueue,
WorkerCallback,
WorkerFarmOptions,
WorkerInterface,
WorkerSchedulingPolicy,
type ChildMessage,
type OnCustomMessage,
type OnEnd,
type OnStart,
type PromiseWithCustomMessage,
type QueueChildMessage,
type TaskQueue,
type WorkerCallback,
type WorkerFarmOptions,
type WorkerInterface,
type WorkerSchedulingPolicy,
} from './types';
export default class Farm {

View File

@ -8,8 +8,8 @@
import FifoQueue from '../FifoQueue';
import {
CHILD_MESSAGE_CALL,
ChildMessageCall,
QueueChildMessage,
type ChildMessageCall,
type QueueChildMessage,
} from '../types';
it('returns the shared tasks in FIFO ordering', () => {

View File

@ -8,8 +8,8 @@
import PriorityQueue from '../PriorityQueue';
import {
CHILD_MESSAGE_CALL,
ChildMessageCall,
QueueChildMessage,
type ChildMessageCall,
type QueueChildMessage,
} from '../types';
it('returns the tasks in order', () => {

View File

@ -9,7 +9,7 @@ import {tmpdir} from 'os';
import {join} from 'path';
import {writeFileSync} from 'graceful-fs';
import LeakDetector from 'jest-leak-detector';
import {JestWorkerFarm, Worker} from '../../build';
import {type JestWorkerFarm, Worker} from '../../build';
describe('WorkerThreads leaks', () => {
let workerFile: string;

View File

@ -9,10 +9,10 @@ import mergeStream = require('merge-stream');
import {
CHILD_MESSAGE_CALL_SETUP,
CHILD_MESSAGE_END,
PoolExitResult,
WorkerInterface,
WorkerOptions,
WorkerPoolOptions,
type PoolExitResult,
type WorkerInterface,
type WorkerOptions,
type WorkerPoolOptions,
WorkerStates,
} from '../types';

View File

@ -7,9 +7,9 @@
import {
CHILD_MESSAGE_END,
WorkerInterface,
WorkerOptions,
WorkerPoolOptions,
type WorkerInterface,
type WorkerOptions,
type WorkerPoolOptions,
} from '../../types';
import BaseWorkerPool from '../BaseWorkerPool';

View File

@ -5,25 +5,25 @@
* LICENSE file in the root directory of this source tree.
*/
import {ChildProcess, ForkOptions, fork} from 'child_process';
import {type ChildProcess, type ForkOptions, fork} from 'child_process';
import {totalmem} from 'os';
import mergeStream = require('merge-stream');
import {stdout as stdoutSupportsColor} from 'supports-color';
import {
CHILD_MESSAGE_INITIALIZE,
CHILD_MESSAGE_MEM_USAGE,
ChildMessage,
OnCustomMessage,
OnEnd,
OnStart,
type ChildMessage,
type OnCustomMessage,
type OnEnd,
type OnStart,
PARENT_MESSAGE_CLIENT_ERROR,
PARENT_MESSAGE_CUSTOM,
PARENT_MESSAGE_MEM_USAGE,
PARENT_MESSAGE_OK,
PARENT_MESSAGE_SETUP_ERROR,
ParentMessage,
WorkerInterface,
WorkerOptions,
type ParentMessage,
type WorkerInterface,
type WorkerOptions,
WorkerStates,
} from '../types';
import WorkerAbstract from './WorkerAbstract';

View File

@ -11,18 +11,18 @@ import mergeStream = require('merge-stream');
import {
CHILD_MESSAGE_INITIALIZE,
CHILD_MESSAGE_MEM_USAGE,
ChildMessage,
OnCustomMessage,
OnEnd,
OnStart,
type ChildMessage,
type OnCustomMessage,
type OnEnd,
type OnStart,
PARENT_MESSAGE_CLIENT_ERROR,
PARENT_MESSAGE_CUSTOM,
PARENT_MESSAGE_MEM_USAGE,
PARENT_MESSAGE_OK,
PARENT_MESSAGE_SETUP_ERROR,
ParentMessage,
WorkerInterface,
WorkerOptions,
type ParentMessage,
type WorkerInterface,
type WorkerOptions,
WorkerStates,
} from '../types';
import WorkerAbstract from './WorkerAbstract';

View File

@ -8,8 +8,8 @@
import {EventEmitter, PassThrough} from 'stream';
import {
WorkerEvents,
WorkerInterface,
WorkerOptions,
type WorkerInterface,
type WorkerOptions,
WorkerStates,
} from '../types';

View File

@ -13,13 +13,13 @@ import {
CHILD_MESSAGE_CALL,
CHILD_MESSAGE_INITIALIZE,
CHILD_MESSAGE_MEM_USAGE,
ChildMessage,
ChildMessageCall,
type ChildMessage,
type ChildMessageCall,
PARENT_MESSAGE_CLIENT_ERROR,
PARENT_MESSAGE_CUSTOM,
PARENT_MESSAGE_MEM_USAGE,
PARENT_MESSAGE_OK,
WorkerOptions,
type WorkerOptions,
} from '../../types';
jest.useFakeTimers();

View File

@ -11,11 +11,11 @@ import getStream = require('get-stream');
import {
CHILD_MESSAGE_CALL,
CHILD_MESSAGE_INITIALIZE,
ChildMessageCall,
type ChildMessageCall,
PARENT_MESSAGE_CLIENT_ERROR,
PARENT_MESSAGE_CUSTOM,
PARENT_MESSAGE_OK,
WorkerOptions,
type WorkerOptions,
} from '../../types';
let Worker: typeof import('../NodeThreadsWorker').default;

View File

@ -11,7 +11,7 @@ import {transformFileAsync} from '@babel/core';
import {
CHILD_MESSAGE_CALL,
WorkerEvents,
WorkerOptions,
type WorkerOptions,
WorkerStates,
} from '../../types';
import ChildProcessWorker, {SIGKILL_DELAY} from '../ChildProcessWorker';

View File

@ -12,14 +12,14 @@ import {
CHILD_MESSAGE_END,
CHILD_MESSAGE_INITIALIZE,
CHILD_MESSAGE_MEM_USAGE,
ChildMessageCall,
ChildMessageInitialize,
type ChildMessageCall,
type ChildMessageInitialize,
PARENT_MESSAGE_CLIENT_ERROR,
PARENT_MESSAGE_ERROR,
type PARENT_MESSAGE_ERROR,
PARENT_MESSAGE_MEM_USAGE,
PARENT_MESSAGE_OK,
PARENT_MESSAGE_SETUP_ERROR,
ParentMessageMemUsage,
type ParentMessageMemUsage,
} from '../types';
type UnknownFunction = (...args: Array<unknown>) => unknown | Promise<unknown>;

View File

@ -13,14 +13,14 @@ import {
CHILD_MESSAGE_END,
CHILD_MESSAGE_INITIALIZE,
CHILD_MESSAGE_MEM_USAGE,
ChildMessageCall,
ChildMessageInitialize,
type ChildMessageCall,
type ChildMessageInitialize,
PARENT_MESSAGE_CLIENT_ERROR,
PARENT_MESSAGE_ERROR,
type PARENT_MESSAGE_ERROR,
PARENT_MESSAGE_MEM_USAGE,
PARENT_MESSAGE_OK,
PARENT_MESSAGE_SETUP_ERROR,
ParentMessageMemUsage,
type ParentMessageMemUsage,
} from '../types';
type UnknownFunction = (...args: Array<unknown>) => unknown | Promise<unknown>;

View File

@ -7,7 +7,7 @@
/* eslint-disable local/prefer-rest-params-eventually */
import prettyFormat, {PrettyFormatOptions} from '../';
import prettyFormat, {type PrettyFormatOptions} from '../';
function returnArguments(..._args: Array<unknown>) {
return arguments;

View File

@ -736,7 +736,7 @@ export function setDateNow(now: number): jest.Spied<typeof Date.now> {
```
```ts
import {afterEach, expect, jest, test} from '@jest/globals';
import {afterEach, expect, type jest, test} from '@jest/globals';
import {setDateNow} from './__utils__/setDateNow';
let spiedDateNow: jest.Spied<typeof Date.now> | undefined = undefined;

Some files were not shown because too many files have changed in this diff Show More