From f9132f9106e3f1b3ae6f81d1f36222055c3fe111 Mon Sep 17 00:00:00 2001 From: Simen Bekkhus Date: Sat, 31 Oct 2020 20:48:50 +0100 Subject: [PATCH] chore: sort imports alphabetically (#10757) --- .eslintrc.js | 35 +++++++++++++++- docs/BypassingModuleMocks.md | 1 - docs/Configuration.md | 2 +- docs/Es6ClassMocks.md | 2 +- docs/JestObjectAPI.md | 3 +- docs/Puppeteer.md | 4 +- e2e/Utils.ts | 8 ++-- e2e/__tests__/asyncAndCallback.test.ts | 4 +- e2e/__tests__/babelPluginJestHoist.test.ts | 2 +- e2e/__tests__/beforeEachQueue.ts | 2 +- e2e/__tests__/chaiAssertionLibrary.ts | 2 +- e2e/__tests__/circusDeclarationErrors.test.ts | 2 +- e2e/__tests__/customMatcherStackTrace.test.ts | 2 +- e2e/__tests__/customReporters.test.ts | 2 +- e2e/__tests__/customTestSequencers.test.ts | 2 +- e2e/__tests__/dependencyClash.test.ts | 2 +- e2e/__tests__/domDiffing.test.ts | 2 +- e2e/__tests__/each.test.ts | 2 +- e2e/__tests__/emptyDescribeWithHooks.test.ts | 2 +- e2e/__tests__/errorOnDeprecated.test.ts | 2 +- e2e/__tests__/existentRoots.test.ts | 2 +- e2e/__tests__/expectAsyncMatcher.test.ts | 2 +- e2e/__tests__/fatalWorkerError.test.ts | 2 +- e2e/__tests__/forceExit.test.ts | 2 +- e2e/__tests__/globalSetup.test.ts | 2 +- e2e/__tests__/globalTeardown.test.ts | 2 +- e2e/__tests__/globals.test.ts | 4 +- e2e/__tests__/injectGlobals.test.ts | 4 +- e2e/__tests__/jest.config.js.test.ts | 2 +- e2e/__tests__/jest.config.ts.test.ts | 2 +- e2e/__tests__/jestChangedFiles.test.ts | 2 +- e2e/__tests__/jestEnvironmentJsdom.test.ts | 2 +- e2e/__tests__/jestRequireActual.test.ts | 2 +- e2e/__tests__/jestRequireMock.test.ts | 2 +- e2e/__tests__/logHeapUsage.test.ts | 2 +- e2e/__tests__/moduleNameMapper.test.ts | 2 +- e2e/__tests__/nativeEsm.test.ts | 2 +- e2e/__tests__/nestedTestDefinitions.test.ts | 2 +- e2e/__tests__/onlyChanged.test.ts | 2 +- e2e/__tests__/pnp.test.ts | 2 +- e2e/__tests__/promiseReject.test.ts | 2 +- e2e/__tests__/resolveNoFileExtensions.test.ts | 2 +- e2e/__tests__/resolveWithPaths.test.ts | 2 +- e2e/__tests__/runProgrammatically.test.ts | 1 - e2e/__tests__/runTestsByPath.test.ts | 2 +- e2e/__tests__/selectProjects.test.ts | 1 - .../setupFilesAfterEnvConfig.test.ts | 2 +- e2e/__tests__/showConfig.test.ts | 4 +- e2e/__tests__/snapshotMockFs.test.ts | 2 +- e2e/__tests__/stackTrace.test.ts | 2 +- e2e/__tests__/testEnvironment.test.ts | 1 - e2e/__tests__/testEnvironmentAsync.test.ts | 4 +- e2e/__tests__/testFailureExitCode.test.ts | 2 +- .../testPathPatternReporterMessage.test.ts | 2 +- e2e/__tests__/testTodo.test.ts | 2 +- e2e/__tests__/transform.test.ts | 2 +- e2e/__tests__/unexpectedToken.test.ts | 2 +- e2e/__tests__/useStderr.test.ts | 2 +- e2e/__tests__/version.test.ts | 2 +- e2e/__tests__/watchModeOnlyFailed.test.ts | 2 +- e2e/__tests__/watchModePatterns.test.ts | 2 +- e2e/__tests__/watchModeUpdateSnapshot.test.ts | 2 +- e2e/__tests__/workerForceExit.test.ts | 1 - e2e/__tests__/wrongEnv.test.ts | 2 +- .../__tests__/importJest.test.js | 1 - .../__tests__/integration.test.js | 3 +- .../__tests__/typescript.test.ts | 2 +- e2e/native-esm/__tests__/native-esm.test.js | 8 ++-- e2e/runJest.ts | 6 +-- e2e/test-environment-async/TestEnvironment.js | 2 +- e2e/test-retries/__tests__/e2e.test.js | 2 +- .../__tests__/multipleTransformers.test.js | 1 - .../multiple-transformers/src/App.js | 3 +- packages/babel-jest/src/__tests__/index.ts | 2 +- packages/babel-jest/src/index.ts | 12 +++--- packages/babel-plugin-jest-hoist/src/index.ts | 4 +- packages/diff-sequences/perf/index.js | 1 - .../src/__tests__/asymmetricMatchers.test.ts | 1 - packages/expect/src/__tests__/extend.test.ts | 6 +-- .../matchers-toStrictEqual.property.test.ts | 2 +- .../expect/src/__tests__/matchers.test.js | 6 +-- packages/expect/src/asymmetricMatchers.ts | 1 - packages/expect/src/index.ts | 41 +++++++++---------- packages/expect/src/matchers.ts | 4 +- packages/expect/src/spyMatchers.ts | 2 +- packages/expect/src/toThrowMatchers.ts | 2 +- packages/jest-changed-files/src/git.ts | 1 - packages/jest-changed-files/src/hg.ts | 1 - packages/jest-changed-files/src/index.ts | 3 +- packages/jest-circus/README.md | 2 +- .../jest-circus/src/__mocks__/testUtils.ts | 4 +- packages/jest-circus/src/eventHandler.ts | 9 ++-- .../jest-circus/src/formatNodeAssertErrors.ts | 2 +- packages/jest-circus/src/index.ts | 2 +- .../legacy-code-todo-rewrite/jestAdapter.ts | 2 +- .../jestAdapterInit.ts | 12 +++--- .../legacy-code-todo-rewrite/jestExpect.ts | 1 - packages/jest-circus/src/run.ts | 3 +- packages/jest-circus/src/state.ts | 5 +-- packages/jest-circus/src/types.ts | 2 +- packages/jest-circus/src/utils.ts | 8 ++-- .../jest-cli/src/__tests__/cli/args.test.ts | 2 +- packages/jest-cli/src/cli/args.ts | 2 +- packages/jest-cli/src/cli/index.ts | 12 +++--- packages/jest-cli/src/init/index.ts | 4 +- packages/jest-config/src/Deprecated.ts | 2 +- .../src/ReporterValidationErrors.ts | 4 +- .../src/__tests__/normalize.test.js | 3 +- .../src/__tests__/resolveConfigPath.test.ts | 3 +- packages/jest-config/src/getCacheDirectory.ts | 2 +- packages/jest-config/src/index.ts | 8 ++-- packages/jest-config/src/normalize.ts | 30 +++++++------- .../src/readConfigFileAndSetRootDir.ts | 6 +-- packages/jest-config/src/setFromArgv.ts | 2 +- packages/jest-config/src/utils.ts | 4 +- packages/jest-console/src/CustomConsole.ts | 2 +- .../src/__tests__/getConsoleOutput.test.ts | 4 +- packages/jest-console/src/getConsoleOutput.ts | 2 +- packages/jest-core/src/FailedTestsCache.ts | 4 +- packages/jest-core/src/ReporterDispatcher.ts | 2 +- packages/jest-core/src/SearchSource.ts | 8 ++-- .../jest-core/src/SnapshotInteractiveMode.ts | 4 +- .../jest-core/src/TestNamePatternPrompt.ts | 2 +- .../jest-core/src/TestPathPatternPrompt.ts | 3 +- packages/jest-core/src/TestScheduler.ts | 12 +++--- .../src/__tests__/SearchSource.test.ts | 4 +- .../src/__tests__/TestScheduler.test.js | 2 +- .../jest-core/src/__tests__/watch.test.js | 1 + .../src/__tests__/watchFileChanges.test.ts | 10 ++--- .../watchFilenamePatternMode.test.js | 1 + .../watchTestNamePatternMode.test.js | 1 + packages/jest-core/src/cli/index.ts | 34 +++++++-------- packages/jest-core/src/collectHandles.ts | 2 +- .../jest-core/src/getChangedFilesPromise.ts | 2 +- packages/jest-core/src/getNoTestFound.ts | 2 +- .../jest-core/src/getNoTestsFoundMessage.ts | 6 +-- .../src/lib/__tests__/isValidPath.test.ts | 2 +- .../lib/__tests__/logDebugMessages.test.ts | 2 +- packages/jest-core/src/lib/createContext.ts | 2 +- .../jest-core/src/lib/logDebugMessages.ts | 1 - .../jest-core/src/lib/updateGlobalConfig.ts | 2 +- .../src/plugins/UpdateSnapshotsInteractive.ts | 2 +- packages/jest-core/src/runGlobalHook.ts | 2 +- packages/jest-core/src/runJest.ts | 20 ++++----- packages/jest-core/src/types.ts | 4 +- packages/jest-core/src/watch.ts | 28 ++++++------- .../src/index.ts | 4 +- packages/jest-diff/src/__tests__/diff.test.ts | 3 +- packages/jest-diff/src/diffStrings.ts | 1 - packages/jest-diff/src/index.ts | 6 +-- .../jest-diff/src/normalizeDiffOptions.ts | 1 - packages/jest-each/src/bind.ts | 1 - packages/jest-each/src/table/array.ts | 3 +- packages/jest-each/src/table/template.ts | 4 +- packages/jest-each/src/validation.ts | 2 +- packages/jest-environment-jsdom/src/index.ts | 8 ++-- packages/jest-environment-node/src/index.ts | 4 +- packages/jest-environment/src/index.ts | 2 +- .../jest-fake-timers/src/legacyFakeTimers.ts | 2 +- packages/jest-globals/src/index.ts | 2 +- packages/jest-haste-map/src/HasteFS.ts | 6 +-- packages/jest-haste-map/src/ModuleMap.ts | 5 +-- .../src/__tests__/index.test.js | 2 +- .../src/__tests__/worker.test.js | 3 +- packages/jest-haste-map/src/crawlers/node.ts | 2 +- .../jest-haste-map/src/crawlers/watchman.ts | 2 +- packages/jest-haste-map/src/index.ts | 21 +++++----- .../jest-haste-map/src/lib/FSEventsWatcher.ts | 4 +- .../jest-haste-map/src/lib/WatchmanWatcher.js | 4 +- packages/jest-haste-map/src/types.ts | 2 +- packages/jest-haste-map/src/worker.ts | 2 +- .../src/__tests__/reporter.test.ts | 4 +- .../src/assertionErrorMessage.ts | 2 +- .../src/expectationResultFactory.ts | 2 +- packages/jest-jasmine2/src/index.ts | 13 +++--- packages/jest-jasmine2/src/jasmine/Env.ts | 4 +- packages/jest-jasmine2/src/jasmine/Spec.ts | 5 +-- packages/jest-jasmine2/src/jasmine/Suite.ts | 2 +- .../jest-jasmine2/src/jasmine/jasmineLight.ts | 4 +- .../jest-jasmine2/src/jasmine/spyRegistry.ts | 2 +- .../jest-jasmine2/src/jasmineAsyncInstall.ts | 4 +- packages/jest-jasmine2/src/jestExpect.ts | 2 +- packages/jest-jasmine2/src/reporter.ts | 2 +- .../jest-jasmine2/src/setup_jest_globals.ts | 2 +- packages/jest-jasmine2/src/types.ts | 13 +++--- packages/jest-leak-detector/src/index.ts | 4 +- .../src/__tests__/index.test.ts | 2 +- packages/jest-message-util/src/index.ts | 8 ++-- packages/jest-repl/src/cli/index.ts | 7 ++-- .../jest-reporters/src/CoverageReporter.ts | 22 +++++----- packages/jest-reporters/src/CoverageWorker.ts | 5 +-- .../jest-reporters/src/DefaultReporter.ts | 9 ++-- packages/jest-reporters/src/NotifyReporter.ts | 4 +- packages/jest-reporters/src/Status.ts | 6 +-- .../jest-reporters/src/SummaryReporter.ts | 8 ++-- .../jest-reporters/src/VerboseReporter.ts | 6 +-- .../src/__tests__/NotifyReporter.test.ts | 2 +- .../__tests__/generateEmptyCoverage.test.js | 7 ++-- .../src/__tests__/getWatermarks.test.ts | 2 +- .../src/__tests__/utils.test.ts | 2 +- .../src/generateEmptyCoverage.ts | 6 +-- .../jest-reporters/src/getResultHeader.ts | 6 +-- .../jest-reporters/src/getSnapshotSummary.ts | 4 +- packages/jest-reporters/src/getWatermarks.ts | 2 +- packages/jest-reporters/src/types.ts | 2 +- packages/jest-reporters/src/utils.ts | 4 +- .../src/__tests__/dependency_resolver.test.ts | 2 +- .../jest-resolve/src/ModuleNotFoundError.ts | 2 +- .../src/__tests__/resolve.test.ts | 4 +- packages/jest-resolve/src/defaultResolver.ts | 4 +- packages/jest-resolve/src/index.ts | 12 +++--- packages/jest-resolve/src/shouldLoadAsEsm.ts | 2 +- packages/jest-runner/src/index.ts | 8 ++-- packages/jest-runner/src/runTest.ts | 18 ++++---- packages/jest-runner/src/testWorker.ts | 9 ++-- packages/jest-runner/src/types.ts | 4 +- .../src/__tests__/instrumentation.test.ts | 2 +- packages/jest-runtime/src/cli/index.ts | 6 +-- packages/jest-runtime/src/helpers.ts | 2 +- packages/jest-runtime/src/index.ts | 30 +++++++------- packages/jest-runtime/src/types.ts | 2 +- .../src/__tests__/index.test.ts | 1 - packages/jest-snapshot/src/InlineSnapshots.ts | 6 +-- .../jest-snapshot/src/SnapshotResolver.ts | 2 +- packages/jest-snapshot/src/State.ts | 5 +-- .../src/__tests__/InlineSnapshots.test.ts | 3 +- .../src/__tests__/SnapshotResolver.test.ts | 1 - .../src/__tests__/mockSerializer.test.ts | 1 - .../src/__tests__/printSnapshot.test.ts | 19 ++++----- .../jest-snapshot/src/__tests__/utils.test.ts | 5 +-- packages/jest-snapshot/src/index.ts | 1 - packages/jest-snapshot/src/plugins.ts | 1 - packages/jest-snapshot/src/printSnapshot.ts | 1 - packages/jest-snapshot/src/utils.ts | 2 +- packages/jest-source-map/src/getCallsite.ts | 2 +- packages/jest-test-result/src/types.ts | 2 +- packages/jest-test-sequencer/src/index.ts | 2 +- .../jest-transform/src/ScriptTransformer.ts | 29 +++++++------ .../src/__tests__/should_instrument.test.ts | 2 +- .../jest-transform/src/shouldInstrument.ts | 2 +- packages/jest-types/src/Config.ts | 4 +- packages/jest-util/src/index.ts | 6 +-- .../src/__tests__/validate.test.ts | 5 +-- packages/jest-validate/src/defaultConfig.ts | 7 ++-- packages/jest-validate/src/deprecated.ts | 1 - packages/jest-validate/src/errors.ts | 2 +- packages/jest-validate/src/utils.ts | 2 +- packages/jest-validate/src/validate.ts | 2 +- .../jest-validate/src/validateCLIOptions.ts | 8 ++-- packages/jest-watcher/src/PatternPrompt.ts | 2 +- packages/jest-watcher/src/lib/Prompt.ts | 2 +- .../src/lib/__tests__/prompt.test.ts | 2 +- .../src/lib/formatTestNameByPattern.ts | 1 - .../src/lib/patternModeHelpers.ts | 2 +- packages/jest-watcher/src/types.ts | 2 +- packages/jest-worker/src/WorkerPool.ts | 1 - .../src/__tests__/WorkerPool.test.js | 7 +--- .../src/__tests__/process-integration.test.js | 1 - .../src/__tests__/thread-integration.test.js | 1 - .../jest-worker/src/base/BaseWorkerPool.ts | 1 - .../src/base/__tests__/BaseWorkerPool.test.js | 1 - packages/jest-worker/src/index.ts | 2 +- packages/jest-worker/src/types.ts | 2 +- .../src/workers/ChildProcessWorker.ts | 1 - .../src/workers/NodeThreadsWorker.ts | 1 - .../__tests__/ChildProcessWorker.test.js | 3 +- .../__tests__/NodeThreadsWorker.test.js | 1 - .../jest-worker/src/workers/threadChild.ts | 1 - packages/pretty-format/README.md | 10 ++--- packages/pretty-format/perf/test.js | 2 +- .../src/__tests__/AsymmetricMatcher.test.ts | 3 +- .../src/__tests__/Immutable.test.ts | 3 +- .../src/__tests__/react.test.tsx | 3 +- packages/pretty-format/src/index.ts | 4 +- .../src/plugins/AsymmetricMatcher.ts | 3 +- .../src/plugins/DOMCollection.ts | 3 +- .../pretty-format/src/plugins/DOMElement.ts | 1 - .../pretty-format/src/plugins/Immutable.ts | 2 +- .../pretty-format/src/plugins/ReactElement.ts | 1 - .../src/plugins/ReactTestComponent.ts | 13 +++--- .../pretty-format/src/plugins/lib/markup.ts | 1 - scripts/build.js | 3 +- scripts/buildTs.js | 1 - scripts/checkCopyrightHeaders.js | 2 +- scripts/mapCoverage.js | 2 +- scripts/remove-prettier-dep.js | 3 +- scripts/verifyOldTs.js | 1 - scripts/watch.js | 4 +- website/fetchSupporters.js | 2 +- website/pages/en/help.js | 5 +-- website/pages/en/index.js | 8 ++-- website/pages/en/versions.js | 1 - website/pages/en/videos.js | 1 - .../version-22.x/BypassingModuleMocks.md | 1 - .../version-22.x/Es6ClassMocks.md | 2 +- .../version-22.x/JestObjectAPI.md | 3 +- .../versioned_docs/version-22.x/Puppeteer.md | 4 +- .../version-23.x/JestObjectAPI.md | 3 +- .../versioned_docs/version-23.x/Puppeteer.md | 4 +- .../version-24.x/Configuration.md | 2 +- .../version-24.x/Es6ClassMocks.md | 2 +- .../version-24.x/JestObjectAPI.md | 3 +- .../version-25.x/Configuration.md | 2 +- .../version-25.x/JestObjectAPI.md | 3 +- .../version-26.0/Configuration.md | 2 +- .../version-26.0/JestObjectAPI.md | 3 +- .../version-26.2/Configuration.md | 2 +- .../version-26.4/Configuration.md | 2 +- .../version-26.5/Configuration.md | 2 +- .../version-26.6/Configuration.md | 2 +- 310 files changed, 602 insertions(+), 663 deletions(-) diff --git a/.eslintrc.js b/.eslintrc.js index ccd06a86e048..a8f9d91bab87 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -5,6 +5,17 @@ * LICENSE file in the root directory of this source tree. */ +const {sync: readPkg} = require('read-pkg'); +const {getPackages} = require('./scripts/buildUtils'); + +const internalPackages = getPackages() + .map(packageDir => { + const pkg = readPkg({cwd: packageDir}); + + return pkg.name; + }) + .sort(); + module.exports = { extends: [ 'fb-strict', @@ -243,11 +254,29 @@ module.exports = { 'scripts/**', 'babel.config.js', 'testSetupFile.js', + '.eslintrc.js', ], }, ], 'import/no-unresolved': ['error', {ignore: ['fsevents']}], - 'import/order': 'error', + 'import/order': [ + 'error', + { + alphabetize: { + order: 'asc', + }, + // this is the default order except for added `internal` in the middle + groups: [ + 'builtin', + 'external', + 'internal', + 'parent', + 'sibling', + 'index', + ], + 'newlines-between': 'never', + }, + ], 'no-console': 'off', 'no-restricted-imports': [ 'error', @@ -262,5 +291,9 @@ module.exports = { }, settings: { 'import/ignore': ['react-native'], + // using `new RegExp` makes sure to escape `/` + 'import/internal-regex': new RegExp( + internalPackages.map(pkg => `^${pkg}$`).join('|'), + ).source, }, }; diff --git a/docs/BypassingModuleMocks.md b/docs/BypassingModuleMocks.md index 62d5bae45de1..5e48a05b9fb4 100644 --- a/docs/BypassingModuleMocks.md +++ b/docs/BypassingModuleMocks.md @@ -24,7 +24,6 @@ Your test will want to mock the `fetch` function so that we can be sure that it jest.mock('node-fetch'); import fetch, {Response} from 'node-fetch'; - import {createUser} from './createUser'; test('createUser calls fetch with the right args and returns the user id', async () => { diff --git a/docs/Configuration.md b/docs/Configuration.md index 9133dd2e8b97..dd3cc6901e1b 100644 --- a/docs/Configuration.md +++ b/docs/Configuration.md @@ -300,8 +300,8 @@ Default: `undefined` This option allows the use of a custom dependency extractor. It must be a node module that exports an object with an `extract` function. E.g.: ```javascript -const fs = require('fs'); const crypto = require('crypto'); +const fs = require('fs'); module.exports = { extract(code, filePath, defaultExtract) { diff --git a/docs/Es6ClassMocks.md b/docs/Es6ClassMocks.md index 2a21ca815409..334e98a8a83f 100644 --- a/docs/Es6ClassMocks.md +++ b/docs/Es6ClassMocks.md @@ -328,8 +328,8 @@ Here's a complete test file which uses the module factory parameter to `jest.moc ```javascript // sound-player-consumer.test.js -import SoundPlayerConsumer from './sound-player-consumer'; import SoundPlayer from './sound-player'; +import SoundPlayerConsumer from './sound-player-consumer'; const mockPlaySoundFile = jest.fn(); jest.mock('./sound-player', () => { diff --git a/docs/JestObjectAPI.md b/docs/JestObjectAPI.md index fb06e001904d..b62c319e33d4 100644 --- a/docs/JestObjectAPI.md +++ b/docs/JestObjectAPI.md @@ -538,6 +538,7 @@ module.exports = audio; Example test: ```js +const audio = require('./audio'); const video = require('./video'); test('plays video', () => { @@ -550,8 +551,6 @@ test('plays video', () => { spy.mockRestore(); }); -const audio = require('./audio'); - test('plays audio', () => { const spy = jest.spyOn(audio, 'volume', 'set'); // we pass 'set' audio.volume = 100; diff --git a/docs/Puppeteer.md b/docs/Puppeteer.md index b5934c0ad8de..e071d8161fe3 100644 --- a/docs/Puppeteer.md +++ b/docs/Puppeteer.md @@ -55,9 +55,9 @@ Here's an example of the GlobalSetup script ```js // setup.js -const path = require('path'); const fs = require('fs'); const os = require('os'); +const path = require('path'); const mkdirp = require('mkdirp'); const puppeteer = require('puppeteer'); @@ -80,8 +80,8 @@ Then we need a custom Test Environment for puppeteer ```js // puppeteer_environment.js const fs = require('fs'); -const path = require('path'); const os = require('os'); +const path = require('path'); const puppeteer = require('puppeteer'); const NodeEnvironment = require('jest-environment-node'); diff --git a/e2e/Utils.ts b/e2e/Utils.ts index 6da33e7d55fb..c8d20585e834 100644 --- a/e2e/Utils.ts +++ b/e2e/Utils.ts @@ -6,13 +6,13 @@ */ import * as path from 'path'; -import * as fs from 'graceful-fs'; -import type {Config} from '@jest/types'; +import dedent = require('dedent'); import {ExecaReturnValue, sync as spawnSync} from 'execa'; -import type {PackageJson} from 'type-fest'; +import * as fs from 'graceful-fs'; import rimraf = require('rimraf'); -import dedent = require('dedent'); +import type {PackageJson} from 'type-fest'; import which = require('which'); +import type {Config} from '@jest/types'; interface RunResult extends ExecaReturnValue { status: number; diff --git a/e2e/__tests__/asyncAndCallback.test.ts b/e2e/__tests__/asyncAndCallback.test.ts index 81112af6ed72..76cb059cc551 100644 --- a/e2e/__tests__/asyncAndCallback.test.ts +++ b/e2e/__tests__/asyncAndCallback.test.ts @@ -5,10 +5,10 @@ * LICENSE file in the root directory of this source tree. */ -import {skipSuiteOnJasmine} from '@jest/test-utils'; import wrap from 'jest-snapshot-serializer-raw'; -import runJest from '../runJest'; +import {skipSuiteOnJasmine} from '@jest/test-utils'; import {extractSummary} from '../Utils'; +import runJest from '../runJest'; skipSuiteOnJasmine(); diff --git a/e2e/__tests__/babelPluginJestHoist.test.ts b/e2e/__tests__/babelPluginJestHoist.test.ts index e7eeab6925a5..31f0d62326d6 100644 --- a/e2e/__tests__/babelPluginJestHoist.test.ts +++ b/e2e/__tests__/babelPluginJestHoist.test.ts @@ -6,8 +6,8 @@ */ import * as path from 'path'; -import {json as runWithJson} from '../runJest'; import {runYarn} from '../Utils'; +import {json as runWithJson} from '../runJest'; const DIR = path.resolve(__dirname, '..', 'babel-plugin-jest-hoist'); diff --git a/e2e/__tests__/beforeEachQueue.ts b/e2e/__tests__/beforeEachQueue.ts index 23f84ad72e4a..2b6ed2d4968a 100644 --- a/e2e/__tests__/beforeEachQueue.ts +++ b/e2e/__tests__/beforeEachQueue.ts @@ -5,8 +5,8 @@ * LICENSE file in the root directory of this source tree. */ -import {skipSuiteOnJestCircus} from '@jest/test-utils'; import {wrap} from 'jest-snapshot-serializer-raw'; +import {skipSuiteOnJestCircus} from '@jest/test-utils'; import runJest from '../runJest'; skipSuiteOnJestCircus(); // Circus does not support funky async definitions diff --git a/e2e/__tests__/chaiAssertionLibrary.ts b/e2e/__tests__/chaiAssertionLibrary.ts index 858eb860605a..9cad190a4353 100644 --- a/e2e/__tests__/chaiAssertionLibrary.ts +++ b/e2e/__tests__/chaiAssertionLibrary.ts @@ -7,8 +7,8 @@ import * as path from 'path'; import {wrap} from 'jest-snapshot-serializer-raw'; -import runJest from '../runJest'; import {extractSummary, runYarn} from '../Utils'; +import runJest from '../runJest'; test('chai assertion errors should display properly', () => { const dir = path.resolve(__dirname, '../chai-assertion-library-errors'); diff --git a/e2e/__tests__/circusDeclarationErrors.test.ts b/e2e/__tests__/circusDeclarationErrors.test.ts index 9de4ff365930..667b1742b4f5 100644 --- a/e2e/__tests__/circusDeclarationErrors.test.ts +++ b/e2e/__tests__/circusDeclarationErrors.test.ts @@ -5,8 +5,8 @@ * LICENSE file in the root directory of this source tree. */ -import {skipSuiteOnJasmine} from '@jest/test-utils'; import {wrap} from 'jest-snapshot-serializer-raw'; +import {skipSuiteOnJasmine} from '@jest/test-utils'; import {extractSummary} from '../Utils'; import runJest from '../runJest'; diff --git a/e2e/__tests__/customMatcherStackTrace.test.ts b/e2e/__tests__/customMatcherStackTrace.test.ts index 155c13b23808..5d33a5b39b41 100644 --- a/e2e/__tests__/customMatcherStackTrace.test.ts +++ b/e2e/__tests__/customMatcherStackTrace.test.ts @@ -6,8 +6,8 @@ */ import {wrap} from 'jest-snapshot-serializer-raw'; -import runJest from '../runJest'; import {extractSummary} from '../Utils'; +import runJest from '../runJest'; test('works with custom matchers', () => { const {stderr} = runJest('custom-matcher-stack-trace', ['sync.test.js']); diff --git a/e2e/__tests__/customReporters.test.ts b/e2e/__tests__/customReporters.test.ts index 41b405c2b017..d0dc1d78455c 100644 --- a/e2e/__tests__/customReporters.test.ts +++ b/e2e/__tests__/customReporters.test.ts @@ -8,8 +8,8 @@ import {tmpdir} from 'os'; import * as path from 'path'; import {wrap} from 'jest-snapshot-serializer-raw'; -import runJest from '../runJest'; import {cleanup, extractSummary, writeFiles} from '../Utils'; +import runJest from '../runJest'; const DIR = path.resolve(tmpdir(), 'custom-reporters-test-dir'); diff --git a/e2e/__tests__/customTestSequencers.test.ts b/e2e/__tests__/customTestSequencers.test.ts index 5a6c03f9bf94..809ffd7896b9 100644 --- a/e2e/__tests__/customTestSequencers.test.ts +++ b/e2e/__tests__/customTestSequencers.test.ts @@ -6,8 +6,8 @@ */ import * as path from 'path'; -import runJest from '../runJest'; import {extractSummary} from '../Utils'; +import runJest from '../runJest'; const dir = path.resolve(__dirname, '../custom-test-sequencer'); test('run prioritySequence first sync', () => { diff --git a/e2e/__tests__/dependencyClash.test.ts b/e2e/__tests__/dependencyClash.test.ts index dddd0c1fc466..87b9c81eee77 100644 --- a/e2e/__tests__/dependencyClash.test.ts +++ b/e2e/__tests__/dependencyClash.test.ts @@ -5,8 +5,8 @@ * LICENSE file in the root directory of this source tree. */ -import * as path from 'path'; import {tmpdir} from 'os'; +import * as path from 'path'; import {cleanup, createEmptyPackage, writeFiles} from '../Utils'; import runJest from '../runJest'; diff --git a/e2e/__tests__/domDiffing.test.ts b/e2e/__tests__/domDiffing.test.ts index 64d4622ac156..b61baff2d6eb 100644 --- a/e2e/__tests__/domDiffing.test.ts +++ b/e2e/__tests__/domDiffing.test.ts @@ -6,8 +6,8 @@ * */ -import runJest from '../runJest'; import {replaceTime} from '../Utils'; +import runJest from '../runJest'; test('should work without error', () => { const output = runJest('dom-diffing'); diff --git a/e2e/__tests__/each.test.ts b/e2e/__tests__/each.test.ts index c95245a269de..f65e74bdff04 100644 --- a/e2e/__tests__/each.test.ts +++ b/e2e/__tests__/each.test.ts @@ -7,8 +7,8 @@ import * as path from 'path'; import {wrap} from 'jest-snapshot-serializer-raw'; -import runJest from '../runJest'; import {extractSummary} from '../Utils'; +import runJest from '../runJest'; const dir = path.resolve(__dirname, '../each'); diff --git a/e2e/__tests__/emptyDescribeWithHooks.test.ts b/e2e/__tests__/emptyDescribeWithHooks.test.ts index a0c3b7aff39c..050347b40df6 100644 --- a/e2e/__tests__/emptyDescribeWithHooks.test.ts +++ b/e2e/__tests__/emptyDescribeWithHooks.test.ts @@ -7,8 +7,8 @@ import * as path from 'path'; import {skipSuiteOnJasmine} from '@jest/test-utils'; -import runJest from '../runJest'; import {extractSummary} from '../Utils'; +import runJest from '../runJest'; const dir = path.resolve(__dirname, '../empty-describe-with-hooks'); diff --git a/e2e/__tests__/errorOnDeprecated.test.ts b/e2e/__tests__/errorOnDeprecated.test.ts index 38353f73497b..e0d2f1d28e4c 100644 --- a/e2e/__tests__/errorOnDeprecated.test.ts +++ b/e2e/__tests__/errorOnDeprecated.test.ts @@ -7,8 +7,8 @@ import {wrap} from 'jest-snapshot-serializer-raw'; import {skipSuiteOnJestCircus} from '@jest/test-utils'; -import runJest from '../runJest'; import {extractSummary} from '../Utils'; +import runJest from '../runJest'; skipSuiteOnJestCircus(); diff --git a/e2e/__tests__/existentRoots.test.ts b/e2e/__tests__/existentRoots.test.ts index 398b62d09fdd..0181635309cf 100644 --- a/e2e/__tests__/existentRoots.test.ts +++ b/e2e/__tests__/existentRoots.test.ts @@ -5,8 +5,8 @@ * LICENSE file in the root directory of this source tree. */ -import * as path from 'path'; import {tmpdir} from 'os'; +import * as path from 'path'; import {tryRealpath} from 'jest-util'; import {cleanup, writeFiles} from '../Utils'; import runJest from '../runJest'; diff --git a/e2e/__tests__/expectAsyncMatcher.test.ts b/e2e/__tests__/expectAsyncMatcher.test.ts index c5cac29042ef..e8c71ae418b2 100644 --- a/e2e/__tests__/expectAsyncMatcher.test.ts +++ b/e2e/__tests__/expectAsyncMatcher.test.ts @@ -7,8 +7,8 @@ import * as path from 'path'; import {wrap} from 'jest-snapshot-serializer-raw'; -import runJest from '../runJest'; import {extractSummary, runYarn} from '../Utils'; +import runJest from '../runJest'; const dir = path.resolve(__dirname, '../expect-async-matcher'); diff --git a/e2e/__tests__/fatalWorkerError.test.ts b/e2e/__tests__/fatalWorkerError.test.ts index 566467c8a28d..92acb18139bf 100644 --- a/e2e/__tests__/fatalWorkerError.test.ts +++ b/e2e/__tests__/fatalWorkerError.test.ts @@ -5,8 +5,8 @@ * LICENSE file in the root directory of this source tree. */ -import * as path from 'path'; import {tmpdir} from 'os'; +import * as path from 'path'; import { cleanup, generateTestFilesToForceUsingWorkers, diff --git a/e2e/__tests__/forceExit.test.ts b/e2e/__tests__/forceExit.test.ts index d54c41b159e6..3af3936d5df7 100644 --- a/e2e/__tests__/forceExit.test.ts +++ b/e2e/__tests__/forceExit.test.ts @@ -7,8 +7,8 @@ import {tmpdir} from 'os'; import * as path from 'path'; -import runJest from '../runJest'; import {cleanup, writeFiles} from '../Utils'; +import runJest from '../runJest'; const DIR = path.resolve(tmpdir(), 'force-exit-test'); diff --git a/e2e/__tests__/globalSetup.test.ts b/e2e/__tests__/globalSetup.test.ts index c64a78b731ba..a37e5063808b 100644 --- a/e2e/__tests__/globalSetup.test.ts +++ b/e2e/__tests__/globalSetup.test.ts @@ -8,8 +8,8 @@ import {tmpdir} from 'os'; import * as path from 'path'; import * as fs from 'graceful-fs'; -import runJest, {json as runWithJson} from '../runJest'; import {cleanup, runYarn} from '../Utils'; +import runJest, {json as runWithJson} from '../runJest'; const DIR = path.join(tmpdir(), 'jest-global-setup'); const project1DIR = path.join(tmpdir(), 'jest-global-setup-project-1'); diff --git a/e2e/__tests__/globalTeardown.test.ts b/e2e/__tests__/globalTeardown.test.ts index 8c4642eb8a50..1d1b229e5474 100644 --- a/e2e/__tests__/globalTeardown.test.ts +++ b/e2e/__tests__/globalTeardown.test.ts @@ -9,8 +9,8 @@ import {tmpdir} from 'os'; import * as path from 'path'; import * as fs from 'graceful-fs'; import {createDirectory} from 'jest-util'; -import runJest, {json as runWithJson} from '../runJest'; import {cleanup, runYarn} from '../Utils'; +import runJest, {json as runWithJson} from '../runJest'; const DIR = path.join(tmpdir(), 'jest-global-teardown'); const project1DIR = path.join(tmpdir(), 'jest-global-teardown-project-1'); diff --git a/e2e/__tests__/globals.test.ts b/e2e/__tests__/globals.test.ts index 1007da3160ec..dc75ecf893b0 100644 --- a/e2e/__tests__/globals.test.ts +++ b/e2e/__tests__/globals.test.ts @@ -5,16 +5,16 @@ * LICENSE file in the root directory of this source tree. */ -import * as path from 'path'; import {tmpdir} from 'os'; +import * as path from 'path'; import {wrap} from 'jest-snapshot-serializer-raw'; -import runJest from '../runJest'; import { cleanup, createEmptyPackage, extractSummary, writeFiles, } from '../Utils'; +import runJest from '../runJest'; const DIR = path.resolve(tmpdir(), 'globalVariables.test'); const TEST_DIR = path.resolve(DIR, '__tests__'); diff --git a/e2e/__tests__/injectGlobals.test.ts b/e2e/__tests__/injectGlobals.test.ts index 95f625250aaa..8649cd23e92e 100644 --- a/e2e/__tests__/injectGlobals.test.ts +++ b/e2e/__tests__/injectGlobals.test.ts @@ -5,17 +5,17 @@ * LICENSE file in the root directory of this source tree. */ -import * as path from 'path'; import {tmpdir} from 'os'; +import * as path from 'path'; import {wrap} from 'jest-snapshot-serializer-raw'; import {skipSuiteOnJasmine} from '@jest/test-utils'; -import {json as runJest} from '../runJest'; import { cleanup, createEmptyPackage, extractSummary, writeFiles, } from '../Utils'; +import {json as runJest} from '../runJest'; const DIR = path.resolve(tmpdir(), 'injectGlobalVariables.test'); const TEST_DIR = path.resolve(DIR, '__tests__'); diff --git a/e2e/__tests__/jest.config.js.test.ts b/e2e/__tests__/jest.config.js.test.ts index a81611071cd7..82129fc5fca1 100644 --- a/e2e/__tests__/jest.config.js.test.ts +++ b/e2e/__tests__/jest.config.js.test.ts @@ -7,8 +7,8 @@ import * as path from 'path'; import {wrap} from 'jest-snapshot-serializer-raw'; -import runJest from '../runJest'; import {cleanup, extractSummary, writeFiles} from '../Utils'; +import runJest from '../runJest'; const DIR = path.resolve(__dirname, '../jest-config-js'); diff --git a/e2e/__tests__/jest.config.ts.test.ts b/e2e/__tests__/jest.config.ts.test.ts index d93dc33bfd84..7792c8612d0b 100644 --- a/e2e/__tests__/jest.config.ts.test.ts +++ b/e2e/__tests__/jest.config.ts.test.ts @@ -7,8 +7,8 @@ import * as path from 'path'; import {wrap} from 'jest-snapshot-serializer-raw'; -import runJest from '../runJest'; import {cleanup, extractSummary, writeFiles} from '../Utils'; +import runJest from '../runJest'; const DIR = path.resolve(__dirname, '../jest-config-ts'); diff --git a/e2e/__tests__/jestChangedFiles.test.ts b/e2e/__tests__/jestChangedFiles.test.ts index 9f422c6b6112..0cab7aa45340 100644 --- a/e2e/__tests__/jestChangedFiles.test.ts +++ b/e2e/__tests__/jestChangedFiles.test.ts @@ -8,8 +8,8 @@ import {tmpdir} from 'os'; import * as path from 'path'; import {wrap} from 'jest-snapshot-serializer-raw'; -import {findRepos, getChangedFilesForRoots} from 'jest-changed-files'; import slash from 'slash'; +import {findRepos, getChangedFilesForRoots} from 'jest-changed-files'; import {cleanup, run, testIfHg, writeFiles} from '../Utils'; import runJest from '../runJest'; diff --git a/e2e/__tests__/jestEnvironmentJsdom.test.ts b/e2e/__tests__/jestEnvironmentJsdom.test.ts index e13abfcec114..887c802ec35a 100644 --- a/e2e/__tests__/jestEnvironmentJsdom.test.ts +++ b/e2e/__tests__/jestEnvironmentJsdom.test.ts @@ -5,8 +5,8 @@ * LICENSE file in the root directory of this source tree. */ -import * as path from 'path'; import {tmpdir} from 'os'; +import * as path from 'path'; import {cleanup, writeFiles} from '../Utils'; import runJest from '../runJest'; diff --git a/e2e/__tests__/jestRequireActual.test.ts b/e2e/__tests__/jestRequireActual.test.ts index 031324dedca0..e7cb16218826 100644 --- a/e2e/__tests__/jestRequireActual.test.ts +++ b/e2e/__tests__/jestRequireActual.test.ts @@ -5,8 +5,8 @@ * LICENSE file in the root directory of this source tree. */ -import * as path from 'path'; import {tmpdir} from 'os'; +import * as path from 'path'; import {cleanup, writeFiles} from '../Utils'; import runJest from '../runJest'; diff --git a/e2e/__tests__/jestRequireMock.test.ts b/e2e/__tests__/jestRequireMock.test.ts index e6c91943c368..6e6a6f9d371b 100644 --- a/e2e/__tests__/jestRequireMock.test.ts +++ b/e2e/__tests__/jestRequireMock.test.ts @@ -5,8 +5,8 @@ * LICENSE file in the root directory of this source tree. */ -import * as path from 'path'; import {tmpdir} from 'os'; +import * as path from 'path'; import {cleanup, writeFiles} from '../Utils'; import runJest from '../runJest'; diff --git a/e2e/__tests__/logHeapUsage.test.ts b/e2e/__tests__/logHeapUsage.test.ts index ff2ff0e95ab6..315e8ed1a42e 100644 --- a/e2e/__tests__/logHeapUsage.test.ts +++ b/e2e/__tests__/logHeapUsage.test.ts @@ -5,8 +5,8 @@ * LICENSE file in the root directory of this source tree. */ -import * as path from 'path'; import {tmpdir} from 'os'; +import * as path from 'path'; import {cleanup, writeFiles} from '../Utils'; import runJest from '../runJest'; diff --git a/e2e/__tests__/moduleNameMapper.test.ts b/e2e/__tests__/moduleNameMapper.test.ts index 9b0eb82075a9..447970a9727d 100644 --- a/e2e/__tests__/moduleNameMapper.test.ts +++ b/e2e/__tests__/moduleNameMapper.test.ts @@ -6,8 +6,8 @@ */ import {wrap} from 'jest-snapshot-serializer-raw'; -import runJest, {json as runWithJson} from '../runJest'; import {extractSummary} from '../Utils'; +import runJest, {json as runWithJson} from '../runJest'; test('moduleNameMapper wrong configuration', () => { const {stderr, exitCode} = runJest('module-name-mapper-wrong-config'); diff --git a/e2e/__tests__/nativeEsm.test.ts b/e2e/__tests__/nativeEsm.test.ts index 66d6c6d09c1a..9aa963af31c7 100644 --- a/e2e/__tests__/nativeEsm.test.ts +++ b/e2e/__tests__/nativeEsm.test.ts @@ -8,8 +8,8 @@ import {resolve} from 'path'; import wrap from 'jest-snapshot-serializer-raw'; import {onNodeVersions} from '@jest/test-utils'; -import runJest, {getConfig} from '../runJest'; import {extractSummary} from '../Utils'; +import runJest, {getConfig} from '../runJest'; const DIR = resolve(__dirname, '../native-esm'); diff --git a/e2e/__tests__/nestedTestDefinitions.test.ts b/e2e/__tests__/nestedTestDefinitions.test.ts index ab000c325e19..b5830c8ffd35 100644 --- a/e2e/__tests__/nestedTestDefinitions.test.ts +++ b/e2e/__tests__/nestedTestDefinitions.test.ts @@ -7,8 +7,8 @@ import {wrap} from 'jest-snapshot-serializer-raw'; import {isJestCircusRun} from '@jest/test-utils'; -import runJest from '../runJest'; import {extractSummary} from '../Utils'; +import runJest from '../runJest'; const cleanupRunnerStack = (stderr: string) => wrap( diff --git a/e2e/__tests__/onlyChanged.test.ts b/e2e/__tests__/onlyChanged.test.ts index 947a11d50ddc..6690bf528047 100644 --- a/e2e/__tests__/onlyChanged.test.ts +++ b/e2e/__tests__/onlyChanged.test.ts @@ -7,8 +7,8 @@ import {tmpdir} from 'os'; import * as path from 'path'; -import runJest from '../runJest'; import {cleanup, run, testIfHg, writeFiles} from '../Utils'; +import runJest from '../runJest'; const DIR = path.resolve(tmpdir(), 'jest_only_changed'); const GIT = 'git -c user.name=jest_test -c user.email=jest_test@test.com'; diff --git a/e2e/__tests__/pnp.test.ts b/e2e/__tests__/pnp.test.ts index b8bf3643a13f..9c419592ce07 100644 --- a/e2e/__tests__/pnp.test.ts +++ b/e2e/__tests__/pnp.test.ts @@ -6,8 +6,8 @@ */ import * as path from 'path'; -import {json as runWithJson} from '../runJest'; import {runYarn} from '../Utils'; +import {json as runWithJson} from '../runJest'; const DIR = path.resolve(__dirname, '..', 'pnp'); diff --git a/e2e/__tests__/promiseReject.test.ts b/e2e/__tests__/promiseReject.test.ts index c4306efc67c7..e079c567c2de 100644 --- a/e2e/__tests__/promiseReject.test.ts +++ b/e2e/__tests__/promiseReject.test.ts @@ -6,8 +6,8 @@ */ import * as path from 'path'; -import runJest from '../runJest'; import {cleanup, writeFiles} from '../Utils'; +import runJest from '../runJest'; const DIR = path.resolve('../promise-reject'); diff --git a/e2e/__tests__/resolveNoFileExtensions.test.ts b/e2e/__tests__/resolveNoFileExtensions.test.ts index 824eef1bf8c9..6ed78161d2df 100644 --- a/e2e/__tests__/resolveNoFileExtensions.test.ts +++ b/e2e/__tests__/resolveNoFileExtensions.test.ts @@ -7,8 +7,8 @@ import * as path from 'path'; import {wrap} from 'jest-snapshot-serializer-raw'; -import runJest from '../runJest'; import {cleanup, extractSummary, writeFiles} from '../Utils'; +import runJest from '../runJest'; const DIR = path.resolve(__dirname, '../resolve-no-extensions-no-js'); diff --git a/e2e/__tests__/resolveWithPaths.test.ts b/e2e/__tests__/resolveWithPaths.test.ts index 58e47e4e9285..7a8fff290c9e 100644 --- a/e2e/__tests__/resolveWithPaths.test.ts +++ b/e2e/__tests__/resolveWithPaths.test.ts @@ -6,8 +6,8 @@ */ import {resolve} from 'path'; -import runJest from '../runJest'; import {cleanup, writeFiles} from '../Utils'; +import runJest from '../runJest'; const workdirNodeModules = resolve( __dirname, diff --git a/e2e/__tests__/runProgrammatically.test.ts b/e2e/__tests__/runProgrammatically.test.ts index e9c1a8641e78..0d60f9d99c8b 100644 --- a/e2e/__tests__/runProgrammatically.test.ts +++ b/e2e/__tests__/runProgrammatically.test.ts @@ -6,7 +6,6 @@ */ import {resolve} from 'path'; - import {run} from '../Utils'; const dir = resolve(__dirname, '..', 'run-programmatically'); diff --git a/e2e/__tests__/runTestsByPath.test.ts b/e2e/__tests__/runTestsByPath.test.ts index c779083f7b22..5792fe8c3d71 100644 --- a/e2e/__tests__/runTestsByPath.test.ts +++ b/e2e/__tests__/runTestsByPath.test.ts @@ -7,8 +7,8 @@ import {tmpdir} from 'os'; import * as path from 'path'; -import runJest from '../runJest'; import {cleanup, writeFiles} from '../Utils'; +import runJest from '../runJest'; const DIR = path.resolve(tmpdir(), 'run-tests-by-path-test'); diff --git a/e2e/__tests__/selectProjects.test.ts b/e2e/__tests__/selectProjects.test.ts index 472221575cc7..2e48085b6cf1 100644 --- a/e2e/__tests__/selectProjects.test.ts +++ b/e2e/__tests__/selectProjects.test.ts @@ -6,7 +6,6 @@ */ import {resolve} from 'path'; - import run, { RunJestJsonResult, RunJestResult, diff --git a/e2e/__tests__/setupFilesAfterEnvConfig.test.ts b/e2e/__tests__/setupFilesAfterEnvConfig.test.ts index a9c0b791b82b..90ee80b72327 100644 --- a/e2e/__tests__/setupFilesAfterEnvConfig.test.ts +++ b/e2e/__tests__/setupFilesAfterEnvConfig.test.ts @@ -7,8 +7,8 @@ import * as path from 'path'; import * as fs from 'graceful-fs'; -import {json as runWithJson} from '../runJest'; import {writeFiles} from '../Utils'; +import {json as runWithJson} from '../runJest'; const DIR = path.resolve(__dirname, '../setup-files-after-env-config'); diff --git a/e2e/__tests__/showConfig.test.ts b/e2e/__tests__/showConfig.test.ts index 0ef9c2a51ef5..3505a9f66c37 100644 --- a/e2e/__tests__/showConfig.test.ts +++ b/e2e/__tests__/showConfig.test.ts @@ -5,11 +5,11 @@ * LICENSE file in the root directory of this source tree. */ -import * as path from 'path'; import {tmpdir} from 'os'; +import * as path from 'path'; import {wrap} from 'jest-snapshot-serializer-raw'; -import runJest from '../runJest'; import {cleanup, writeFiles} from '../Utils'; +import runJest from '../runJest'; const DIR = path.resolve(tmpdir(), 'show-config-test'); diff --git a/e2e/__tests__/snapshotMockFs.test.ts b/e2e/__tests__/snapshotMockFs.test.ts index a10cedf5e2aa..6b796b4c1b92 100644 --- a/e2e/__tests__/snapshotMockFs.test.ts +++ b/e2e/__tests__/snapshotMockFs.test.ts @@ -6,8 +6,8 @@ */ import * as path from 'path'; -import rimraf = require('rimraf'); import {wrap} from 'jest-snapshot-serializer-raw'; +import rimraf = require('rimraf'); import {extractSummary} from '../Utils'; import {json as runJestJson} from '../runJest'; diff --git a/e2e/__tests__/stackTrace.test.ts b/e2e/__tests__/stackTrace.test.ts index 48904bff60e5..a82a02b72217 100644 --- a/e2e/__tests__/stackTrace.test.ts +++ b/e2e/__tests__/stackTrace.test.ts @@ -6,8 +6,8 @@ */ import {wrap} from 'jest-snapshot-serializer-raw'; -import runJest from '../runJest'; import {extractSummary} from '../Utils'; +import runJest from '../runJest'; describe('Stack Trace', () => { it('prints a stack trace for runtime errors', () => { diff --git a/e2e/__tests__/testEnvironment.test.ts b/e2e/__tests__/testEnvironment.test.ts index da6202fa1e41..8b70dab5d7d4 100644 --- a/e2e/__tests__/testEnvironment.test.ts +++ b/e2e/__tests__/testEnvironment.test.ts @@ -6,7 +6,6 @@ */ import {json as runWithJson} from '../runJest'; - import * as testFixturePackage from '../test-environment/package.json'; it('respects testEnvironment docblock', () => { diff --git a/e2e/__tests__/testEnvironmentAsync.test.ts b/e2e/__tests__/testEnvironmentAsync.test.ts index 114af7aae14f..fdb8f6a0fa6e 100644 --- a/e2e/__tests__/testEnvironmentAsync.test.ts +++ b/e2e/__tests__/testEnvironmentAsync.test.ts @@ -5,11 +5,11 @@ * LICENSE file in the root directory of this source tree. */ -import * as path from 'path'; import {tmpdir} from 'os'; +import * as path from 'path'; import * as fs from 'graceful-fs'; -import runJest from '../runJest'; import {cleanup} from '../Utils'; +import runJest from '../runJest'; const DIR = tmpdir() + '/jest-test-environment'; diff --git a/e2e/__tests__/testFailureExitCode.test.ts b/e2e/__tests__/testFailureExitCode.test.ts index 6b60983746ca..a7c8506721fb 100644 --- a/e2e/__tests__/testFailureExitCode.test.ts +++ b/e2e/__tests__/testFailureExitCode.test.ts @@ -5,8 +5,8 @@ * LICENSE file in the root directory of this source tree. */ -import * as path from 'path'; import {tmpdir} from 'os'; +import * as path from 'path'; import {cleanup, writeFiles} from '../Utils'; import runJest from '../runJest'; diff --git a/e2e/__tests__/testPathPatternReporterMessage.test.ts b/e2e/__tests__/testPathPatternReporterMessage.test.ts index e12164cb912a..38d5346c8504 100644 --- a/e2e/__tests__/testPathPatternReporterMessage.test.ts +++ b/e2e/__tests__/testPathPatternReporterMessage.test.ts @@ -7,8 +7,8 @@ import {tmpdir} from 'os'; import * as path from 'path'; -import runJest from '../runJest'; import {cleanup, writeFiles} from '../Utils'; +import runJest from '../runJest'; const DIR = path.resolve(tmpdir(), 'jest-path-pattern-reporter-message'); diff --git a/e2e/__tests__/testTodo.test.ts b/e2e/__tests__/testTodo.test.ts index 7982d37534cc..8e7def195543 100644 --- a/e2e/__tests__/testTodo.test.ts +++ b/e2e/__tests__/testTodo.test.ts @@ -7,8 +7,8 @@ import * as path from 'path'; import {wrap} from 'jest-snapshot-serializer-raw'; -import runJest from '../runJest'; import {extractSummary} from '../Utils'; +import runJest from '../runJest'; const dir = path.resolve(__dirname, '../test-todo'); test('works with all statuses', () => { diff --git a/e2e/__tests__/transform.test.ts b/e2e/__tests__/transform.test.ts index 17cfc315b20e..db68750b7d86 100644 --- a/e2e/__tests__/transform.test.ts +++ b/e2e/__tests__/transform.test.ts @@ -5,8 +5,8 @@ * LICENSE file in the root directory of this source tree. */ -import * as path from 'path'; import {tmpdir} from 'os'; +import * as path from 'path'; import {wrap} from 'jest-snapshot-serializer-raw'; import { cleanup, diff --git a/e2e/__tests__/unexpectedToken.test.ts b/e2e/__tests__/unexpectedToken.test.ts index db83fed1b701..9d119fcb33f2 100644 --- a/e2e/__tests__/unexpectedToken.test.ts +++ b/e2e/__tests__/unexpectedToken.test.ts @@ -7,8 +7,8 @@ import {tmpdir} from 'os'; import * as path from 'path'; -import runJest from '../runJest'; import {cleanup, writeFiles} from '../Utils'; +import runJest from '../runJest'; const DIR = path.resolve(tmpdir(), 'unexpected-token'); const nodeMajorVersion = Number(process.versions.node.split('.')[0]); diff --git a/e2e/__tests__/useStderr.test.ts b/e2e/__tests__/useStderr.test.ts index 37c4d5b84f3f..f49715effa86 100644 --- a/e2e/__tests__/useStderr.test.ts +++ b/e2e/__tests__/useStderr.test.ts @@ -7,8 +7,8 @@ import {tmpdir} from 'os'; import * as path from 'path'; -import runJest from '../runJest'; import {cleanup, writeFiles} from '../Utils'; +import runJest from '../runJest'; const DIR = path.resolve(tmpdir(), 'use-stderr-test'); diff --git a/e2e/__tests__/version.test.ts b/e2e/__tests__/version.test.ts index 3acbfb1ad4f2..54df9a3dca4a 100644 --- a/e2e/__tests__/version.test.ts +++ b/e2e/__tests__/version.test.ts @@ -5,8 +5,8 @@ * LICENSE file in the root directory of this source tree. */ -import * as path from 'path'; import {tmpdir} from 'os'; +import * as path from 'path'; import {cleanup, writeFiles} from '../Utils'; import runJest from '../runJest'; diff --git a/e2e/__tests__/watchModeOnlyFailed.test.ts b/e2e/__tests__/watchModeOnlyFailed.test.ts index be7b80078319..2462c571d0d8 100644 --- a/e2e/__tests__/watchModeOnlyFailed.test.ts +++ b/e2e/__tests__/watchModeOnlyFailed.test.ts @@ -5,8 +5,8 @@ * LICENSE file in the root directory of this source tree. */ -import * as path from 'path'; import {tmpdir} from 'os'; +import * as path from 'path'; import {wrap} from 'jest-snapshot-serializer-raw'; import {cleanup, extractSummaries, writeFiles} from '../Utils'; import runJest from '../runJest'; diff --git a/e2e/__tests__/watchModePatterns.test.ts b/e2e/__tests__/watchModePatterns.test.ts index 7d39c7045adf..6a635bc68472 100644 --- a/e2e/__tests__/watchModePatterns.test.ts +++ b/e2e/__tests__/watchModePatterns.test.ts @@ -5,8 +5,8 @@ * LICENSE file in the root directory of this source tree. */ -import * as path from 'path'; import {tmpdir} from 'os'; +import * as path from 'path'; import {wrap} from 'jest-snapshot-serializer-raw'; import {cleanup, extractSummaries, writeFiles} from '../Utils'; import runJest from '../runJest'; diff --git a/e2e/__tests__/watchModeUpdateSnapshot.test.ts b/e2e/__tests__/watchModeUpdateSnapshot.test.ts index 27dea938525e..a779d23086fe 100644 --- a/e2e/__tests__/watchModeUpdateSnapshot.test.ts +++ b/e2e/__tests__/watchModeUpdateSnapshot.test.ts @@ -5,8 +5,8 @@ * LICENSE file in the root directory of this source tree. */ -import * as path from 'path'; import {tmpdir} from 'os'; +import * as path from 'path'; import {wrap} from 'jest-snapshot-serializer-raw'; import {cleanup, extractSummaries, writeFiles} from '../Utils'; import runJest from '../runJest'; diff --git a/e2e/__tests__/workerForceExit.test.ts b/e2e/__tests__/workerForceExit.test.ts index ec27fa0cd197..6d0de93336d5 100644 --- a/e2e/__tests__/workerForceExit.test.ts +++ b/e2e/__tests__/workerForceExit.test.ts @@ -8,7 +8,6 @@ import {tmpdir} from 'os'; import {resolve} from 'path'; import findProcess = require('find-process'); - import { cleanup, generateTestFilesToForceUsingWorkers, diff --git a/e2e/__tests__/wrongEnv.test.ts b/e2e/__tests__/wrongEnv.test.ts index 2cb5f255ed92..e2b0c184c8c4 100644 --- a/e2e/__tests__/wrongEnv.test.ts +++ b/e2e/__tests__/wrongEnv.test.ts @@ -6,8 +6,8 @@ */ import wrap from 'jest-snapshot-serializer-raw'; -import runJest from '../runJest'; import {extractSummary} from '../Utils'; +import runJest from '../runJest'; function assertFailuresAndSnapshot(args: Array) { const result = runJest('wrong-env', args); diff --git a/e2e/babel-plugin-jest-hoist/__tests__/importJest.test.js b/e2e/babel-plugin-jest-hoist/__tests__/importJest.test.js index 2933ad991e6e..21bce0f6957f 100644 --- a/e2e/babel-plugin-jest-hoist/__tests__/importJest.test.js +++ b/e2e/babel-plugin-jest-hoist/__tests__/importJest.test.js @@ -11,7 +11,6 @@ import {jest} from '@jest/globals'; import {jest as aliasedJest} from '@jest/globals'; import * as JestGlobals from '@jest/globals'; /* eslint-enable import/no-duplicates */ - import a from '../__test_modules__/a'; import b from '../__test_modules__/b'; import c from '../__test_modules__/c'; diff --git a/e2e/babel-plugin-jest-hoist/__tests__/integration.test.js b/e2e/babel-plugin-jest-hoist/__tests__/integration.test.js index 4b534faa9fb2..7077db3920f4 100644 --- a/e2e/babel-plugin-jest-hoist/__tests__/integration.test.js +++ b/e2e/babel-plugin-jest-hoist/__tests__/integration.test.js @@ -9,15 +9,14 @@ 'use strict'; import React from 'react'; -import Unmocked from '../__test_modules__/Unmocked'; import Mocked from '../__test_modules__/Mocked'; +import Unmocked from '../__test_modules__/Unmocked'; import a from '../__test_modules__/a'; import b from '../__test_modules__/b'; import c from '../__test_modules__/c'; import d from '../__test_modules__/d'; import f from '../__test_modules__/f'; import jestBackticks from '../__test_modules__/jestBackticks'; - // The virtual mock call below will be hoisted above this `require` call. const virtualModule = require('virtual-module'); diff --git a/e2e/babel-plugin-jest-hoist/__tests__/typescript.test.ts b/e2e/babel-plugin-jest-hoist/__tests__/typescript.test.ts index 793eee7875fb..5bb56da357c4 100644 --- a/e2e/babel-plugin-jest-hoist/__tests__/typescript.test.ts +++ b/e2e/babel-plugin-jest-hoist/__tests__/typescript.test.ts @@ -8,8 +8,8 @@ /* eslint-disable local/ban-types-eventually */ -import type {Color} from '../types'; import {color} from '../entry'; +import type {Color} from '../types'; jest.mock('some-module', () => ({} as Partial<{}>), {virtual: true}); diff --git a/e2e/native-esm/__tests__/native-esm.test.js b/e2e/native-esm/__tests__/native-esm.test.js index ae2dcc2fa52d..019f0ff2f340 100644 --- a/e2e/native-esm/__tests__/native-esm.test.js +++ b/e2e/native-esm/__tests__/native-esm.test.js @@ -12,16 +12,16 @@ import {createRequire} from 'module'; import {dirname, resolve} from 'path'; import {fileURLToPath} from 'url'; import {jest as jestObject} from '@jest/globals'; -import staticImportedStateful from '../stateful.mjs'; import staticImportedStatefulFromCjs from '../fromCjs.mjs'; +import {double} from '../index'; +import defaultFromCjs, {namedFunction} from '../namedExport.cjs'; +import {bag} from '../namespaceExport.js'; +import staticImportedStateful from '../stateful.mjs'; // https://github.com/benmosher/eslint-plugin-import/issues/1739 /* eslint-disable import/no-unresolved */ import staticImportedStatefulWithQuery from '../stateful.mjs?query=1'; import staticImportedStatefulWithAnotherQuery from '../stateful.mjs?query=2'; /* eslint-enable */ -import {double} from '../index'; -import defaultFromCjs, {namedFunction} from '../namedExport.cjs'; -import {bag} from '../namespaceExport.js'; test('should have correct import.meta', () => { expect(typeof require).toBe('undefined'); diff --git a/e2e/runJest.ts b/e2e/runJest.ts index 20c567f680d5..d082ca739cea 100644 --- a/e2e/runJest.ts +++ b/e2e/runJest.ts @@ -8,11 +8,11 @@ import * as path from 'path'; import {Writable} from 'stream'; -import * as fs from 'graceful-fs'; import execa = require('execa'); -import type {Config} from '@jest/types'; -import type {FormattedTestResults} from '@jest/test-result'; +import * as fs from 'graceful-fs'; import stripAnsi = require('strip-ansi'); +import type {FormattedTestResults} from '@jest/test-result'; +import type {Config} from '@jest/types'; import {normalizeIcons} from './Utils'; const JEST_PATH = path.resolve(__dirname, '../packages/jest-cli/bin/jest.js'); diff --git a/e2e/test-environment-async/TestEnvironment.js b/e2e/test-environment-async/TestEnvironment.js index 550bb3f4eb79..95cda7ce15a5 100644 --- a/e2e/test-environment-async/TestEnvironment.js +++ b/e2e/test-environment-async/TestEnvironment.js @@ -9,8 +9,8 @@ const fs = require('fs'); const os = require('os'); -const {createDirectory} = require('jest-util'); const JSDOMEnvironment = require('jest-environment-jsdom'); +const {createDirectory} = require('jest-util'); const DIR = os.tmpdir() + '/jest-test-environment'; diff --git a/e2e/test-retries/__tests__/e2e.test.js b/e2e/test-retries/__tests__/e2e.test.js index 9ae0047d8a8b..bee11e3d90f3 100644 --- a/e2e/test-retries/__tests__/e2e.test.js +++ b/e2e/test-retries/__tests__/e2e.test.js @@ -6,8 +6,8 @@ */ 'use strict'; -const path = require('path'); const fs = require('fs'); +const path = require('path'); const countPath = path.join(__dirname, '.tries'); diff --git a/e2e/transform/multiple-transformers/__tests__/multipleTransformers.test.js b/e2e/transform/multiple-transformers/__tests__/multipleTransformers.test.js index f4e53cf1f2c7..1994a1cb656a 100644 --- a/e2e/transform/multiple-transformers/__tests__/multipleTransformers.test.js +++ b/e2e/transform/multiple-transformers/__tests__/multipleTransformers.test.js @@ -7,7 +7,6 @@ import React from 'react'; import renderer from 'react-test-renderer'; - import App from '../src/App'; it('generates a snapshot with correctly transformed dependencies', () => { diff --git a/e2e/transform/multiple-transformers/src/App.js b/e2e/transform/multiple-transformers/src/App.js index c3c2239a80ee..3d1ff6f17ae1 100644 --- a/e2e/transform/multiple-transformers/src/App.js +++ b/e2e/transform/multiple-transformers/src/App.js @@ -6,9 +6,8 @@ */ import React, {Component} from 'react'; -import logo from './logo.svg'; - import styles from './App.css'; +import logo from './logo.svg'; class App extends Component { render() { diff --git a/packages/babel-jest/src/__tests__/index.ts b/packages/babel-jest/src/__tests__/index.ts index df0387390ce6..d024f829c3de 100644 --- a/packages/babel-jest/src/__tests__/index.ts +++ b/packages/babel-jest/src/__tests__/index.ts @@ -5,9 +5,9 @@ * LICENSE file in the root directory of this source tree. */ +import {makeProjectConfig} from '../../../../TestUtils'; import babelJest = require('../index'); import {loadPartialConfig} from '../loadBabelConfig'; -import {makeProjectConfig} from '../../../../TestUtils'; jest.mock('../loadBabelConfig', () => { const actual = jest.requireActual('@babel/core'); diff --git a/packages/babel-jest/src/index.ts b/packages/babel-jest/src/index.ts index 6f7d08202c5b..d180959db2e7 100644 --- a/packages/babel-jest/src/index.ts +++ b/packages/babel-jest/src/index.ts @@ -7,12 +7,6 @@ import {createHash} from 'crypto'; import * as path from 'path'; -import * as fs from 'graceful-fs'; -import type { - TransformOptions as JestTransformOptions, - Transformer, -} from '@jest/transform'; -import type {Config} from '@jest/types'; import { PartialConfig, PluginItem, @@ -21,7 +15,13 @@ import { transformSync as babelTransform, } from '@babel/core'; import chalk = require('chalk'); +import * as fs from 'graceful-fs'; import slash = require('slash'); +import type { + TransformOptions as JestTransformOptions, + Transformer, +} from '@jest/transform'; +import type {Config} from '@jest/types'; import {loadPartialConfig} from './loadBabelConfig'; const THIS_FILE = fs.readFileSync(__filename); diff --git a/packages/babel-plugin-jest-hoist/src/index.ts b/packages/babel-plugin-jest-hoist/src/index.ts index 71046346a579..99e0d8b50749 100644 --- a/packages/babel-plugin-jest-hoist/src/index.ts +++ b/packages/babel-plugin-jest-hoist/src/index.ts @@ -6,6 +6,8 @@ * */ +import type {PluginObj} from '@babel/core'; +import {statement} from '@babel/template'; import type {NodePath} from '@babel/traverse'; import { BlockStatement, @@ -18,8 +20,6 @@ import { emptyStatement, isIdentifier, } from '@babel/types'; -import {statement} from '@babel/template'; -import type {PluginObj} from '@babel/core'; const JEST_GLOBAL_NAME = 'jest'; const JEST_GLOBALS_MODULE_NAME = '@jest/globals'; diff --git a/packages/diff-sequences/perf/index.js b/packages/diff-sequences/perf/index.js index e49bb3459a85..5673f9db1ee3 100644 --- a/packages/diff-sequences/perf/index.js +++ b/packages/diff-sequences/perf/index.js @@ -16,7 +16,6 @@ /* eslint import/no-extraneous-dependencies: "off" */ const Benchmark = require('benchmark'); - const diffBaseline = require('diff').diffLines; const diffImproved = require('../build/index.js').default; diff --git a/packages/expect/src/__tests__/asymmetricMatchers.test.ts b/packages/expect/src/__tests__/asymmetricMatchers.test.ts index dac1a7c1b804..9da8f2cda5c6 100644 --- a/packages/expect/src/__tests__/asymmetricMatchers.test.ts +++ b/packages/expect/src/__tests__/asymmetricMatchers.test.ts @@ -7,7 +7,6 @@ */ import jestExpect from '../'; - import { any, anything, diff --git a/packages/expect/src/__tests__/extend.test.ts b/packages/expect/src/__tests__/extend.test.ts index fb9e30540c8d..898fa98640d5 100644 --- a/packages/expect/src/__tests__/extend.test.ts +++ b/packages/expect/src/__tests__/extend.test.ts @@ -6,11 +6,11 @@ * */ -import * as matcherUtils from 'jest-matcher-utils'; import {alignedAnsiStyleSerializer} from '@jest/test-utils'; -import {iterableEquality, subsetEquality} from '../utils'; -import {equals} from '../jasmineUtils'; +import * as matcherUtils from 'jest-matcher-utils'; import jestExpect from '../'; +import {equals} from '../jasmineUtils'; +import {iterableEquality, subsetEquality} from '../utils'; expect.addSnapshotSerializer(alignedAnsiStyleSerializer); diff --git a/packages/expect/src/__tests__/matchers-toStrictEqual.property.test.ts b/packages/expect/src/__tests__/matchers-toStrictEqual.property.test.ts index 547478a3e542..185a814d0b9b 100644 --- a/packages/expect/src/__tests__/matchers-toStrictEqual.property.test.ts +++ b/packages/expect/src/__tests__/matchers-toStrictEqual.property.test.ts @@ -7,8 +7,8 @@ */ import assert from 'assert'; -import {onNodeVersions} from '@jest/test-utils'; import fc from 'fast-check'; +import {onNodeVersions} from '@jest/test-utils'; import expect from '..'; import { anythingSettings, diff --git a/packages/expect/src/__tests__/matchers.test.js b/packages/expect/src/__tests__/matchers.test.js index 6030060a8bba..6e7b4e619090 100644 --- a/packages/expect/src/__tests__/matchers.test.js +++ b/packages/expect/src/__tests__/matchers.test.js @@ -5,10 +5,10 @@ * LICENSE file in the root directory of this source tree. */ -const {stringify} = require('jest-matcher-utils'); -const {alignedAnsiStyleSerializer} = require('@jest/test-utils'); -const Immutable = require('immutable'); const chalk = require('chalk'); +const Immutable = require('immutable'); +const {alignedAnsiStyleSerializer} = require('@jest/test-utils'); +const {stringify} = require('jest-matcher-utils'); const jestExpect = require('../'); const chalkEnabled = chalk.enabled; diff --git a/packages/expect/src/asymmetricMatchers.ts b/packages/expect/src/asymmetricMatchers.ts index 280ebc9d5fe2..de604b205f13 100644 --- a/packages/expect/src/asymmetricMatchers.ts +++ b/packages/expect/src/asymmetricMatchers.ts @@ -7,7 +7,6 @@ */ import {equals, fnNameFor, hasProperty, isA, isUndefined} from './jasmineUtils'; - import {emptyObject} from './utils'; export class AsymmetricMatcher { diff --git a/packages/expect/src/index.ts b/packages/expect/src/index.ts index a99571dbf8c5..e050afe40a48 100644 --- a/packages/expect/src/index.ts +++ b/packages/expect/src/index.ts @@ -9,26 +9,6 @@ /* eslint-disable local/prefer-spread-eventually */ import * as matcherUtils from 'jest-matcher-utils'; -import type { - AsyncExpectationResult, - Expect, - ExpectationResult, - MatcherState as JestMatcherState, - Matchers as MatcherInterface, - MatchersObject, - PromiseMatcherFn, - RawMatcherFn, - SyncExpectationResult, - ThrowingMatcherFn, -} from './types'; - -import {iterableEquality, subsetEquality} from './utils'; -import matchers from './matchers'; -import spyMatchers from './spyMatchers'; -import toThrowMatchers, { - createMatcher as createThrowMatcher, -} from './toThrowMatchers'; -import {equals} from './jasmineUtils'; import { any, anything, @@ -41,6 +21,8 @@ import { stringNotContaining, stringNotMatching, } from './asymmetricMatchers'; +import extractExpectedAssertionsErrors from './extractExpectedAssertionsErrors'; +import {equals} from './jasmineUtils'; import { INTERNAL_MATCHER_FLAG, getMatchers, @@ -48,7 +30,24 @@ import { setMatchers, setState, } from './jestMatchersObject'; -import extractExpectedAssertionsErrors from './extractExpectedAssertionsErrors'; +import matchers from './matchers'; +import spyMatchers from './spyMatchers'; +import toThrowMatchers, { + createMatcher as createThrowMatcher, +} from './toThrowMatchers'; +import type { + AsyncExpectationResult, + Expect, + ExpectationResult, + MatcherState as JestMatcherState, + Matchers as MatcherInterface, + MatchersObject, + PromiseMatcherFn, + RawMatcherFn, + SyncExpectationResult, + ThrowingMatcherFn, +} from './types'; +import {iterableEquality, subsetEquality} from './utils'; class JestAssertionError extends Error { matcherResult?: SyncExpectationResult; diff --git a/packages/expect/src/matchers.ts b/packages/expect/src/matchers.ts index 2a5e3959d612..f39313f4b99b 100644 --- a/packages/expect/src/matchers.ts +++ b/packages/expect/src/matchers.ts @@ -27,7 +27,7 @@ import { printWithType, stringify, } from 'jest-matcher-utils'; -import type {MatcherState, MatchersObject} from './types'; +import {equals} from './jasmineUtils'; import { printCloseTo, printExpectedConstructorName, @@ -38,6 +38,7 @@ import { printReceivedStringContainExpectedResult, printReceivedStringContainExpectedSubstring, } from './print'; +import type {MatcherState, MatchersObject} from './types'; import { getObjectSubset, getPath, @@ -46,7 +47,6 @@ import { subsetEquality, typeEquality, } from './utils'; -import {equals} from './jasmineUtils'; // Omit colon and one or more spaces, so can call getLabelPrinter. const EXPECTED_LABEL = 'Expected'; diff --git a/packages/expect/src/spyMatchers.ts b/packages/expect/src/spyMatchers.ts index b448f232bbd3..381791368593 100644 --- a/packages/expect/src/spyMatchers.ts +++ b/packages/expect/src/spyMatchers.ts @@ -21,12 +21,12 @@ import { printWithType, stringify, } from 'jest-matcher-utils'; +import {equals} from './jasmineUtils'; import type { MatcherState, MatchersObject, SyncExpectationResult, } from './types'; -import {equals} from './jasmineUtils'; import {iterableEquality} from './utils'; // The optional property of matcher context is true if undefined. diff --git a/packages/expect/src/toThrowMatchers.ts b/packages/expect/src/toThrowMatchers.ts index f21e760911c8..8be9a79ae5fd 100644 --- a/packages/expect/src/toThrowMatchers.ts +++ b/packages/expect/src/toThrowMatchers.ts @@ -8,7 +8,6 @@ /* eslint-disable local/ban-types-eventually */ -import {formatStackTrace, separateMessageFromStack} from 'jest-message-util'; import { EXPECTED_COLOR, MatcherHintOptions, @@ -20,6 +19,7 @@ import { printReceived, printWithType, } from 'jest-matcher-utils'; +import {formatStackTrace, separateMessageFromStack} from 'jest-message-util'; import { printExpectedConstructorName, printExpectedConstructorNameNot, diff --git a/packages/jest-changed-files/src/git.ts b/packages/jest-changed-files/src/git.ts index f5cae575fa9b..6ea2233aa582 100644 --- a/packages/jest-changed-files/src/git.ts +++ b/packages/jest-changed-files/src/git.ts @@ -9,7 +9,6 @@ import * as path from 'path'; import execa = require('execa'); import type {Config} from '@jest/types'; - import type {SCMAdapter} from './types'; const findChangedFilesUsingCommand = async ( diff --git a/packages/jest-changed-files/src/hg.ts b/packages/jest-changed-files/src/hg.ts index 3840bc983554..c4d2f527600d 100644 --- a/packages/jest-changed-files/src/hg.ts +++ b/packages/jest-changed-files/src/hg.ts @@ -9,7 +9,6 @@ import * as path from 'path'; import execa = require('execa'); import type {Config} from '@jest/types'; - import type {SCMAdapter} from './types'; const env = {...process.env, HGPLAIN: '1'}; diff --git a/packages/jest-changed-files/src/index.ts b/packages/jest-changed-files/src/index.ts index fd9323e243cf..69ddb8ce3b11 100644 --- a/packages/jest-changed-files/src/index.ts +++ b/packages/jest-changed-files/src/index.ts @@ -8,10 +8,9 @@ import throat from 'throat'; import type {Config} from '@jest/types'; - -import type {ChangedFilesPromise, Options, Repos, SCMAdapter} from './types'; import git from './git'; import hg from './hg'; +import type {ChangedFilesPromise, Options, Repos, SCMAdapter} from './types'; type RootPromise = ReturnType; diff --git a/packages/jest-circus/README.md b/packages/jest-circus/README.md index 45f7218d64e9..f2644d412dfd 100644 --- a/packages/jest-circus/README.md +++ b/packages/jest-circus/README.md @@ -12,8 +12,8 @@ Circus is a flux-based test runner for Jest that is fast, maintainable, and simp Circus allows you to bind to events via an optional event handler on any [custom environment](https://jestjs.io/docs/en/configuration#testenvironment-string). See the [type definitions](https://github.com/facebook/jest/blob/master/packages/jest-circus/src/types.ts) for more information on the events and state data currently available. ```js -import NodeEnvironment from 'jest-environment-node'; import {Event, State} from 'jest-circus'; +import NodeEnvironment from 'jest-environment-node'; class MyCustomEnvironment extends NodeEnvironment { //... diff --git a/packages/jest-circus/src/__mocks__/testUtils.ts b/packages/jest-circus/src/__mocks__/testUtils.ts index 0f3827b18af3..52557f72fcb8 100644 --- a/packages/jest-circus/src/__mocks__/testUtils.ts +++ b/packages/jest-circus/src/__mocks__/testUtils.ts @@ -5,11 +5,11 @@ * LICENSE file in the root directory of this source tree. */ +import {createHash} from 'crypto'; import {tmpdir} from 'os'; import * as path from 'path'; -import {createHash} from 'crypto'; -import * as fs from 'graceful-fs'; import {ExecaSyncReturnValue, sync as spawnSync} from 'execa'; +import * as fs from 'graceful-fs'; const CIRCUS_PATH = require.resolve('../../build').replace(/\\/g, '\\\\'); const CIRCUS_RUN_PATH = require diff --git a/packages/jest-circus/src/eventHandler.ts b/packages/jest-circus/src/eventHandler.ts index dfe916a629a1..31a0362ce321 100644 --- a/packages/jest-circus/src/eventHandler.ts +++ b/packages/jest-circus/src/eventHandler.ts @@ -6,8 +6,11 @@ */ import type {Circus} from '@jest/types'; +import { + injectGlobalErrorHandlers, + restoreGlobalErrorHandlers, +} from './globalErrorHandlers'; import {TEST_TIMEOUT_SYMBOL} from './types'; - import { addErrorToEachTestUnderDescribe, describeBlockHasTests, @@ -16,10 +19,6 @@ import { makeDescribe, makeTest, } from './utils'; -import { - injectGlobalErrorHandlers, - restoreGlobalErrorHandlers, -} from './globalErrorHandlers'; // TODO: investigate why a shorter (event, state) signature results into TS7006 compiler error const eventHandler: Circus.EventHandler = ( diff --git a/packages/jest-circus/src/formatNodeAssertErrors.ts b/packages/jest-circus/src/formatNodeAssertErrors.ts index 10ffc8d1e25f..602d1414c61c 100644 --- a/packages/jest-circus/src/formatNodeAssertErrors.ts +++ b/packages/jest-circus/src/formatNodeAssertErrors.ts @@ -6,6 +6,7 @@ */ import {AssertionError} from 'assert'; +import chalk = require('chalk'); import type {Circus} from '@jest/types'; import { DiffOptions, @@ -13,7 +14,6 @@ import { printExpected, printReceived, } from 'jest-matcher-utils'; -import chalk = require('chalk'); import prettyFormat = require('pretty-format'); interface AssertionErrorWithStack extends AssertionError { diff --git a/packages/jest-circus/src/index.ts b/packages/jest-circus/src/index.ts index 782bb5ce1387..bd85fbd5cbbc 100644 --- a/packages/jest-circus/src/index.ts +++ b/packages/jest-circus/src/index.ts @@ -6,10 +6,10 @@ */ import chalk = require('chalk'); +import type {Circus, Global} from '@jest/types'; import {bind as bindEach} from 'jest-each'; import {formatExecError} from 'jest-message-util'; import {ErrorWithStack, isPromise} from 'jest-util'; -import type {Circus, Global} from '@jest/types'; import {dispatchSync} from './state'; type THook = (fn: Circus.HookFn, timeout?: number) => void; diff --git a/packages/jest-circus/src/legacy-code-todo-rewrite/jestAdapter.ts b/packages/jest-circus/src/legacy-code-todo-rewrite/jestAdapter.ts index bddb5d5606a0..f20ef5c0df68 100644 --- a/packages/jest-circus/src/legacy-code-todo-rewrite/jestAdapter.ts +++ b/packages/jest-circus/src/legacy-code-todo-rewrite/jestAdapter.ts @@ -5,9 +5,9 @@ * LICENSE file in the root directory of this source tree. */ -import type {Config} from '@jest/types'; import type {JestEnvironment} from '@jest/environment'; import type {TestResult} from '@jest/test-result'; +import type {Config} from '@jest/types'; import type {TestFileEvent} from 'jest-runner'; import type {RuntimeType as Runtime} from 'jest-runtime'; import type {SnapshotStateType} from 'jest-snapshot'; diff --git a/packages/jest-circus/src/legacy-code-todo-rewrite/jestAdapterInit.ts b/packages/jest-circus/src/legacy-code-todo-rewrite/jestAdapterInit.ts index b8820e32fe80..46e73ade095d 100644 --- a/packages/jest-circus/src/legacy-code-todo-rewrite/jestAdapterInit.ts +++ b/packages/jest-circus/src/legacy-code-todo-rewrite/jestAdapterInit.ts @@ -6,7 +6,7 @@ */ import type BabelTraverse from '@babel/traverse'; -import type {Circus, Config, Global} from '@jest/types'; +import throat from 'throat'; import type {JestEnvironment} from '@jest/environment'; import { AssertionResult, @@ -14,7 +14,9 @@ import { TestResult, createEmptyTestResult, } from '@jest/test-result'; +import type {Circus, Config, Global} from '@jest/types'; import {extractExpectedAssertionsErrors, getState, setState} from 'expect'; +import {bind} from 'jest-each'; import {formatExecError, formatResultsErrors} from 'jest-message-util'; import type {TestFileEvent} from 'jest-runner'; import { @@ -23,18 +25,16 @@ import { addSerializer, buildSnapshotResolver, } from 'jest-snapshot'; -import {bind} from 'jest-each'; -import throat from 'throat'; +import globals from '..'; +import run from '../run'; import { ROOT_DESCRIBE_BLOCK_NAME, addEventHandler, dispatch, getState as getRunnerState, } from '../state'; -import {getTestID} from '../utils'; -import run from '../run'; import testCaseReportHandler from '../testCaseReportHandler'; -import globals from '..'; +import {getTestID} from '../utils'; import createExpect, {Expect} from './jestExpect'; type Process = NodeJS.Process; diff --git a/packages/jest-circus/src/legacy-code-todo-rewrite/jestExpect.ts b/packages/jest-circus/src/legacy-code-todo-rewrite/jestExpect.ts index 81a62f3cfe75..a13ce01bd3a8 100644 --- a/packages/jest-circus/src/legacy-code-todo-rewrite/jestExpect.ts +++ b/packages/jest-circus/src/legacy-code-todo-rewrite/jestExpect.ts @@ -7,7 +7,6 @@ import type {Config} from '@jest/types'; import expect = require('expect'); - import { addSerializer, toMatchInlineSnapshot, diff --git a/packages/jest-circus/src/run.ts b/packages/jest-circus/src/run.ts index c3509943c4c4..8f198dadf166 100644 --- a/packages/jest-circus/src/run.ts +++ b/packages/jest-circus/src/run.ts @@ -6,9 +6,8 @@ */ import type {Circus} from '@jest/types'; -import {RETRY_TIMES} from './types'; - import {dispatch, getState} from './state'; +import {RETRY_TIMES} from './types'; import { callAsyncCircusFn, getAllHooksForDescribe, diff --git a/packages/jest-circus/src/state.ts b/packages/jest-circus/src/state.ts index be81a73045f6..5af3c07c22b0 100644 --- a/packages/jest-circus/src/state.ts +++ b/packages/jest-circus/src/state.ts @@ -6,11 +6,10 @@ */ import type {Circus} from '@jest/types'; -import {STATE_SYM} from './types'; - -import {makeDescribe} from './utils'; import eventHandler from './eventHandler'; import formatNodeAssertErrors from './formatNodeAssertErrors'; +import {STATE_SYM} from './types'; +import {makeDescribe} from './utils'; const eventHandlers: Array = [ eventHandler, diff --git a/packages/jest-circus/src/types.ts b/packages/jest-circus/src/types.ts index 78fc35ccc8da..60c406117cf0 100644 --- a/packages/jest-circus/src/types.ts +++ b/packages/jest-circus/src/types.ts @@ -6,8 +6,8 @@ */ // Used as type -import expect = require('expect'); import type {Circus} from '@jest/types'; +import expect = require('expect'); export const STATE_SYM = (Symbol( 'JEST_STATE_SYMBOL', diff --git a/packages/jest-circus/src/utils.ts b/packages/jest-circus/src/utils.ts index 03f02e69d173..7a52de3a46af 100644 --- a/packages/jest-circus/src/utils.ts +++ b/packages/jest-circus/src/utils.ts @@ -6,14 +6,14 @@ */ import * as path from 'path'; -import type {Circus} from '@jest/types'; -import {ErrorWithStack, convertDescriptorToString, formatTime} from 'jest-util'; -import isGeneratorFn from 'is-generator-fn'; import co from 'co'; import dedent = require('dedent'); +import isGeneratorFn from 'is-generator-fn'; import StackUtils = require('stack-utils'); -import prettyFormat = require('pretty-format'); import type {AssertionResult, Status} from '@jest/test-result'; +import type {Circus} from '@jest/types'; +import {ErrorWithStack, convertDescriptorToString, formatTime} from 'jest-util'; +import prettyFormat = require('pretty-format'); import {ROOT_DESCRIBE_BLOCK_NAME, getState} from './state'; const stackUtils = new StackUtils({cwd: 'A path that does not exist'}); diff --git a/packages/jest-cli/src/__tests__/cli/args.test.ts b/packages/jest-cli/src/__tests__/cli/args.test.ts index 9abd2b945761..1e8bc855ebaf 100644 --- a/packages/jest-cli/src/__tests__/cli/args.test.ts +++ b/packages/jest-cli/src/__tests__/cli/args.test.ts @@ -8,8 +8,8 @@ import type {Config} from '@jest/types'; import {constants} from 'jest-config'; -import {check} from '../../cli/args'; import {buildArgv} from '../../cli'; +import {check} from '../../cli/args'; describe('check', () => { it('returns true if the arguments are valid', () => { diff --git a/packages/jest-cli/src/cli/args.ts b/packages/jest-cli/src/cli/args.ts index a053a20faad8..61a637eda59f 100644 --- a/packages/jest-cli/src/cli/args.ts +++ b/packages/jest-cli/src/cli/args.ts @@ -5,9 +5,9 @@ * LICENSE file in the root directory of this source tree. */ +import isCI = require('is-ci'); import type {Config} from '@jest/types'; import {constants, isJSONString} from 'jest-config'; -import isCI = require('is-ci'); export function check(argv: Config.Argv): true { if (argv.runInBand && argv.hasOwnProperty('maxWorkers')) { diff --git a/packages/jest-cli/src/cli/index.ts b/packages/jest-cli/src/cli/index.ts index 6e0d853aa8c3..a20eae54d50d 100644 --- a/packages/jest-cli/src/cli/index.ts +++ b/packages/jest-cli/src/cli/index.ts @@ -6,15 +6,15 @@ */ import * as path from 'path'; -import type {Config} from '@jest/types'; -import type {AggregatedResult} from '@jest/test-result'; -import {clearLine, tryRealpath} from 'jest-util'; -import {validateCLIOptions} from 'jest-validate'; -import {deprecationEntries} from 'jest-config'; -import {getVersion, runCLI} from '@jest/core'; import chalk = require('chalk'); import exit = require('exit'); import yargs = require('yargs'); +import {getVersion, runCLI} from '@jest/core'; +import type {AggregatedResult} from '@jest/test-result'; +import type {Config} from '@jest/types'; +import {deprecationEntries} from 'jest-config'; +import {clearLine, tryRealpath} from 'jest-util'; +import {validateCLIOptions} from 'jest-validate'; import init from '../init'; import * as args from './args'; diff --git a/packages/jest-cli/src/init/index.ts b/packages/jest-cli/src/init/index.ts index 67eef8cdd02b..b063fcb66b91 100644 --- a/packages/jest-cli/src/init/index.ts +++ b/packages/jest-cli/src/init/index.ts @@ -6,15 +6,15 @@ */ import * as path from 'path'; -import * as fs from 'graceful-fs'; import chalk = require('chalk'); +import * as fs from 'graceful-fs'; import prompts = require('prompts'); import {constants} from 'jest-config'; import {tryRealpath} from 'jest-util'; -import defaultQuestions, {testScriptQuestion} from './questions'; import {MalformedPackageJsonError, NotFoundPackageJsonError} from './errors'; import generateConfigFile from './generateConfigFile'; import modifyPackageJson from './modifyPackageJson'; +import defaultQuestions, {testScriptQuestion} from './questions'; import type {ProjectPackageJson} from './types'; const { diff --git a/packages/jest-config/src/Deprecated.ts b/packages/jest-config/src/Deprecated.ts index 493a44770692..841983fa1a3b 100644 --- a/packages/jest-config/src/Deprecated.ts +++ b/packages/jest-config/src/Deprecated.ts @@ -6,8 +6,8 @@ */ import chalk = require('chalk'); -import prettyFormat = require('pretty-format'); import type {DeprecatedOptions} from 'jest-validate'; +import prettyFormat = require('pretty-format'); const format = (value: unknown) => prettyFormat(value, {min: true}); diff --git a/packages/jest-config/src/ReporterValidationErrors.ts b/packages/jest-config/src/ReporterValidationErrors.ts index 271d810ea117..8f15a50a0162 100644 --- a/packages/jest-config/src/ReporterValidationErrors.ts +++ b/packages/jest-config/src/ReporterValidationErrors.ts @@ -5,10 +5,10 @@ * LICENSE file in the root directory of this source tree. */ -import type {Config} from '@jest/types'; -import {ValidationError} from 'jest-validate'; import chalk = require('chalk'); +import type {Config} from '@jest/types'; import getType = require('jest-get-type'); +import {ValidationError} from 'jest-validate'; import {BULLET, DOCUMENTATION_NOTE} from './utils'; const validReporterTypes = ['array', 'string']; diff --git a/packages/jest-config/src/__tests__/normalize.test.js b/packages/jest-config/src/__tests__/normalize.test.js index efd348a2bc48..ae3b198b2fed 100644 --- a/packages/jest-config/src/__tests__/normalize.test.js +++ b/packages/jest-config/src/__tests__/normalize.test.js @@ -9,10 +9,9 @@ import crypto from 'crypto'; import path from 'path'; import {escapeStrForRegex} from 'jest-regex-util'; -import normalize from '../normalize'; import Defaults from '../Defaults'; - import {DEFAULT_JS_PATTERN} from '../constants'; +import normalize from '../normalize'; const DEFAULT_CSS_PATTERN = '\\.(css)$'; diff --git a/packages/jest-config/src/__tests__/resolveConfigPath.test.ts b/packages/jest-config/src/__tests__/resolveConfigPath.test.ts index b90166c73877..78c0882f8dfc 100644 --- a/packages/jest-config/src/__tests__/resolveConfigPath.test.ts +++ b/packages/jest-config/src/__tests__/resolveConfigPath.test.ts @@ -7,9 +7,8 @@ import {tmpdir} from 'os'; import * as path from 'path'; -import resolveConfigPath from '../resolveConfigPath'; import {JEST_CONFIG_EXT_ORDER} from '../constants'; - +import resolveConfigPath from '../resolveConfigPath'; const {cleanup, writeFiles} = require('../../../../e2e/Utils'); const DIR = path.resolve(tmpdir(), 'resolve_config_path_test'); diff --git a/packages/jest-config/src/getCacheDirectory.ts b/packages/jest-config/src/getCacheDirectory.ts index c23a08870a26..12944ccff4a8 100644 --- a/packages/jest-config/src/getCacheDirectory.ts +++ b/packages/jest-config/src/getCacheDirectory.ts @@ -5,8 +5,8 @@ * LICENSE file in the root directory of this source tree. */ -import * as path from 'path'; import {tmpdir} from 'os'; +import * as path from 'path'; import type {Config} from '@jest/types'; import {tryRealpath} from 'jest-util'; diff --git a/packages/jest-config/src/index.ts b/packages/jest-config/src/index.ts index 17f930260df2..2d3212933f2b 100644 --- a/packages/jest-config/src/index.ts +++ b/packages/jest-config/src/index.ts @@ -6,21 +6,21 @@ */ import * as path from 'path'; +import chalk = require('chalk'); import * as fs from 'graceful-fs'; import type {Config} from '@jest/types'; import {tryRealpath} from 'jest-util'; -import chalk = require('chalk'); -import {isJSONString, replaceRootDirInPath} from './utils'; +import * as constants from './constants'; import normalize from './normalize'; -import resolveConfigPath from './resolveConfigPath'; import readConfigFileAndSetRootDir from './readConfigFileAndSetRootDir'; +import resolveConfigPath from './resolveConfigPath'; +import {isJSONString, replaceRootDirInPath} from './utils'; export {getTestEnvironment, isJSONString} from './utils'; export {default as normalize} from './normalize'; export {default as deprecationEntries} from './Deprecated'; export {replaceRootDirInPath} from './utils'; export {default as defaults} from './Defaults'; export {default as descriptions} from './Descriptions'; -import * as constants from './constants'; export {constants}; type ReadConfig = { diff --git a/packages/jest-config/src/normalize.ts b/packages/jest-config/src/normalize.ts index ce1915d33daf..82da0cc8a397 100644 --- a/packages/jest-config/src/normalize.ts +++ b/packages/jest-config/src/normalize.ts @@ -7,18 +7,24 @@ import {createHash} from 'crypto'; import * as path from 'path'; -import {statSync} from 'graceful-fs'; -import {sync as glob} from 'glob'; -import type {Config} from '@jest/types'; -import {ValidationError, validate} from 'jest-validate'; -import {clearLine, replacePathSepForGlob, tryRealpath} from 'jest-util'; import chalk = require('chalk'); +import merge = require('deepmerge'); +import {sync as glob} from 'glob'; +import {statSync} from 'graceful-fs'; import micromatch = require('micromatch'); -import Resolver = require('jest-resolve'); +import type {Config} from '@jest/types'; import {replacePathSepForRegex} from 'jest-regex-util'; -import merge = require('deepmerge'); -import validatePattern from './validatePattern'; +import Resolver = require('jest-resolve'); +import {clearLine, replacePathSepForGlob, tryRealpath} from 'jest-util'; +import {ValidationError, validate} from 'jest-validate'; +import DEFAULT_CONFIG from './Defaults'; +import DEPRECATED_CONFIG from './Deprecated'; +import {validateReporters} from './ReporterValidationErrors'; +import VALID_CONFIG from './ValidConfig'; +import {getDisplayNameColor} from './color'; +import {DEFAULT_JS_PATTERN, DEFAULT_REPORTER_LABEL} from './constants'; import getMaxWorkers from './getMaxWorkers'; +import setFromArgv from './setFromArgv'; import { BULLET, DOCUMENTATION_NOTE, @@ -31,13 +37,7 @@ import { replaceRootDirInPath, resolve, } from './utils'; -import {DEFAULT_JS_PATTERN, DEFAULT_REPORTER_LABEL} from './constants'; -import {validateReporters} from './ReporterValidationErrors'; -import DEFAULT_CONFIG from './Defaults'; -import DEPRECATED_CONFIG from './Deprecated'; -import setFromArgv from './setFromArgv'; -import VALID_CONFIG from './ValidConfig'; -import {getDisplayNameColor} from './color'; +import validatePattern from './validatePattern'; const ERROR = `${BULLET}Validation Error`; const PRESET_EXTENSIONS = ['.json', '.js']; const PRESET_NAME = 'jest-preset'; diff --git a/packages/jest-config/src/readConfigFileAndSetRootDir.ts b/packages/jest-config/src/readConfigFileAndSetRootDir.ts index 68cee0e87a6b..fe1ba50935ce 100644 --- a/packages/jest-config/src/readConfigFileAndSetRootDir.ts +++ b/packages/jest-config/src/readConfigFileAndSetRootDir.ts @@ -8,16 +8,16 @@ import * as path from 'path'; import {pathToFileURL} from 'url'; import * as fs from 'graceful-fs'; +import type {Register} from 'ts-node'; import type {Config} from '@jest/types'; import {interopRequireDefault} from 'jest-util'; -import type {Register} from 'ts-node'; -// @ts-expect-error: vendored -import jsonlint from './vendor/jsonlint'; import { JEST_CONFIG_EXT_JSON, JEST_CONFIG_EXT_TS, PACKAGE_JSON, } from './constants'; +// @ts-expect-error: vendored +import jsonlint from './vendor/jsonlint'; // Read the configuration and set its `rootDir` // 1. If it's a `package.json` file, we look into its "jest" property diff --git a/packages/jest-config/src/setFromArgv.ts b/packages/jest-config/src/setFromArgv.ts index e9e287f64893..aedb9b3792f8 100644 --- a/packages/jest-config/src/setFromArgv.ts +++ b/packages/jest-config/src/setFromArgv.ts @@ -6,9 +6,9 @@ */ import type {Config} from '@jest/types'; +import {isJSONString} from './utils'; const specialArgs = ['_', '$0', 'h', 'help', 'config']; -import {isJSONString} from './utils'; export default function setFromArgv( options: Config.InitialOptions, diff --git a/packages/jest-config/src/utils.ts b/packages/jest-config/src/utils.ts index baa834fffcf9..e763b94267cc 100644 --- a/packages/jest-config/src/utils.ts +++ b/packages/jest-config/src/utils.ts @@ -6,10 +6,10 @@ */ import * as path from 'path'; +import chalk = require('chalk'); import type {Config} from '@jest/types'; -import {ValidationError} from 'jest-validate'; import Resolver = require('jest-resolve'); -import chalk = require('chalk'); +import {ValidationError} from 'jest-validate'; type ResolveOptions = { rootDir: Config.Path; diff --git a/packages/jest-console/src/CustomConsole.ts b/packages/jest-console/src/CustomConsole.ts index 0bbb8561db2d..5c3ed54da576 100644 --- a/packages/jest-console/src/CustomConsole.ts +++ b/packages/jest-console/src/CustomConsole.ts @@ -6,8 +6,8 @@ */ import assert = require('assert'); -import {format} from 'util'; import {Console} from 'console'; +import {format} from 'util'; import chalk = require('chalk'); import {clearLine, formatTime} from 'jest-util'; import type {LogCounters, LogMessage, LogTimers, LogType} from './types'; diff --git a/packages/jest-console/src/__tests__/getConsoleOutput.test.ts b/packages/jest-console/src/__tests__/getConsoleOutput.test.ts index fc0a2749a49f..1eaa491ac8f1 100644 --- a/packages/jest-console/src/__tests__/getConsoleOutput.test.ts +++ b/packages/jest-console/src/__tests__/getConsoleOutput.test.ts @@ -6,10 +6,10 @@ */ import {formatStackTrace} from 'jest-message-util'; -import getConsoleOutput from '../getConsoleOutput'; +import {makeGlobalConfig} from '../../../../TestUtils'; import BufferedConsole from '../BufferedConsole'; +import getConsoleOutput from '../getConsoleOutput'; import type {LogType} from '../types'; -import {makeGlobalConfig} from '../../../../TestUtils'; jest.mock('jest-message-util', () => ({ formatStackTrace: jest.fn(), diff --git a/packages/jest-console/src/getConsoleOutput.ts b/packages/jest-console/src/getConsoleOutput.ts index f6f0369f50ee..386cd85b482c 100644 --- a/packages/jest-console/src/getConsoleOutput.ts +++ b/packages/jest-console/src/getConsoleOutput.ts @@ -6,12 +6,12 @@ */ import chalk = require('chalk'); +import type {Config} from '@jest/types'; import { StackTraceConfig, StackTraceOptions, formatStackTrace, } from 'jest-message-util'; -import type {Config} from '@jest/types'; import type {ConsoleBuffer} from './types'; export default ( diff --git a/packages/jest-core/src/FailedTestsCache.ts b/packages/jest-core/src/FailedTestsCache.ts index 0bcda8046500..13915707ad84 100644 --- a/packages/jest-core/src/FailedTestsCache.ts +++ b/packages/jest-core/src/FailedTestsCache.ts @@ -5,9 +5,9 @@ * LICENSE file in the root directory of this source tree. */ -import type {Test} from 'jest-runner'; -import type {Config} from '@jest/types'; import type {TestResult} from '@jest/test-result'; +import type {Config} from '@jest/types'; +import type {Test} from 'jest-runner'; type TestMap = Record>; diff --git a/packages/jest-core/src/ReporterDispatcher.ts b/packages/jest-core/src/ReporterDispatcher.ts index 9f152607c5bb..de69ec7d1d40 100644 --- a/packages/jest-core/src/ReporterDispatcher.ts +++ b/packages/jest-core/src/ReporterDispatcher.ts @@ -7,6 +7,7 @@ /* eslint-disable local/ban-types-eventually */ +import type {Reporter, ReporterOnStartOptions} from '@jest/reporters'; import type { AggregatedResult, TestCaseResult, @@ -14,7 +15,6 @@ import type { } from '@jest/test-result'; import type {Test} from 'jest-runner'; import type {Context} from 'jest-runtime'; -import type {Reporter, ReporterOnStartOptions} from '@jest/reporters'; export default class ReporterDispatcher { private _reporters: Array; diff --git a/packages/jest-core/src/SearchSource.ts b/packages/jest-core/src/SearchSource.ts index 333d8539f314..e473732e5dc4 100644 --- a/packages/jest-core/src/SearchSource.ts +++ b/packages/jest-core/src/SearchSource.ts @@ -8,13 +8,13 @@ import * as os from 'os'; import * as path from 'path'; import micromatch = require('micromatch'); -import type {Context} from 'jest-runtime'; import type {Config} from '@jest/types'; -import type {Test} from 'jest-runner'; import type {ChangedFiles} from 'jest-changed-files'; -import DependencyResolver = require('jest-resolve-dependencies'); -import {escapePathForRegex} from 'jest-regex-util'; import {replaceRootDirInPath} from 'jest-config'; +import {escapePathForRegex} from 'jest-regex-util'; +import DependencyResolver = require('jest-resolve-dependencies'); +import type {Test} from 'jest-runner'; +import type {Context} from 'jest-runtime'; import {buildSnapshotResolver} from 'jest-snapshot'; import {globsToMatcher, testPathPatternToRegExp} from 'jest-util'; import type {Filter, Stats, TestPathCases} from './types'; diff --git a/packages/jest-core/src/SnapshotInteractiveMode.ts b/packages/jest-core/src/SnapshotInteractiveMode.ts index 360c35f5473e..576c97f91146 100644 --- a/packages/jest-core/src/SnapshotInteractiveMode.ts +++ b/packages/jest-core/src/SnapshotInteractiveMode.ts @@ -5,11 +5,11 @@ * LICENSE file in the root directory of this source tree. */ -import chalk = require('chalk'); import ansiEscapes = require('ansi-escapes'); +import chalk = require('chalk'); import type {AggregatedResult, AssertionLocation} from '@jest/test-result'; -import {KEYS} from 'jest-watcher'; import {pluralize, specialChars} from 'jest-util'; +import {KEYS} from 'jest-watcher'; const {ARROW, CLEAR} = specialChars; diff --git a/packages/jest-core/src/TestNamePatternPrompt.ts b/packages/jest-core/src/TestNamePatternPrompt.ts index 8fd02b108501..4405af30e603 100644 --- a/packages/jest-core/src/TestNamePatternPrompt.ts +++ b/packages/jest-core/src/TestNamePatternPrompt.ts @@ -5,6 +5,7 @@ * LICENSE file in the root directory of this source tree. */ +import type {TestResult} from '@jest/test-result'; import { PatternPrompt, Prompt, @@ -12,7 +13,6 @@ import { printPatternCaret, printRestoredPatternCaret, } from 'jest-watcher'; -import type {TestResult} from '@jest/test-result'; // TODO: Make underscored props `private` export default class TestNamePatternPrompt extends PatternPrompt { diff --git a/packages/jest-core/src/TestPathPatternPrompt.ts b/packages/jest-core/src/TestPathPatternPrompt.ts index 7e6622e23335..19ff54161101 100644 --- a/packages/jest-core/src/TestPathPatternPrompt.ts +++ b/packages/jest-core/src/TestPathPatternPrompt.ts @@ -5,9 +5,8 @@ * LICENSE file in the root directory of this source tree. */ -import type {Context} from 'jest-runtime'; import type {Test} from 'jest-runner'; - +import type {Context} from 'jest-runtime'; import { PatternPrompt, Prompt, diff --git a/packages/jest-core/src/TestScheduler.ts b/packages/jest-core/src/TestScheduler.ts index 3daa3731bb8c..79fad4c133c4 100644 --- a/packages/jest-core/src/TestScheduler.ts +++ b/packages/jest-core/src/TestScheduler.ts @@ -8,11 +8,7 @@ /* eslint-disable local/ban-types-eventually */ import chalk = require('chalk'); -import {formatExecError} from 'jest-message-util'; -import type {Config} from '@jest/types'; -import snapshot = require('jest-snapshot'); -import TestRunner = require('jest-runner'); -import type {Context} from 'jest-runtime'; +import exit = require('exit'); import { CoverageReporter, DefaultReporter, @@ -21,7 +17,6 @@ import { SummaryReporter, VerboseReporter, } from '@jest/reporters'; -import exit = require('exit'); import { AggregatedResult, SerializableError, @@ -30,6 +25,11 @@ import { buildFailureTestResult, makeEmptyAggregatedTestResult, } from '@jest/test-result'; +import type {Config} from '@jest/types'; +import {formatExecError} from 'jest-message-util'; +import TestRunner = require('jest-runner'); +import type {Context} from 'jest-runtime'; +import snapshot = require('jest-snapshot'); import {interopRequireDefault} from 'jest-util'; import ReporterDispatcher from './ReporterDispatcher'; import type TestWatcher from './TestWatcher'; diff --git a/packages/jest-core/src/__tests__/SearchSource.test.ts b/packages/jest-core/src/__tests__/SearchSource.test.ts index 7cd80b9f3c23..2f96cc1b4fe4 100644 --- a/packages/jest-core/src/__tests__/SearchSource.test.ts +++ b/packages/jest-core/src/__tests__/SearchSource.test.ts @@ -7,10 +7,10 @@ */ import * as path from 'path'; -import Runtime = require('jest-runtime'); +import type {Config} from '@jest/types'; import {normalize} from 'jest-config'; import {Test} from 'jest-runner'; -import type {Config} from '@jest/types'; +import Runtime = require('jest-runtime'); import SearchSource, {SearchResult} from '../SearchSource'; jest.setTimeout(15000); diff --git a/packages/jest-core/src/__tests__/TestScheduler.test.js b/packages/jest-core/src/__tests__/TestScheduler.test.js index dbbe8c052165..61434c1fac86 100644 --- a/packages/jest-core/src/__tests__/TestScheduler.test.js +++ b/packages/jest-core/src/__tests__/TestScheduler.test.js @@ -7,9 +7,9 @@ */ import {SummaryReporter} from '@jest/reporters'; +import {makeProjectConfig} from '../../../../TestUtils'; import TestScheduler from '../TestScheduler'; import * as testSchedulerHelper from '../testSchedulerHelper'; -import {makeProjectConfig} from '../../../../TestUtils'; jest.mock('@jest/reporters'); const mockSerialRunner = { diff --git a/packages/jest-core/src/__tests__/watch.test.js b/packages/jest-core/src/__tests__/watch.test.js index 732c390d91d6..fbf6bead2573 100644 --- a/packages/jest-core/src/__tests__/watch.test.js +++ b/packages/jest-core/src/__tests__/watch.test.js @@ -8,6 +8,7 @@ import chalk from 'chalk'; import {JestHook, KEYS} from 'jest-watcher'; +// eslint-disable-next-line import/order import TestWatcher from '../TestWatcher'; const runJestMock = jest.fn(); diff --git a/packages/jest-core/src/__tests__/watchFileChanges.test.ts b/packages/jest-core/src/__tests__/watchFileChanges.test.ts index ea953f7d7b4d..8f19c1746b02 100644 --- a/packages/jest-core/src/__tests__/watchFileChanges.test.ts +++ b/packages/jest-core/src/__tests__/watchFileChanges.test.ts @@ -6,15 +6,15 @@ * */ -import * as path from 'path'; import {tmpdir} from 'os'; +import * as path from 'path'; import * as fs from 'graceful-fs'; -import {JestHook} from 'jest-watcher'; -import Runtime = require('jest-runtime'); -import {normalize} from 'jest-config'; -import HasteMap = require('jest-haste-map'); import rimraf = require('rimraf'); import type {AggregatedResult} from '@jest/test-result'; +import {normalize} from 'jest-config'; +import HasteMap = require('jest-haste-map'); +import Runtime = require('jest-runtime'); +import {JestHook} from 'jest-watcher'; describe('Watch mode flows with changed files', () => { jest.resetModules(); diff --git a/packages/jest-core/src/__tests__/watchFilenamePatternMode.test.js b/packages/jest-core/src/__tests__/watchFilenamePatternMode.test.js index 0684b22960e7..a6ab863697dd 100644 --- a/packages/jest-core/src/__tests__/watchFilenamePatternMode.test.js +++ b/packages/jest-core/src/__tests__/watchFilenamePatternMode.test.js @@ -8,6 +8,7 @@ import chalk from 'chalk'; import wrap from 'jest-snapshot-serializer-raw'; +// eslint-disable-next-line import/order import {KEYS} from 'jest-watcher'; const runJestMock = jest.fn(); diff --git a/packages/jest-core/src/__tests__/watchTestNamePatternMode.test.js b/packages/jest-core/src/__tests__/watchTestNamePatternMode.test.js index f4d231c524f6..59ac0c590af6 100644 --- a/packages/jest-core/src/__tests__/watchTestNamePatternMode.test.js +++ b/packages/jest-core/src/__tests__/watchTestNamePatternMode.test.js @@ -8,6 +8,7 @@ import chalk from 'chalk'; import wrap from 'jest-snapshot-serializer-raw'; +// eslint-disable-next-line import/order import {KEYS} from 'jest-watcher'; const runJestMock = jest.fn(); diff --git a/packages/jest-core/src/cli/index.ts b/packages/jest-core/src/cli/index.ts index a6938bea6482..c115e865dd09 100644 --- a/packages/jest-core/src/cli/index.ts +++ b/packages/jest-core/src/cli/index.ts @@ -5,30 +5,30 @@ * LICENSE file in the root directory of this source tree. */ -import type {Config} from '@jest/types'; -import type {AggregatedResult} from '@jest/test-result'; +import chalk = require('chalk'); +import exit = require('exit'); +import rimraf = require('rimraf'); import {CustomConsole} from '@jest/console'; -import {createDirectory, preRunMessage} from 'jest-util'; -import {readConfigs} from 'jest-config'; -import Runtime = require('jest-runtime'); +import type {AggregatedResult} from '@jest/test-result'; +import type {Config} from '@jest/types'; import type {ChangedFilesPromise} from 'jest-changed-files'; +import {readConfigs} from 'jest-config'; import HasteMap = require('jest-haste-map'); -import chalk = require('chalk'); -import rimraf = require('rimraf'); -import exit = require('exit'); -import type {Filter} from '../types'; -import createContext from '../lib/createContext'; -import getChangedFilesPromise from '../getChangedFilesPromise'; -import {formatHandleErrors} from '../collectHandles'; -import handleDeprecationWarnings from '../lib/handleDeprecationWarnings'; -import runJest from '../runJest'; +import Runtime = require('jest-runtime'); +import {createDirectory, preRunMessage} from 'jest-util'; import TestWatcher from '../TestWatcher'; -import watch from '../watch'; -import pluralize from '../pluralize'; -import logDebugMessages from '../lib/logDebugMessages'; +import {formatHandleErrors} from '../collectHandles'; +import getChangedFilesPromise from '../getChangedFilesPromise'; import getConfigsOfProjectsToRun from '../getConfigsOfProjectsToRun'; import getProjectNamesMissingWarning from '../getProjectNamesMissingWarning'; import getSelectProjectsMessage from '../getSelectProjectsMessage'; +import createContext from '../lib/createContext'; +import handleDeprecationWarnings from '../lib/handleDeprecationWarnings'; +import logDebugMessages from '../lib/logDebugMessages'; +import pluralize from '../pluralize'; +import runJest from '../runJest'; +import type {Filter} from '../types'; +import watch from '../watch'; const {print: preRunMessagePrint} = preRunMessage; diff --git a/packages/jest-core/src/collectHandles.ts b/packages/jest-core/src/collectHandles.ts index f09eb7cd52ee..b39310aebc10 100644 --- a/packages/jest-core/src/collectHandles.ts +++ b/packages/jest-core/src/collectHandles.ts @@ -8,10 +8,10 @@ /* eslint-disable local/ban-types-eventually */ import * as asyncHooks from 'async_hooks'; +import stripAnsi = require('strip-ansi'); import type {Config} from '@jest/types'; import {formatExecError} from 'jest-message-util'; import {ErrorWithStack} from 'jest-util'; -import stripAnsi = require('strip-ansi'); function stackIsFromUser(stack: string) { // Either the test file, or something required by it diff --git a/packages/jest-core/src/getChangedFilesPromise.ts b/packages/jest-core/src/getChangedFilesPromise.ts index 61364a25cd1b..c96ea986be26 100644 --- a/packages/jest-core/src/getChangedFilesPromise.ts +++ b/packages/jest-core/src/getChangedFilesPromise.ts @@ -5,10 +5,10 @@ * LICENSE file in the root directory of this source tree. */ +import chalk = require('chalk'); import type {Config} from '@jest/types'; import {ChangedFilesPromise, getChangedFilesForRoots} from 'jest-changed-files'; import {formatExecError} from 'jest-message-util'; -import chalk = require('chalk'); export default ( globalConfig: Config.GlobalConfig, diff --git a/packages/jest-core/src/getNoTestFound.ts b/packages/jest-core/src/getNoTestFound.ts index 290d879ec8a1..53d2a0b9355e 100644 --- a/packages/jest-core/src/getNoTestFound.ts +++ b/packages/jest-core/src/getNoTestFound.ts @@ -7,8 +7,8 @@ import chalk = require('chalk'); import type {Config} from '@jest/types'; -import type {TestRunData} from './types'; import pluralize from './pluralize'; +import type {TestRunData} from './types'; export default function getNoTestFound( testRunData: TestRunData, diff --git a/packages/jest-core/src/getNoTestsFoundMessage.ts b/packages/jest-core/src/getNoTestsFoundMessage.ts index 2c2db0e8ef0c..d6f2b3d988bf 100644 --- a/packages/jest-core/src/getNoTestsFoundMessage.ts +++ b/packages/jest-core/src/getNoTestsFoundMessage.ts @@ -6,12 +6,12 @@ */ import type {Config} from '@jest/types'; -import type {TestRunData} from './types'; import getNoTestFound from './getNoTestFound'; -import getNoTestFoundRelatedToChangedFiles from './getNoTestFoundRelatedToChangedFiles'; -import getNoTestFoundVerbose from './getNoTestFoundVerbose'; import getNoTestFoundFailed from './getNoTestFoundFailed'; import getNoTestFoundPassWithNoTests from './getNoTestFoundPassWithNoTests'; +import getNoTestFoundRelatedToChangedFiles from './getNoTestFoundRelatedToChangedFiles'; +import getNoTestFoundVerbose from './getNoTestFoundVerbose'; +import type {TestRunData} from './types'; export default function getNoTestsFoundMessage( testRunData: TestRunData, diff --git a/packages/jest-core/src/lib/__tests__/isValidPath.test.ts b/packages/jest-core/src/lib/__tests__/isValidPath.test.ts index 53ca0972e254..e755671280fb 100644 --- a/packages/jest-core/src/lib/__tests__/isValidPath.test.ts +++ b/packages/jest-core/src/lib/__tests__/isValidPath.test.ts @@ -6,8 +6,8 @@ */ import * as path from 'path'; -import isValidPath from '../isValidPath'; import {makeGlobalConfig} from '../../../../../TestUtils'; +import isValidPath from '../isValidPath'; const rootDir = path.resolve(path.sep, 'root'); diff --git a/packages/jest-core/src/lib/__tests__/logDebugMessages.test.ts b/packages/jest-core/src/lib/__tests__/logDebugMessages.test.ts index 96ab5a6ac83b..7ec7f6fef3f1 100644 --- a/packages/jest-core/src/lib/__tests__/logDebugMessages.test.ts +++ b/packages/jest-core/src/lib/__tests__/logDebugMessages.test.ts @@ -7,8 +7,8 @@ */ import {wrap} from 'jest-snapshot-serializer-raw'; -import logDebugMessages from '../logDebugMessages'; import {makeGlobalConfig, makeProjectConfig} from '../../../../../TestUtils'; +import logDebugMessages from '../logDebugMessages'; jest.mock('../../../package.json', () => ({version: 123})); diff --git a/packages/jest-core/src/lib/createContext.ts b/packages/jest-core/src/lib/createContext.ts index 410e0b998c87..9937a1342ff5 100644 --- a/packages/jest-core/src/lib/createContext.ts +++ b/packages/jest-core/src/lib/createContext.ts @@ -6,8 +6,8 @@ */ import type {Config} from '@jest/types'; -import Runtime = require('jest-runtime'); import type {HasteMapObject} from 'jest-haste-map'; +import Runtime = require('jest-runtime'); export default ( config: Config.ProjectConfig, diff --git a/packages/jest-core/src/lib/logDebugMessages.ts b/packages/jest-core/src/lib/logDebugMessages.ts index 944c3cb5a4c9..eeb7ab80fadc 100644 --- a/packages/jest-core/src/lib/logDebugMessages.ts +++ b/packages/jest-core/src/lib/logDebugMessages.ts @@ -6,7 +6,6 @@ */ import type {Config} from '@jest/types'; - const VERSION = require('../../package.json').version; // if the output here changes, update `getConfig` in e2e/runJest.ts diff --git a/packages/jest-core/src/lib/updateGlobalConfig.ts b/packages/jest-core/src/lib/updateGlobalConfig.ts index b6aa38b7f878..a3d30ea135fa 100644 --- a/packages/jest-core/src/lib/updateGlobalConfig.ts +++ b/packages/jest-core/src/lib/updateGlobalConfig.ts @@ -5,8 +5,8 @@ * LICENSE file in the root directory of this source tree. */ -import {replacePathSepForRegex} from 'jest-regex-util'; import type {Config} from '@jest/types'; +import {replacePathSepForRegex} from 'jest-regex-util'; import type {AllowedConfigOptions} from 'jest-watcher'; type ExtraConfigOptions = Partial< diff --git a/packages/jest-core/src/plugins/UpdateSnapshotsInteractive.ts b/packages/jest-core/src/plugins/UpdateSnapshotsInteractive.ts index defb56b49a35..9c812f2ebacc 100644 --- a/packages/jest-core/src/plugins/UpdateSnapshotsInteractive.ts +++ b/packages/jest-core/src/plugins/UpdateSnapshotsInteractive.ts @@ -7,8 +7,8 @@ /* eslint-disable local/ban-types-eventually */ -import type {Config} from '@jest/types'; import type {AggregatedResult, AssertionLocation} from '@jest/test-result'; +import type {Config} from '@jest/types'; import {BaseWatchPlugin, JestHookSubscriber, UsageData} from 'jest-watcher'; import SnapshotInteractiveMode from '../SnapshotInteractiveMode'; diff --git a/packages/jest-core/src/runGlobalHook.ts b/packages/jest-core/src/runGlobalHook.ts index 405e5df5c00a..c6779becf80e 100644 --- a/packages/jest-core/src/runGlobalHook.ts +++ b/packages/jest-core/src/runGlobalHook.ts @@ -6,9 +6,9 @@ */ import pEachSeries = require('p-each-series'); +import {ScriptTransformer} from '@jest/transform'; import type {Config} from '@jest/types'; import type {Test} from 'jest-runner'; -import {ScriptTransformer} from '@jest/transform'; import {interopRequireDefault} from 'jest-util'; export default async ({ diff --git a/packages/jest-core/src/runJest.ts b/packages/jest-core/src/runJest.ts index fcb7c0a58532..9609b37d72d7 100644 --- a/packages/jest-core/src/runJest.ts +++ b/packages/jest-core/src/runJest.ts @@ -7,28 +7,28 @@ import * as path from 'path'; import chalk = require('chalk'); -import {CustomConsole} from '@jest/console'; -import {interopRequireDefault, tryRealpath} from 'jest-util'; import exit = require('exit'); import * as fs from 'graceful-fs'; -import {JestHook, JestHookEmitter} from 'jest-watcher'; -import type {Context} from 'jest-runtime'; -import type {Test} from 'jest-runner'; -import type {Config} from '@jest/types'; +import {CustomConsole} from '@jest/console'; import { AggregatedResult, formatTestResults, makeEmptyAggregatedTestResult, } from '@jest/test-result'; import type TestSequencer from '@jest/test-sequencer'; +import type {Config} from '@jest/types'; import type {ChangedFiles, ChangedFilesPromise} from 'jest-changed-files'; -import getNoTestsFoundMessage from './getNoTestsFoundMessage'; -import runGlobalHook from './runGlobalHook'; +import type {Test} from 'jest-runner'; +import type {Context} from 'jest-runtime'; +import {interopRequireDefault, tryRealpath} from 'jest-util'; +import {JestHook, JestHookEmitter} from 'jest-watcher'; +import type FailedTestsCache from './FailedTestsCache'; import SearchSource from './SearchSource'; import TestScheduler, {TestSchedulerContext} from './TestScheduler'; -import type FailedTestsCache from './FailedTestsCache'; -import collectNodeHandles from './collectHandles'; import type TestWatcher from './TestWatcher'; +import collectNodeHandles from './collectHandles'; +import getNoTestsFoundMessage from './getNoTestsFoundMessage'; +import runGlobalHook from './runGlobalHook'; import type {Filter, TestRunData} from './types'; const getTestPaths = async ( diff --git a/packages/jest-core/src/types.ts b/packages/jest-core/src/types.ts index efba913eee8b..ca7895bb4b42 100644 --- a/packages/jest-core/src/types.ts +++ b/packages/jest-core/src/types.ts @@ -5,9 +5,9 @@ * LICENSE file in the root directory of this source tree. */ -import type {Context} from 'jest-runtime'; -import type {Test} from 'jest-runner'; import type {Config} from '@jest/types'; +import type {Test} from 'jest-runner'; +import type {Context} from 'jest-runtime'; export type Stats = { roots: number; diff --git a/packages/jest-core/src/watch.ts b/packages/jest-core/src/watch.ts index 40e9415d029a..5704f735e14d 100644 --- a/packages/jest-core/src/watch.ts +++ b/packages/jest-core/src/watch.ts @@ -10,13 +10,13 @@ import ansiEscapes = require('ansi-escapes'); import chalk = require('chalk'); import exit = require('exit'); import slash = require('slash'); +import type {Config} from '@jest/types'; import HasteMap = require('jest-haste-map'); import {formatExecError} from 'jest-message-util'; +import Resolver = require('jest-resolve'); +import type {Context} from 'jest-runtime'; import {isInteractive, preRunMessage, specialChars} from 'jest-util'; import {ValidationError} from 'jest-validate'; -import type {Context} from 'jest-runtime'; -import Resolver = require('jest-resolve'); -import type {Config} from '@jest/types'; import { AllowedConfigOptions, JestHook, @@ -24,24 +24,24 @@ import { WatchPlugin, WatchPluginClass, } from 'jest-watcher'; +import FailedTestsCache from './FailedTestsCache'; +import SearchSource from './SearchSource'; +import TestWatcher from './TestWatcher'; import getChangedFilesPromise from './getChangedFilesPromise'; -import isValidPath from './lib/isValidPath'; +import activeFilters from './lib/activeFiltersMessage'; import createContext from './lib/createContext'; -import runJest from './runJest'; +import isValidPath from './lib/isValidPath'; import updateGlobalConfig from './lib/updateGlobalConfig'; -import SearchSource from './SearchSource'; -import TestWatcher from './TestWatcher'; -import FailedTestsCache from './FailedTestsCache'; -import TestPathPatternPlugin from './plugins/TestPathPattern'; -import TestNamePatternPlugin from './plugins/TestNamePattern'; -import UpdateSnapshotsPlugin from './plugins/UpdateSnapshots'; -import UpdateSnapshotsInteractivePlugin from './plugins/UpdateSnapshotsInteractive'; -import QuitPlugin from './plugins/Quit'; import { filterInteractivePlugins, getSortedUsageRows, } from './lib/watchPluginsHelpers'; -import activeFilters from './lib/activeFiltersMessage'; +import QuitPlugin from './plugins/Quit'; +import TestNamePatternPlugin from './plugins/TestNamePattern'; +import TestPathPatternPlugin from './plugins/TestPathPattern'; +import UpdateSnapshotsPlugin from './plugins/UpdateSnapshots'; +import UpdateSnapshotsInteractivePlugin from './plugins/UpdateSnapshotsInteractive'; +import runJest from './runJest'; import type {Filter} from './types'; type ReservedInfo = { diff --git a/packages/jest-create-cache-key-function/src/index.ts b/packages/jest-create-cache-key-function/src/index.ts index 8b87deb69ef8..e606e64f14e8 100644 --- a/packages/jest-create-cache-key-function/src/index.ts +++ b/packages/jest-create-cache-key-function/src/index.ts @@ -7,9 +7,9 @@ */ import {createHash} from 'crypto'; -import {relative} from 'path'; -/* eslint-disable-next-line no-restricted-imports */ +// eslint-disable-next-line no-restricted-imports import {readFileSync} from 'fs'; +import {relative} from 'path'; import type {Config} from '@jest/types'; type CacheKeyOptions = { diff --git a/packages/jest-diff/src/__tests__/diff.test.ts b/packages/jest-diff/src/__tests__/diff.test.ts index e63d9b999b70..817be18bbaeb 100644 --- a/packages/jest-diff/src/__tests__/diff.test.ts +++ b/packages/jest-diff/src/__tests__/diff.test.ts @@ -8,13 +8,12 @@ import chalk = require('chalk'); import stripAnsi = require('strip-ansi'); import {alignedAnsiStyleSerializer} from '@jest/test-utils'; - import diff from '../'; +import {NO_DIFF_MESSAGE} from '../constants'; import {diffLinesUnified, diffLinesUnified2} from '../diffLines'; import {noColor} from '../normalizeDiffOptions'; import {diffStringsUnified} from '../printDiffs'; import {DiffOptions} from '../types'; -import {NO_DIFF_MESSAGE} from '../constants'; const optionsCounts: DiffOptions = { includeChangeCounts: true, diff --git a/packages/jest-diff/src/diffStrings.ts b/packages/jest-diff/src/diffStrings.ts index 9003f8575cac..b88bd3b93ead 100644 --- a/packages/jest-diff/src/diffStrings.ts +++ b/packages/jest-diff/src/diffStrings.ts @@ -6,7 +6,6 @@ */ import diffSequences from 'diff-sequences'; - import {DIFF_DELETE, DIFF_EQUAL, DIFF_INSERT, Diff} from './cleanupSemantic'; const diffStrings = (a: string, b: string): Array => { diff --git a/packages/jest-diff/src/index.ts b/packages/jest-diff/src/index.ts index fd0e680eea03..6f6ba8be46f0 100644 --- a/packages/jest-diff/src/index.ts +++ b/packages/jest-diff/src/index.ts @@ -5,14 +5,14 @@ * LICENSE file in the root directory of this source tree. */ -import prettyFormat = require('pretty-format'); import chalk = require('chalk'); import getType = require('jest-get-type'); +import prettyFormat = require('pretty-format'); import {DIFF_DELETE, DIFF_EQUAL, DIFF_INSERT, Diff} from './cleanupSemantic'; -import {normalizeDiffOptions} from './normalizeDiffOptions'; +import {NO_DIFF_MESSAGE, SIMILAR_MESSAGE} from './constants'; import {diffLinesRaw, diffLinesUnified, diffLinesUnified2} from './diffLines'; +import {normalizeDiffOptions} from './normalizeDiffOptions'; import {diffStringsRaw, diffStringsUnified} from './printDiffs'; -import {NO_DIFF_MESSAGE, SIMILAR_MESSAGE} from './constants'; import type {DiffOptions} from './types'; export type {DiffOptions, DiffOptionsColor} from './types'; diff --git a/packages/jest-diff/src/normalizeDiffOptions.ts b/packages/jest-diff/src/normalizeDiffOptions.ts index b059c1c490f3..0f4aedc8ceaf 100644 --- a/packages/jest-diff/src/normalizeDiffOptions.ts +++ b/packages/jest-diff/src/normalizeDiffOptions.ts @@ -6,7 +6,6 @@ */ import chalk = require('chalk'); - import type {DiffOptions, DiffOptionsNormalized} from './types'; export const noColor = (string: string): string => string; diff --git a/packages/jest-each/src/bind.ts b/packages/jest-each/src/bind.ts index e2d0649c3952..ba4ae6abcaa0 100644 --- a/packages/jest-each/src/bind.ts +++ b/packages/jest-each/src/bind.ts @@ -8,7 +8,6 @@ import type {Global} from '@jest/types'; import {ErrorWithStack} from 'jest-util'; - import convertArrayTable from './table/array'; import convertTemplateTable from './table/template'; import {validateArrayTable, validateTemplateTableHeadings} from './validation'; diff --git a/packages/jest-each/src/table/array.ts b/packages/jest-each/src/table/array.ts index 61eeb1e58ee2..016bf4baa778 100644 --- a/packages/jest-each/src/table/array.ts +++ b/packages/jest-each/src/table/array.ts @@ -7,9 +7,8 @@ */ import * as util from 'util'; -import pretty = require('pretty-format'); - import type {Global} from '@jest/types'; +import pretty = require('pretty-format'); import type {EachTests} from '../bind'; const SUPPORTED_PLACEHOLDERS = /%[sdifjoOp%]/g; diff --git a/packages/jest-each/src/table/template.ts b/packages/jest-each/src/table/template.ts index 936410189a7d..995a1fbe0738 100644 --- a/packages/jest-each/src/table/template.ts +++ b/packages/jest-each/src/table/template.ts @@ -6,9 +6,9 @@ * */ -import pretty = require('pretty-format'); -import {isPrimitive} from 'jest-get-type'; import type {Global} from '@jest/types'; +import {isPrimitive} from 'jest-get-type'; +import pretty = require('pretty-format'); import type {EachTests} from '../bind'; type Template = Record; diff --git a/packages/jest-each/src/validation.ts b/packages/jest-each/src/validation.ts index 7fb2df3c3cf2..3782bedebea1 100644 --- a/packages/jest-each/src/validation.ts +++ b/packages/jest-each/src/validation.ts @@ -7,8 +7,8 @@ */ import chalk = require('chalk'); -import pretty = require('pretty-format'); import type {Global} from '@jest/types'; +import pretty = require('pretty-format'); type TemplateData = Global.TemplateData; diff --git a/packages/jest-environment-jsdom/src/index.ts b/packages/jest-environment-jsdom/src/index.ts index bdd5eec27734..e34a62e67e61 100644 --- a/packages/jest-environment-jsdom/src/index.ts +++ b/packages/jest-environment-jsdom/src/index.ts @@ -6,12 +6,12 @@ */ import type {Context, Script} from 'vm'; +import {JSDOM, VirtualConsole} from 'jsdom'; +import type {EnvironmentContext, JestEnvironment} from '@jest/environment'; +import {LegacyFakeTimers, ModernFakeTimers} from '@jest/fake-timers'; import type {Config, Global} from '@jest/types'; -import {installCommonGlobals} from 'jest-util'; import {ModuleMocker} from 'jest-mock'; -import {LegacyFakeTimers, ModernFakeTimers} from '@jest/fake-timers'; -import type {EnvironmentContext, JestEnvironment} from '@jest/environment'; -import {JSDOM, VirtualConsole} from 'jsdom'; +import {installCommonGlobals} from 'jest-util'; // The `Window` interface does not have an `Error.stackTraceLimit` property, but // `JSDOMEnvironment` assumes it is there. diff --git a/packages/jest-environment-node/src/index.ts b/packages/jest-environment-node/src/index.ts index 51a803cc5e9b..6fdfa89d313e 100644 --- a/packages/jest-environment-node/src/index.ts +++ b/packages/jest-environment-node/src/index.ts @@ -6,11 +6,11 @@ */ import {Context, Script, createContext, runInContext} from 'vm'; +import type {JestEnvironment} from '@jest/environment'; +import {LegacyFakeTimers, ModernFakeTimers} from '@jest/fake-timers'; import type {Config, Global} from '@jest/types'; import {ModuleMocker} from 'jest-mock'; import {installCommonGlobals} from 'jest-util'; -import {LegacyFakeTimers, ModernFakeTimers} from '@jest/fake-timers'; -import type {JestEnvironment} from '@jest/environment'; type Timer = { id: number; diff --git a/packages/jest-environment/src/index.ts b/packages/jest-environment/src/index.ts index 3a28550df5e4..2d786570f711 100644 --- a/packages/jest-environment/src/index.ts +++ b/packages/jest-environment/src/index.ts @@ -6,9 +6,9 @@ */ import type {Context, Script} from 'vm'; +import type {LegacyFakeTimers, ModernFakeTimers} from '@jest/fake-timers'; import type {Circus, Config, Global} from '@jest/types'; import jestMock = require('jest-mock'); -import type {LegacyFakeTimers, ModernFakeTimers} from '@jest/fake-timers'; type JestMockFn = typeof jestMock.fn; type JestMockSpyOn = typeof jestMock.spyOn; diff --git a/packages/jest-fake-timers/src/legacyFakeTimers.ts b/packages/jest-fake-timers/src/legacyFakeTimers.ts index cb7a2abab30c..cd94923d00fe 100644 --- a/packages/jest-fake-timers/src/legacyFakeTimers.ts +++ b/packages/jest-fake-timers/src/legacyFakeTimers.ts @@ -8,8 +8,8 @@ /* eslint-disable local/ban-types-eventually, local/prefer-spread-eventually */ import util = require('util'); -import type {ModuleMocker} from 'jest-mock'; import {StackTraceConfig, formatStackTrace} from 'jest-message-util'; +import type {ModuleMocker} from 'jest-mock'; import {setGlobal} from 'jest-util'; type Callback = (...args: Array) => void; diff --git a/packages/jest-globals/src/index.ts b/packages/jest-globals/src/index.ts index cc13927c0d13..772ee1a8c5ff 100644 --- a/packages/jest-globals/src/index.ts +++ b/packages/jest-globals/src/index.ts @@ -5,9 +5,9 @@ * LICENSE file in the root directory of this source tree. */ -import importedExpect = require('expect'); import type {Jest} from '@jest/environment'; import type {Global} from '@jest/types'; +import importedExpect = require('expect'); export declare const jest: Jest; diff --git a/packages/jest-haste-map/src/HasteFS.ts b/packages/jest-haste-map/src/HasteFS.ts index bdad6f292a82..64478ee22871 100644 --- a/packages/jest-haste-map/src/HasteFS.ts +++ b/packages/jest-haste-map/src/HasteFS.ts @@ -5,11 +5,11 @@ * LICENSE file in the root directory of this source tree. */ -import {globsToMatcher, replacePathSepForGlob} from 'jest-util'; import type {Config} from '@jest/types'; -import type {FileData} from './types'; -import * as fastPath from './lib/fast_path'; +import {globsToMatcher, replacePathSepForGlob} from 'jest-util'; import H from './constants'; +import * as fastPath from './lib/fast_path'; +import type {FileData} from './types'; export default class HasteFS { private readonly _rootDir: Config.Path; diff --git a/packages/jest-haste-map/src/ModuleMap.ts b/packages/jest-haste-map/src/ModuleMap.ts index 6719bf2d6c49..1501e4df5df4 100644 --- a/packages/jest-haste-map/src/ModuleMap.ts +++ b/packages/jest-haste-map/src/ModuleMap.ts @@ -6,6 +6,8 @@ */ import type {Config} from '@jest/types'; +import H from './constants'; +import * as fastPath from './lib/fast_path'; import type { DuplicatesSet, HTypeValue, @@ -15,9 +17,6 @@ import type { RawModuleMap, } from './types'; -import * as fastPath from './lib/fast_path'; -import H from './constants'; - const EMPTY_OBJ: Record = {}; const EMPTY_MAP = new Map(); diff --git a/packages/jest-haste-map/src/__tests__/index.test.js b/packages/jest-haste-map/src/__tests__/index.test.js index 0ddddf58895b..6dba04a9a81e 100644 --- a/packages/jest-haste-map/src/__tests__/index.test.js +++ b/packages/jest-haste-map/src/__tests__/index.test.js @@ -6,8 +6,8 @@ * */ -import * as path from 'path'; import crypto from 'crypto'; +import * as path from 'path'; import wrap from 'jest-snapshot-serializer-raw'; function mockHashContents(contents) { diff --git a/packages/jest-haste-map/src/__tests__/worker.test.js b/packages/jest-haste-map/src/__tests__/worker.test.js index e88cea8aeb44..8412161dc931 100644 --- a/packages/jest-haste-map/src/__tests__/worker.test.js +++ b/packages/jest-haste-map/src/__tests__/worker.test.js @@ -10,9 +10,8 @@ import * as path from 'path'; import * as fs from 'graceful-fs'; - -import {getSha1, worker} from '../worker'; import H from '../constants'; +import {getSha1, worker} from '../worker'; jest.mock('graceful-fs', () => { const path = require('path'); diff --git a/packages/jest-haste-map/src/crawlers/node.ts b/packages/jest-haste-map/src/crawlers/node.ts index 7fdc6bbf8020..ef04a2762b42 100644 --- a/packages/jest-haste-map/src/crawlers/node.ts +++ b/packages/jest-haste-map/src/crawlers/node.ts @@ -5,8 +5,8 @@ * LICENSE file in the root directory of this source tree. */ -import * as path from 'path'; import {spawn} from 'child_process'; +import * as path from 'path'; import * as fs from 'graceful-fs'; import H from '../constants'; import * as fastPath from '../lib/fast_path'; diff --git a/packages/jest-haste-map/src/crawlers/watchman.ts b/packages/jest-haste-map/src/crawlers/watchman.ts index 5d47d33f8842..e5647370813b 100644 --- a/packages/jest-haste-map/src/crawlers/watchman.ts +++ b/packages/jest-haste-map/src/crawlers/watchman.ts @@ -8,9 +8,9 @@ import * as path from 'path'; import watchman = require('fb-watchman'); import type {Config} from '@jest/types'; +import H from '../constants'; import * as fastPath from '../lib/fast_path'; import normalizePathSep from '../lib/normalizePathSep'; -import H from '../constants'; import type { CrawlerOptions, FileData, diff --git a/packages/jest-haste-map/src/index.ts b/packages/jest-haste-map/src/index.ts index 37b2e292fae8..c7d82bf36c0a 100644 --- a/packages/jest-haste-map/src/index.ts +++ b/packages/jest-haste-map/src/index.ts @@ -15,24 +15,23 @@ import * as path from 'path'; import type {Stats} from 'graceful-fs'; import {NodeWatcher, Watcher as SaneWatcher} from 'sane'; import type {Config} from '@jest/types'; +import {escapePathForRegex} from 'jest-regex-util'; import serializer from 'jest-serializer'; import Worker from 'jest-worker'; -import {escapePathForRegex} from 'jest-regex-util'; -import {getSha1, worker} from './worker'; -import getMockName from './getMockName'; -import getPlatformExtension from './lib/getPlatformExtension'; -import H from './constants'; import HasteFS from './HasteFS'; import HasteModuleMap, { SerializableModuleMap as HasteSerializableModuleMap, } from './ModuleMap'; +import H from './constants'; import nodeCrawl = require('./crawlers/node'); -import normalizePathSep from './lib/normalizePathSep'; import watchmanCrawl = require('./crawlers/watchman'); +import getMockName from './getMockName'; +import FSEventsWatcher = require('./lib/FSEventsWatcher'); // @ts-expect-error: not converted to TypeScript - it's a fork: https://github.com/facebook/jest/pull/5387 import WatchmanWatcher from './lib/WatchmanWatcher'; -import FSEventsWatcher = require('./lib/FSEventsWatcher'); import * as fastPath from './lib/fast_path'; +import getPlatformExtension from './lib/getPlatformExtension'; +import normalizePathSep from './lib/normalizePathSep'; import type { ChangeEvent, CrawlerOptions, @@ -47,6 +46,10 @@ import type { ModuleMetaData, WorkerMetadata, } from './types'; +import {getSha1, worker} from './worker'; +// TypeScript doesn't like us importing from outside `rootDir`, but it doesn't +// understand `require`. +const {version: VERSION} = require('../package.json'); type HType = typeof H; @@ -120,10 +123,6 @@ const VCS_DIRECTORIES = ['.git', '.hg'] .map(vcs => escapePathForRegex(path.sep + vcs + path.sep)) .join('|'); -// TypeScript doesn't like us importing from outside `rootDir`, but it doesn't -// understand `require`. -const {version: VERSION} = require('../package.json'); - const canUseWatchman = ((): boolean => { try { execSync('watchman --version', {stdio: ['ignore']}); diff --git a/packages/jest-haste-map/src/lib/FSEventsWatcher.ts b/packages/jest-haste-map/src/lib/FSEventsWatcher.ts index c0625f4cb172..faf15f7b6617 100644 --- a/packages/jest-haste-map/src/lib/FSEventsWatcher.ts +++ b/packages/jest-haste-map/src/lib/FSEventsWatcher.ts @@ -8,10 +8,10 @@ /* eslint-disable local/ban-types-eventually */ -import * as path from 'path'; import {EventEmitter} from 'events'; -import * as fs from 'graceful-fs'; +import * as path from 'path'; import anymatch, {Matcher} from 'anymatch'; +import * as fs from 'graceful-fs'; import micromatch = require('micromatch'); // @ts-expect-error no types import walker from 'walker'; diff --git a/packages/jest-haste-map/src/lib/WatchmanWatcher.js b/packages/jest-haste-map/src/lib/WatchmanWatcher.js index 5f10a750684f..4471c0ec34ae 100644 --- a/packages/jest-haste-map/src/lib/WatchmanWatcher.js +++ b/packages/jest-haste-map/src/lib/WatchmanWatcher.js @@ -5,11 +5,11 @@ * LICENSE file in the root directory of this source tree. */ -import path from 'path'; import assert from 'assert'; import {EventEmitter} from 'events'; -import * as fs from 'graceful-fs'; +import path from 'path'; import watchman from 'fb-watchman'; +import * as fs from 'graceful-fs'; import common from 'sane/src/common'; import RecrawlWarning from 'sane/src/utils/recrawl-warning-dedupe'; diff --git a/packages/jest-haste-map/src/types.ts b/packages/jest-haste-map/src/types.ts index 6d09b1fdc182..14a08bac856e 100644 --- a/packages/jest-haste-map/src/types.ts +++ b/packages/jest-haste-map/src/types.ts @@ -7,8 +7,8 @@ import type {Stats} from 'graceful-fs'; import type {Config} from '@jest/types'; -import type ModuleMap from './ModuleMap'; import type HasteFS from './HasteFS'; +import type ModuleMap from './ModuleMap'; export type IgnoreMatcher = (item: string) => boolean; diff --git a/packages/jest-haste-map/src/worker.ts b/packages/jest-haste-map/src/worker.ts index 6ad6d31e6527..15986c9efd45 100644 --- a/packages/jest-haste-map/src/worker.ts +++ b/packages/jest-haste-map/src/worker.ts @@ -8,10 +8,10 @@ import {createHash} from 'crypto'; import * as path from 'path'; import * as fs from 'graceful-fs'; -import type {HasteImpl, WorkerMessage, WorkerMetadata} from './types'; import blacklist from './blacklist'; import H from './constants'; import * as dependencyExtractor from './lib/dependencyExtractor'; +import type {HasteImpl, WorkerMessage, WorkerMetadata} from './types'; const PACKAGE_JSON = path.sep + 'package.json'; diff --git a/packages/jest-jasmine2/src/__tests__/reporter.test.ts b/packages/jest-jasmine2/src/__tests__/reporter.test.ts index 4bd50777fcc1..88b79073d469 100644 --- a/packages/jest-jasmine2/src/__tests__/reporter.test.ts +++ b/packages/jest-jasmine2/src/__tests__/reporter.test.ts @@ -6,9 +6,9 @@ * */ -import JasmineReporter from '../reporter'; -import {SuiteResult} from '../jasmine/Suite'; import {SpecResult} from '../jasmine/Spec'; +import {SuiteResult} from '../jasmine/Suite'; +import JasmineReporter from '../reporter'; describe('Jasmine2Reporter', () => { let reporter: JasmineReporter; diff --git a/packages/jest-jasmine2/src/assertionErrorMessage.ts b/packages/jest-jasmine2/src/assertionErrorMessage.ts index 9f252eec604c..2a73a861f5af 100644 --- a/packages/jest-jasmine2/src/assertionErrorMessage.ts +++ b/packages/jest-jasmine2/src/assertionErrorMessage.ts @@ -5,13 +5,13 @@ * LICENSE file in the root directory of this source tree. */ +import chalk = require('chalk'); import { DiffOptions, diff, printExpected, printReceived, } from 'jest-matcher-utils'; -import chalk = require('chalk'); import type {AssertionErrorWithStack} from './types'; const assertOperatorsMap: Record = { diff --git a/packages/jest-jasmine2/src/expectationResultFactory.ts b/packages/jest-jasmine2/src/expectationResultFactory.ts index 11f903afa5cc..69d5893202dc 100644 --- a/packages/jest-jasmine2/src/expectationResultFactory.ts +++ b/packages/jest-jasmine2/src/expectationResultFactory.ts @@ -5,8 +5,8 @@ * LICENSE file in the root directory of this source tree. */ -import prettyFormat = require('pretty-format'); import type {FailedAssertion} from '@jest/test-result'; +import prettyFormat = require('pretty-format'); function messageFormatter({error, message, passed}: Options) { if (passed) { diff --git a/packages/jest-jasmine2/src/index.ts b/packages/jest-jasmine2/src/index.ts index 0e02a7569e00..b0b3069a971e 100644 --- a/packages/jest-jasmine2/src/index.ts +++ b/packages/jest-jasmine2/src/index.ts @@ -6,18 +6,17 @@ */ import * as path from 'path'; -import type {Config, Global} from '@jest/types'; -import type {AssertionResult, TestResult} from '@jest/test-result'; import type {JestEnvironment} from '@jest/environment'; -import type {SnapshotStateType} from 'jest-snapshot'; -import type {RuntimeType as Runtime} from 'jest-runtime'; - import {getCallsite} from '@jest/source-map'; +import type {AssertionResult, TestResult} from '@jest/test-result'; +import type {Config, Global} from '@jest/types'; +import type {RuntimeType as Runtime} from 'jest-runtime'; +import type {SnapshotStateType} from 'jest-snapshot'; import installEach from './each'; import {installErrorOnPrivate} from './errorOnPrivate'; -import JasmineReporter from './reporter'; -import jasmineAsyncInstall from './jasmineAsyncInstall'; import type Spec from './jasmine/Spec'; +import jasmineAsyncInstall from './jasmineAsyncInstall'; +import JasmineReporter from './reporter'; import type {Jasmine as JestJasmine} from './types'; const JASMINE = require.resolve('./jasmine/jasmineLight'); diff --git a/packages/jest-jasmine2/src/jasmine/Env.ts b/packages/jest-jasmine2/src/jasmine/Env.ts index d5ce7845f1eb..1eec2c46c99d 100644 --- a/packages/jest-jasmine2/src/jasmine/Env.ts +++ b/packages/jest-jasmine2/src/jasmine/Env.ts @@ -34,13 +34,13 @@ import {AssertionError} from 'assert'; import chalk = require('chalk'); import {formatExecError} from 'jest-message-util'; import {ErrorWithStack, isPromise} from 'jest-util'; +import assertionErrorMessage from '../assertionErrorMessage'; +import isError from '../isError'; import queueRunner, { Options as QueueRunnerOptions, QueueableFn, } from '../queueRunner'; import treeProcessor, {TreeNode} from '../treeProcessor'; -import isError from '../isError'; -import assertionErrorMessage from '../assertionErrorMessage'; import type { AssertionErrorWithStack, Jasmine, diff --git a/packages/jest-jasmine2/src/jasmine/Spec.ts b/packages/jest-jasmine2/src/jasmine/Spec.ts index 4328285a290d..4043416075e2 100644 --- a/packages/jest-jasmine2/src/jasmine/Spec.ts +++ b/packages/jest-jasmine2/src/jasmine/Spec.ts @@ -31,14 +31,13 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. /* eslint-disable sort-keys, local/prefer-spread-eventually, local/prefer-rest-params-eventually */ import {AssertionError} from 'assert'; -import type {Config} from '@jest/types'; import type {FailedAssertion, Milliseconds, Status} from '@jest/test-result'; - +import type {Config} from '@jest/types'; import ExpectationFailed from '../ExpectationFailed'; +import assertionErrorMessage from '../assertionErrorMessage'; import expectationResultFactory, { Options as ExpectationResultFactoryOptions, } from '../expectationResultFactory'; -import assertionErrorMessage from '../assertionErrorMessage'; import type {QueueableFn, default as queueRunner} from '../queueRunner'; import type {AssertionErrorWithStack} from '../types'; diff --git a/packages/jest-jasmine2/src/jasmine/Suite.ts b/packages/jest-jasmine2/src/jasmine/Suite.ts index 2ca210ed3589..4ea4d10802f0 100644 --- a/packages/jest-jasmine2/src/jasmine/Suite.ts +++ b/packages/jest-jasmine2/src/jasmine/Suite.ts @@ -31,8 +31,8 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. /* eslint-disable local/ban-types-eventually, sort-keys, local/prefer-spread-eventually, local/prefer-rest-params-eventually */ -import {convertDescriptorToString} from 'jest-util'; import type {Config} from '@jest/types'; +import {convertDescriptorToString} from 'jest-util'; import ExpectationFailed from '../ExpectationFailed'; import expectationResultFactory from '../expectationResultFactory'; import type {QueueableFn} from '../queueRunner'; diff --git a/packages/jest-jasmine2/src/jasmine/jasmineLight.ts b/packages/jest-jasmine2/src/jasmine/jasmineLight.ts index 508aac4e09f6..d7ee8aec1fd4 100644 --- a/packages/jest-jasmine2/src/jasmine/jasmineLight.ts +++ b/packages/jest-jasmine2/src/jasmine/jasmineLight.ts @@ -31,14 +31,14 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. /* eslint-disable sort-keys, local/prefer-spread-eventually, local/prefer-rest-params-eventually */ import type {Jasmine, SpecDefinitionsFn} from '../types'; -import createSpy from './createSpy'; import Env from './Env'; import JsApiReporter from './JsApiReporter'; import ReportDispatcher from './ReportDispatcher'; import Spec from './Spec'; -import SpyRegistry from './spyRegistry'; import Suite from './Suite'; import Timer from './Timer'; +import createSpy from './createSpy'; +import SpyRegistry from './spyRegistry'; export const create = function (createOptions: Record): Jasmine { const j$ = {...createOptions} as Jasmine; diff --git a/packages/jest-jasmine2/src/jasmine/spyRegistry.ts b/packages/jest-jasmine2/src/jasmine/spyRegistry.ts index 6b7d4ecf0081..d966f35929e2 100644 --- a/packages/jest-jasmine2/src/jasmine/spyRegistry.ts +++ b/packages/jest-jasmine2/src/jasmine/spyRegistry.ts @@ -31,8 +31,8 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. import type {Spy} from '../types'; import CallTracker from './CallTracker'; -import createSpy from './createSpy'; import SpyStrategy from './SpyStrategy'; +import createSpy from './createSpy'; const formatErrorMsg = (domain: string, usage?: string) => { const usageDefinition = usage ? '\nUsage: ' + usage : ''; diff --git a/packages/jest-jasmine2/src/jasmineAsyncInstall.ts b/packages/jest-jasmine2/src/jasmineAsyncInstall.ts index db15f338ed75..896344f5515a 100644 --- a/packages/jest-jasmine2/src/jasmineAsyncInstall.ts +++ b/packages/jest-jasmine2/src/jasmineAsyncInstall.ts @@ -10,14 +10,14 @@ * returning a promise from `it/test` and `before/afterEach/All` blocks. */ -import type {Config, Global} from '@jest/types'; import co from 'co'; import isGeneratorFn from 'is-generator-fn'; import throat from 'throat'; +import type {Config, Global} from '@jest/types'; import isError from './isError'; -import type {Jasmine} from './types'; import type Spec from './jasmine/Spec'; import type {DoneFn, QueueableFn} from './queueRunner'; +import type {Jasmine} from './types'; function isPromise(obj: any): obj is PromiseLike { return obj && typeof obj.then === 'function'; diff --git a/packages/jest-jasmine2/src/jestExpect.ts b/packages/jest-jasmine2/src/jestExpect.ts index 5a7abb1877d0..7b2b105d36f3 100644 --- a/packages/jest-jasmine2/src/jestExpect.ts +++ b/packages/jest-jasmine2/src/jestExpect.ts @@ -7,8 +7,8 @@ /* eslint-disable local/prefer-spread-eventually */ -import expect = require('expect'); import type {Global} from '@jest/types'; +import expect = require('expect'); import { addSerializer, toMatchInlineSnapshot, diff --git a/packages/jest-jasmine2/src/reporter.ts b/packages/jest-jasmine2/src/reporter.ts index 14518026ba07..507295b0f946 100644 --- a/packages/jest-jasmine2/src/reporter.ts +++ b/packages/jest-jasmine2/src/reporter.ts @@ -5,12 +5,12 @@ * LICENSE file in the root directory of this source tree. */ -import type {Config} from '@jest/types'; import { AssertionResult, TestResult, createEmptyTestResult, } from '@jest/test-result'; +import type {Config} from '@jest/types'; import {formatResultsErrors} from 'jest-message-util'; import type {SpecResult} from './jasmine/Spec'; import type {SuiteResult} from './jasmine/Suite'; diff --git a/packages/jest-jasmine2/src/setup_jest_globals.ts b/packages/jest-jasmine2/src/setup_jest_globals.ts index 4164015263bc..1787d549e155 100644 --- a/packages/jest-jasmine2/src/setup_jest_globals.ts +++ b/packages/jest-jasmine2/src/setup_jest_globals.ts @@ -6,7 +6,6 @@ */ import type {Config, Global} from '@jest/types'; -import type {Plugin} from 'pretty-format'; import {extractExpectedAssertionsErrors, getState, setState} from 'expect'; import { SnapshotState, @@ -14,6 +13,7 @@ import { addSerializer, buildSnapshotResolver, } from 'jest-snapshot'; +import type {Plugin} from 'pretty-format'; import type { Attributes, default as JasmineSpec, diff --git a/packages/jest-jasmine2/src/types.ts b/packages/jest-jasmine2/src/types.ts index 616e6105da7b..269dba59fe3a 100644 --- a/packages/jest-jasmine2/src/types.ts +++ b/packages/jest-jasmine2/src/types.ts @@ -7,18 +7,17 @@ import type {AssertionError} from 'assert'; import type {Config} from '@jest/types'; - import expect = require('expect'); -import type {default as Spec, SpecResult} from './jasmine/Spec'; +import type CallTracker from './jasmine/CallTracker'; +import type Env from './jasmine/Env'; import type JsApiReporter from './jasmine/JsApiReporter'; +import type ReportDispatcher from './jasmine/ReportDispatcher'; +import type {default as Spec, SpecResult} from './jasmine/Spec'; +import type SpyStrategy from './jasmine/SpyStrategy'; +import type {default as Suite, SuiteResult} from './jasmine/Suite'; import type Timer from './jasmine/Timer'; -import type Env from './jasmine/Env'; import type createSpy from './jasmine/createSpy'; -import type ReportDispatcher from './jasmine/ReportDispatcher'; import type SpyRegistry from './jasmine/spyRegistry'; -import type {default as Suite, SuiteResult} from './jasmine/Suite'; -import type SpyStrategy from './jasmine/SpyStrategy'; -import type CallTracker from './jasmine/CallTracker'; export type SpecDefinitionsFn = () => void; diff --git a/packages/jest-leak-detector/src/index.ts b/packages/jest-leak-detector/src/index.ts index e7bd026edc21..d1c115a2cf6c 100644 --- a/packages/jest-leak-detector/src/index.ts +++ b/packages/jest-leak-detector/src/index.ts @@ -7,11 +7,11 @@ /* eslint-disable local/ban-types-eventually */ +import {promisify} from 'util'; import {setFlagsFromString} from 'v8'; import {runInNewContext} from 'vm'; -import {promisify} from 'util'; -import prettyFormat = require('pretty-format'); import {isPrimitive} from 'jest-get-type'; +import prettyFormat = require('pretty-format'); const tick = promisify(setImmediate); diff --git a/packages/jest-matcher-utils/src/__tests__/index.test.ts b/packages/jest-matcher-utils/src/__tests__/index.test.ts index fbba12527ebc..2e28dfba9441 100644 --- a/packages/jest-matcher-utils/src/__tests__/index.test.ts +++ b/packages/jest-matcher-utils/src/__tests__/index.test.ts @@ -7,8 +7,8 @@ */ import chalk = require('chalk'); -import prettyFormat = require('pretty-format'); import {alignedAnsiStyleSerializer} from '@jest/test-utils'; +import prettyFormat = require('pretty-format'); import { MatcherHintOptions, diff, diff --git a/packages/jest-message-util/src/index.ts b/packages/jest-message-util/src/index.ts index 098e404707be..5cba011fed04 100644 --- a/packages/jest-message-util/src/index.ts +++ b/packages/jest-message-util/src/index.ts @@ -6,14 +6,14 @@ */ import * as path from 'path'; -import * as fs from 'graceful-fs'; -import type {Config, TestResult} from '@jest/types'; +import {codeFrameColumns} from '@babel/code-frame'; import chalk = require('chalk'); +import * as fs from 'graceful-fs'; import micromatch = require('micromatch'); -import prettyFormat = require('pretty-format'); import slash = require('slash'); -import {codeFrameColumns} from '@babel/code-frame'; import StackUtils = require('stack-utils'); +import type {Config, TestResult} from '@jest/types'; +import prettyFormat = require('pretty-format'); import type {Frame} from './types'; export type {Frame} from './types'; diff --git a/packages/jest-repl/src/cli/index.ts b/packages/jest-repl/src/cli/index.ts index 9d027435023c..e756fc2fef13 100644 --- a/packages/jest-repl/src/cli/index.ts +++ b/packages/jest-repl/src/cli/index.ts @@ -7,13 +7,12 @@ * */ -import Runtime = require('jest-runtime'); import yargs = require('yargs'); -import {validateCLIOptions} from 'jest-validate'; -import {deprecationEntries} from 'jest-config'; import type {Config} from '@jest/types'; +import {deprecationEntries} from 'jest-config'; +import Runtime = require('jest-runtime'); +import {validateCLIOptions} from 'jest-validate'; import * as args from './args'; - const {version: VERSION} = require('../../package.json'); const REPL_SCRIPT = require.resolve('./repl.js'); diff --git a/packages/jest-reporters/src/CoverageReporter.ts b/packages/jest-reporters/src/CoverageReporter.ts index 612cdedaae40..c10511911034 100644 --- a/packages/jest-reporters/src/CoverageReporter.ts +++ b/packages/jest-reporters/src/CoverageReporter.ts @@ -6,33 +6,33 @@ */ import * as path from 'path'; +import {mergeProcessCovs} from '@bcoe/v8-coverage'; +import chalk = require('chalk'); +import glob = require('glob'); import * as fs from 'graceful-fs'; -import type {Config} from '@jest/types'; +import istanbulCoverage = require('istanbul-lib-coverage'); +import istanbulReport = require('istanbul-lib-report'); +import libSourceMaps = require('istanbul-lib-source-maps'); +import istanbulReports = require('istanbul-reports'); +import type {RawSourceMap} from 'source-map'; +import v8toIstanbul = require('v8-to-istanbul'); import type { AggregatedResult, RuntimeTransformResult, TestResult, V8CoverageResult, } from '@jest/test-result'; +import type {Config} from '@jest/types'; import {clearLine, isInteractive} from 'jest-util'; -import istanbulReport = require('istanbul-lib-report'); -import istanbulReports = require('istanbul-reports'); -import chalk = require('chalk'); -import istanbulCoverage = require('istanbul-lib-coverage'); -import libSourceMaps = require('istanbul-lib-source-maps'); -import {mergeProcessCovs} from '@bcoe/v8-coverage'; import Worker from 'jest-worker'; -import glob = require('glob'); -import v8toIstanbul = require('v8-to-istanbul'); -import type {RawSourceMap} from 'source-map'; import BaseReporter from './BaseReporter'; +import getWatermarks from './getWatermarks'; import type { Context, CoverageReporterOptions, CoverageWorker, Test, } from './types'; -import getWatermarks from './getWatermarks'; // This is fixed in a newer versions of source-map, but our dependencies are still stuck on old versions interface FixedRawSourceMap extends Omit { diff --git a/packages/jest-reporters/src/CoverageWorker.ts b/packages/jest-reporters/src/CoverageWorker.ts index f40c1aadc3d4..0b887919e1a3 100644 --- a/packages/jest-reporters/src/CoverageWorker.ts +++ b/packages/jest-reporters/src/CoverageWorker.ts @@ -5,14 +5,13 @@ * LICENSE file in the root directory of this source tree. */ +import exit = require('exit'); import * as fs from 'graceful-fs'; import type {Config} from '@jest/types'; -import exit = require('exit'); -import type {CoverageReporterSerializedOptions} from './types'; - import generateEmptyCoverage, { CoverageWorkerResult, } from './generateEmptyCoverage'; +import type {CoverageReporterSerializedOptions} from './types'; export type CoverageWorkerData = { globalConfig: Config.GlobalConfig; diff --git a/packages/jest-reporters/src/DefaultReporter.ts b/packages/jest-reporters/src/DefaultReporter.ts index d45c07138ab9..f1867ec719c0 100644 --- a/packages/jest-reporters/src/DefaultReporter.ts +++ b/packages/jest-reporters/src/DefaultReporter.ts @@ -5,21 +5,20 @@ * LICENSE file in the root directory of this source tree. */ -import type {Config} from '@jest/types'; +import chalk = require('chalk'); +import {getConsoleOutput} from '@jest/console'; import type { AggregatedResult, TestCaseResult, TestResult, } from '@jest/test-result'; - +import type {Config} from '@jest/types'; import {clearLine, isInteractive} from 'jest-util'; -import {getConsoleOutput} from '@jest/console'; -import chalk = require('chalk'); -import type {ReporterOnStartOptions, Test} from './types'; import BaseReporter from './BaseReporter'; import Status from './Status'; import getResultHeader from './getResultHeader'; import getSnapshotStatus from './getSnapshotStatus'; +import type {ReporterOnStartOptions, Test} from './types'; type write = NodeJS.WriteStream['write']; type FlushBufferedOutput = () => void; diff --git a/packages/jest-reporters/src/NotifyReporter.ts b/packages/jest-reporters/src/NotifyReporter.ts index 0c9012282a1c..54579e1f5b50 100644 --- a/packages/jest-reporters/src/NotifyReporter.ts +++ b/packages/jest-reporters/src/NotifyReporter.ts @@ -8,11 +8,11 @@ import * as path from 'path'; import * as util from 'util'; import exit = require('exit'); -import type {Config} from '@jest/types'; import type {AggregatedResult} from '@jest/test-result'; +import type {Config} from '@jest/types'; import {pluralize} from 'jest-util'; -import type {Context, TestSchedulerContext} from './types'; import BaseReporter from './BaseReporter'; +import type {Context, TestSchedulerContext} from './types'; const isDarwin = process.platform === 'darwin'; diff --git a/packages/jest-reporters/src/Status.ts b/packages/jest-reporters/src/Status.ts index 8eb9a154a120..839bb870ba27 100644 --- a/packages/jest-reporters/src/Status.ts +++ b/packages/jest-reporters/src/Status.ts @@ -5,14 +5,14 @@ * LICENSE file in the root directory of this source tree. */ -import type {Config} from '@jest/types'; +import chalk = require('chalk'); +import stringLength = require('string-length'); import type { AggregatedResult, TestCaseResult, TestResult, } from '@jest/test-result'; -import chalk = require('chalk'); -import stringLength = require('string-length'); +import type {Config} from '@jest/types'; import type {ReporterOnStartOptions, Test} from './types'; import { getSummary, diff --git a/packages/jest-reporters/src/SummaryReporter.ts b/packages/jest-reporters/src/SummaryReporter.ts index 203b365ead9a..f145e3b1820a 100644 --- a/packages/jest-reporters/src/SummaryReporter.ts +++ b/packages/jest-reporters/src/SummaryReporter.ts @@ -5,15 +5,15 @@ * LICENSE file in the root directory of this source tree. */ -import type {Config} from '@jest/types'; -import type {AggregatedResult, SnapshotSummary} from '@jest/test-result'; import chalk = require('chalk'); +import type {AggregatedResult, SnapshotSummary} from '@jest/test-result'; +import type {Config} from '@jest/types'; import {testPathPatternToRegExp} from 'jest-util'; -import type {Context, ReporterOnStartOptions} from './types'; import BaseReporter from './BaseReporter'; -import {getSummary} from './utils'; import getResultHeader from './getResultHeader'; import getSnapshotSummary from './getSnapshotSummary'; +import type {Context, ReporterOnStartOptions} from './types'; +import {getSummary} from './utils'; const TEST_SUMMARY_THRESHOLD = 20; diff --git a/packages/jest-reporters/src/VerboseReporter.ts b/packages/jest-reporters/src/VerboseReporter.ts index d6c5f986e3b8..ef74577e6db3 100644 --- a/packages/jest-reporters/src/VerboseReporter.ts +++ b/packages/jest-reporters/src/VerboseReporter.ts @@ -5,17 +5,17 @@ * LICENSE file in the root directory of this source tree. */ -import type {Config} from '@jest/types'; +import chalk = require('chalk'); import type { AggregatedResult, AssertionResult, Suite, TestResult, } from '@jest/test-result'; -import chalk = require('chalk'); +import type {Config} from '@jest/types'; import {formatTime, specialChars} from 'jest-util'; -import type {Test} from './types'; import DefaultReporter from './DefaultReporter'; +import type {Test} from './types'; const {ICONS} = specialChars; diff --git a/packages/jest-reporters/src/__tests__/NotifyReporter.test.ts b/packages/jest-reporters/src/__tests__/NotifyReporter.test.ts index 137a264483d1..86f23265862f 100644 --- a/packages/jest-reporters/src/__tests__/NotifyReporter.test.ts +++ b/packages/jest-reporters/src/__tests__/NotifyReporter.test.ts @@ -8,8 +8,8 @@ import type {AggregatedResult} from '@jest/test-result'; import type {Config} from '@jest/types'; import Resolver from 'jest-resolve'; -import NotifyReporter from '../NotifyReporter'; import {makeGlobalConfig} from '../../../../TestUtils'; +import NotifyReporter from '../NotifyReporter'; jest.mock('../DefaultReporter'); jest.mock('node-notifier', () => ({ diff --git a/packages/jest-reporters/src/__tests__/generateEmptyCoverage.test.js b/packages/jest-reporters/src/__tests__/generateEmptyCoverage.test.js index 1142e0d449db..133bca047554 100644 --- a/packages/jest-reporters/src/__tests__/generateEmptyCoverage.test.js +++ b/packages/jest-reporters/src/__tests__/generateEmptyCoverage.test.js @@ -5,14 +5,13 @@ * LICENSE file in the root directory of this source tree. */ -import path from 'path'; import os from 'os'; -import {shouldInstrument} from '@jest/transform'; +import path from 'path'; import istanbulCoverage from 'istanbul-lib-coverage'; import libSourceMaps from 'istanbul-lib-source-maps'; -import generateEmptyCoverage from '../generateEmptyCoverage'; - +import {shouldInstrument} from '@jest/transform'; import {makeGlobalConfig, makeProjectConfig} from '../../../../TestUtils'; +import generateEmptyCoverage from '../generateEmptyCoverage'; jest.mock('@jest/transform', () => ({ ...jest.requireActual('@jest/transform'), diff --git a/packages/jest-reporters/src/__tests__/getWatermarks.test.ts b/packages/jest-reporters/src/__tests__/getWatermarks.test.ts index 9e4f67341e47..b4a869512664 100644 --- a/packages/jest-reporters/src/__tests__/getWatermarks.test.ts +++ b/packages/jest-reporters/src/__tests__/getWatermarks.test.ts @@ -5,8 +5,8 @@ * LICENSE file in the root directory of this source tree. */ -import getWatermarks from '../getWatermarks'; import {makeGlobalConfig} from '../../../../TestUtils'; +import getWatermarks from '../getWatermarks'; describe('getWatermarks', () => { test(`that watermarks use thresholds as upper target`, () => { diff --git a/packages/jest-reporters/src/__tests__/utils.test.ts b/packages/jest-reporters/src/__tests__/utils.test.ts index 8e1887daf7f5..86bd362bed14 100644 --- a/packages/jest-reporters/src/__tests__/utils.test.ts +++ b/packages/jest-reporters/src/__tests__/utils.test.ts @@ -8,8 +8,8 @@ import * as path from 'path'; import chalk = require('chalk'); import stripAnsi = require('strip-ansi'); -import {printDisplayName, trimAndFormatPath, wrapAnsiString} from '../utils'; import {makeProjectConfig} from '../../../../TestUtils'; +import {printDisplayName, trimAndFormatPath, wrapAnsiString} from '../utils'; describe('wrapAnsiString()', () => { it('wraps a long string containing ansi chars', () => { diff --git a/packages/jest-reporters/src/generateEmptyCoverage.ts b/packages/jest-reporters/src/generateEmptyCoverage.ts index e4f35e7c02cf..a56b5100d253 100644 --- a/packages/jest-reporters/src/generateEmptyCoverage.ts +++ b/packages/jest-reporters/src/generateEmptyCoverage.ts @@ -5,12 +5,12 @@ * LICENSE file in the root directory of this source tree. */ +import type {V8Coverage} from 'collect-v8-coverage'; import * as fs from 'graceful-fs'; -import type {Config} from '@jest/types'; -import {readInitialCoverage} from 'istanbul-lib-instrument'; import {FileCoverage, createFileCoverage} from 'istanbul-lib-coverage'; +import {readInitialCoverage} from 'istanbul-lib-instrument'; import {ScriptTransformer, shouldInstrument} from '@jest/transform'; -import type {V8Coverage} from 'collect-v8-coverage'; +import type {Config} from '@jest/types'; type SingleV8Coverage = V8Coverage[number]; diff --git a/packages/jest-reporters/src/getResultHeader.ts b/packages/jest-reporters/src/getResultHeader.ts index d336714f6c5b..68f6dc82bfd5 100644 --- a/packages/jest-reporters/src/getResultHeader.ts +++ b/packages/jest-reporters/src/getResultHeader.ts @@ -5,11 +5,11 @@ * LICENSE file in the root directory of this source tree. */ -import type {Config} from '@jest/types'; -import type {TestResult} from '@jest/test-result'; import chalk = require('chalk'); -import {formatTime} from 'jest-util'; import terminalLink = require('terminal-link'); +import type {TestResult} from '@jest/test-result'; +import type {Config} from '@jest/types'; +import {formatTime} from 'jest-util'; import {formatTestPath, printDisplayName} from './utils'; const LONG_TEST_COLOR = chalk.reset.bold.bgRed; diff --git a/packages/jest-reporters/src/getSnapshotSummary.ts b/packages/jest-reporters/src/getSnapshotSummary.ts index 3e8e1aa2ad81..66bf7cd4227f 100644 --- a/packages/jest-reporters/src/getSnapshotSummary.ts +++ b/packages/jest-reporters/src/getSnapshotSummary.ts @@ -5,9 +5,9 @@ * LICENSE file in the root directory of this source tree. */ -import type {Config} from '@jest/types'; -import type {SnapshotSummary} from '@jest/test-result'; import chalk = require('chalk'); +import type {SnapshotSummary} from '@jest/test-result'; +import type {Config} from '@jest/types'; import {pluralize} from 'jest-util'; import {formatTestPath} from './utils'; diff --git a/packages/jest-reporters/src/getWatermarks.ts b/packages/jest-reporters/src/getWatermarks.ts index 6c3bd174bf25..5caacf927445 100644 --- a/packages/jest-reporters/src/getWatermarks.ts +++ b/packages/jest-reporters/src/getWatermarks.ts @@ -5,8 +5,8 @@ * LICENSE file in the root directory of this source tree. */ -import type {Config} from '@jest/types'; import istanbulReport = require('istanbul-lib-report'); +import type {Config} from '@jest/types'; export default function getWatermarks( config: Config.GlobalConfig, diff --git a/packages/jest-reporters/src/types.ts b/packages/jest-reporters/src/types.ts index 2add1587a315..5b54f7c80dfe 100644 --- a/packages/jest-reporters/src/types.ts +++ b/packages/jest-reporters/src/types.ts @@ -5,13 +5,13 @@ * LICENSE file in the root directory of this source tree. */ -import type {Config} from '@jest/types'; import type { AggregatedResult, SerializableError, TestCaseResult, TestResult, } from '@jest/test-result'; +import type {Config} from '@jest/types'; import type {FS as HasteFS, ModuleMap} from 'jest-haste-map'; import type {ResolverType} from 'jest-resolve'; import type {worker} from './CoverageWorker'; diff --git a/packages/jest-reporters/src/utils.ts b/packages/jest-reporters/src/utils.ts index 956a1de4a063..346314c5d1ce 100644 --- a/packages/jest-reporters/src/utils.ts +++ b/packages/jest-reporters/src/utils.ts @@ -6,10 +6,10 @@ */ import * as path from 'path'; -import type {Config} from '@jest/types'; -import type {AggregatedResult, TestCaseResult} from '@jest/test-result'; import chalk = require('chalk'); import slash = require('slash'); +import type {AggregatedResult, TestCaseResult} from '@jest/test-result'; +import type {Config} from '@jest/types'; import {formatTime, pluralize} from 'jest-util'; import type {SummaryOptions, Test} from './types'; diff --git a/packages/jest-resolve-dependencies/src/__tests__/dependency_resolver.test.ts b/packages/jest-resolve-dependencies/src/__tests__/dependency_resolver.test.ts index 3862becf46dd..1b6cd6c1c906 100644 --- a/packages/jest-resolve-dependencies/src/__tests__/dependency_resolver.test.ts +++ b/packages/jest-resolve-dependencies/src/__tests__/dependency_resolver.test.ts @@ -7,8 +7,8 @@ import {tmpdir} from 'os'; import * as path from 'path'; -import Resolver = require('jest-resolve'); import type {Config} from '@jest/types'; +import Resolver = require('jest-resolve'); import {buildSnapshotResolver} from 'jest-snapshot'; import {makeProjectConfig} from '../../../../TestUtils'; import DependencyResolver from '../index'; diff --git a/packages/jest-resolve/src/ModuleNotFoundError.ts b/packages/jest-resolve/src/ModuleNotFoundError.ts index 723d1303b5ae..a2b0935c6348 100644 --- a/packages/jest-resolve/src/ModuleNotFoundError.ts +++ b/packages/jest-resolve/src/ModuleNotFoundError.ts @@ -6,8 +6,8 @@ */ import * as path from 'path'; -import type {Config} from '@jest/types'; import slash = require('slash'); +import type {Config} from '@jest/types'; export default class ModuleNotFoundError extends Error { public code = 'MODULE_NOT_FOUND'; diff --git a/packages/jest-resolve/src/__tests__/resolve.test.ts b/packages/jest-resolve/src/__tests__/resolve.test.ts index 822cdede4d2d..cd1bee69ac80 100644 --- a/packages/jest-resolve/src/__tests__/resolve.test.ts +++ b/packages/jest-resolve/src/__tests__/resolve.test.ts @@ -8,12 +8,12 @@ import * as path from 'path'; import * as fs from 'graceful-fs'; -import {ModuleMap} from 'jest-haste-map'; import {sync as resolveSync} from 'resolve'; +import {ModuleMap} from 'jest-haste-map'; import Resolver = require('../'); import userResolver from '../__mocks__/userResolver'; -import nodeModulesPaths from '../nodeModulesPaths'; import defaultResolver from '../defaultResolver'; +import nodeModulesPaths from '../nodeModulesPaths'; import type {ResolverConfig} from '../types'; jest.mock('../__mocks__/userResolver'); diff --git a/packages/jest-resolve/src/defaultResolver.ts b/packages/jest-resolve/src/defaultResolver.ts index c925ae8fe3b0..3f15929f1a8e 100644 --- a/packages/jest-resolve/src/defaultResolver.ts +++ b/packages/jest-resolve/src/defaultResolver.ts @@ -6,10 +6,10 @@ */ import * as fs from 'graceful-fs'; -import {Opts as ResolveOpts, sync as resolveSync} from 'resolve'; import pnpResolver from 'jest-pnp-resolver'; -import {tryRealpath} from 'jest-util'; +import {Opts as ResolveOpts, sync as resolveSync} from 'resolve'; import type {Config} from '@jest/types'; +import {tryRealpath} from 'jest-util'; type ResolverOptions = { allowPnp?: boolean; diff --git a/packages/jest-resolve/src/index.ts b/packages/jest-resolve/src/index.ts index d77ab35738a6..cec294fcf5e2 100644 --- a/packages/jest-resolve/src/index.ts +++ b/packages/jest-resolve/src/index.ts @@ -8,17 +8,17 @@ /* eslint-disable local/prefer-spread-eventually */ import * as path from 'path'; +import chalk = require('chalk'); +import slash = require('slash'); import type {Config} from '@jest/types'; import type {ModuleMap} from 'jest-haste-map'; import {tryRealpath} from 'jest-util'; -import slash = require('slash'); -import chalk = require('chalk'); -import nodeModulesPaths from './nodeModulesPaths'; -import isBuiltinModule from './isBuiltinModule'; -import defaultResolver, {clearDefaultResolverCache} from './defaultResolver'; -import type {ResolverConfig} from './types'; import ModuleNotFoundError from './ModuleNotFoundError'; +import defaultResolver, {clearDefaultResolverCache} from './defaultResolver'; +import isBuiltinModule from './isBuiltinModule'; +import nodeModulesPaths from './nodeModulesPaths'; import shouldLoadAsEsm, {clearCachedLookups} from './shouldLoadAsEsm'; +import type {ResolverConfig} from './types'; type FindNodeModuleConfig = { basedir: Config.Path; diff --git a/packages/jest-resolve/src/shouldLoadAsEsm.ts b/packages/jest-resolve/src/shouldLoadAsEsm.ts index cab7b850eae6..70599cf48f6f 100644 --- a/packages/jest-resolve/src/shouldLoadAsEsm.ts +++ b/packages/jest-resolve/src/shouldLoadAsEsm.ts @@ -8,8 +8,8 @@ import {dirname, extname} from 'path'; // @ts-expect-error: experimental, not added to the types import {SyntheticModule} from 'vm'; -import type {Config} from '@jest/types'; import readPkgUp = require('read-pkg-up'); +import type {Config} from '@jest/types'; const runtimeSupportsVmModules = typeof SyntheticModule === 'function'; diff --git a/packages/jest-runner/src/index.ts b/packages/jest-runner/src/index.ts index 73fe2ad539cc..957bbef9693e 100644 --- a/packages/jest-runner/src/index.ts +++ b/packages/jest-runner/src/index.ts @@ -5,14 +5,14 @@ * LICENSE file in the root directory of this source tree. */ -import type {Config} from '@jest/types'; -import type {SerializableError, TestResult} from '@jest/test-result'; -import exit = require('exit'); import chalk = require('chalk'); import Emittery = require('emittery'); +import exit = require('exit'); import throat from 'throat'; -import Worker, {PromiseWithCustomMessage} from 'jest-worker'; +import type {SerializableError, TestResult} from '@jest/test-result'; +import type {Config} from '@jest/types'; import {deepCyclicCopy} from 'jest-util'; +import Worker, {PromiseWithCustomMessage} from 'jest-worker'; import runTest from './runTest'; import type {SerializableResolver, worker} from './testWorker'; import type { diff --git a/packages/jest-runner/src/runTest.ts b/packages/jest-runner/src/runTest.ts index 85aadd468329..4770bf5369c5 100644 --- a/packages/jest-runner/src/runTest.ts +++ b/packages/jest-runner/src/runTest.ts @@ -6,8 +6,9 @@ * */ -import type {Config} from '@jest/types'; -import type {TestResult} from '@jest/test-result'; +import chalk = require('chalk'); +import * as fs from 'graceful-fs'; +import sourcemapSupport = require('source-map-support'); import { BufferedConsole, CustomConsole, @@ -17,16 +18,15 @@ import { getConsoleOutput, } from '@jest/console'; import type {JestEnvironment} from '@jest/environment'; -import RuntimeClass = require('jest-runtime'); -import * as fs from 'graceful-fs'; -import {ErrorWithStack, interopRequireDefault, setGlobal} from 'jest-util'; -import LeakDetector from 'jest-leak-detector'; -import type {ResolverType} from 'jest-resolve'; +import type {TestResult} from '@jest/test-result'; +import type {Config} from '@jest/types'; import {getTestEnvironment} from 'jest-config'; import * as docblock from 'jest-docblock'; +import LeakDetector from 'jest-leak-detector'; import {formatExecError} from 'jest-message-util'; -import sourcemapSupport = require('source-map-support'); -import chalk = require('chalk'); +import type {ResolverType} from 'jest-resolve'; +import RuntimeClass = require('jest-runtime'); +import {ErrorWithStack, interopRequireDefault, setGlobal} from 'jest-util'; import type {TestFileEvent, TestFramework, TestRunnerContext} from './types'; type RunTestInternalResult = { diff --git a/packages/jest-runner/src/testWorker.ts b/packages/jest-runner/src/testWorker.ts index 10e2e3e0b318..263d3994cb58 100644 --- a/packages/jest-runner/src/testWorker.ts +++ b/packages/jest-runner/src/testWorker.ts @@ -6,22 +6,21 @@ * */ -import type {Config} from '@jest/types'; +import exit = require('exit'); import type {SerializableError, TestResult} from '@jest/test-result'; +import type {Config} from '@jest/types'; import HasteMap = require('jest-haste-map'); -import exit = require('exit'); import {separateMessageFromStack} from 'jest-message-util'; -import Runtime = require('jest-runtime'); import type {ResolverType} from 'jest-resolve'; +import Runtime = require('jest-runtime'); import {messageParent} from 'jest-worker'; +import runTest from './runTest'; import type { ErrorWithCode, TestFileEvent, TestRunnerSerializedContext, } from './types'; -import runTest from './runTest'; - export type SerializableResolver = { config: Config.ProjectConfig; serializableModuleMap: HasteMap.SerializableModuleMap; diff --git a/packages/jest-runner/src/types.ts b/packages/jest-runner/src/types.ts index 4b20d260e910..351770603241 100644 --- a/packages/jest-runner/src/types.ts +++ b/packages/jest-runner/src/types.ts @@ -6,13 +6,13 @@ */ import type {EventEmitter} from 'events'; -import type {Config} from '@jest/types'; +import type {JestEnvironment} from '@jest/environment'; import type { AssertionResult, SerializableError, TestResult, } from '@jest/test-result'; -import type {JestEnvironment} from '@jest/environment'; +import type {Config} from '@jest/types'; import type {FS as HasteFS, ModuleMap} from 'jest-haste-map'; import type {ResolverType} from 'jest-resolve'; import type {RuntimeType} from 'jest-runtime'; diff --git a/packages/jest-runtime/src/__tests__/instrumentation.test.ts b/packages/jest-runtime/src/__tests__/instrumentation.test.ts index 0de407f14862..3cc99787bcdf 100644 --- a/packages/jest-runtime/src/__tests__/instrumentation.test.ts +++ b/packages/jest-runtime/src/__tests__/instrumentation.test.ts @@ -6,8 +6,8 @@ * */ -import * as path from 'path'; import * as os from 'os'; +import * as path from 'path'; import {ScriptTransformer} from '@jest/transform'; import {makeGlobalConfig, makeProjectConfig} from '../../../../TestUtils'; diff --git a/packages/jest-runtime/src/cli/index.ts b/packages/jest-runtime/src/cli/index.ts index c49da6cce333..270a3c82a849 100644 --- a/packages/jest-runtime/src/cli/index.ts +++ b/packages/jest-runtime/src/cli/index.ts @@ -9,12 +9,12 @@ import {cpus} from 'os'; import * as path from 'path'; import chalk = require('chalk'); import yargs = require('yargs'); -import type {Config} from '@jest/types'; -import type {JestEnvironment} from '@jest/environment'; import {CustomConsole} from '@jest/console'; +import type {JestEnvironment} from '@jest/environment'; +import type {Config} from '@jest/types'; +import {deprecationEntries, readConfig} from 'jest-config'; import {setGlobal, tryRealpath} from 'jest-util'; import {validateCLIOptions} from 'jest-validate'; -import {deprecationEntries, readConfig} from 'jest-config'; import {VERSION} from '../version'; import * as args from './args'; diff --git a/packages/jest-runtime/src/helpers.ts b/packages/jest-runtime/src/helpers.ts index 4a7d28aa7f27..3b32d08ee2bb 100644 --- a/packages/jest-runtime/src/helpers.ts +++ b/packages/jest-runtime/src/helpers.ts @@ -6,8 +6,8 @@ */ import * as path from 'path'; -import slash = require('slash'); import glob = require('glob'); +import slash = require('slash'); import type {Config} from '@jest/types'; const OUTSIDE_JEST_VM_PROTOCOL = 'jest-main:'; diff --git a/packages/jest-runtime/src/index.ts b/packages/jest-runtime/src/index.ts index 8af7c41b0135..1f8f8f7ef6a7 100644 --- a/packages/jest-runtime/src/index.ts +++ b/packages/jest-runtime/src/index.ts @@ -5,8 +5,9 @@ * LICENSE file in the root directory of this source tree. */ -import {URL, fileURLToPath, pathToFileURL} from 'url'; +import * as nativeModule from 'module'; import * as path from 'path'; +import {URL, fileURLToPath, pathToFileURL} from 'url'; import { Script, // @ts-expect-error: experimental, not added to the types @@ -17,22 +18,21 @@ import { // @ts-expect-error: experimental, not added to the types Module as VMModule, } from 'vm'; -import * as nativeModule from 'module'; // @ts-expect-error import parseCjs = require('cjs-module-lexer'); -import type {Config, Global} from '@jest/types'; +import {CoverageInstrumenter, V8Coverage} from 'collect-v8-coverage'; +import * as fs from 'graceful-fs'; +import stripBOM = require('strip-bom'); import type { Jest, JestEnvironment, Module, ModuleWrapper, } from '@jest/environment'; +import {LegacyFakeTimers, ModernFakeTimers} from '@jest/fake-timers'; import type * as JestGlobals from '@jest/globals'; import type {SourceMapRegistry} from '@jest/source-map'; -import {LegacyFakeTimers, ModernFakeTimers} from '@jest/fake-timers'; -import {formatStackTrace, separateMessageFromStack} from 'jest-message-util'; -import {createDirectory, deepCyclicCopy} from 'jest-util'; -import {escapePathForRegex} from 'jest-regex-util'; +import type {RuntimeTransformResult, V8CoverageResult} from '@jest/test-result'; import { CallerTransformOptions, ScriptTransformer, @@ -41,22 +41,22 @@ import { handlePotentialSyntaxError, shouldInstrument, } from '@jest/transform'; -import type {RuntimeTransformResult, V8CoverageResult} from '@jest/test-result'; -import {CoverageInstrumenter, V8Coverage} from 'collect-v8-coverage'; -import * as fs from 'graceful-fs'; -import jestMock = require('jest-mock'); +import type {Config, Global} from '@jest/types'; import HasteMap = require('jest-haste-map'); +import {formatStackTrace, separateMessageFromStack} from 'jest-message-util'; +import jestMock = require('jest-mock'); +import {escapePathForRegex} from 'jest-regex-util'; import Resolver = require('jest-resolve'); import Snapshot = require('jest-snapshot'); -import stripBOM = require('strip-bom'); -import type {Context as JestContext} from './types'; +import {createDirectory, deepCyclicCopy} from 'jest-util'; +import {run as cliRun} from './cli'; +import {options as cliOptions} from './cli/args'; import { createOutsideJestVmPath, decodePossibleOutsideJestVmPath, findSiblingsWithFileExtension, } from './helpers'; -import {options as cliOptions} from './cli/args'; -import {run as cliRun} from './cli'; +import type {Context as JestContext} from './types'; const esmIsAvailable = typeof SourceTextModule === 'function'; diff --git a/packages/jest-runtime/src/types.ts b/packages/jest-runtime/src/types.ts index 7ef3887ec060..744b24dc7c15 100644 --- a/packages/jest-runtime/src/types.ts +++ b/packages/jest-runtime/src/types.ts @@ -6,8 +6,8 @@ */ import type {Config} from '@jest/types'; -import type {ResolverType} from 'jest-resolve'; import type {FS as HasteFS, ModuleMap} from 'jest-haste-map'; +import type {ResolverType} from 'jest-resolve'; export type Context = { config: Config.ProjectConfig; diff --git a/packages/jest-serializer/src/__tests__/index.test.ts b/packages/jest-serializer/src/__tests__/index.test.ts index 61bea44cbb7a..d6c8f82e157b 100644 --- a/packages/jest-serializer/src/__tests__/index.test.ts +++ b/packages/jest-serializer/src/__tests__/index.test.ts @@ -9,7 +9,6 @@ import {tmpdir} from 'os'; import * as path from 'path'; import * as fs from 'graceful-fs'; import prettyFormat = require('pretty-format'); - import serializer from '..'; const objs = [ diff --git a/packages/jest-snapshot/src/InlineSnapshots.ts b/packages/jest-snapshot/src/InlineSnapshots.ts index 77a8cf6cbc00..b8736ff89156 100644 --- a/packages/jest-snapshot/src/InlineSnapshots.ts +++ b/packages/jest-snapshot/src/InlineSnapshots.ts @@ -6,16 +6,16 @@ */ import * as path from 'path'; -import * as fs from 'graceful-fs'; -import semver = require('semver'); import {file, templateElement, templateLiteral} from '@babel/types'; -import type {Frame} from 'jest-message-util'; +import * as fs from 'graceful-fs'; import type { BuiltInParsers as PrettierBuiltInParsers, CustomParser as PrettierCustomParser, BuiltInParserName as PrettierParserName, } from 'prettier'; +import semver = require('semver'); import type {Config} from '@jest/types'; +import type {Frame} from 'jest-message-util'; import type {BabelTraverse, Prettier} from './types'; import {escapeBacktickString} from './utils'; diff --git a/packages/jest-snapshot/src/SnapshotResolver.ts b/packages/jest-snapshot/src/SnapshotResolver.ts index 684e34dc408d..dbc773b1e228 100644 --- a/packages/jest-snapshot/src/SnapshotResolver.ts +++ b/packages/jest-snapshot/src/SnapshotResolver.ts @@ -6,8 +6,8 @@ */ import * as path from 'path'; -import type {Config} from '@jest/types'; import chalk = require('chalk'); +import type {Config} from '@jest/types'; export type SnapshotResolver = { testPathForConsistencyCheck: string; diff --git a/packages/jest-snapshot/src/State.ts b/packages/jest-snapshot/src/State.ts index fecfbf86996a..898a358c7bcf 100644 --- a/packages/jest-snapshot/src/State.ts +++ b/packages/jest-snapshot/src/State.ts @@ -7,8 +7,9 @@ import * as fs from 'graceful-fs'; import type {Config} from '@jest/types'; - import {getStackTraceLines, getTopFrame} from 'jest-message-util'; +import {InlineSnapshot, saveInlineSnapshots} from './InlineSnapshots'; +import type {BabelTraverse, Prettier, SnapshotData} from './types'; import { addExtraLineBreaks, getSnapshotData, @@ -19,8 +20,6 @@ import { serialize, testNameToKey, } from './utils'; -import {InlineSnapshot, saveInlineSnapshots} from './InlineSnapshots'; -import type {BabelTraverse, Prettier, SnapshotData} from './types'; export type SnapshotStateOptions = { updateSnapshot: Config.SnapshotUpdateState; diff --git a/packages/jest-snapshot/src/__tests__/InlineSnapshots.test.ts b/packages/jest-snapshot/src/__tests__/InlineSnapshots.test.ts index 1de8f4ca3dcc..6c5cb17f89c6 100644 --- a/packages/jest-snapshot/src/__tests__/InlineSnapshots.test.ts +++ b/packages/jest-snapshot/src/__tests__/InlineSnapshots.test.ts @@ -16,11 +16,10 @@ jest.mock('graceful-fs', () => ({ jest.mock('prettier'); import * as path from 'path'; +import babelTraverse from '@babel/traverse'; import * as fs from 'graceful-fs'; import prettier from 'prettier'; -import babelTraverse from '@babel/traverse'; import {Frame} from 'jest-message-util'; - import {saveInlineSnapshots} from '../InlineSnapshots'; beforeEach(() => { (prettier.resolveConfig.sync as jest.Mock).mockReset(); diff --git a/packages/jest-snapshot/src/__tests__/SnapshotResolver.test.ts b/packages/jest-snapshot/src/__tests__/SnapshotResolver.test.ts index 312d6aca21b0..2e4e166836b0 100644 --- a/packages/jest-snapshot/src/__tests__/SnapshotResolver.test.ts +++ b/packages/jest-snapshot/src/__tests__/SnapshotResolver.test.ts @@ -7,7 +7,6 @@ import * as path from 'path'; import {makeProjectConfig} from '../../../../TestUtils'; - import {SnapshotResolver, buildSnapshotResolver} from '../SnapshotResolver'; describe('defaults', () => { diff --git a/packages/jest-snapshot/src/__tests__/mockSerializer.test.ts b/packages/jest-snapshot/src/__tests__/mockSerializer.test.ts index 902c72540d85..821c86a86025 100644 --- a/packages/jest-snapshot/src/__tests__/mockSerializer.test.ts +++ b/packages/jest-snapshot/src/__tests__/mockSerializer.test.ts @@ -6,7 +6,6 @@ */ import prettyFormat = require('pretty-format'); - import plugin from '../mockSerializer'; test('mock with 0 calls and default name', () => { diff --git a/packages/jest-snapshot/src/__tests__/printSnapshot.test.ts b/packages/jest-snapshot/src/__tests__/printSnapshot.test.ts index 85bd10a85786..38cc0cf821d5 100644 --- a/packages/jest-snapshot/src/__tests__/printSnapshot.test.ts +++ b/packages/jest-snapshot/src/__tests__/printSnapshot.test.ts @@ -9,16 +9,6 @@ import ansiRegex = require('ansi-regex'); import styles = require('ansi-styles'); import chalk = require('chalk'); import format = require('pretty-format'); - -import jestSnapshot = require('../index'); -import { - getReceivedColorForChalkInstance, - getSnapshotColorForChalkInstance, - noColor, - printPropertiesAndReceived, - printSnapshotAndReceived, -} from '../printSnapshot'; -import {serialize} from '../utils'; import { aBackground2, aBackground3, @@ -29,6 +19,15 @@ import { bForeground2, bForeground3, } from '../colors'; +import jestSnapshot = require('../index'); +import { + getReceivedColorForChalkInstance, + getSnapshotColorForChalkInstance, + noColor, + printPropertiesAndReceived, + printSnapshotAndReceived, +} from '../printSnapshot'; +import {serialize} from '../utils'; const aOpenForeground1 = styles.magenta.open; const aOpenBackground1 = styles.bgYellowBright.open; diff --git a/packages/jest-snapshot/src/__tests__/utils.test.ts b/packages/jest-snapshot/src/__tests__/utils.test.ts index b983f6c8f6fe..222ce9e758be 100644 --- a/packages/jest-snapshot/src/__tests__/utils.test.ts +++ b/packages/jest-snapshot/src/__tests__/utils.test.ts @@ -10,11 +10,10 @@ jest.mock('graceful-fs', () => ({ existsSync: jest.fn().mockReturnValue(true), })); -import * as path from 'path'; import assert = require('assert'); -import * as fs from 'graceful-fs'; +import * as path from 'path'; import chalk = require('chalk'); - +import * as fs from 'graceful-fs'; import { SNAPSHOT_GUIDE_LINK, SNAPSHOT_VERSION, diff --git a/packages/jest-snapshot/src/index.ts b/packages/jest-snapshot/src/index.ts index f2b978c96220..9aee3860ef2b 100644 --- a/packages/jest-snapshot/src/index.ts +++ b/packages/jest-snapshot/src/index.ts @@ -10,7 +10,6 @@ import * as fs from 'graceful-fs'; import type {Config} from '@jest/types'; import type {FS as HasteFS} from 'jest-haste-map'; - import { BOLD_WEIGHT, EXPECTED_COLOR, diff --git a/packages/jest-snapshot/src/plugins.ts b/packages/jest-snapshot/src/plugins.ts index 10c481474f68..fdaf455e4470 100644 --- a/packages/jest-snapshot/src/plugins.ts +++ b/packages/jest-snapshot/src/plugins.ts @@ -6,7 +6,6 @@ */ import prettyFormat = require('pretty-format'); - import jestMockSerializer from './mockSerializer'; const { diff --git a/packages/jest-snapshot/src/printSnapshot.ts b/packages/jest-snapshot/src/printSnapshot.ts index ddd5814b0b14..2cb0732027b3 100644 --- a/packages/jest-snapshot/src/printSnapshot.ts +++ b/packages/jest-snapshot/src/printSnapshot.ts @@ -34,7 +34,6 @@ import { matcherHint, } from 'jest-matcher-utils'; import prettyFormat = require('pretty-format'); - import { aBackground2, aBackground3, diff --git a/packages/jest-snapshot/src/utils.ts b/packages/jest-snapshot/src/utils.ts index da5867ce2121..4441b3825a94 100644 --- a/packages/jest-snapshot/src/utils.ts +++ b/packages/jest-snapshot/src/utils.ts @@ -6,9 +6,9 @@ */ import * as path from 'path'; +import chalk = require('chalk'); import * as fs from 'graceful-fs'; import naturalCompare = require('natural-compare'); -import chalk = require('chalk'); import type {Config} from '@jest/types'; import prettyFormat = require('pretty-format'); import {getSerializers} from './plugins'; diff --git a/packages/jest-source-map/src/getCallsite.ts b/packages/jest-source-map/src/getCallsite.ts index 0106c0ee0396..1af2fe6973fa 100644 --- a/packages/jest-source-map/src/getCallsite.ts +++ b/packages/jest-source-map/src/getCallsite.ts @@ -5,8 +5,8 @@ * LICENSE file in the root directory of this source tree. */ -import {readFileSync} from 'graceful-fs'; import callsites = require('callsites'); +import {readFileSync} from 'graceful-fs'; import {SourceMapConsumer} from 'source-map'; import type {SourceMapRegistry} from './types'; diff --git a/packages/jest-test-result/src/types.ts b/packages/jest-test-result/src/types.ts index 92c013a86586..d31721d6b231 100644 --- a/packages/jest-test-result/src/types.ts +++ b/packages/jest-test-result/src/types.ts @@ -5,10 +5,10 @@ * LICENSE file in the root directory of this source tree. */ +import type {V8Coverage} from 'collect-v8-coverage'; import type {CoverageMap, CoverageMapData} from 'istanbul-lib-coverage'; import type {ConsoleBuffer} from '@jest/console'; import type {Config, TestResult, TransformTypes} from '@jest/types'; -import type {V8Coverage} from 'collect-v8-coverage'; export interface RuntimeTransformResult extends TransformTypes.TransformResult { // TODO: Make mandatory in Jest 27 diff --git a/packages/jest-test-sequencer/src/index.ts b/packages/jest-test-sequencer/src/index.ts index d4aea61c9e76..8c191843d1fc 100644 --- a/packages/jest-test-sequencer/src/index.ts +++ b/packages/jest-test-sequencer/src/index.ts @@ -8,8 +8,8 @@ import * as fs from 'graceful-fs'; import type {AggregatedResult} from '@jest/test-result'; import {getCacheFilePath} from 'jest-haste-map'; -import type {Context} from 'jest-runtime'; import type {Test} from 'jest-runner'; +import type {Context} from 'jest-runtime'; const FAIL = 0; const SUCCESS = 1; diff --git a/packages/jest-transform/src/ScriptTransformer.ts b/packages/jest-transform/src/ScriptTransformer.ts index 7fd85863146d..921d9c22669c 100644 --- a/packages/jest-transform/src/ScriptTransformer.ts +++ b/packages/jest-transform/src/ScriptTransformer.ts @@ -7,31 +7,33 @@ import {createHash} from 'crypto'; import * as path from 'path'; -import type {Config} from '@jest/types'; -import { - createDirectory, - interopRequireDefault, - isPromise, - tryRealpath, -} from 'jest-util'; -import * as fs from 'graceful-fs'; import {transformSync as babelTransform} from '@babel/core'; // @ts-expect-error: should just be `require.resolve`, but the tests mess that up import babelPluginIstanbul from 'babel-plugin-istanbul'; import {fromSource as sourcemapFromSource} from 'convert-source-map'; -import HasteMap = require('jest-haste-map'); import stableStringify = require('fast-json-stable-stringify'); +import * as fs from 'graceful-fs'; +import {addHook} from 'pirates'; import slash = require('slash'); import {sync as writeFileAtomic} from 'write-file-atomic'; -import {addHook} from 'pirates'; +import type {Config} from '@jest/types'; +import HasteMap = require('jest-haste-map'); +import { + createDirectory, + interopRequireDefault, + isPromise, + tryRealpath, +} from 'jest-util'; +import handlePotentialSyntaxError from './enhanceUnexpectedTokenMessage'; +import shouldInstrument from './shouldInstrument'; import type { Options, TransformResult, TransformedSource, Transformer, } from './types'; -import shouldInstrument from './shouldInstrument'; -import handlePotentialSyntaxError from './enhanceUnexpectedTokenMessage'; +// Use `require` to avoid TS rootDir +const {version: VERSION} = require('../package.json'); type ProjectCache = { configString: string; @@ -40,9 +42,6 @@ type ProjectCache = { transformedFiles: Map; }; -// Use `require` to avoid TS rootDir -const {version: VERSION} = require('../package.json'); - // This data structure is used to avoid recalculating some data every time that // we need to transform a file. Since ScriptTransformer is instantiated for each // file we need to keep this object in the local scope of this module. diff --git a/packages/jest-transform/src/__tests__/should_instrument.test.ts b/packages/jest-transform/src/__tests__/should_instrument.test.ts index 1e1702d746f0..504fd1b5ae97 100644 --- a/packages/jest-transform/src/__tests__/should_instrument.test.ts +++ b/packages/jest-transform/src/__tests__/should_instrument.test.ts @@ -6,8 +6,8 @@ */ import type {Config} from '@jest/types'; -import shouldInstrument from '../shouldInstrument'; import {makeGlobalConfig, makeProjectConfig} from '../../../../TestUtils'; +import shouldInstrument from '../shouldInstrument'; import {Options} from '../types'; describe('shouldInstrument', () => { diff --git a/packages/jest-transform/src/shouldInstrument.ts b/packages/jest-transform/src/shouldInstrument.ts index 8b729ace3afb..a876bf4676e6 100644 --- a/packages/jest-transform/src/shouldInstrument.ts +++ b/packages/jest-transform/src/shouldInstrument.ts @@ -6,10 +6,10 @@ */ import * as path from 'path'; +import micromatch = require('micromatch'); import type {Config} from '@jest/types'; import {escapePathForRegex} from 'jest-regex-util'; import {globsToMatcher, replacePathSepForGlob} from 'jest-util'; -import micromatch = require('micromatch'); import type {ShouldInstrumentOptions} from './types'; const MOCKS_PATTERN = new RegExp( diff --git a/packages/jest-types/src/Config.ts b/packages/jest-types/src/Config.ts index 1044d255afa7..114d69a0df36 100644 --- a/packages/jest-types/src/Config.ts +++ b/packages/jest-types/src/Config.ts @@ -5,9 +5,9 @@ * LICENSE file in the root directory of this source tree. */ -import type {Arguments} from 'yargs'; -import type {ReportOptions} from 'istanbul-reports'; import type {ForegroundColor} from 'chalk'; +import type {ReportOptions} from 'istanbul-reports'; +import type {Arguments} from 'yargs'; type CoverageProvider = 'babel' | 'v8'; diff --git a/packages/jest-util/src/index.ts b/packages/jest-util/src/index.ts index 40d200b1930d..df75ff0548b9 100644 --- a/packages/jest-util/src/index.ts +++ b/packages/jest-util/src/index.ts @@ -15,13 +15,11 @@ export {default as isPromise} from './isPromise'; export {default as setGlobal} from './setGlobal'; export {default as deepCyclicCopy} from './deepCyclicCopy'; export {default as convertDescriptorToString} from './convertDescriptorToString'; -import * as specialChars from './specialChars'; +export * as specialChars from './specialChars'; export {default as replacePathSepForGlob} from './replacePathSepForGlob'; export {default as testPathPatternToRegExp} from './testPathPatternToRegExp'; export {default as globsToMatcher} from './globsToMatcher'; -import * as preRunMessage from './preRunMessage'; +export * as preRunMessage from './preRunMessage'; export {default as pluralize} from './pluralize'; export {default as formatTime} from './formatTime'; export {default as tryRealpath} from './tryRealpath'; - -export {preRunMessage, specialChars}; diff --git a/packages/jest-validate/src/__tests__/validate.test.ts b/packages/jest-validate/src/__tests__/validate.test.ts index e241c7140261..60a6f0bc357b 100644 --- a/packages/jest-validate/src/__tests__/validate.test.ts +++ b/packages/jest-validate/src/__tests__/validate.test.ts @@ -6,11 +6,10 @@ * */ -import validate from '../validate'; import {multipleValidOptions} from '../condition'; -import jestValidateExampleConfig from '../exampleConfig'; import jestValidateDefaultConfig from '../defaultConfig'; - +import jestValidateExampleConfig from '../exampleConfig'; +import validate from '../validate'; const { defaultConfig, validConfig, diff --git a/packages/jest-validate/src/defaultConfig.ts b/packages/jest-validate/src/defaultConfig.ts index 4b932dbccad9..0fdaaca05dcb 100644 --- a/packages/jest-validate/src/defaultConfig.ts +++ b/packages/jest-validate/src/defaultConfig.ts @@ -5,13 +5,12 @@ * LICENSE file in the root directory of this source tree. */ -import type {ValidationOptions} from './types'; - +import {validationCondition} from './condition'; import {deprecationWarning} from './deprecated'; -import {unknownOptionWarning} from './warnings'; import {errorMessage} from './errors'; -import {validationCondition} from './condition'; +import type {ValidationOptions} from './types'; import {DEPRECATION, ERROR, WARNING} from './utils'; +import {unknownOptionWarning} from './warnings'; const validationOptions: ValidationOptions = { comment: '', diff --git a/packages/jest-validate/src/deprecated.ts b/packages/jest-validate/src/deprecated.ts index d6776bc7686d..695c6847a686 100644 --- a/packages/jest-validate/src/deprecated.ts +++ b/packages/jest-validate/src/deprecated.ts @@ -6,7 +6,6 @@ */ import type {DeprecatedOptions, ValidationOptions} from './types'; - import {DEPRECATION, logValidationWarning} from './utils'; const deprecationMessage = (message: string, options: ValidationOptions) => { diff --git a/packages/jest-validate/src/errors.ts b/packages/jest-validate/src/errors.ts index ebd6c1d6a3b3..28e00563274e 100644 --- a/packages/jest-validate/src/errors.ts +++ b/packages/jest-validate/src/errors.ts @@ -7,9 +7,9 @@ import chalk = require('chalk'); import getType = require('jest-get-type'); -import {ERROR, ValidationError, formatPrettyObject} from './utils'; import {getValues} from './condition'; import type {ValidationOptions} from './types'; +import {ERROR, ValidationError, formatPrettyObject} from './utils'; export const errorMessage = ( option: string, diff --git a/packages/jest-validate/src/utils.ts b/packages/jest-validate/src/utils.ts index 48d2beabe980..a7fb56787224 100644 --- a/packages/jest-validate/src/utils.ts +++ b/packages/jest-validate/src/utils.ts @@ -6,8 +6,8 @@ */ import chalk = require('chalk'); -import prettyFormat = require('pretty-format'); import leven from 'leven'; +import prettyFormat = require('pretty-format'); const BULLET: string = chalk.bold('\u25cf'); export const DEPRECATION = `${BULLET} Deprecation Warning`; diff --git a/packages/jest-validate/src/validate.ts b/packages/jest-validate/src/validate.ts index 7c4089ba0131..ea2704e9a133 100644 --- a/packages/jest-validate/src/validate.ts +++ b/packages/jest-validate/src/validate.ts @@ -5,8 +5,8 @@ * LICENSE file in the root directory of this source tree. */ -import type {ValidationOptions} from './types'; import defaultConfig from './defaultConfig'; +import type {ValidationOptions} from './types'; import {ValidationError} from './utils'; let hasDeprecationWarnings = false; diff --git a/packages/jest-validate/src/validateCLIOptions.ts b/packages/jest-validate/src/validateCLIOptions.ts index 80627d12ff6e..644801dfe282 100644 --- a/packages/jest-validate/src/validateCLIOptions.ts +++ b/packages/jest-validate/src/validateCLIOptions.ts @@ -5,14 +5,14 @@ * LICENSE file in the root directory of this source tree. */ -import type {Config} from '@jest/types'; -import chalk = require('chalk'); import camelcase = require('camelcase'); +import chalk = require('chalk'); import type {Options} from 'yargs'; -import {ValidationError, createDidYouMeanMessage, format} from './utils'; -import {deprecationWarning} from './deprecated'; +import type {Config} from '@jest/types'; import defaultConfig from './defaultConfig'; +import {deprecationWarning} from './deprecated'; import type {DeprecatedOptionFunc, DeprecatedOptions} from './types'; +import {ValidationError, createDidYouMeanMessage, format} from './utils'; const BULLET: string = chalk.bold('\u25cf'); export const DOCUMENTATION_NOTE = ` ${chalk.bold('CLI Options Documentation:')} diff --git a/packages/jest-watcher/src/PatternPrompt.ts b/packages/jest-watcher/src/PatternPrompt.ts index c5b610b27334..a17b44307dbf 100644 --- a/packages/jest-watcher/src/PatternPrompt.ts +++ b/packages/jest-watcher/src/PatternPrompt.ts @@ -5,8 +5,8 @@ * LICENSE file in the root directory of this source tree. */ -import chalk = require('chalk'); import ansiEscapes = require('ansi-escapes'); +import chalk = require('chalk'); import {specialChars} from 'jest-util'; import type Prompt from './lib/Prompt'; import type {ScrollOptions} from './types'; diff --git a/packages/jest-watcher/src/lib/Prompt.ts b/packages/jest-watcher/src/lib/Prompt.ts index 508442739ffb..287d3bea027d 100644 --- a/packages/jest-watcher/src/lib/Prompt.ts +++ b/packages/jest-watcher/src/lib/Prompt.ts @@ -5,8 +5,8 @@ * LICENSE file in the root directory of this source tree. */ -import type {ScrollOptions} from '../types'; import {KEYS} from '../constants'; +import type {ScrollOptions} from '../types'; export default class Prompt { private _entering: boolean; diff --git a/packages/jest-watcher/src/lib/__tests__/prompt.test.ts b/packages/jest-watcher/src/lib/__tests__/prompt.test.ts index 1ade9d33331c..da68d77da31d 100644 --- a/packages/jest-watcher/src/lib/__tests__/prompt.test.ts +++ b/packages/jest-watcher/src/lib/__tests__/prompt.test.ts @@ -6,8 +6,8 @@ * */ -import Prompt from '../Prompt'; import {KEYS} from '../../constants'; +import Prompt from '../Prompt'; it('calls handler on change value', () => { const options = {max: 10, offset: -1}; diff --git a/packages/jest-watcher/src/lib/formatTestNameByPattern.ts b/packages/jest-watcher/src/lib/formatTestNameByPattern.ts index a470bf4ad4f0..2690e9dd25a4 100644 --- a/packages/jest-watcher/src/lib/formatTestNameByPattern.ts +++ b/packages/jest-watcher/src/lib/formatTestNameByPattern.ts @@ -6,7 +6,6 @@ */ import chalk = require('chalk'); - import colorize from './colorize'; const DOTS = '...'; diff --git a/packages/jest-watcher/src/lib/patternModeHelpers.ts b/packages/jest-watcher/src/lib/patternModeHelpers.ts index 6ef76847dbff..0a9f31aeff53 100644 --- a/packages/jest-watcher/src/lib/patternModeHelpers.ts +++ b/packages/jest-watcher/src/lib/patternModeHelpers.ts @@ -5,8 +5,8 @@ * LICENSE file in the root directory of this source tree. */ -import chalk = require('chalk'); import ansiEscapes = require('ansi-escapes'); +import chalk = require('chalk'); import stringLength = require('string-length'); export const printPatternCaret = ( diff --git a/packages/jest-watcher/src/types.ts b/packages/jest-watcher/src/types.ts index 90335fc163de..38fc070c1652 100644 --- a/packages/jest-watcher/src/types.ts +++ b/packages/jest-watcher/src/types.ts @@ -5,8 +5,8 @@ * LICENSE file in the root directory of this source tree. */ -import type {Config} from '@jest/types'; import type {AggregatedResult} from '@jest/test-result'; +import type {Config} from '@jest/types'; type TestSuiteInfo = { config: Config.ProjectConfig; diff --git a/packages/jest-worker/src/WorkerPool.ts b/packages/jest-worker/src/WorkerPool.ts index dc3039652cfe..92b8ce008234 100644 --- a/packages/jest-worker/src/WorkerPool.ts +++ b/packages/jest-worker/src/WorkerPool.ts @@ -6,7 +6,6 @@ */ import BaseWorkerPool from './base/BaseWorkerPool'; - import type { ChildMessage, OnCustomMessage, diff --git a/packages/jest-worker/src/__tests__/WorkerPool.test.js b/packages/jest-worker/src/__tests__/WorkerPool.test.js index 7c2cbcedbfa1..91283ef514b8 100644 --- a/packages/jest-worker/src/__tests__/WorkerPool.test.js +++ b/packages/jest-worker/src/__tests__/WorkerPool.test.js @@ -5,9 +5,9 @@ * LICENSE file in the root directory of this source tree. */ -'use strict'; - import WorkerPool from '../WorkerPool'; +import ChildProcessWorker from '../workers/ChildProcessWorker'; +import NodeThreadWorker from '../workers/NodeThreadsWorker'; jest.mock('../workers/ChildProcessWorker', () => { const fakeClass = jest.fn(() => ({ @@ -35,9 +35,6 @@ jest.mock('../workers/NodeThreadsWorker', () => { }; }); -const ChildProcessWorker = require('../workers/ChildProcessWorker').default; -const NodeThreadWorker = require('../workers/NodeThreadsWorker').default; - describe('WorkerPool', () => { beforeEach(() => { ChildProcessWorker.mockClear(); diff --git a/packages/jest-worker/src/__tests__/process-integration.test.js b/packages/jest-worker/src/__tests__/process-integration.test.js index 11e435a1f1bd..b2d716669915 100644 --- a/packages/jest-worker/src/__tests__/process-integration.test.js +++ b/packages/jest-worker/src/__tests__/process-integration.test.js @@ -8,7 +8,6 @@ 'use strict'; import EventEmitter from 'events'; - import {CHILD_MESSAGE_CALL, PARENT_MESSAGE_OK} from '../types'; let Farm; diff --git a/packages/jest-worker/src/__tests__/thread-integration.test.js b/packages/jest-worker/src/__tests__/thread-integration.test.js index 30f8d6241d04..fb97ecf24b30 100644 --- a/packages/jest-worker/src/__tests__/thread-integration.test.js +++ b/packages/jest-worker/src/__tests__/thread-integration.test.js @@ -8,7 +8,6 @@ 'use strict'; import EventEmitter from 'events'; - import {CHILD_MESSAGE_CALL, PARENT_MESSAGE_OK} from '../types'; let Farm; diff --git a/packages/jest-worker/src/base/BaseWorkerPool.ts b/packages/jest-worker/src/base/BaseWorkerPool.ts index a92e383dc50e..4d51517b4a33 100644 --- a/packages/jest-worker/src/base/BaseWorkerPool.ts +++ b/packages/jest-worker/src/base/BaseWorkerPool.ts @@ -7,7 +7,6 @@ import * as path from 'path'; import mergeStream = require('merge-stream'); - import { CHILD_MESSAGE_END, PoolExitResult, diff --git a/packages/jest-worker/src/base/__tests__/BaseWorkerPool.test.js b/packages/jest-worker/src/base/__tests__/BaseWorkerPool.test.js index c249c0a2bd2c..d8eb3fc6b3bb 100644 --- a/packages/jest-worker/src/base/__tests__/BaseWorkerPool.test.js +++ b/packages/jest-worker/src/base/__tests__/BaseWorkerPool.test.js @@ -8,7 +8,6 @@ 'use strict'; import {CHILD_MESSAGE_END} from '../../types'; - import BaseWorkerPool from '../BaseWorkerPool'; const Worker = jest.fn(); diff --git a/packages/jest-worker/src/index.ts b/packages/jest-worker/src/index.ts index af430beac0c2..5b2613acda37 100644 --- a/packages/jest-worker/src/index.ts +++ b/packages/jest-worker/src/index.ts @@ -8,8 +8,8 @@ /* eslint-disable local/ban-types-eventually */ import {cpus} from 'os'; -import WorkerPool from './WorkerPool'; import Farm from './Farm'; +import WorkerPool from './WorkerPool'; import type { FarmOptions, PoolExitResult, diff --git a/packages/jest-worker/src/types.ts b/packages/jest-worker/src/types.ts index af59e7fd87ef..9afa7f92f3c5 100644 --- a/packages/jest-worker/src/types.ts +++ b/packages/jest-worker/src/types.ts @@ -5,8 +5,8 @@ * LICENSE file in the root directory of this source tree. */ -import type {EventEmitter} from 'events'; import type {ForkOptions} from 'child_process'; +import type {EventEmitter} from 'events'; // import type {ResourceLimits} from 'worker_threads'; // This is not present in the Node 12 typings diff --git a/packages/jest-worker/src/workers/ChildProcessWorker.ts b/packages/jest-worker/src/workers/ChildProcessWorker.ts index 4d1822979cb3..6b7daa4758f2 100644 --- a/packages/jest-worker/src/workers/ChildProcessWorker.ts +++ b/packages/jest-worker/src/workers/ChildProcessWorker.ts @@ -9,7 +9,6 @@ import {ChildProcess, fork} from 'child_process'; import {PassThrough} from 'stream'; import mergeStream = require('merge-stream'); import {stdout as stdoutSupportsColor} from 'supports-color'; - import { CHILD_MESSAGE_INITIALIZE, ChildMessage, diff --git a/packages/jest-worker/src/workers/NodeThreadsWorker.ts b/packages/jest-worker/src/workers/NodeThreadsWorker.ts index 9d1920819766..ab7178b89a8e 100644 --- a/packages/jest-worker/src/workers/NodeThreadsWorker.ts +++ b/packages/jest-worker/src/workers/NodeThreadsWorker.ts @@ -9,7 +9,6 @@ import * as path from 'path'; import {PassThrough} from 'stream'; import {Worker} from 'worker_threads'; import mergeStream = require('merge-stream'); - import { CHILD_MESSAGE_INITIALIZE, ChildMessage, diff --git a/packages/jest-worker/src/workers/__tests__/ChildProcessWorker.test.js b/packages/jest-worker/src/workers/__tests__/ChildProcessWorker.test.js index 46256731438a..e5e7e1e99694 100644 --- a/packages/jest-worker/src/workers/__tests__/ChildProcessWorker.test.js +++ b/packages/jest-worker/src/workers/__tests__/ChildProcessWorker.test.js @@ -7,9 +7,8 @@ import EventEmitter from 'events'; import {PassThrough} from 'stream'; -import supportsColor from 'supports-color'; import getStream from 'get-stream'; - +import supportsColor from 'supports-color'; import { CHILD_MESSAGE_CALL, CHILD_MESSAGE_INITIALIZE, diff --git a/packages/jest-worker/src/workers/__tests__/NodeThreadsWorker.test.js b/packages/jest-worker/src/workers/__tests__/NodeThreadsWorker.test.js index c4de7434096d..5bc2fe215aa1 100644 --- a/packages/jest-worker/src/workers/__tests__/NodeThreadsWorker.test.js +++ b/packages/jest-worker/src/workers/__tests__/NodeThreadsWorker.test.js @@ -8,7 +8,6 @@ 'use strict'; import getStream from 'get-stream'; - import { CHILD_MESSAGE_CALL, CHILD_MESSAGE_INITIALIZE, diff --git a/packages/jest-worker/src/workers/threadChild.ts b/packages/jest-worker/src/workers/threadChild.ts index 52a1f1c239e1..6783ec843510 100644 --- a/packages/jest-worker/src/workers/threadChild.ts +++ b/packages/jest-worker/src/workers/threadChild.ts @@ -6,7 +6,6 @@ */ import {isMainThread, parentPort} from 'worker_threads'; - import { CHILD_MESSAGE_CALL, CHILD_MESSAGE_END, diff --git a/packages/pretty-format/README.md b/packages/pretty-format/README.md index ca445cfaf7b2..92a235d99b85 100755 --- a/packages/pretty-format/README.md +++ b/packages/pretty-format/README.md @@ -100,21 +100,19 @@ The `pretty-format` package provides some built-in plugins, including: ```js // CommonJS +const React = require('react'); +const renderer = require('react-test-renderer'); const prettyFormat = require('pretty-format'); const ReactElement = prettyFormat.plugins.ReactElement; const ReactTestComponent = prettyFormat.plugins.ReactTestComponent; - -const React = require('react'); -const renderer = require('react-test-renderer'); ``` ```js +import React from 'react'; +import renderer from 'react-test-renderer'; // ES2015 modules and destructuring assignment import prettyFormat from 'pretty-format'; const {ReactElement, ReactTestComponent} = prettyFormat.plugins; - -import React from 'react'; -import renderer from 'react-test-renderer'; ``` ```js diff --git a/packages/pretty-format/perf/test.js b/packages/pretty-format/perf/test.js index 9159d76f3e5f..c9e9141252b3 100644 --- a/packages/pretty-format/perf/test.js +++ b/packages/pretty-format/perf/test.js @@ -8,8 +8,8 @@ const util = require('util'); const chalk = require('chalk'); const React = require('react'); -const {formatTime} = require('jest-util'); const ReactTestRenderer = require('react-test-renderer'); +const {formatTime} = require('jest-util'); const prettyFormat = require('../build'); const ReactTestComponent = require('../build/plugins/ReactTestComponent'); const worldGeoJson = require('./world.geo.json'); diff --git a/packages/pretty-format/src/__tests__/AsymmetricMatcher.test.ts b/packages/pretty-format/src/__tests__/AsymmetricMatcher.test.ts index e31c763efe7b..3ba1f18253cc 100644 --- a/packages/pretty-format/src/__tests__/AsymmetricMatcher.test.ts +++ b/packages/pretty-format/src/__tests__/AsymmetricMatcher.test.ts @@ -5,9 +5,8 @@ * LICENSE file in the root directory of this source tree. */ -import {OptionsReceived} from '../types'; - import prettyFormat from '../'; +import {OptionsReceived} from '../types'; const {AsymmetricMatcher} = prettyFormat.plugins; let options: OptionsReceived; diff --git a/packages/pretty-format/src/__tests__/Immutable.test.ts b/packages/pretty-format/src/__tests__/Immutable.test.ts index 22494f4e47f0..751ed51623d9 100644 --- a/packages/pretty-format/src/__tests__/Immutable.test.ts +++ b/packages/pretty-format/src/__tests__/Immutable.test.ts @@ -7,9 +7,8 @@ /* eslint-disable local/prefer-rest-params-eventually */ -import React from 'react'; import Immutable from 'immutable'; - +import React from 'react'; import prettyFormat from '..'; import setPrettyPrint from './setPrettyPrint'; diff --git a/packages/pretty-format/src/__tests__/react.test.tsx b/packages/pretty-format/src/__tests__/react.test.tsx index c79cef239e77..8591eaa43d72 100644 --- a/packages/pretty-format/src/__tests__/react.test.tsx +++ b/packages/pretty-format/src/__tests__/react.test.tsx @@ -7,9 +7,8 @@ import React from 'react'; import renderer from 'react-test-renderer'; - -import {OptionsReceived} from '../types'; import prettyFormat from '..'; +import {OptionsReceived} from '../types'; const elementSymbol = Symbol.for('react.element'); const fragmentSymbol = Symbol.for('react.fragment'); diff --git a/packages/pretty-format/src/index.ts b/packages/pretty-format/src/index.ts index aeef901e40ee..e37a12c34863 100644 --- a/packages/pretty-format/src/index.ts +++ b/packages/pretty-format/src/index.ts @@ -8,15 +8,12 @@ /* eslint-disable local/ban-types-eventually */ import style = require('ansi-styles'); -import type * as PrettyFormat from './types'; - import { printIteratorEntries, printIteratorValues, printListItems, printObjectProperties, } from './collections'; - import AsymmetricMatcher from './plugins/AsymmetricMatcher'; import ConvertAnsi from './plugins/ConvertAnsi'; import DOMCollection from './plugins/DOMCollection'; @@ -24,6 +21,7 @@ import DOMElement from './plugins/DOMElement'; import Immutable from './plugins/Immutable'; import ReactElement from './plugins/ReactElement'; import ReactTestComponent from './plugins/ReactTestComponent'; +import type * as PrettyFormat from './types'; const toString = Object.prototype.toString; const toISOString = Date.prototype.toISOString; diff --git a/packages/pretty-format/src/plugins/AsymmetricMatcher.ts b/packages/pretty-format/src/plugins/AsymmetricMatcher.ts index c5bc0963441f..a9fcb797a89f 100644 --- a/packages/pretty-format/src/plugins/AsymmetricMatcher.ts +++ b/packages/pretty-format/src/plugins/AsymmetricMatcher.ts @@ -5,9 +5,8 @@ * LICENSE file in the root directory of this source tree. */ -import type {Config, NewPlugin, Printer, Refs} from '../types'; - import {printListItems, printObjectProperties} from '../collections'; +import type {Config, NewPlugin, Printer, Refs} from '../types'; const asymmetricMatcher = typeof Symbol === 'function' && Symbol.for diff --git a/packages/pretty-format/src/plugins/DOMCollection.ts b/packages/pretty-format/src/plugins/DOMCollection.ts index e19188afbef8..3140e872a3ed 100644 --- a/packages/pretty-format/src/plugins/DOMCollection.ts +++ b/packages/pretty-format/src/plugins/DOMCollection.ts @@ -7,9 +7,8 @@ /* eslint-disable local/ban-types-eventually */ -import type {Config, NewPlugin, Printer, Refs} from '../types'; - import {printListItems, printObjectProperties} from '../collections'; +import type {Config, NewPlugin, Printer, Refs} from '../types'; const SPACE = ' '; diff --git a/packages/pretty-format/src/plugins/DOMElement.ts b/packages/pretty-format/src/plugins/DOMElement.ts index cb855856883e..48e46ae39d7c 100644 --- a/packages/pretty-format/src/plugins/DOMElement.ts +++ b/packages/pretty-format/src/plugins/DOMElement.ts @@ -6,7 +6,6 @@ */ import type {Config, NewPlugin, Printer, Refs} from '../types'; - import { printChildren, printComment, diff --git a/packages/pretty-format/src/plugins/Immutable.ts b/packages/pretty-format/src/plugins/Immutable.ts index c455391844c8..1fd974e0629e 100644 --- a/packages/pretty-format/src/plugins/Immutable.ts +++ b/packages/pretty-format/src/plugins/Immutable.ts @@ -5,8 +5,8 @@ * LICENSE file in the root directory of this source tree. */ -import type {Config, NewPlugin, Printer, Refs} from '../types'; import {printIteratorEntries, printIteratorValues} from '../collections'; +import type {Config, NewPlugin, Printer, Refs} from '../types'; // SENTINEL constants are from https://github.com/facebook/immutable-js const IS_ITERABLE_SENTINEL = '@@__IMMUTABLE_ITERABLE__@@'; diff --git a/packages/pretty-format/src/plugins/ReactElement.ts b/packages/pretty-format/src/plugins/ReactElement.ts index a8091845ff99..0856d43bd237 100644 --- a/packages/pretty-format/src/plugins/ReactElement.ts +++ b/packages/pretty-format/src/plugins/ReactElement.ts @@ -7,7 +7,6 @@ import * as ReactIs from 'react-is'; import type {Config, NewPlugin, Printer, Refs} from '../types'; - import { printChildren, printElement, diff --git a/packages/pretty-format/src/plugins/ReactTestComponent.ts b/packages/pretty-format/src/plugins/ReactTestComponent.ts index b58d31d36ec3..770a66d0e8b8 100644 --- a/packages/pretty-format/src/plugins/ReactTestComponent.ts +++ b/packages/pretty-format/src/plugins/ReactTestComponent.ts @@ -6,6 +6,12 @@ */ import type {Config, NewPlugin, Printer, Refs} from '../types'; +import { + printChildren, + printElement, + printElementAsLeaf, + printProps, +} from './lib/markup'; export type ReactTestObject = { $$typeof: symbol; @@ -17,13 +23,6 @@ export type ReactTestObject = { // Child can be `number` in Stack renderer but not in Fiber renderer. type ReactTestChild = ReactTestObject | string | number; -import { - printChildren, - printElement, - printElementAsLeaf, - printProps, -} from './lib/markup'; - const testSymbol = typeof Symbol === 'function' && Symbol.for ? Symbol.for('react.test.json') diff --git a/packages/pretty-format/src/plugins/lib/markup.ts b/packages/pretty-format/src/plugins/lib/markup.ts index 13c5c4a0f750..5128d4278934 100644 --- a/packages/pretty-format/src/plugins/lib/markup.ts +++ b/packages/pretty-format/src/plugins/lib/markup.ts @@ -6,7 +6,6 @@ */ import type {Config, Printer, Refs} from '../../types'; - import escapeHTML from './escapeHTML'; // Return empty string if keys is empty. diff --git a/scripts/build.js b/scripts/build.js index 25e4ddebb9bb..c9d24f7ee00f 100644 --- a/scripts/build.js +++ b/scripts/build.js @@ -22,10 +22,9 @@ const fs = require('fs'); const path = require('path'); -const glob = require('glob'); - const babel = require('@babel/core'); const chalk = require('chalk'); +const glob = require('glob'); const micromatch = require('micromatch'); const prettier = require('prettier'); const transformOptions = require('../babel.config.js'); diff --git a/scripts/buildTs.js b/scripts/buildTs.js index e42fef17e130..5630d61f9315 100644 --- a/scripts/buildTs.js +++ b/scripts/buildTs.js @@ -12,7 +12,6 @@ const fs = require('fs'); const os = require('os'); const path = require('path'); const util = require('util'); - const chalk = require('chalk'); const execa = require('execa'); const globby = require('globby'); diff --git a/scripts/checkCopyrightHeaders.js b/scripts/checkCopyrightHeaders.js index c1038c78fc5f..3972de557871 100755 --- a/scripts/checkCopyrightHeaders.js +++ b/scripts/checkCopyrightHeaders.js @@ -7,8 +7,8 @@ 'use strict'; -const fs = require('fs'); const {execSync} = require('child_process'); +const fs = require('fs'); const {isBinaryFileSync} = require('isbinaryfile'); const getFileContents = path => fs.readFileSync(path, {encoding: 'utf-8'}); diff --git a/scripts/mapCoverage.js b/scripts/mapCoverage.js index ce146ce8c855..cf0a5e47f028 100644 --- a/scripts/mapCoverage.js +++ b/scripts/mapCoverage.js @@ -25,9 +25,9 @@ * produce a full coverage report. */ +const istanbulCoverage = require('istanbul-lib-coverage'); const istanbulReport = require('istanbul-lib-report'); const istanbulReports = require('istanbul-reports'); -const istanbulCoverage = require('istanbul-lib-coverage'); const coverage = require('../coverage/coverage-final.json'); const map = istanbulCoverage.createCoverageMap(); diff --git a/scripts/remove-prettier-dep.js b/scripts/remove-prettier-dep.js index 90db4ad2f53b..9675ba9ee14f 100644 --- a/scripts/remove-prettier-dep.js +++ b/scripts/remove-prettier-dep.js @@ -8,11 +8,10 @@ 'use strict'; const {writeFileSync} = require('fs'); +const pkg = require('../package.json'); const pkgPath = require.resolve('../package.json'); -const pkg = require('../package.json'); - delete pkg.devDependencies.prettier; writeFileSync(pkgPath, `${JSON.stringify(pkg, null, 2)}\n`); diff --git a/scripts/verifyOldTs.js b/scripts/verifyOldTs.js index ca5224c26dd1..543b9c5c0d22 100644 --- a/scripts/verifyOldTs.js +++ b/scripts/verifyOldTs.js @@ -9,7 +9,6 @@ const fs = require('fs'); const path = require('path'); - const chalk = require('chalk'); const execa = require('execa'); const rimraf = require('rimraf'); diff --git a/scripts/watch.js b/scripts/watch.js index ced260327fee..9c340b084c84 100644 --- a/scripts/watch.js +++ b/scripts/watch.js @@ -9,11 +9,11 @@ * Watch files for changes and rebuild (copy from 'src/' to `build/`) if changed */ -const fs = require('fs'); const {execSync} = require('child_process'); +const fs = require('fs'); const path = require('path'); -const chokidar = require('chokidar'); const chalk = require('chalk'); +const chokidar = require('chokidar'); const {PACKAGES_DIR, getPackages} = require('./buildUtils'); const BUILD_CMD = `node ${path.resolve(__dirname, './build.js')}`; diff --git a/website/fetchSupporters.js b/website/fetchSupporters.js index 96973c3eeb17..994a85211023 100644 --- a/website/fetchSupporters.js +++ b/website/fetchSupporters.js @@ -8,8 +8,8 @@ */ const fs = require('fs'); -const {promisify} = require('util'); const path = require('path'); +const {promisify} = require('util'); const {gql, request} = require('graphql-request'); const graphqlQuery = gql` diff --git a/website/pages/en/help.js b/website/pages/en/help.js index 735837e574aa..7e988780aa81 100755 --- a/website/pages/en/help.js +++ b/website/pages/en/help.js @@ -6,13 +6,12 @@ */ const React = require('react'); - const CompLibrary = require('../../core/CompLibrary.js'); +const translate = require('../../server/translate.js').translate; + const Container = CompLibrary.Container; const GridBlock = CompLibrary.GridBlock; -const translate = require('../../server/translate.js').translate; - class Help extends React.Component { render() { const supportLinks = [ diff --git a/website/pages/en/index.js b/website/pages/en/index.js index 8a307506915b..4933db1c3c88 100755 --- a/website/pages/en/index.js +++ b/website/pages/en/index.js @@ -5,15 +5,15 @@ * LICENSE file in the root directory of this source tree. */ const React = require('react'); - const CompLibrary = require('../../core/CompLibrary.js'); +const translate = require('../../server/translate.js').translate; +const backers = require(process.cwd() + '/backers.json'); +const siteConfig = require(process.cwd() + '/siteConfig.js'); + const MarkdownBlock = CompLibrary.MarkdownBlock; /* Used to read markdown */ const Container = CompLibrary.Container; const GridBlock = CompLibrary.GridBlock; -const translate = require('../../server/translate.js').translate; -const backers = require(process.cwd() + '/backers.json'); -const siteConfig = require(process.cwd() + '/siteConfig.js'); const getDocsUrl = (url, language) => siteConfig.baseUrl + 'docs/' + language + url; const getUrl = (url, language) => siteConfig.baseUrl + language + url; diff --git a/website/pages/en/versions.js b/website/pages/en/versions.js index adec13ab457f..294c5cf374d2 100644 --- a/website/pages/en/versions.js +++ b/website/pages/en/versions.js @@ -6,7 +6,6 @@ */ const React = require('react'); - const CompLibrary = require('../../core/CompLibrary'); const Container = CompLibrary.Container; diff --git a/website/pages/en/videos.js b/website/pages/en/videos.js index 04d5401ca03f..89ebcfcefbe9 100644 --- a/website/pages/en/videos.js +++ b/website/pages/en/videos.js @@ -6,7 +6,6 @@ */ const React = require('react'); - const {Container, MarkdownBlock} = require('../../core/CompLibrary.js'); const {translate} = require('../../server/translate.js'); const siteConfig = require(process.cwd() + '/siteConfig.js'); diff --git a/website/versioned_docs/version-22.x/BypassingModuleMocks.md b/website/versioned_docs/version-22.x/BypassingModuleMocks.md index 1ca6d611f63b..c379f2d6b292 100644 --- a/website/versioned_docs/version-22.x/BypassingModuleMocks.md +++ b/website/versioned_docs/version-22.x/BypassingModuleMocks.md @@ -25,7 +25,6 @@ Your test will want to mock the `fetch` function so that we can be sure that it jest.mock('node-fetch'); import fetch, {Response} from 'node-fetch'; - import {createUser} from './createUser'; test('createUser calls fetch with the right args and returns the user id', async () => { diff --git a/website/versioned_docs/version-22.x/Es6ClassMocks.md b/website/versioned_docs/version-22.x/Es6ClassMocks.md index a0c3702b527a..4b0c6e1c595b 100644 --- a/website/versioned_docs/version-22.x/Es6ClassMocks.md +++ b/website/versioned_docs/version-22.x/Es6ClassMocks.md @@ -329,8 +329,8 @@ Here's a complete test file which uses the module factory parameter to `jest.moc ```javascript // sound-player-consumer.test.js -import SoundPlayerConsumer from './sound-player-consumer'; import SoundPlayer from './sound-player'; +import SoundPlayerConsumer from './sound-player-consumer'; const mockPlaySoundFile = jest.fn(); jest.mock('./sound-player', () => { diff --git a/website/versioned_docs/version-22.x/JestObjectAPI.md b/website/versioned_docs/version-22.x/JestObjectAPI.md index a177bc8df624..72b611c506f1 100644 --- a/website/versioned_docs/version-22.x/JestObjectAPI.md +++ b/website/versioned_docs/version-22.x/JestObjectAPI.md @@ -522,6 +522,7 @@ module.exports = audio; Example test: ```js +const audio = require('./audio'); const video = require('./video'); test('plays video', () => { @@ -534,8 +535,6 @@ test('plays video', () => { spy.mockRestore(); }); -const audio = require('./audio'); - test('plays audio', () => { const spy = jest.spyOn(audio, 'volume', 'set'); // we pass 'set' audio.volume = 100; diff --git a/website/versioned_docs/version-22.x/Puppeteer.md b/website/versioned_docs/version-22.x/Puppeteer.md index f317ef65fd93..da6c01b95816 100644 --- a/website/versioned_docs/version-22.x/Puppeteer.md +++ b/website/versioned_docs/version-22.x/Puppeteer.md @@ -20,9 +20,9 @@ Here's an example of the GlobalSetup script ```js // setup.js -const path = require('path'); const fs = require('fs'); const os = require('os'); +const path = require('path'); const mkdirp = require('mkdirp'); const puppeteer = require('puppeteer'); @@ -45,8 +45,8 @@ Then we need a custom Test Environment for puppeteer ```js // puppeteer_environment.js const fs = require('fs'); -const path = require('path'); const os = require('os'); +const path = require('path'); const puppeteer = require('puppeteer'); const NodeEnvironment = require('jest-environment-node'); diff --git a/website/versioned_docs/version-23.x/JestObjectAPI.md b/website/versioned_docs/version-23.x/JestObjectAPI.md index 4797c5d61ed7..8a39acd5c18b 100644 --- a/website/versioned_docs/version-23.x/JestObjectAPI.md +++ b/website/versioned_docs/version-23.x/JestObjectAPI.md @@ -522,6 +522,7 @@ module.exports = audio; Example test: ```js +const audio = require('./audio'); const video = require('./video'); test('plays video', () => { @@ -534,8 +535,6 @@ test('plays video', () => { spy.mockRestore(); }); -const audio = require('./audio'); - test('plays audio', () => { const spy = jest.spyOn(audio, 'volume', 'set'); // we pass 'set' audio.volume = 100; diff --git a/website/versioned_docs/version-23.x/Puppeteer.md b/website/versioned_docs/version-23.x/Puppeteer.md index 616dd3b6e853..f66457a716f5 100644 --- a/website/versioned_docs/version-23.x/Puppeteer.md +++ b/website/versioned_docs/version-23.x/Puppeteer.md @@ -56,9 +56,9 @@ Here's an example of the GlobalSetup script ```js // setup.js -const path = require('path'); const fs = require('fs'); const os = require('os'); +const path = require('path'); const mkdirp = require('mkdirp'); const puppeteer = require('puppeteer'); @@ -81,8 +81,8 @@ Then we need a custom Test Environment for puppeteer ```js // puppeteer_environment.js const fs = require('fs'); -const path = require('path'); const os = require('os'); +const path = require('path'); const puppeteer = require('puppeteer'); const NodeEnvironment = require('jest-environment-node'); diff --git a/website/versioned_docs/version-24.x/Configuration.md b/website/versioned_docs/version-24.x/Configuration.md index 2b4f49b0a6f9..265d9238e7b6 100644 --- a/website/versioned_docs/version-24.x/Configuration.md +++ b/website/versioned_docs/version-24.x/Configuration.md @@ -265,8 +265,8 @@ Default: `undefined` This option allows the use of a custom dependency extractor. It must be a node module that exports an object with an `extract` function. E.g.: ```javascript -const fs = require('fs'); const crypto = require('crypto'); +const fs = require('fs'); module.exports = { extract(code, filePath, defaultExtract) { diff --git a/website/versioned_docs/version-24.x/Es6ClassMocks.md b/website/versioned_docs/version-24.x/Es6ClassMocks.md index 278bb73151d2..c3ca28d7ffde 100644 --- a/website/versioned_docs/version-24.x/Es6ClassMocks.md +++ b/website/versioned_docs/version-24.x/Es6ClassMocks.md @@ -329,8 +329,8 @@ Here's a complete test file which uses the module factory parameter to `jest.moc ```javascript // sound-player-consumer.test.js -import SoundPlayerConsumer from './sound-player-consumer'; import SoundPlayer from './sound-player'; +import SoundPlayerConsumer from './sound-player-consumer'; const mockPlaySoundFile = jest.fn(); jest.mock('./sound-player', () => { diff --git a/website/versioned_docs/version-24.x/JestObjectAPI.md b/website/versioned_docs/version-24.x/JestObjectAPI.md index 3af37cbd9301..bd19814336dd 100644 --- a/website/versioned_docs/version-24.x/JestObjectAPI.md +++ b/website/versioned_docs/version-24.x/JestObjectAPI.md @@ -535,6 +535,7 @@ module.exports = audio; Example test: ```js +const audio = require('./audio'); const video = require('./video'); test('plays video', () => { @@ -547,8 +548,6 @@ test('plays video', () => { spy.mockRestore(); }); -const audio = require('./audio'); - test('plays audio', () => { const spy = jest.spyOn(audio, 'volume', 'set'); // we pass 'set' audio.volume = 100; diff --git a/website/versioned_docs/version-25.x/Configuration.md b/website/versioned_docs/version-25.x/Configuration.md index 69f4f7ebc42a..aa08f7439c6c 100644 --- a/website/versioned_docs/version-25.x/Configuration.md +++ b/website/versioned_docs/version-25.x/Configuration.md @@ -283,8 +283,8 @@ Default: `undefined` This option allows the use of a custom dependency extractor. It must be a node module that exports an object with an `extract` function. E.g.: ```javascript -const fs = require('fs'); const crypto = require('crypto'); +const fs = require('fs'); module.exports = { extract(code, filePath, defaultExtract) { diff --git a/website/versioned_docs/version-25.x/JestObjectAPI.md b/website/versioned_docs/version-25.x/JestObjectAPI.md index 70410c09f37e..0896dc790871 100644 --- a/website/versioned_docs/version-25.x/JestObjectAPI.md +++ b/website/versioned_docs/version-25.x/JestObjectAPI.md @@ -535,6 +535,7 @@ module.exports = audio; Example test: ```js +const audio = require('./audio'); const video = require('./video'); test('plays video', () => { @@ -547,8 +548,6 @@ test('plays video', () => { spy.mockRestore(); }); -const audio = require('./audio'); - test('plays audio', () => { const spy = jest.spyOn(audio, 'volume', 'set'); // we pass 'set' audio.volume = 100; diff --git a/website/versioned_docs/version-26.0/Configuration.md b/website/versioned_docs/version-26.0/Configuration.md index 1b63269ce4bf..7b55d763daa7 100644 --- a/website/versioned_docs/version-26.0/Configuration.md +++ b/website/versioned_docs/version-26.0/Configuration.md @@ -273,8 +273,8 @@ Default: `undefined` This option allows the use of a custom dependency extractor. It must be a node module that exports an object with an `extract` function. E.g.: ```javascript -const fs = require('fs'); const crypto = require('crypto'); +const fs = require('fs'); module.exports = { extract(code, filePath, defaultExtract) { diff --git a/website/versioned_docs/version-26.0/JestObjectAPI.md b/website/versioned_docs/version-26.0/JestObjectAPI.md index 5e0c7be62fc1..a8f8473c3971 100644 --- a/website/versioned_docs/version-26.0/JestObjectAPI.md +++ b/website/versioned_docs/version-26.0/JestObjectAPI.md @@ -539,6 +539,7 @@ module.exports = audio; Example test: ```js +const audio = require('./audio'); const video = require('./video'); test('plays video', () => { @@ -551,8 +552,6 @@ test('plays video', () => { spy.mockRestore(); }); -const audio = require('./audio'); - test('plays audio', () => { const spy = jest.spyOn(audio, 'volume', 'set'); // we pass 'set' audio.volume = 100; diff --git a/website/versioned_docs/version-26.2/Configuration.md b/website/versioned_docs/version-26.2/Configuration.md index 4d2d887cd86e..ee944bba2183 100644 --- a/website/versioned_docs/version-26.2/Configuration.md +++ b/website/versioned_docs/version-26.2/Configuration.md @@ -281,8 +281,8 @@ Default: `undefined` This option allows the use of a custom dependency extractor. It must be a node module that exports an object with an `extract` function. E.g.: ```javascript -const fs = require('fs'); const crypto = require('crypto'); +const fs = require('fs'); module.exports = { extract(code, filePath, defaultExtract) { diff --git a/website/versioned_docs/version-26.4/Configuration.md b/website/versioned_docs/version-26.4/Configuration.md index 5b5018dffcfa..fd052bbafc3d 100644 --- a/website/versioned_docs/version-26.4/Configuration.md +++ b/website/versioned_docs/version-26.4/Configuration.md @@ -281,8 +281,8 @@ Default: `undefined` This option allows the use of a custom dependency extractor. It must be a node module that exports an object with an `extract` function. E.g.: ```javascript -const fs = require('fs'); const crypto = require('crypto'); +const fs = require('fs'); module.exports = { extract(code, filePath, defaultExtract) { diff --git a/website/versioned_docs/version-26.5/Configuration.md b/website/versioned_docs/version-26.5/Configuration.md index 2da49191fff4..4c5554dfcd9e 100644 --- a/website/versioned_docs/version-26.5/Configuration.md +++ b/website/versioned_docs/version-26.5/Configuration.md @@ -281,8 +281,8 @@ Default: `undefined` This option allows the use of a custom dependency extractor. It must be a node module that exports an object with an `extract` function. E.g.: ```javascript -const fs = require('fs'); const crypto = require('crypto'); +const fs = require('fs'); module.exports = { extract(code, filePath, defaultExtract) { diff --git a/website/versioned_docs/version-26.6/Configuration.md b/website/versioned_docs/version-26.6/Configuration.md index bf863c761af3..3882466520bf 100644 --- a/website/versioned_docs/version-26.6/Configuration.md +++ b/website/versioned_docs/version-26.6/Configuration.md @@ -301,8 +301,8 @@ Default: `undefined` This option allows the use of a custom dependency extractor. It must be a node module that exports an object with an `extract` function. E.g.: ```javascript -const fs = require('fs'); const crypto = require('crypto'); +const fs = require('fs'); module.exports = { extract(code, filePath, defaultExtract) {