From 6fc0af8936c91b86e025bc2414356273d89dd641 Mon Sep 17 00:00:00 2001 From: Pedro Yamada Date: Tue, 1 Oct 2024 01:55:02 +0000 Subject: [PATCH 01/10] Remove use of inline interfaces --- packages/core/fs/src/MemoryFS.js | 6 +++++- packages/core/test-utils/src/fsFixture.js | 4 ++-- packages/core/utils/src/DefaultMap.js | 4 +++- packages/core/utils/src/dependency-location.js | 3 ++- 4 files changed, 12 insertions(+), 5 deletions(-) diff --git a/packages/core/fs/src/MemoryFS.js b/packages/core/fs/src/MemoryFS.js index f1a7e9c8d..54a82b293 100644 --- a/packages/core/fs/src/MemoryFS.js +++ b/packages/core/fs/src/MemoryFS.js @@ -852,11 +852,15 @@ class Stat { } } +interface IEntry { + mode: number; +} + class Dirent { name: string; #mode: number; - constructor(name: string, entry: interface {mode: number}) { + constructor(name: string, entry: IEntry) { this.name = name; this.#mode = entry.mode; } diff --git a/packages/core/test-utils/src/fsFixture.js b/packages/core/test-utils/src/fsFixture.js index de4233fb9..238e69eab 100644 --- a/packages/core/test-utils/src/fsFixture.js +++ b/packages/core/test-utils/src/fsFixture.js @@ -17,7 +17,7 @@ export function fsFixture( ): ( strings: Array, ...exprs: Array< - null | string | number | boolean | interface {} | $ReadOnlyArray, + null | string | number | boolean | {...} | $ReadOnlyArray, > ) => Promise { return async function apply(strings, ...exprs) { @@ -415,7 +415,7 @@ export function escapeFixtureContent(content: string): string { export function dedentRaw( strings: Array, ...exprs: Array< - null | string | number | boolean | interface {} | $ReadOnlyArray, + null | string | number | boolean | {...} | $ReadOnlyArray, > ): string { let src = ''; diff --git a/packages/core/utils/src/DefaultMap.js b/packages/core/utils/src/DefaultMap.js index 40e7cbfe4..f4a48245d 100644 --- a/packages/core/utils/src/DefaultMap.js +++ b/packages/core/utils/src/DefaultMap.js @@ -22,9 +22,11 @@ export class DefaultMap extends Map { } } +interface IKey {} + // Duplicated from DefaultMap implementation for Flow // Roughly mirrors https://github.com/facebook/flow/blob/2eb5a78d92c167117ba9caae070afd2b9f598599/lib/core.js#L617 -export class DefaultWeakMap extends WeakMap { +export class DefaultWeakMap extends WeakMap { _getDefault: K => V; constructor(getDefault: K => V, entries?: Iterable<[K, V]>) { diff --git a/packages/core/utils/src/dependency-location.js b/packages/core/utils/src/dependency-location.js index 0587a8697..a1a9e22ee 100644 --- a/packages/core/utils/src/dependency-location.js +++ b/packages/core/utils/src/dependency-location.js @@ -1,9 +1,10 @@ // @flow export default function createDependencyLocation( - start: interface { + start: { line: number, column: number, + ... }, specifier: string, lineOffset: number = 0, From ce99540b23810e97bd6418e7811952a22f6daf32 Mon Sep 17 00:00:00 2001 From: Pedro Yamada Date: Tue, 1 Oct 2024 02:05:53 +0000 Subject: [PATCH 02/10] Remove import extensions --- .../core/core/src/requests/ConfigRequest.js | 2 +- .../package-manager/src/installPackage.js | 2 +- packages/dev/query/src/cli.js | 4 +- packages/dev/query/src/deep-imports.js | 40 +++++++++---------- .../dev/repl/SimplePackageInstaller/index.js | 2 +- .../dev/repl/src/atlaspack/AtlaspackWorker.js | 4 +- packages/dev/repl/src/components/helper.js | 2 +- 7 files changed, 28 insertions(+), 28 deletions(-) diff --git a/packages/core/core/src/requests/ConfigRequest.js b/packages/core/core/src/requests/ConfigRequest.js index c46899389..33fbb6109 100644 --- a/packages/core/core/src/requests/ConfigRequest.js +++ b/packages/core/core/src/requests/ConfigRequest.js @@ -18,7 +18,7 @@ import type {LoadedPlugin} from '../AtlaspackConfig'; import type {RequestResult, RunAPI} from '../RequestTracker'; import type {ProjectPath} from '../projectPath'; -import {serializeRaw} from '../serializer.js'; +import {serializeRaw} from '../serializer'; import {PluginLogger} from '@atlaspack/logger'; import PluginOptions from '../public/PluginOptions'; import ThrowableDiagnostic, {errorToDiagnostic} from '@atlaspack/diagnostic'; diff --git a/packages/core/package-manager/src/installPackage.js b/packages/core/package-manager/src/installPackage.js index 2fc5ee586..bc844637f 100644 --- a/packages/core/package-manager/src/installPackage.js +++ b/packages/core/package-manager/src/installPackage.js @@ -24,7 +24,7 @@ import WorkerFarm from '@atlaspack/workers'; import {Npm} from './Npm'; import {Yarn} from './Yarn'; -import {Pnpm} from './Pnpm.js'; +import {Pnpm} from './Pnpm'; import {getConflictingLocalDependencies} from './utils'; import getCurrentPackageManager from './getCurrentPackageManager'; import validateModuleSpecifier from './validateModuleSpecifier'; diff --git a/packages/dev/query/src/cli.js b/packages/dev/query/src/cli.js index ee18b3f92..45dcff87f 100644 --- a/packages/dev/query/src/cli.js +++ b/packages/dev/query/src/cli.js @@ -14,13 +14,13 @@ import {serialize} from 'v8'; // $FlowFixMe import {table} from 'table'; -import {loadGraphs} from './index.js'; +import {loadGraphs} from './index'; const { BundleGraph: {bundleGraphEdgeTypes: bundleGraphEdgeTypes}, Priority, fromProjectPathRelative, -} = require('./deep-imports.js'); +} = require('./deep-imports'); export async function run(input: string[]) { let args = input; diff --git a/packages/dev/query/src/deep-imports.js b/packages/dev/query/src/deep-imports.js index bfd949082..fe497cf6d 100644 --- a/packages/dev/query/src/deep-imports.js +++ b/packages/dev/query/src/deep-imports.js @@ -1,43 +1,43 @@ // @flow /* eslint-disable monorepo/no-internal-import */ -import typeof AssetGraph from '@atlaspack/core/src/AssetGraph.js'; +import typeof AssetGraph from '@atlaspack/core/src/AssetGraph'; import typeof BundleGraph, { bundleGraphEdgeTypes, -} from '@atlaspack/core/src/BundleGraph.js'; +} from '@atlaspack/core/src/BundleGraph'; import typeof RequestTracker, { RequestGraph, readAndDeserializeRequestGraph, -} from '@atlaspack/core/src/RequestTracker.js'; -import typeof {requestGraphEdgeTypes} from '@atlaspack/core/src/RequestTracker.js'; -import typeof {LMDBCache} from '@atlaspack/cache/src/LMDBCache.js'; -import typeof {Priority} from '@atlaspack/core/src/types.js'; -import typeof {fromProjectPathRelative} from '@atlaspack/core/src/projectPath.js'; +} from '@atlaspack/core/src/RequestTracker'; +import typeof {requestGraphEdgeTypes} from '@atlaspack/core/src/RequestTracker'; +import typeof {LMDBCache} from '@atlaspack/cache/src/LMDBCache'; +import typeof {Priority} from '@atlaspack/core/src/types'; +import typeof {fromProjectPathRelative} from '@atlaspack/core/src/projectPath'; const v = process.env.ATLASPACK_BUILD_ENV === 'production' ? { // Split up require specifier to outsmart packages/dev/babel-register/babel-plugin-module-translate.js // $FlowFixMe(unsupported-syntax) - AssetGraph: require('@atlaspack/core' + '/lib/AssetGraph.js').default, + AssetGraph: require('@atlaspack/core' + '/lib/AssetGraph').default, // $FlowFixMe(unsupported-syntax) - BundleGraph: require('@atlaspack/core' + '/lib/BundleGraph.js'), + BundleGraph: require('@atlaspack/core' + '/lib/BundleGraph'), // $FlowFixMe(unsupported-syntax) - RequestTracker: require('@atlaspack/core' + '/lib/RequestTracker.js'), + RequestTracker: require('@atlaspack/core' + '/lib/RequestTracker'), // $FlowFixMe(unsupported-syntax) - LMDBCache: require('@atlaspack/cache' + '/lib/LMDBCache.js').LMDBCache, + LMDBCache: require('@atlaspack/cache' + '/lib/LMDBCache').LMDBCache, // $FlowFixMe(unsupported-syntax) - Priority: require('@atlaspack/core' + '/lib/types.js').Priority, + Priority: require('@atlaspack/core' + '/lib/types').Priority, // $FlowFixMe(unsupported-syntax) - fromProjectPathRelative: require('@atlaspack/core' + - '/lib/projectPath.js').fromProjectPathRelative, + fromProjectPathRelative: require('@atlaspack/core' + '/lib/projectPath') + .fromProjectPathRelative, } : { - AssetGraph: require('@atlaspack/core/src/AssetGraph.js').default, - BundleGraph: require('@atlaspack/core/src/BundleGraph.js'), - RequestTracker: require('@atlaspack/core/src/RequestTracker.js'), - LMDBCache: require('@atlaspack/cache/src/LMDBCache.js').LMDBCache, - Priority: require('@atlaspack/core/src/types.js').Priority, - fromProjectPathRelative: require('@atlaspack/core/src/projectPath.js') + AssetGraph: require('@atlaspack/core/src/AssetGraph').default, + BundleGraph: require('@atlaspack/core/src/BundleGraph'), + RequestTracker: require('@atlaspack/core/src/RequestTracker'), + LMDBCache: require('@atlaspack/cache/src/LMDBCache').LMDBCache, + Priority: require('@atlaspack/core/src/types').Priority, + fromProjectPathRelative: require('@atlaspack/core/src/projectPath') .fromProjectPathRelative, }; diff --git a/packages/dev/repl/SimplePackageInstaller/index.js b/packages/dev/repl/SimplePackageInstaller/index.js index 29c1fbd32..72ddd1ea9 100644 --- a/packages/dev/repl/SimplePackageInstaller/index.js +++ b/packages/dev/repl/SimplePackageInstaller/index.js @@ -6,7 +6,7 @@ import type {PackageInstaller, ModuleRequest} from '@atlaspack/package-manager'; import fetch from 'isomorphic-fetch'; import path from 'path'; import semver from 'semver'; -import untar from './untar.js'; +import untar from './untar'; async function findPackage(fs, dir) { while (dir !== '/' && path.basename(dir) !== 'node_modules') { diff --git a/packages/dev/repl/src/atlaspack/AtlaspackWorker.js b/packages/dev/repl/src/atlaspack/AtlaspackWorker.js index a9a45312a..05e09bc2f 100644 --- a/packages/dev/repl/src/atlaspack/AtlaspackWorker.js +++ b/packages/dev/repl/src/atlaspack/AtlaspackWorker.js @@ -20,8 +20,8 @@ import configRepl from '@atlaspack/config-repl'; import {ExtendedMemoryFS} from './ExtendedMemoryFS'; import {generatePackageJson, nthIndex} from '../utils/'; import path from 'path'; -import {yarnInstall} from './yarn.js'; -import {BrowserPackageManager} from './BrowserPackageManager.js'; +import {yarnInstall} from './yarn'; +import {BrowserPackageManager} from './BrowserPackageManager'; export type BundleOutputError = {| type: 'failure', diff --git a/packages/dev/repl/src/components/helper.js b/packages/dev/repl/src/components/helper.js index 8c97bd75b..bab0fc3f6 100644 --- a/packages/dev/repl/src/components/helper.js +++ b/packages/dev/repl/src/components/helper.js @@ -2,7 +2,7 @@ import type {BundleOutputError} from '../atlaspack/AtlaspackWorker'; import {useCallback, useState, useEffect, useRef, memo} from 'react'; import {ctrlKey} from '../utils'; -import renderGraph from '../graphs/index.js'; +import renderGraph from '../graphs/index'; import {ASSET_PRESETS, extractZIP} from '../utils'; import {type FSMap} from '../utils/assets'; /* eslint-disable react/jsx-no-bind */ From 2e556f94063449b6b166a6feff2ce581e054f308 Mon Sep 17 00:00:00 2001 From: Pedro Yamada Date: Tue, 1 Oct 2024 02:22:29 +0000 Subject: [PATCH 03/10] Use arrow parens --- .prettierrc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.prettierrc b/.prettierrc index 6e76d2a1a..222142ad4 100644 --- a/.prettierrc +++ b/.prettierrc @@ -3,7 +3,7 @@ "endOfLine": "lf", "singleQuote": true, "trailingComma": "all", - "arrowParens": "avoid", + "arrowParens": "always", "overrides": [ { "files": [ From 729c1198759d3e67df6dfdf3c275058ab7020865 Mon Sep 17 00:00:00 2001 From: Pedro Yamada Date: Tue, 1 Oct 2024 02:24:14 +0000 Subject: [PATCH 04/10] Update with arrow parens always --- .../bundlers/default/src/DefaultBundler.js | 40 ++--- packages/core/cache/src/IDBCache.browser.js | 6 +- packages/core/cli/src/cli.js | 18 +- packages/core/codeframe/src/codeframe.js | 10 +- packages/core/core/src/AssetGraph.js | 22 +-- packages/core/core/src/Atlaspack.js | 4 +- packages/core/core/src/AtlaspackConfig.js | 20 ++- .../core/core/src/AtlaspackConfig.schema.js | 2 +- packages/core/core/src/BundleGraph.js | 158 +++++++++--------- packages/core/core/src/CommittedAsset.js | 2 +- packages/core/core/src/PackagerRunner.js | 8 +- packages/core/core/src/ReporterRunner.js | 8 +- packages/core/core/src/RequestTracker.js | 34 ++-- packages/core/core/src/SymbolPropagation.js | 48 +++--- packages/core/core/src/Transformation.js | 24 +-- packages/core/core/src/UncommittedAsset.js | 4 +- packages/core/core/src/Validation.js | 10 +- packages/core/core/src/applyRuntimes.js | 4 +- .../core/core/src/atlaspack-v3/AtlaspackV3.js | 2 +- packages/core/core/src/dumpGraphToGraphViz.js | 2 +- packages/core/core/src/loadDotEnv.js | 2 +- packages/core/core/src/public/Asset.js | 2 +- packages/core/core/src/public/Bundle.js | 6 +- packages/core/core/src/public/BundleGraph.js | 26 +-- packages/core/core/src/public/Config.js | 2 +- .../core/src/public/MutableBundleGraph.js | 16 +- .../core/src/requests/AssetGraphRequest.js | 20 +-- .../src/requests/AssetGraphRequestRust.js | 6 +- .../core/core/src/requests/AssetRequest.js | 6 +- .../src/requests/AtlaspackConfigRequest.js | 8 +- .../core/src/requests/BundleGraphRequest.js | 12 +- .../core/core/src/requests/ConfigRequest.js | 8 +- .../core/core/src/requests/DevDepRequest.js | 14 +- .../core/core/src/requests/EntryRequest.js | 4 +- .../core/core/src/requests/TargetRequest.js | 17 +- .../core/src/requests/ValidationRequest.js | 4 +- .../core/src/requests/WriteBundleRequest.js | 8 +- .../core/src/requests/WriteBundlesRequest.js | 12 +- .../core/src/requests/asset-graph-diff.js | 8 +- packages/core/core/src/resolveOptions.js | 6 +- packages/core/core/src/serializer.js | 4 +- .../core/core/src/serializerCore.browser.js | 5 +- packages/core/core/src/serializerCore.js | 4 +- packages/core/core/src/utils.js | 4 +- .../core/test/AtlaspackConfigRequest.test.js | 2 +- packages/core/core/test/BundleGraph.test.js | 6 +- .../test/PublicMutableBundleGraph.test.js | 4 +- .../core/core/test/RequestTracker.test.js | 9 +- .../core/core/test/SymbolPropagation.test.js | 18 +- .../core/test/requests/ConfigRequest.test.js | 2 +- packages/core/core/test/utils.test.js | 2 +- packages/core/diagnostic/src/diagnostic.js | 4 +- packages/core/fs/src/MemoryFS.js | 16 +- packages/core/fs/src/NodeFS.js | 10 +- packages/core/graph/src/AdjacencyList.js | 6 +- packages/core/graph/src/Graph.js | 27 +-- .../core/graph/test/AdjacencyList.test.js | 2 +- packages/core/graph/test/BitSet.test.js | 4 +- packages/core/graph/test/Graph.test.js | 2 +- .../integration-tests/test/BundleGraph.js | 8 +- packages/core/integration-tests/test/babel.js | 10 +- .../core/integration-tests/test/bundler.js | 20 +-- packages/core/integration-tests/test/cache.js | 72 ++++---- .../integration-tests/test/contentHashing.js | 4 +- .../integration-tests/test/css-modules.js | 44 ++--- .../core/integration-tests/test/encodedURI.js | 2 +- packages/core/integration-tests/test/glob.js | 6 +- .../core/integration-tests/test/globals.js | 14 +- packages/core/integration-tests/test/hmr.js | 36 ++-- packages/core/integration-tests/test/html.js | 64 +++---- packages/core/integration-tests/test/image.js | 38 +++-- .../test/incremental-bundling.js | 8 +- .../core/integration-tests/test/javascript.js | 100 +++++------ .../integration-tests/test/json-reporter.js | 2 +- .../integration-tests/test/lazy-compile.js | 10 +- .../integration-tests/test/library-bundler.js | 20 +-- .../core/integration-tests/test/macros.js | 2 +- .../core/integration-tests/test/monorepos.js | 2 +- .../integration-tests/test/output-formats.js | 91 +++++----- .../core/integration-tests/test/plugin.js | 8 +- packages/core/integration-tests/test/proxy.js | 4 +- .../integration-tests/test/react-refresh.js | 12 +- .../core/integration-tests/test/reporters.js | 4 +- .../integration-tests/test/scope-hoisting.js | 105 +++++++----- .../core/integration-tests/test/server.js | 5 +- .../core/integration-tests/test/sourcemaps.js | 4 +- packages/core/integration-tests/test/svg.js | 20 +-- .../integration-tests/test/tailwind-tests.js | 2 +- .../core/integration-tests/test/tracing.js | 2 +- .../integration-tests/test/transpilation.js | 4 +- .../integration-tests/test/ts-validation.js | 4 +- .../core/integration-tests/test/watcher.js | 4 +- .../integration-tests/test/webextension.js | 4 +- .../integration-tests/test/webmanifest.js | 4 +- .../core/integration-tests/test/workers.js | 26 +-- packages/core/integration-tests/test/xml.js | 10 +- packages/core/logger/src/Logger.js | 10 +- .../package-manager/src/NodePackageManager.js | 24 +-- packages/core/package-manager/src/Pnpm.js | 6 +- packages/core/package-manager/src/Yarn.js | 4 +- .../package-manager/src/installPackage.js | 10 +- .../package-manager/src/promiseFromProcess.js | 2 +- .../test/NodePackageManager.test.js | 6 +- .../test/validateModuleSpecifiers.test.js | 4 +- packages/core/register/example/count.js | 2 +- packages/core/register/example/number.js | 2 +- packages/core/register/src/register.js | 2 +- packages/core/register/src/syncPromise.js | 4 +- packages/core/test-utils/src/fsFixture.js | 12 +- packages/core/test-utils/src/mochaSetup.js | 2 +- packages/core/test-utils/src/utils.js | 46 ++--- packages/core/utils/src/DefaultMap.js | 8 +- packages/core/utils/src/PromiseQueue.js | 4 +- packages/core/utils/src/TapStream.js | 4 +- packages/core/utils/src/alternatives.js | 12 +- packages/core/utils/src/config.js | 2 +- packages/core/utils/src/escape-html.js | 2 +- .../core/utils/src/generateBuildMetrics.js | 14 +- packages/core/utils/src/glob.js | 4 +- packages/core/utils/src/hash.js | 6 +- packages/core/utils/src/http-server.js | 2 +- packages/core/utils/src/prettyDiagnostic.js | 4 +- .../core/utils/src/replaceBundleReferences.js | 10 +- packages/core/utils/src/schema.js | 22 +-- packages/core/utils/src/sourcemap.js | 2 +- packages/core/utils/src/stream.js | 8 +- packages/core/utils/test/DefaultMap.test.js | 8 +- packages/core/utils/test/PromiseQueue.test.js | 2 +- packages/core/workers/src/Worker.js | 8 +- packages/core/workers/src/WorkerFarm.js | 12 +- packages/core/workers/src/child.js | 6 +- packages/core/workers/src/cpuCount.js | 2 +- .../core/workers/src/process/ProcessChild.js | 4 +- .../core/workers/src/process/ProcessWorker.js | 33 ++-- .../core/workers/src/threads/ThreadsChild.js | 2 +- .../core/workers/src/threads/ThreadsWorker.js | 4 +- packages/core/workers/test/workerfarm.js | 6 +- .../atlaspack-link/src/AtlaspackLinkConfig.js | 2 +- packages/dev/atlaspack-link/src/link.js | 4 +- packages/dev/atlaspack-link/src/unlink.js | 6 +- packages/dev/babel-preset/index.js | 4 +- .../babel-plugin-module-translate.js | 2 +- packages/dev/babel-register/index.js | 2 +- packages/dev/esm-fuzzer/generateExample.js | 4 +- packages/dev/esm-fuzzer/index.js | 6 +- packages/dev/esm-fuzzer/runESM.js | 4 +- packages/dev/query/src/cli.js | 24 +-- packages/dev/query/src/index.js | 10 +- .../dev/repl/SimplePackageInstaller/index.js | 4 +- .../dev/repl/SimplePackageInstaller/untar.js | 4 +- .../dev/repl/src/atlaspack/AtlaspackWorker.js | 24 +-- .../src/atlaspack/BrowserPackageManager.js | 8 +- .../repl/src/atlaspack/ExtendedMemoryFS.js | 10 +- packages/dev/repl/src/atlaspack/index.js | 12 +- packages/dev/repl/src/atlaspack/yarn.js | 2 +- packages/dev/repl/src/codemirror.js | 2 +- packages/dev/repl/src/components/Editor.js | 2 +- .../dev/repl/src/components/FileBrowser.js | 18 +- packages/dev/repl/src/components/Options.js | 26 +-- packages/dev/repl/src/components/helper.js | 27 +-- packages/dev/repl/src/components/state.js | 12 +- packages/dev/repl/src/graphs/worker.js | 2 +- packages/dev/repl/src/index.js | 12 +- packages/dev/repl/src/sw.js | 14 +- packages/namers/default/src/DefaultNamer.js | 8 +- packages/optimizers/css/src/CSSOptimizer.js | 4 +- .../inline-requires/src/InlineRequires.js | 2 +- .../test/RequireInliningVisitor.test.js | 2 +- packages/optimizers/swc/src/SwcOptimizer.js | 2 +- packages/packagers/css/src/CSSPackager.js | 12 +- packages/packagers/html/src/HTMLPackager.js | 14 +- packages/packagers/js/src/DevPackager.js | 8 +- .../packagers/js/src/ScopeHoistingPackager.js | 37 ++-- packages/packagers/js/src/index.js | 2 +- packages/packagers/js/src/utils.js | 2 +- .../packagers/raw-url/src/RawUrlPackager.js | 4 +- packages/packagers/raw/src/RawPackager.js | 2 +- packages/packagers/svg/src/SVGPackager.js | 14 +- packages/packagers/ts/src/TSPackager.js | 2 +- packages/packagers/wasm/src/WasmPackager.js | 2 +- .../webextension/src/WebExtensionPackager.js | 26 +-- packages/packagers/xml/src/XMLPackager.js | 6 +- .../build-metrics/src/BuildMetricsReporter.js | 2 +- .../reporters/bundle-analyzer/client/index.js | 2 +- .../src/BundleAnalyzerReporter.js | 2 +- .../bundle-buddy/src/BundleBuddyReporter.js | 2 +- packages/reporters/cli/src/CLIReporter.js | 2 +- packages/reporters/cli/src/bundleReport.js | 2 +- .../reporters/cli/test/CLIReporter.test.js | 4 +- .../reporters/dev-server-sw/src/HMRServer.js | 12 +- .../dev-server-sw/src/ServerReporter.js | 4 +- .../reporters/dev-server/src/HMRServer.js | 14 +- packages/reporters/dev-server/src/Server.js | 22 +-- .../dev-server/src/ServerReporter.js | 2 +- packages/reporters/json/src/JSONReporter.js | 2 +- .../reporters/lsp-reporter/src/LspReporter.js | 24 +-- packages/reporters/lsp-reporter/src/ipc.js | 2 +- .../reporters/tracer/src/TracerReporter.js | 2 +- packages/resolvers/glob/src/GlobResolver.js | 2 +- .../runtimes/hmr/src/loaders/hmr-runtime.js | 18 +- packages/runtimes/js/src/JSRuntime.js | 18 +- .../helpers/browser/esm-js-loader-retry.js | 2 +- .../js/src/helpers/browser/import-polyfill.js | 2 +- .../src/ServiceWorkerRuntime.js | 2 +- .../webextension/src/WebExtensionRuntime.js | 8 +- .../webextension/src/autoreload-bg.js | 6 +- packages/transformers/babel/src/config.js | 8 +- packages/transformers/babel/src/jsx.js | 2 +- .../babel/src/remapAstLocations.js | 2 +- .../transformers/css/src/CSSTransformer.js | 10 +- .../transformers/html/src/HTMLTransformer.js | 4 +- .../transformers/html/src/dependencies.js | 4 +- .../html/test/HTMLTransformer.test.js | 10 +- packages/transformers/js/src/JSTransformer.js | 14 +- .../jsonld/src/JSONLDTransformer.js | 6 +- .../transformers/less/src/LessTransformer.js | 4 +- packages/transformers/less/src/loadConfig.js | 2 +- .../postcss/src/PostCSSTransformer.js | 12 +- .../transformers/postcss/src/loadConfig.js | 6 +- .../transformers/postcss/src/loadPlugins.js | 4 +- .../transformers/posthtml/src/loadPlugins.js | 4 +- .../src/ReactRefreshWrapTransformer.js | 2 +- .../transformers/sass/src/SassTransformer.js | 6 +- .../transformers/svg/src/SVGTransformer.js | 2 +- packages/transformers/svg/src/dependencies.js | 4 +- .../src/TSTypesTransformer.js | 8 +- .../typescript-types/src/collect.js | 2 +- .../typescript-types/src/shake.js | 8 +- .../typescript-types/src/utils.js | 4 +- .../typescript-types/src/wrappers.js | 2 +- .../src/WebExtensionTransformer.js | 4 +- .../transformers/webextension/src/schema.js | 3 +- .../webmanifest/src/WebManifestTransformer.js | 2 +- .../transformers/xml/src/XMLTransformer.js | 2 +- .../src/wrapper.js | 2 +- .../src/index.js | 6 +- packages/utils/babel-preset-env/src/index.js | 6 +- packages/utils/create-react-app/src/cli.js | 4 +- packages/utils/events/src/Disposable.js | 2 +- .../utils/node-resolver-core/src/Wrapper.js | 14 +- packages/utils/ts-utils/src/FSHost.js | 6 +- .../validators/eslint/src/EslintValidator.js | 2 +- .../typescript/src/TypeScriptValidator.js | 6 +- 243 files changed, 1346 insertions(+), 1243 deletions(-) diff --git a/packages/bundlers/default/src/DefaultBundler.js b/packages/bundlers/default/src/DefaultBundler.js index 5d63c56cf..9f3edc0d2 100644 --- a/packages/bundlers/default/src/DefaultBundler.js +++ b/packages/bundlers/default/src/DefaultBundler.js @@ -185,7 +185,7 @@ function decorateLegacyGraph( dependencyBundleGraph.getNodeIdByContentKey(String(bundleNodeId)), ALL_EDGE_TYPES, ) - .map(nodeId => { + .map((nodeId) => { let dependency = nullthrows(dependencyBundleGraph.getNode(nodeId)); invariant(dependency.type === 'dependency'); return dependency.value; @@ -222,7 +222,7 @@ function decorateLegacyGraph( let uniqueKey = idealBundle.uniqueKey != null ? idealBundle.uniqueKey - : [...idealBundle.assets].map(asset => asset.id).join(','); + : [...idealBundle.assets].map((asset) => asset.id).join(','); bundle = nullthrows( bundleGraph.createBundle({ @@ -271,7 +271,7 @@ function decorateLegacyGraph( if (!idealBundle || idealBundle === 'root') continue; let bundle = nullthrows(idealBundleToLegacyBundle.get(idealBundle)); if (idealBundle.internalizedAssets) { - idealBundle.internalizedAssets.forEach(internalized => { + idealBundle.internalizedAssets.forEach((internalized) => { let incomingDeps = bundleGraph.getIncomingDependencies( idealGraph.assets[internalized], ); @@ -469,7 +469,7 @@ function createIdealGraph( } let parentAsset = configToParentAsset.get(c); - let assetRegexes = c.assets.map(glob => globToRegex(glob)); + let assetRegexes = c.assets.map((glob) => globToRegex(glob)); assetGraph.traverse((node, _, actions) => { if ( @@ -480,7 +480,7 @@ function createIdealGraph( config.projectRoot, node.value.filePath, ); - if (!assetRegexes.some(regex => regex.test(projectRelativePath))) { + if (!assetRegexes.some((regex) => regex.test(projectRelativePath))) { return; } @@ -890,7 +890,7 @@ function createIdealGraph( if (asset.meta.isConstantModule === true) { let parents = assetGraph .getIncomingDependencies(asset) - .map(dep => nullthrows(assetGraph.getAssetWithDependency(dep))); + .map((dep) => nullthrows(assetGraph.getAssetWithDependency(dep))); for (let parent of parents) { inlineConstantDeps.get(parent).add(asset); @@ -1084,7 +1084,7 @@ function createIdealGraph( // Neither can non-splittable, isolated, or needing of stable name bundles. // Reserve those filtered out bundles since we add the asset back into them. reachableNonEntries.clear(); - reachableRoots[i].forEach(nodeId => { + reachableRoots[i].forEach((nodeId) => { let assetId = bundleRootGraph.getNode(nodeId); if (assetId == null) return; // deleted let a = assets[assetId]; @@ -1112,7 +1112,7 @@ function createIdealGraph( let bundleId; let manualSharedBundleKey = manualSharedObject.name + ',' + asset.type; let sourceBundles = []; - reachable.forEach(id => { + reachable.forEach((id) => { sourceBundles.push(nullthrows(bundleRoots.get(assets[id]))[0]); }); @@ -1175,7 +1175,7 @@ function createIdealGraph( // if a bundle b is a subgraph of another bundle f, reuse it, drawing an edge between the two if (config.disableSharedBundles === false) { - reachableNonEntries.forEach(candidateId => { + reachableNonEntries.forEach((candidateId) => { let candidateSourceBundleRoot = assets[candidateId]; let candidateSourceBundleId = nullthrows( bundleRoots.get(candidateSourceBundleRoot), @@ -1201,7 +1201,7 @@ function createIdealGraph( ], ); - reachableIntersection.forEach(otherCandidateId => { + reachableIntersection.forEach((otherCandidateId) => { let otherReuseCandidate = assets[otherCandidateId]; if (candidateSourceBundleRoot === otherReuseCandidate) return; let reusableBundleId = nullthrows( @@ -1221,7 +1221,7 @@ function createIdealGraph( } let reachableArray = []; - reachable.forEach(id => { + reachable.forEach((id) => { reachableArray.push(assets[id]); }); @@ -1231,9 +1231,9 @@ function createIdealGraph( reachableArray.length > config.minBundles ) { let sourceBundles = reachableArray.map( - a => nullthrows(bundleRoots.get(a))[0], + (a) => nullthrows(bundleRoots.get(a))[0], ); - let key = reachableArray.map(a => a.id).join(',') + '.' + asset.type; + let key = reachableArray.map((a) => a.id).join(',') + '.' + asset.type; let bundleId = bundles.get(key); let bundle; if (bundleId == null) { @@ -1401,7 +1401,7 @@ function createIdealGraph( }, 0); if (numBundlesContributingToPRL > config.maxParallelRequests) { - let sharedBundleIdsInBundleGroup = bundleIdsInGroup.filter(b => { + let sharedBundleIdsInBundleGroup = bundleIdsInGroup.filter((b) => { let bundle = nullthrows(bundleGraph.getNode(b)); // shared bundles must have source bundles, we could have a bundle // connected to another bundle that isnt a shared bundle, so check @@ -1415,7 +1415,7 @@ function createIdealGraph( // Sort the bundles so the smallest ones are removed first. let sharedBundlesInGroup = sharedBundleIdsInBundleGroup - .map(id => ({ + .map((id) => ({ id, bundle: nullthrows(bundleGraph.getNode(id)), })) @@ -1438,7 +1438,7 @@ function createIdealGraph( // but total # bundles still exceeds limit due to non shared bundles // Add all assets in the shared bundle into the source bundles that are within this bundle group. - let sourceBundles = [...bundleToRemove.sourceBundles].filter(b => + let sourceBundles = [...bundleToRemove.sourceBundles].filter((b) => bundleIdsInGroup.includes(b), ); @@ -1520,7 +1520,7 @@ function createIdealGraph( } function getBundlesForBundleGroup(bundleGroupId) { let bundlesInABundleGroup = []; - bundleGraph.traverse(nodeId => { + bundleGraph.traverse((nodeId) => { bundlesInABundleGroup.push(nodeId); }, bundleGroupId); return bundlesInABundleGroup; @@ -1578,7 +1578,7 @@ function createIdealGraph( for (let asset of bundle.assets) { assetReference.set( asset, - assetReference.get(asset).filter(t => !t.includes(bundle)), + assetReference.get(asset).filter((t) => !t.includes(bundle)), ); for (let sourceBundleId of bundle.sourceBundles) { let sourceBundle = nullthrows(bundleGraph.getNode(sourceBundleId)); @@ -1605,7 +1605,7 @@ const CONFIG_SCHEMA: SchemaEntity = { properties: { http: { type: 'number', - enum: Object.keys(HTTP_OPTIONS).map(k => Number(k)), + enum: Object.keys(HTTP_OPTIONS).map((k) => Number(k)), }, manualSharedBundles: { type: 'array', @@ -1775,7 +1775,7 @@ async function loadBundlerConfig( } if (modeConfig.manualSharedBundles) { - let nameArray = modeConfig.manualSharedBundles.map(a => a.name); + let nameArray = modeConfig.manualSharedBundles.map((a) => a.name); let nameSet = new Set(nameArray); invariant( nameSet.size == nameArray.length, diff --git a/packages/core/cache/src/IDBCache.browser.js b/packages/core/cache/src/IDBCache.browser.js index f85d50075..94d3a7928 100644 --- a/packages/core/cache/src/IDBCache.browser.js +++ b/packages/core/cache/src/IDBCache.browser.js @@ -63,9 +63,9 @@ export class IDBCache implements Cache { getStream(key: string): Readable { let dataPromise = this.store - .then(s => s.get(STORE_NAME, key)) - .then(d => Buffer.from(d)) - .catch(e => e); + .then((s) => s.get(STORE_NAME, key)) + .then((d) => Buffer.from(d)) + .catch((e) => e); const stream = new Readable({ // $FlowFixMe(incompatible-call) async read() { diff --git a/packages/core/cli/src/cli.js b/packages/core/cli/src/cli.js index 7be0424fb..f6b811e47 100755 --- a/packages/core/cli/src/cli.js +++ b/packages/core/cli/src/cli.js @@ -47,10 +47,10 @@ async function logUncaughtError(e: mixed) { } // A hack to definitely ensure we logged the uncaught exception - await new Promise(resolve => setTimeout(resolve, 100)); + await new Promise((resolve) => setTimeout(resolve, 100)); } -const handleUncaughtException = async exception => { +const handleUncaughtException = async (exception) => { try { await logUncaughtError(exception); } catch (err) { @@ -100,7 +100,7 @@ const commonOptions = { 'set the root watch directory. defaults to nearest lockfile or source control dir.', '--watch-ignore [path]': [ `list of directories watcher should not be tracking for changes. defaults to ['.git', '.hg']`, - dirs => dirs.split(','), + (dirs) => dirs.split(','), ], '--watch-backend': new commander.Option( '--watch-backend ', @@ -234,7 +234,7 @@ program .command('help [command]') .description('display help information for a command') .action(function (command) { - let cmd = program.commands.find(c => c.name() === command) || program; + let cmd = program.commands.find((c) => c.name() === command) || program; cmd.help(); }); @@ -263,7 +263,7 @@ commander.Command.prototype.optionMissingArgument = function (option) { var args = process.argv; if (args[2] === '--help' || args[2] === '-h') args[2] = 'help'; -if (!args[2] || !program.commands.some(c => c.name() === args[2])) { +if (!args[2] || !program.commands.some((c) => c.name() === args[2])) { args.splice(2, 0, 'serve'); } @@ -282,7 +282,7 @@ async function run( entries = ['.']; } - entries = entries.map(entry => path.resolve(entry)); + entries = entries.map((entry) => path.resolve(entry)); let Atlaspack = require('@atlaspack/core').default; let fs = new NodeFS(); @@ -364,7 +364,7 @@ async function run( } if (isWatching) { - ({unsubscribe} = await atlaspack.watch(err => { + ({unsubscribe} = await atlaspack.watch((err) => { if (err) { throw err; } @@ -511,7 +511,7 @@ async function normalizeOptions( let additionalReporters = [ {packageName: '@atlaspack/reporter-cli', resolveFrom: __filename}, - ...(command.reporter: Array).map(packageName => ({ + ...(command.reporter: Array).map((packageName) => ({ packageName, resolveFrom: path.join(inputFS.cwd(), 'index'), })), @@ -528,7 +528,7 @@ async function normalizeOptions( const normalizeIncludeExcludeList = (input?: string): string[] => { if (typeof input !== 'string') return []; - return input.split(',').map(value => value.trim()); + return input.split(',').map((value) => value.trim()); }; return { diff --git a/packages/core/codeframe/src/codeframe.js b/packages/core/codeframe/src/codeframe.js index 4caac17e8..71c3dcf4d 100644 --- a/packages/core/codeframe/src/codeframe.js +++ b/packages/core/codeframe/src/codeframe.js @@ -85,7 +85,7 @@ export default function codeFrame( // Make columns/lines start at 1 let originalHighlights = highlights; - highlights = highlights.map(h => { + highlights = highlights.map((h) => { return { start: { column: h.start.column - 1, @@ -116,13 +116,13 @@ export default function codeFrame( let tail; if (endLineIndex - startLine > opts.maxLines) { let maxLine = startLine + opts.maxLines - 1; - highlights = highlights.filter(h => h.start.line < maxLine); + highlights = highlights.filter((h) => h.start.line < maxLine); lastHighlight = highlights[0]; endLineIndex = Math.min( maxLine, lastHighlight.end.line + opts.padding.after, ); - tail = originalHighlights.filter(h => h.start.line > endLineIndex); + tail = originalHighlights.filter((h) => h.start.line > endLineIndex); } let lineNumberLength = (endLineIndex + 1).toString(10).length; @@ -148,7 +148,7 @@ export default function codeFrame( // Find highlights that need to get rendered on the current line let lineHighlights = highlights .filter( - highlight => + (highlight) => highlight.start.line <= currentLineIndex && highlight.end.line >= currentLineIndex, ) @@ -162,7 +162,7 @@ export default function codeFrame( let isWholeLine = lineHighlights.length && !!lineHighlights.find( - h => h.start.line < currentLineIndex && h.end.line > currentLineIndex, + (h) => h.start.line < currentLineIndex && h.end.line > currentLineIndex, ); let lineLengthLimit = diff --git a/packages/core/core/src/AssetGraph.js b/packages/core/core/src/AssetGraph.js index c6853a5f0..02079583e 100644 --- a/packages/core/core/src/AssetGraph.js +++ b/packages/core/core/src/AssetGraph.js @@ -169,12 +169,12 @@ export default class AssetGraph extends ContentGraph { } } else if (assetGroups) { nodes.push( - ...assetGroups.map(assetGroup => nodeFromAssetGroup(assetGroup)), + ...assetGroups.map((assetGroup) => nodeFromAssetGroup(assetGroup)), ); } this.replaceNodeIdsConnectedTo( nullthrows(this.rootNodeId), - nodes.map(node => this.addNode(node)), + nodes.map((node) => this.addNode(node)), ); } @@ -213,7 +213,7 @@ export default class AssetGraph extends ContentGraph { this.replaceNodeIdsConnectedTo( entrySpecifierNodeId, - resolved.map(file => this.addNode(nodeFromEntryFile(file))), + resolved.map((file) => this.addNode(nodeFromEntryFile(file))), ); } @@ -222,7 +222,7 @@ export default class AssetGraph extends ContentGraph { targets: Array, correspondingRequest: string, ) { - let depNodes = targets.map(target => { + let depNodes = targets.map((target) => { let node = nodeFromDep( // The passed project path is ignored in this case, because there is no `loc` createDependency('', { @@ -254,7 +254,7 @@ export default class AssetGraph extends ContentGraph { this.replaceNodeIdsConnectedTo( entryNodeId, - depNodes.map(node => this.addNode(node)), + depNodes.map((node) => this.addNode(node)), ); } @@ -340,7 +340,7 @@ export default class AssetGraph extends ContentGraph { let traversedNode = nullthrows(this.getNode(traversedNodeId)); if (traversedNode.type === 'asset') { let hasDeferred = this.getNodeIdsConnectedFrom(traversedNodeId).some( - childNodeId => { + (childNodeId) => { let childNode = nullthrows(this.getNode(childNodeId)); return childNode.hasDeferred == null ? false @@ -417,7 +417,7 @@ export default class AssetGraph extends ContentGraph { let deps = this.getIncomingDependencies(resolvedAsset); - return deps.every(d => { + return deps.every((d) => { // If this dependency has already been through this process, and we // know it's not deferrable, then there's no need to re-check if (this.undeferredDependencies.has(d)) { @@ -428,7 +428,7 @@ export default class AssetGraph extends ContentGraph { d.symbols && !(d.env.isLibrary && d.isEntry) && !d.symbols.has('*') && - ![...d.symbols.keys()].some(symbol => { + ![...d.symbols.keys()].some((symbol) => { let assetSymbol = resolvedAsset.symbols?.get(symbol)?.local; return assetSymbol != null && symbols.has(assetSymbol); }); @@ -532,7 +532,7 @@ export default class AssetGraph extends ContentGraph { }; } let dependentAsset = dependentAssets.find( - a => a.uniqueKey === dep.specifier, + (a) => a.uniqueKey === dep.specifier, ); if (dependentAsset) { depNode.complete = true; @@ -593,7 +593,7 @@ export default class AssetGraph extends ContentGraph { startNodeId: ?NodeId, ): ?TContext { return this.filteredTraverse( - nodeId => { + (nodeId) => { let node = nullthrows(this.getNode(nodeId)); return node.type === 'asset' ? node.value : null; }, @@ -631,7 +631,7 @@ export default class AssetGraph extends ContentGraph { let hash = new Hash(); // TODO: sort?? - this.traverse(nodeId => { + this.traverse((nodeId) => { let node = nullthrows(this.getNode(nodeId)); if (node.type === 'asset') { hash.writeString(nullthrows(node.value.outputHash)); diff --git a/packages/core/core/src/Atlaspack.js b/packages/core/core/src/Atlaspack.js index bdbfe985f..c01d52367 100644 --- a/packages/core/core/src/Atlaspack.js +++ b/packages/core/core/src/Atlaspack.js @@ -396,7 +396,7 @@ export default class Atlaspack { options, ), buildTime: Date.now() - startTime, - requestBundle: async bundle => { + requestBundle: async (bundle) => { let bundleNode = bundleGraph._graph.getNodeByContentKey(bundle.id); invariant(bundleNode?.type === 'bundle', 'Bundle does not exist'); @@ -571,7 +571,7 @@ export default class Atlaspack { let res = await this.#requestTracker.runRequest(request, { force: true, }); - return res.map(asset => + return res.map((asset) => assetFromValue(asset, nullthrows(this.#resolvedOptions)), ); } diff --git a/packages/core/core/src/AtlaspackConfig.js b/packages/core/core/src/AtlaspackConfig.js index e55c5d3a5..711f64ca3 100644 --- a/packages/core/core/src/AtlaspackConfig.js +++ b/packages/core/core/src/AtlaspackConfig.js @@ -154,7 +154,7 @@ export default class AtlaspackConfig { loadPlugins( plugins: PureAtlaspackConfigPipeline, ): Promise>> { - return Promise.all(plugins.map(p => this.loadPlugin(p))); + return Promise.all(plugins.map((p) => this.loadPlugin(p))); } async getResolvers(): Promise>>> { @@ -181,7 +181,7 @@ export default class AtlaspackConfig { getValidatorNames(filePath: ProjectPath): Array { let validators: PureAtlaspackConfigPipeline = this._getValidatorNodes(filePath); - return validators.map(v => v.packageName); + return validators.map((v) => v.packageName); } getValidators( @@ -193,8 +193,8 @@ export default class AtlaspackConfig { getNamedPipelines(): $ReadOnlyArray { return Object.keys(this.transformers) - .filter(glob => glob.includes(':')) - .map(glob => glob.split(':')[0]); + .filter((glob) => glob.includes(':')) + .map((glob) => glob.split(':')[0]); } async getTransformers( @@ -278,7 +278,9 @@ export default class AtlaspackConfig { // Pipelines for bundles come from their entry assets, so the pipeline likely exists in transformers. if (pipeline) { let prefix = pipeline + ':'; - if (!Object.keys(this.optimizers).some(glob => glob.startsWith(prefix))) { + if ( + !Object.keys(this.optimizers).some((glob) => glob.startsWith(prefix)) + ) { pipeline = null; } } @@ -294,7 +296,7 @@ export default class AtlaspackConfig { getOptimizerNames(filePath: FilePath, pipeline: ?string): Array { let optimizers = this._getOptimizerNodes(filePath, pipeline); - return optimizers.map(o => o.packageName); + return optimizers.map((o) => o.packageName); } getOptimizers( @@ -435,7 +437,7 @@ export default class AtlaspackConfig { configsWithPlugin = new Set(getConfigPaths(this.options, plugins)); } else { configsWithPlugin = new Set( - Object.keys(plugins).flatMap(k => + Object.keys(plugins).flatMap((k) => Array.isArray(plugins[k]) ? getConfigPaths(this.options, plugins[k]) : [getConfigPath(this.options, plugins[k])], @@ -451,7 +453,7 @@ export default class AtlaspackConfig { let seenKey = false; let codeFrames = await Promise.all( - [...configsWithPlugin].map(async filePath => { + [...configsWithPlugin].map(async (filePath) => { let configContents = await this.options.inputFS.readFile( filePath, 'utf8', @@ -481,7 +483,7 @@ export default class AtlaspackConfig { function getConfigPaths(options, nodes) { return nodes - .map(node => (node !== '...' ? getConfigPath(options, node) : null)) + .map((node) => (node !== '...' ? getConfigPath(options, node) : null)) .filter(Boolean); } diff --git a/packages/core/core/src/AtlaspackConfig.schema.js b/packages/core/core/src/AtlaspackConfig.schema.js index ad60c18cb..7de7605b8 100644 --- a/packages/core/core/src/AtlaspackConfig.schema.js +++ b/packages/core/core/src/AtlaspackConfig.schema.js @@ -96,7 +96,7 @@ export default { }, bundler: { type: 'string', - __validate: (validatePluginName('bundler', 'bundler'): string => void), + __validate: (validatePluginName('bundler', 'bundler'): (string) => void), }, resolvers: (pipelineSchema('resolver', 'resolvers'): SchemaEntity), transformers: (mapPipelineSchema( diff --git a/packages/core/core/src/BundleGraph.js b/packages/core/core/src/BundleGraph.js index f5c931b79..556251fa9 100644 --- a/packages/core/core/src/BundleGraph.js +++ b/packages/core/core/src/BundleGraph.js @@ -178,7 +178,7 @@ export default class BundleGraph { : null; invariant(assetGraphRootNode != null && assetGraphRootNode.type === 'root'); - assetGraph.dfsFast(nodeId => { + assetGraph.dfsFast((nodeId) => { let node = assetGraph.getNode(nodeId); if (node != null && node.type === 'asset') { @@ -187,7 +187,7 @@ export default class BundleGraph { // If one already exists, use it. let publicId = publicIdByAssetId.get(assetId); if (publicId == null) { - publicId = getPublicId(assetId, existing => + publicId = getPublicId(assetId, (existing) => assetPublicIds.has(existing), ); publicIdByAssetId.set(assetId, publicId); @@ -426,10 +426,10 @@ export default class BundleGraph { continue; } - let to: Array = dependencies.get(edge.to)?.map(v => v.dep) ?? + let to: Array = dependencies.get(edge.to)?.map((v) => v.dep) ?? assetGroupIds .get(edge.to) - ?.map(id => + ?.map((id) => nullthrows(assetGraphNodeIdToBundleGraphNodeId.get(id)), ) ?? [nullthrows(assetGraphNodeIdToBundleGraphNodeId.get(edge.to))]; @@ -503,7 +503,7 @@ export default class BundleGraph { return existing.value; } - let publicId = getPublicId(bundleId, existing => + let publicId = getPublicId(bundleId, (existing) => this._bundlePublicIds.has(existing), ); this._bundlePublicIds.add(publicId); @@ -580,7 +580,7 @@ export default class BundleGraph { for (let [bundleGroupNodeId, bundleGroupNode] of this._graph .getNodeIdsConnectedFrom(dependencyNodeId) - .map(id => [id, nullthrows(this._graph.getNode(id))]) + .map((id) => [id, nullthrows(this._graph.getNode(id))]) .filter(([, node]) => node.type === 'bundle_group')) { invariant(bundleGroupNode.type === 'bundle_group'); this._graph.addEdge( @@ -598,8 +598,8 @@ export default class BundleGraph { dependencyNodeId, bundleGraphEdgeTypes.references, ) - .map(id => nullthrows(this._graph.getNode(id))) - .some(node => node.type === 'bundle') + .map((id) => nullthrows(this._graph.getNode(id))) + .some((node) => node.type === 'bundle') ) { this._graph.addEdge( bundleNodeId, @@ -613,7 +613,7 @@ export default class BundleGraph { addAssetGraphToBundle( asset: Asset, bundle: Bundle, - shouldSkipDependency: Dependency => boolean = d => + shouldSkipDependency: (Dependency) => boolean = (d) => this.isDependencySkipped(d), ) { let assetNodeId = this._graph.getNodeIdByContentKey(asset.id); @@ -645,7 +645,7 @@ export default class BundleGraph { if (node.type === 'dependency') { for (let [bundleGroupNodeId, bundleGroupNode] of this._graph .getNodeIdsConnectedFrom(nodeId) - .map(id => [id, nullthrows(this._graph.getNode(id))]) + .map((id) => [id, nullthrows(this._graph.getNode(id))]) .filter(([, node]) => node.type === 'bundle_group')) { invariant(bundleGroupNode.type === 'bundle_group'); this._graph.addEdge( @@ -660,8 +660,8 @@ export default class BundleGraph { if ( this._graph .getNodeIdsConnectedFrom(nodeId, bundleGraphEdgeTypes.references) - .map(id => nullthrows(this._graph.getNode(id))) - .some(node => node.type === 'bundle') + .map((id) => nullthrows(this._graph.getNode(id))) + .some((node) => node.type === 'bundle') ) { this._graph.addEdge( bundleNodeId, @@ -689,7 +689,7 @@ export default class BundleGraph { addEntryToBundle( asset: Asset, bundle: Bundle, - shouldSkipDependency?: Dependency => boolean, + shouldSkipDependency?: (Dependency) => boolean, ) { this.addAssetGraphToBundle(asset, bundle, shouldSkipDependency); if (!bundle.entryAssetIds.includes(asset.id)) { @@ -746,9 +746,9 @@ export default class BundleGraph { this._graph.getNodeIdByContentKey(getBundleGroupId(bundleGroup)), bundleGraphEdgeTypes.bundle, ) - .map(id => nullthrows(this._graph.getNode(id))) - .filter(node => node.type === 'bundle') - .map(node => { + .map((id) => nullthrows(this._graph.getNode(id))) + .filter((node) => node.type === 'bundle') + .map((node) => { invariant(node.type === 'bundle'); return node.value; }); @@ -804,8 +804,8 @@ export default class BundleGraph { let node = this._graph .getNodeIdsConnectedFrom(this._graph.getNodeIdByContentKey(dependency.id)) - .map(id => nullthrows(this._graph.getNode(id))) - .find(node => node.type === 'bundle_group'); + .map((id) => nullthrows(this._graph.getNode(id))) + .find((node) => node.type === 'bundle_group'); if (node == null) { return; @@ -828,13 +828,13 @@ export default class BundleGraph { dependencyNodeId, bundleGraphEdgeTypes.references, ) - .map(id => nullthrows(this._graph.getNode(id))) - .filter(node => node.type === 'bundle'); + .map((id) => nullthrows(this._graph.getNode(id))) + .filter((node) => node.type === 'bundle'); if (bundleNodes.length) { let bundleNode = bundleNodes.find( - b => b.type === 'bundle' && b.value.type === fromBundle.type, + (b) => b.type === 'bundle' && b.value.type === fromBundle.type, ) || bundleNodes[0]; invariant(bundleNode.type === 'bundle'); return bundleNode.value; @@ -843,14 +843,14 @@ export default class BundleGraph { // If this dependency is async, there will be a bundle group attached to it. let node = this._graph .getNodeIdsConnectedFrom(dependencyNodeId) - .map(id => nullthrows(this._graph.getNode(id))) - .find(node => node.type === 'bundle_group'); + .map((id) => nullthrows(this._graph.getNode(id))) + .find((node) => node.type === 'bundle_group'); if (node != null) { invariant(node.type === 'bundle_group'); return this.getBundlesInBundleGroup(node.value, { includeInline: true, - }).find(b => { + }).find((b) => { let mainEntryId = b.entryAssetIds[b.entryAssetIds.length - 1]; return mainEntryId != null && node.value.entryAssetId === mainEntryId; }); @@ -1012,7 +1012,7 @@ export default class BundleGraph { assert( bundlesInGroup.every( - bundle => this.getBundleGroupsContainingBundle(bundle).length > 0, + (bundle) => this.getBundleGroupsContainingBundle(bundle).length > 0, ), ); } @@ -1021,8 +1021,8 @@ export default class BundleGraph { let bundleNodeId = this._graph.getNodeIdByContentKey(bundle.id); for (let bundleGroupNode of this._graph .getNodeIdsConnectedFrom(this._graph.getNodeIdByContentKey(dependency.id)) - .map(id => nullthrows(this._graph.getNode(id))) - .filter(node => node.type === 'bundle_group')) { + .map((id) => nullthrows(this._graph.getNode(id))) + .filter((node) => node.type === 'bundle_group')) { let bundleGroupNodeId = this._graph.getNodeIdByContentKey( bundleGroupNode.id, ); @@ -1039,9 +1039,9 @@ export default class BundleGraph { let inboundDependencies = this._graph .getNodeIdsConnectedTo(bundleGroupNodeId) - .map(id => nullthrows(this._graph.getNode(id))) - .filter(node => node.type === 'dependency') - .map(node => { + .map((id) => nullthrows(this._graph.getNode(id))) + .filter((node) => node.type === 'dependency') + .map((node) => { invariant(node.type === 'dependency'); return node.value; }); @@ -1051,7 +1051,7 @@ export default class BundleGraph { // this bundle and the group is safe to remove. if ( inboundDependencies.every( - dependency => + (dependency) => dependency.specifierType !== SpecifierType.url && (!this.bundleHasDependency(bundle, dependency) || this._graph.hasEdge( @@ -1105,9 +1105,9 @@ export default class BundleGraph { this._graph.getNodeIdByContentKey(asset.id), bundleGraphEdgeTypes.contains, ) - .map(id => nullthrows(this._graph.getNode(id))) - .filter(node => node.type === 'bundle') - .map(node => { + .map((id) => nullthrows(this._graph.getNode(id))) + .filter((node) => node.type === 'bundle') + .map((node) => { invariant(node.type === 'bundle'); return node.value; }); @@ -1119,9 +1119,9 @@ export default class BundleGraph { nullthrows(this._graph.getNodeIdByContentKey(dependency.id)), bundleGraphEdgeTypes.contains, ) - .map(id => nullthrows(this._graph.getNode(id))) - .filter(node => node.type === 'bundle') - .map(node => { + .map((id) => nullthrows(this._graph.getNode(id))) + .filter((node) => node.type === 'bundle') + .map((node) => { invariant(node.type === 'bundle'); return node.value; }); @@ -1130,9 +1130,9 @@ export default class BundleGraph { getDependencyAssets(dependency: Dependency): Array { return this._graph .getNodeIdsConnectedFrom(this._graph.getNodeIdByContentKey(dependency.id)) - .map(id => nullthrows(this._graph.getNode(id))) - .filter(node => node.type === 'asset') - .map(node => { + .map((id) => nullthrows(this._graph.getNode(id))) + .filter((node) => node.type === 'asset') + .map((node) => { invariant(node.type === 'asset'); return node.value; }); @@ -1146,8 +1146,8 @@ export default class BundleGraph { bundle == null ? firstAsset : // Otherwise, find the first asset that belongs to this bundle. - assets.find(asset => this.bundleHasAsset(bundle, asset)) || - assets.find(a => a.type === bundle.type) || + assets.find((asset) => this.bundleHasAsset(bundle, asset)) || + assets.find((a) => a.type === bundle.type) || firstAsset; // If a resolution still hasn't been found, return the first referenced asset. @@ -1167,7 +1167,7 @@ export default class BundleGraph { ); if (bundle) { - resolved = potential.find(a => a.type === bundle.type); + resolved = potential.find((a) => a.type === bundle.type); } resolved ||= potential[0]; } @@ -1177,7 +1177,7 @@ export default class BundleGraph { getDependencies(asset: Asset): Array { let nodeId = this._graph.getNodeIdByContentKey(asset.id); - return this._graph.getNodeIdsConnectedFrom(nodeId).map(id => { + return this._graph.getNodeIdsConnectedFrom(nodeId).map((id) => { let node = nullthrows(this._graph.getNode(id)); invariant(node.type === 'dependency'); return node.value; @@ -1191,7 +1191,7 @@ export default class BundleGraph { ): ?TContext { return this.traverseBundle( bundle, - mapVisitor(node => (node.type === 'asset' ? node.value : null), visit), + mapVisitor((node) => (node.type === 'asset' ? node.value : null), visit), startAsset, ); } @@ -1200,7 +1200,7 @@ export default class BundleGraph { // If the asset is available in multiple bundles in the same target, it's referenced. if ( this.getBundlesWithAsset(asset).filter( - b => b.target.distDir === bundle.target.distDir, + (b) => b.target.distDir === bundle.target.distDir, ).length > 1 ) { return true; @@ -1211,9 +1211,9 @@ export default class BundleGraph { if ( this._graph .getNodeIdsConnectedTo(assetNodeId, bundleGraphEdgeTypes.references) - .map(id => this._graph.getNode(id)) + .map((id) => this._graph.getNode(id)) .some( - node => + (node) => node?.type === 'dependency' && node.value.priority === Priority.lazy && node.value.specifierType !== SpecifierType.url, @@ -1225,9 +1225,9 @@ export default class BundleGraph { let dependencies = this._graph .getNodeIdsConnectedTo(assetNodeId) - .map(id => nullthrows(this._graph.getNode(id))) - .filter(node => node.type === 'dependency') - .map(node => { + .map((id) => nullthrows(this._graph.getNode(id))) + .filter((node) => node.type === 'dependency') + .map((node) => { invariant(node.type === 'dependency'); return node.value; }); @@ -1235,7 +1235,7 @@ export default class BundleGraph { const bundleHasReference = (bundle: Bundle) => { return ( !this.bundleHasAsset(bundle, asset) && - dependencies.some(dependency => + dependencies.some((dependency) => this.bundleHasDependency(bundle, dependency), ) ); @@ -1243,7 +1243,7 @@ export default class BundleGraph { let visitedBundles: Set = new Set(); let siblingBundles = new Set( - this.getBundleGroupsContainingBundle(bundle).flatMap(bundleGroup => + this.getBundleGroupsContainingBundle(bundle).flatMap((bundleGroup) => this.getBundlesInBundleGroup(bundleGroup, {includeInline: true}), ), ); @@ -1252,7 +1252,7 @@ export default class BundleGraph { // by referencers, or descendants of its referencers use the asset without // an explicit reference edge. This can happen if e.g. the asset has been // deduplicated. - return [...siblingBundles].some(referencer => { + return [...siblingBundles].some((referencer) => { let isReferenced = false; this.traverseBundles((descendant, _, actions) => { if (descendant.id === bundle.id) { @@ -1287,7 +1287,9 @@ export default class BundleGraph { hasParentBundleOfType(bundle: Bundle, type: string): boolean { let parents = this.getParentBundles(bundle); - return parents.length > 0 && parents.every(parent => parent.type === type); + return ( + parents.length > 0 && parents.every((parent) => parent.type === type) + ); } getParentBundles(bundle: Bundle): Array { @@ -1318,12 +1320,12 @@ export default class BundleGraph { // For an asset to be reachable from a bundle, it must either exist in a sibling bundle, // or in an ancestor bundle group reachable from all parent bundles. let bundleGroups = this.getBundleGroupsContainingBundle(bundle); - return bundleGroups.every(bundleGroup => { + return bundleGroups.every((bundleGroup) => { // If the asset is in any sibling bundles of the original bundle, it is reachable. let bundles = this.getBundlesInBundleGroup(bundleGroup); if ( bundles.some( - b => + (b) => b.id !== bundle.id && b.bundleBehavior !== BundleBehavior.isolated && b.bundleBehavior !== BundleBehavior.inline && @@ -1340,7 +1342,7 @@ export default class BundleGraph { ); // Check that every parent bundle has a bundle group in its ancestry that contains the asset. - return parentBundleNodes.every(bundleNodeId => { + return parentBundleNodes.every((bundleNodeId) => { let bundleNode = nullthrows(this._graph.getNode(bundleNodeId)); if ( bundleNode.type !== 'bundle' || @@ -1372,7 +1374,7 @@ export default class BundleGraph { let childBundles = this.getBundlesInBundleGroup(node.value); if ( childBundles.some( - b => + (b) => b.id !== bundle.id && b.bundleBehavior !== BundleBehavior.isolated && b.bundleBehavior !== BundleBehavior.inline && @@ -1431,10 +1433,10 @@ export default class BundleGraph { startNodeId: startAsset ? this._graph.getNodeIdByContentKey(startAsset.id) : bundleNodeId, - getChildren: nodeId => { + getChildren: (nodeId) => { let children = this._graph .getNodeIdsConnectedFrom(nodeId) - .map(id => [id, nullthrows(this._graph.getNode(id))]); + .map((id) => [id, nullthrows(this._graph.getNode(id))]); let sorted = entries && bundle.entryAssetIds.length > 0 @@ -1467,7 +1469,7 @@ export default class BundleGraph { start?: Asset, ): ?TContext { return this._graph.filteredTraverse( - nodeId => { + (nodeId) => { let node = nullthrows(this._graph.getNode(nodeId)); if (node.type === 'asset' || node.type === 'dependency') { return node; @@ -1501,7 +1503,7 @@ export default class BundleGraph { startBundle: ?Bundle, ): ?TContext { return this._graph.filteredTraverse( - nodeId => { + (nodeId) => { let node = nullthrows(this._graph.getNode(nodeId)); return node.type === 'bundle' ? node.value : null; }, @@ -1513,7 +1515,7 @@ export default class BundleGraph { getBundles(opts?: {|includeInline: boolean|}): Array { let bundles = []; - this.traverseBundles(bundle => { + this.traverseBundles((bundle) => { if ( opts?.includeInline || bundle.bundleBehavior !== BundleBehavior.inline @@ -1546,7 +1548,7 @@ export default class BundleGraph { this._graph.traverseAncestors( this._graph.getNodeIdByContentKey(bundle.id), - nodeId => { + (nodeId) => { let node = nullthrows(this._graph.getNode(nodeId)); if (node.type === 'bundle' && node.value.id !== bundle.id) { referencingBundles.add(node.value); @@ -1576,9 +1578,9 @@ export default class BundleGraph { nullthrows(this._graph.getNodeIdByContentKey(bundle.id)), bundleGraphEdgeTypes.bundle, ) - .map(id => nullthrows(this._graph.getNode(id))) - .filter(node => node.type === 'bundle_group') - .map(node => { + .map((id) => nullthrows(this._graph.getNode(id))) + .filter((node) => node.type === 'bundle_group') + .map((node) => { invariant(node.type === 'bundle_group'); return node.value; }); @@ -1643,7 +1645,7 @@ export default class BundleGraph { } }, startNodeId: this._graph.getNodeIdByContentKey(bundle.id), - getChildren: nodeId => + getChildren: (nodeId) => // Shared bundles seem to depend on being used in the opposite order // they were added. // TODO: Should this be the case? @@ -1667,9 +1669,9 @@ export default class BundleGraph { this._graph.getNodeIdByContentKey(asset.id), ALL_EDGE_TYPES, ) - .map(id => nullthrows(this._graph.getNode(id))) - .filter(n => n.type === 'dependency') - .map(n => { + .map((id) => nullthrows(this._graph.getNode(id))) + .filter((n) => n.type === 'dependency') + .map((n) => { invariant(n.type === 'dependency'); return n.value; }); @@ -1941,8 +1943,8 @@ export default class BundleGraph { let resolved = this.getResolvedAsset(dep, boundary); if (!resolved) continue; let exported = this.getExportedSymbols(resolved, boundary) - .filter(s => s.exportSymbol !== 'default') - .map(s => + .filter((s) => s.exportSymbol !== 'default') + .map((s) => s.exportSymbol !== '*' ? {...s, exportAs: s.exportSymbol} : s, ); symbols.push(...exported); @@ -1960,7 +1962,7 @@ export default class BundleGraph { let hash = new Hash(); // TODO: sort?? - this.traverseAssets(bundle, asset => { + this.traverseAssets(bundle, (asset) => { { hash.writeString( [this.getAssetPublicId(asset), asset.id, asset.outputHash].join(':'), @@ -1976,7 +1978,7 @@ export default class BundleGraph { getInlineBundles(bundle: Bundle): Array { let bundles = []; let seen = new Set(); - let addReferencedBundles = bundle => { + let addReferencedBundles = (bundle) => { if (seen.has(bundle.id)) { return; } @@ -2143,8 +2145,8 @@ export default class BundleGraph { ), bundleGraphEdgeTypes.bundle, ) - .map(id => nullthrows(this._graph.getNode(id))) - .some(n => n.type === 'root'); + .map((id) => nullthrows(this._graph.getNode(id))) + .some((n) => n.type === 'root'); } /** diff --git a/packages/core/core/src/CommittedAsset.js b/packages/core/core/src/CommittedAsset.js index cfeca5b15..b1dcc9505 100644 --- a/packages/core/core/src/CommittedAsset.js +++ b/packages/core/core/src/CommittedAsset.js @@ -131,7 +131,7 @@ export default class CommittedAsset { if (this.ast == null) { this.ast = this.options.cache .getBlob(this.value.astKey) - .then(serializedAst => deserializeRaw(serializedAst)); + .then((serializedAst) => deserializeRaw(serializedAst)); } return this.ast; diff --git a/packages/core/core/src/PackagerRunner.js b/packages/core/core/src/PackagerRunner.js index f5dca0ebf..587e6c675 100644 --- a/packages/core/core/src/PackagerRunner.js +++ b/packages/core/core/src/PackagerRunner.js @@ -127,7 +127,7 @@ export default class PackagerRunner { this.previousInvalidations = previousInvalidations; this.invalidations = new Map(); this.pluginOptions = new PluginOptions( - optionsProxy(this.options, option => { + optionsProxy(this.options, (option) => { let invalidation: RequestInvalidation = { type: 'option', key: option, @@ -410,7 +410,7 @@ export default class PackagerRunner { NamedBundle.get.bind(NamedBundle), this.options, ), - getSourceMapReference: map => { + getSourceMapReference: (map) => { return this.getSourceMapReference(bundle, map); }, options: this.pluginOptions, @@ -517,7 +517,7 @@ export default class PackagerRunner { bundleGraph, contents: optimized.contents, map: optimized.map, - getSourceMapReference: map => { + getSourceMapReference: (map) => { return this.getSourceMapReference(bundle, map); }, options: this.pluginOptions, @@ -736,7 +736,7 @@ export default class PackagerRunner { await this.options.cache.setStream( cacheKeys.content, blobToStream(contents).pipe( - new TapStream(buf => { + new TapStream((buf) => { let str = boundaryStr + buf.toString(); hashReferences = hashReferences.concat( str.match(HASH_REF_REGEX) ?? [], diff --git a/packages/core/core/src/ReporterRunner.js b/packages/core/core/src/ReporterRunner.js index d33642790..44417d717 100644 --- a/packages/core/core/src/ReporterRunner.js +++ b/packages/core/core/src/ReporterRunner.js @@ -45,8 +45,8 @@ export default class ReporterRunner { this.workerFarm = opts.workerFarm; this.pluginOptions = new PluginOptions(this.options); - logger.onLog(event => this.report(event)); - tracer.onTrace(event => this.report(event)); + logger.onLog((event) => this.report(event)); + tracer.onTrace((event) => this.report(event)); bus.on('reporterEvent', this.eventHandler); instances.add(this); @@ -58,7 +58,7 @@ export default class ReporterRunner { } } - eventHandler: ReporterEvent => void = (event): void => { + eventHandler: (ReporterEvent) => void = (event): void => { if ( event.type === 'buildProgress' && (event.phase === 'optimizing' || event.phase === 'packaging') && @@ -154,5 +154,5 @@ export function reportWorker(workerApi: WorkerApi, event: ReporterEvent) { } export async function report(event: ReporterEvent): Promise { - await Promise.all([...instances].map(instance => instance.report(event))); + await Promise.all([...instances].map((instance) => instance.report(event))); } diff --git a/packages/core/core/src/RequestTracker.js b/packages/core/core/src/RequestTracker.js index 7638208c2..acd1f4d5d 100644 --- a/packages/core/core/src/RequestTracker.js +++ b/packages/core/core/src/RequestTracker.js @@ -210,9 +210,9 @@ type RequestGraphNode = | ConfigKeyNode; export type RunAPI = {| - invalidateOnFileCreate: InternalFileCreateInvalidation => void, - invalidateOnFileDelete: ProjectPath => void, - invalidateOnFileUpdate: ProjectPath => void, + invalidateOnFileCreate: (InternalFileCreateInvalidation) => void, + invalidateOnFileDelete: (ProjectPath) => void, + invalidateOnFileUpdate: (ProjectPath) => void, invalidateOnConfigKeyChange: ( filePath: ProjectPath, configKey: string, @@ -220,8 +220,8 @@ export type RunAPI = {| ) => void, invalidateOnStartup: () => void, invalidateOnBuild: () => void, - invalidateOnEnvChange: string => void, - invalidateOnOptionChange: string => void, + invalidateOnEnvChange: (string) => void, + invalidateOnOptionChange: (string) => void, getInvalidations(): Array, storeResult(result: TResult, cacheKey?: string): void, getRequestResult(contentKey: ContentKey): Async, @@ -761,7 +761,7 @@ export class RequestGraph extends ContentGraph< requestGraphEdgeTypes.invalidated_by_update, ); return invalidations - .map(nodeId => { + .map((nodeId) => { let node = nullthrows(this.getNode(nodeId)); switch (node.type) { case FILE: @@ -788,7 +788,7 @@ export class RequestGraph extends ContentGraph< requestGraphEdgeTypes.subrequest, ); - return subRequests.map(nodeId => { + return subRequests.map((nodeId) => { let node = nullthrows(this.getNode(nodeId)); invariant(node.type === REQUEST); return node; @@ -806,8 +806,8 @@ export class RequestGraph extends ContentGraph< ); return subRequests - .filter(id => this.invalidNodeIds.has(id)) - .map(nodeId => { + .filter((id) => this.invalidNodeIds.has(id)) + .map((nodeId) => { let node = nullthrows(this.getNode(nodeId)); invariant(node.type === REQUEST); return node; @@ -1331,7 +1331,7 @@ export default class RequestTracker { ): {|api: RunAPI, subRequestContentKeys: Set|} { let subRequestContentKeys = new Set(); let api: RunAPI = { - invalidateOnFileCreate: input => + invalidateOnFileCreate: (input) => this.graph.invalidateOnFileCreate(requestId, input), invalidateOnConfigKeyChange: (filePath, configKey, contentHash) => this.graph.invalidateOnConfigKeyChange( @@ -1340,15 +1340,15 @@ export default class RequestTracker { configKey, contentHash, ), - invalidateOnFileDelete: filePath => + invalidateOnFileDelete: (filePath) => this.graph.invalidateOnFileDelete(requestId, filePath), - invalidateOnFileUpdate: filePath => + invalidateOnFileUpdate: (filePath) => this.graph.invalidateOnFileUpdate(requestId, filePath), invalidateOnStartup: () => this.graph.invalidateOnStartup(requestId), invalidateOnBuild: () => this.graph.invalidateOnBuild(requestId), - invalidateOnEnvChange: env => + invalidateOnEnvChange: (env) => this.graph.invalidateOnEnvChange(requestId, env, this.options.env[env]), - invalidateOnOptionChange: option => + invalidateOnOptionChange: (option) => this.graph.invalidateOnOptionChange( requestId, option, @@ -1366,7 +1366,7 @@ export default class RequestTracker { }, getRequestResult: (id): Async => this.getRequestResult(id), - canSkipSubrequest: contentKey => { + canSkipSubrequest: (contentKey) => { if ( this.graph.hasContentKey(contentKey) && this.hasValidResult(this.graph.getNodeIdByContentKey(contentKey)) @@ -1552,7 +1552,7 @@ export function getWatcherOptions({ }: AtlaspackOptions): WatcherOptions { const vcsDirs = ['.git', '.hg']; const uniqueDirs = [...new Set([...watchIgnore, ...vcsDirs, cacheDir])]; - const ignore = uniqueDirs.map(dir => path.resolve(watchDir, dir)); + const ignore = uniqueDirs.map((dir) => path.resolve(watchDir, dir)); return {ignore, backend: watchBackend}; } @@ -1706,7 +1706,7 @@ function logErrorOnBailout( export function cleanUpOrphans(graph: Graph): NodeId[] { const reachableNodes = new Set(); - graph.traverse(nodeId => { + graph.traverse((nodeId) => { reachableNodes.add(nodeId); }); diff --git a/packages/core/core/src/SymbolPropagation.js b/packages/core/core/src/SymbolPropagation.js index aee870ff1..94feffa3a 100644 --- a/packages/core/core/src/SymbolPropagation.js +++ b/packages/core/core/src/SymbolPropagation.js @@ -33,7 +33,7 @@ export function propagateSymbols({ previousErrors?: ?Map>, |}): Map> { let changedAssets = new Set( - [...changedAssetsPropagation].map(id => + [...changedAssetsPropagation].map((id) => assetGraph.getNodeIdByContentKey(id), ), ); @@ -80,7 +80,7 @@ export function propagateSymbols({ } } let hasNamespaceOutgoingDeps = outgoingDeps.some( - d => d.value.symbols?.get('*')?.local === '*', + (d) => d.value.symbols?.get('*')?.local === '*', ); // 1) Determine what the incomingDeps requests from the asset @@ -193,18 +193,18 @@ export function propagateSymbols({ // we need everything depUsedSymbolsDown.add(symbol); - [...reexportedExportSymbols].forEach(s => + [...reexportedExportSymbols].forEach((s) => assetNode.usedSymbols.delete(s), ); } else { let usedReexportedExportSymbols = [ ...reexportedExportSymbols, - ].filter(s => assetNode.usedSymbols.has(s)); + ].filter((s) => assetNode.usedSymbols.has(s)); if (usedReexportedExportSymbols.length > 0) { // The symbol is indeed a reexport, so it's not used from the asset itself depUsedSymbolsDown.add(symbol); - usedReexportedExportSymbols.forEach(s => + usedReexportedExportSymbols.forEach((s) => assetNode.usedSymbols.delete(s), ); } @@ -338,7 +338,7 @@ export function propagateSymbols({ let reexported = assetSymbolsInverse?.get(local); if (reexported != null) { - reexported.forEach(s => { + reexported.forEach((s) => { // see same code above if (reexportedSymbols.has(s)) { if (!assetNode.usedSymbols.has('*')) { @@ -555,12 +555,12 @@ function propagateSymbolsDown( } else if (node.type === 'asset' && node.usedSymbolsDownDirty) { visit( node, - assetGraph.getIncomingDependencies(node.value).map(d => { + assetGraph.getIncomingDependencies(node.value).map((d) => { let dep = assetGraph.getNodeByContentKey(d.id); invariant(dep && dep.type === 'dependency'); return dep; }), - outgoing.map(dep => { + outgoing.map((dep) => { let depNode = nullthrows(assetGraph.getNode(dep)); invariant(depNode.type === 'dependency'); return depNode; @@ -620,7 +620,7 @@ function propagateSymbolsUp( let changedDepsUsedSymbolsUpDirtyDownAssets = new Set([ ...[...changedDepsUsedSymbolsUpDirtyDown] .reverse() - .flatMap(id => getDependencyResolution(assetGraph, id)), + .flatMap((id) => getDependencyResolution(assetGraph, id)), ...changedAssets, ]); @@ -640,7 +640,7 @@ function propagateSymbolsUp( 'A root node is required to traverse', ); - const nodeVisitor = nodeId => { + const nodeVisitor = (nodeId) => { let node = nullthrows(assetGraph.getNode(nodeId)); let outgoing = assetGraph.getNodeIdsConnectedFrom(nodeId); @@ -656,11 +656,13 @@ function propagateSymbolsUp( } if (node.type === 'asset') { - let incoming = assetGraph.getIncomingDependencies(node.value).map(d => { - let n = assetGraph.getNodeByContentKey(d.id); - invariant(n && n.type === 'dependency'); - return n; - }); + let incoming = assetGraph + .getIncomingDependencies(node.value) + .map((d) => { + let n = assetGraph.getNodeByContentKey(d.id); + invariant(n && n.type === 'dependency'); + return n; + }); for (let dep of incoming) { if (dep.usedSymbolsUpDirtyDown) { dep.usedSymbolsUpDirtyDown = false; @@ -671,7 +673,7 @@ function propagateSymbolsUp( let e = visit( node, incoming, - outgoing.map(depNodeId => { + outgoing.map((depNodeId) => { let depNode = nullthrows(assetGraph.getNode(depNodeId)); invariant(depNode.type === 'dependency'); return depNode; @@ -703,11 +705,13 @@ function propagateSymbolsUp( let queuedNodeId = setPop(queue); let node = nullthrows(assetGraph.getNode(queuedNodeId)); if (node.type === 'asset') { - let incoming = assetGraph.getIncomingDependencies(node.value).map(dep => { - let depNode = assetGraph.getNodeByContentKey(dep.id); - invariant(depNode && depNode.type === 'dependency'); - return depNode; - }); + let incoming = assetGraph + .getIncomingDependencies(node.value) + .map((dep) => { + let depNode = assetGraph.getNodeByContentKey(dep.id); + invariant(depNode && depNode.type === 'dependency'); + return depNode; + }); for (let dep of incoming) { if (dep.usedSymbolsUpDirtyDown) { dep.usedSymbolsUpDirtyDown = false; @@ -716,7 +720,7 @@ function propagateSymbolsUp( } let outgoing = assetGraph .getNodeIdsConnectedFrom(queuedNodeId) - .map(depNodeId => { + .map((depNodeId) => { let depNode = nullthrows(assetGraph.getNode(depNodeId)); invariant(depNode.type === 'dependency'); return depNode; diff --git a/packages/core/core/src/Transformation.js b/packages/core/core/src/Transformation.js index f231e4a25..9016f6945 100644 --- a/packages/core/core/src/Transformation.js +++ b/packages/core/core/src/Transformation.js @@ -121,10 +121,10 @@ export default class Transformation { this.pluginOptions = new PluginOptions( optionsProxy( this.options, - option => { + (option) => { this.invalidations.invalidateOnOptionChange.add(option); }, - devDep => { + (devDep) => { this.pluginDevDeps.push(devDep); }, ), @@ -181,8 +181,8 @@ export default class Transformation { let assets, error; try { let results = await this.runPipelines(pipeline, asset); - await Promise.all(results.map(asset => asset.commit())); - assets = results.map(a => a.value); + await Promise.all(results.map((asset) => asset.commit())); + assets = results.map((a) => a.value); } catch (e) { error = e; } @@ -440,7 +440,7 @@ export default class Transformation { await Promise.all( resultingAssets .filter( - asset => + (asset) => asset.ast != null && !( this.options.mode === 'production' && @@ -448,7 +448,7 @@ export default class Transformation { asset.value.symbols ), ) - .map(async asset => { + .map(async (asset) => { if (asset.isASTDirty && asset.generate) { let output = await asset.generate(); asset.content = output.content; @@ -481,8 +481,8 @@ export default class Transformation { } return { - id: transformers.map(t => t.name).join(':'), - transformers: transformers.map(transformer => ({ + id: transformers.map((t) => t.name).join(':'), + transformers: transformers.map((transformer) => ({ name: transformer.name, resolveFrom: transformer.resolveFrom, config: this.configs.get(transformer.name)?.result, @@ -584,7 +584,7 @@ export default class Transformation { if (result.invalidateOnFileCreate) { this.invalidations.invalidateOnFileCreate.push( - ...result.invalidateOnFileCreate.map(i => + ...result.invalidateOnFileCreate.map((i) => invalidateOnFileCreateToInternal(this.options.projectRoot, i), ), ); @@ -686,7 +686,7 @@ export default class Transformation { assets: Array, ): Promise | null> => { let results = await postProcess.call(transformer, { - assets: assets.map(asset => new MutableAsset(asset)), + assets: assets.map((asset) => new MutableAsset(asset)), config, options: pipeline.pluginOptions, resolve, @@ -695,7 +695,7 @@ export default class Transformation { }); return Promise.all( - results.map(result => + results.map((result) => asset.createChildAsset( result, transformerName, @@ -734,7 +734,7 @@ function normalizeAssets( options, results: Array, ): Array { - return results.map(result => { + return results.map((result) => { if (result instanceof MutableAsset) { return mutableAssetToUncommittedAsset(result); } diff --git a/packages/core/core/src/UncommittedAsset.js b/packages/core/core/src/UncommittedAsset.js index d9daf3a97..29b93a6bb 100644 --- a/packages/core/core/src/UncommittedAsset.js +++ b/packages/core/core/src/UncommittedAsset.js @@ -99,7 +99,7 @@ export default class UncommittedAsset { await Promise.all([ contentKey != null && this.commitContent(contentKey).then( - s => ((size = s.size), (outputHash = s.hash)), + (s) => ((size = s.size), (outputHash = s.hash)), ), this.mapBuffer != null && mapKey != null && @@ -134,7 +134,7 @@ export default class UncommittedAsset { await this.options.cache.setStream( contentKey, content.pipe( - new TapStream(buf => { + new TapStream((buf) => { hash.writeBuffer(buf); size += buf.length; }), diff --git a/packages/core/core/src/Validation.js b/packages/core/core/src/Validation.js index 6741bd54d..8e9dcd271 100644 --- a/packages/core/core/src/Validation.js +++ b/packages/core/core/src/Validation.js @@ -62,7 +62,7 @@ export default class Validation { let pluginOptions = new PluginOptions(this.options); await this.buildAssetsAndValidators(); await Promise.all( - Object.keys(this.allValidators).map(async validatorName => { + Object.keys(this.allValidators).map(async (validatorName) => { let assets = this.allAssets[validatorName]; if (assets) { let plugin = this.allValidators[validatorName]; @@ -76,7 +76,7 @@ export default class Validation { // If the plugin supports the single-threading validateAll method, pass all assets to it. if (plugin.validateAll && this.dedicatedThread) { validatorResults = await plugin.validateAll({ - assets: assets.map(asset => new Asset(asset)), + assets: assets.map((asset) => new Asset(asset)), options: pluginOptions, logger: validatorLogger, tracer: validatorTracer, @@ -96,7 +96,7 @@ export default class Validation { // Otherwise, pass the assets one-at-a-time else if (plugin.validate && !this.dedicatedThread) { await Promise.all( - assets.map(async input => { + assets.map(async (input) => { let config = null; let publicAsset = new Asset(input); if (plugin.getConfig) { @@ -142,7 +142,7 @@ export default class Validation { async buildAssetsAndValidators() { // Figure out what validators need to be run, and group the assets by the relevant validators. await Promise.all( - this.requests.map(async request => { + this.requests.map(async (request) => { this.report({ type: 'validation', filePath: fromProjectPath(this.options.projectRoot, request.filePath), @@ -169,7 +169,7 @@ export default class Validation { handleResults(validatorResults: Array) { let warnings: Array = []; let errors: Array = []; - validatorResults.forEach(result => { + validatorResults.forEach((result) => { if (result) { warnings.push(...result.warnings); errors.push(...result.errors); diff --git a/packages/core/core/src/applyRuntimes.js b/packages/core/core/src/applyRuntimes.js index 3dee06ae7..46bfc201c 100644 --- a/packages/core/core/src/applyRuntimes.js +++ b/packages/core/core/src/applyRuntimes.js @@ -320,7 +320,7 @@ export default async function applyRuntimes({ let assets = runtimesBundleGraph._graph .getNodeIdsConnectedFrom(nodeId) - .map(assetNodeId => { + .map((assetNodeId) => { let assetNode = nullthrows( runtimesBundleGraph._graph.getNode(assetNodeId), ); @@ -393,7 +393,7 @@ function reconcileNewRuntimes( connections: Array, optionsRef: SharedReference, ) { - let assetGroups = connections.map(t => t.assetGroup); + let assetGroups = connections.map((t) => t.assetGroup); let request = createAssetGraphRequest({ name: 'Runtimes', assetGroups, diff --git a/packages/core/core/src/atlaspack-v3/AtlaspackV3.js b/packages/core/core/src/atlaspack-v3/AtlaspackV3.js index 3340619f1..6e59ab0bd 100644 --- a/packages/core/core/src/atlaspack-v3/AtlaspackV3.js +++ b/packages/core/core/src/atlaspack-v3/AtlaspackV3.js @@ -57,7 +57,7 @@ export class AtlaspackV3 { return [ workers, - tx_worker => { + (tx_worker) => { let worker = new Worker(WORKER_PATH, { workerData: { tx_worker, diff --git a/packages/core/core/src/dumpGraphToGraphViz.js b/packages/core/core/src/dumpGraphToGraphViz.js index 2a0e370e6..84bc199fa 100644 --- a/packages/core/core/src/dumpGraphToGraphViz.js +++ b/packages/core/core/src/dumpGraphToGraphViz.js @@ -82,7 +82,7 @@ export default async function dumpGraphToGraphViz( label = node; } else if (node.assets) { label = `(${nodeId(id)}), (assetIds: ${[...node.assets] - .map(a => { + .map((a) => { let arr = a.filePath.split('/'); return arr[arr.length - 1]; }) diff --git a/packages/core/core/src/loadDotEnv.js b/packages/core/core/src/loadDotEnv.js index 5f846f1fb..cd4b4974d 100644 --- a/packages/core/core/src/loadDotEnv.js +++ b/packages/core/core/src/loadDotEnv.js @@ -26,7 +26,7 @@ export default async function loadEnv( ].filter(Boolean); let envs = await Promise.all( - dotenvFiles.map(async dotenvFile => { + dotenvFiles.map(async (dotenvFile) => { const envPath = await resolveConfig( fs, filePath, diff --git a/packages/core/core/src/public/Asset.js b/packages/core/core/src/public/Asset.js index c7423c5c9..5a2fcdc7b 100644 --- a/packages/core/core/src/public/Asset.js +++ b/packages/core/core/src/public/Asset.js @@ -162,7 +162,7 @@ class BaseAsset { getDependencies(): $ReadOnlyArray { return this.#asset .getDependencies() - .map(dep => getPublicDependency(dep, this.#asset.options)); + .map((dep) => getPublicDependency(dep, this.#asset.options)); } getCode(): Promise { diff --git a/packages/core/core/src/public/Bundle.js b/packages/core/core/src/public/Bundle.js index a7c62a7b6..7f3b250c2 100644 --- a/packages/core/core/src/public/Bundle.js +++ b/packages/core/core/src/public/Bundle.js @@ -155,7 +155,7 @@ export class Bundle implements IBundle { } getEntryAssets(): Array { - return this.#bundle.entryAssetIds.map(id => { + return this.#bundle.entryAssetIds.map((id) => { let assetNode = this.#bundleGraph._graph.getNodeByContentKey(id); invariant(assetNode != null && assetNode.type === 'asset'); return assetFromValue(assetNode.value, this.#options); @@ -177,7 +177,7 @@ export class Bundle implements IBundle { ): ?TContext { return this.#bundleGraph.traverseBundle( this.#bundle, - mapVisitor(node => { + mapVisitor((node) => { if (node.type === 'asset') { return { type: 'asset', @@ -199,7 +199,7 @@ export class Bundle implements IBundle { ): ?TContext { return this.#bundleGraph.traverseAssets( this.#bundle, - mapVisitor(asset => assetFromValue(asset, this.#options), visit), + mapVisitor((asset) => assetFromValue(asset, this.#options), visit), startAsset ? assetToAssetValue(startAsset) : undefined, ); } diff --git a/packages/core/core/src/public/BundleGraph.js b/packages/core/core/src/public/BundleGraph.js index 46cccc752..c37cbd1ff 100644 --- a/packages/core/core/src/public/BundleGraph.js +++ b/packages/core/core/src/public/BundleGraph.js @@ -93,7 +93,7 @@ export default class BundleGraph getIncomingDependencies(asset: IAsset): Array { return this.#graph .getIncomingDependencies(assetToAssetValue(asset)) - .map(dep => getPublicDependency(dep, this.#options)); + .map((dep) => getPublicDependency(dep, this.#options)); } getAssetWithDependency(dep: IDependency): ?IAsset { @@ -108,7 +108,7 @@ export default class BundleGraph getBundleGroupsContainingBundle(bundle: IBundle): Array { return this.#graph .getBundleGroupsContainingBundle(bundleToInternalBundle(bundle)) - .map(bundleGroup => new BundleGroup(bundleGroup, this.#options)); + .map((bundleGroup) => new BundleGroup(bundleGroup, this.#options)); } getReferencedBundles( @@ -117,13 +117,13 @@ export default class BundleGraph ): Array { return this.#graph .getReferencedBundles(bundleToInternalBundle(bundle), opts) - .map(bundle => this.#createBundle(bundle, this.#graph, this.#options)); + .map((bundle) => this.#createBundle(bundle, this.#graph, this.#options)); } getReferencingBundles(bundle: IBundle): Array { return this.#graph .getReferencingBundles(bundleToInternalBundle(bundle)) - .map(bundle => this.#createBundle(bundle, this.#graph, this.#options)); + .map((bundle) => this.#createBundle(bundle, this.#graph, this.#options)); } resolveAsyncDependency( @@ -167,7 +167,7 @@ export default class BundleGraph getDependencies(asset: IAsset): Array { return this.#graph .getDependencies(assetToAssetValue(asset)) - .map(dep => getPublicDependency(dep, this.#options)); + .map((dep) => getPublicDependency(dep, this.#options)); } isAssetReachableFromBundle(asset: IAsset, bundle: IBundle): boolean { @@ -200,13 +200,13 @@ export default class BundleGraph bundleGroupToInternalBundleGroup(bundleGroup), opts, ) - .map(bundle => this.#createBundle(bundle, this.#graph, this.#options)); + .map((bundle) => this.#createBundle(bundle, this.#graph, this.#options)); } getBundles(opts?: {|includeInline: boolean|}): Array { return this.#graph .getBundles(opts) - .map(bundle => this.#createBundle(bundle, this.#graph, this.#options)); + .map((bundle) => this.#createBundle(bundle, this.#graph, this.#options)); } isEntryBundleGroup(bundleGroup: IBundleGroup): boolean { @@ -218,13 +218,13 @@ export default class BundleGraph getChildBundles(bundle: IBundle): Array { return this.#graph .getChildBundles(bundleToInternalBundle(bundle)) - .map(bundle => this.#createBundle(bundle, this.#graph, this.#options)); + .map((bundle) => this.#createBundle(bundle, this.#graph, this.#options)); } getParentBundles(bundle: IBundle): Array { return this.#graph .getParentBundles(bundleToInternalBundle(bundle)) - .map(bundle => this.#createBundle(bundle, this.#graph, this.#options)); + .map((bundle) => this.#createBundle(bundle, this.#graph, this.#options)); } getSymbolResolution( @@ -253,7 +253,7 @@ export default class BundleGraph assetToAssetValue(asset), boundary ? bundleToInternalBundle(boundary) : null, ); - return res.map(e => ({ + return res.map((e) => ({ asset: assetFromValue(e.asset, this.#options), exportSymbol: e.exportSymbol, symbol: e.symbol, @@ -296,7 +296,7 @@ export default class BundleGraph ): ?TContext { return this.#graph.traverseBundles( mapVisitor( - bundle => this.#createBundle(bundle, this.#graph, this.#options), + (bundle) => this.#createBundle(bundle, this.#graph, this.#options), visit, ), startBundle == null ? undefined : bundleToInternalBundle(startBundle), @@ -306,13 +306,13 @@ export default class BundleGraph getBundlesWithAsset(asset: IAsset): Array { return this.#graph .getBundlesWithAsset(assetToAssetValue(asset)) - .map(bundle => this.#createBundle(bundle, this.#graph, this.#options)); + .map((bundle) => this.#createBundle(bundle, this.#graph, this.#options)); } getBundlesWithDependency(dependency: IDependency): Array { return this.#graph .getBundlesWithDependency(dependencyToInternalDependency(dependency)) - .map(bundle => this.#createBundle(bundle, this.#graph, this.#options)); + .map((bundle) => this.#createBundle(bundle, this.#graph, this.#options)); } getUsedSymbols(v: IAsset | IDependency): ?$ReadOnlySet { diff --git a/packages/core/core/src/public/Config.js b/packages/core/core/src/public/Config.js index e3c1dd090..27c7e9416 100644 --- a/packages/core/core/src/public/Config.js +++ b/packages/core/core/src/public/Config.js @@ -86,7 +86,7 @@ export default class PublicConfig implements IConfig { this.#config.devDeps.push({ ...devDep, resolveFrom: toProjectPath(this.#options.projectRoot, devDep.resolveFrom), - additionalInvalidations: devDep.additionalInvalidations?.map(i => ({ + additionalInvalidations: devDep.additionalInvalidations?.map((i) => ({ ...i, resolveFrom: toProjectPath(this.#options.projectRoot, i.resolveFrom), })), diff --git a/packages/core/core/src/public/MutableBundleGraph.js b/packages/core/core/src/public/MutableBundleGraph.js index f699cf6b6..efb597913 100644 --- a/packages/core/core/src/public/MutableBundleGraph.js +++ b/packages/core/core/src/public/MutableBundleGraph.js @@ -55,13 +55,13 @@ export default class MutableBundleGraph addAssetGraphToBundle( asset: IAsset, bundle: IBundle, - shouldSkipDependency?: IDependency => boolean, + shouldSkipDependency?: (IDependency) => boolean, ) { this.#graph.addAssetGraphToBundle( assetToAssetValue(asset), bundleToInternalBundle(bundle), shouldSkipDependency - ? d => shouldSkipDependency(new Dependency(d, this.#options)) + ? (d) => shouldSkipDependency(new Dependency(d, this.#options)) : undefined, ); } @@ -69,13 +69,13 @@ export default class MutableBundleGraph addEntryToBundle( asset: IAsset, bundle: IBundle, - shouldSkipDependency?: IDependency => boolean, + shouldSkipDependency?: (IDependency) => boolean, ) { this.#graph.addEntryToBundle( assetToAssetValue(asset), bundleToInternalBundle(bundle), shouldSkipDependency - ? d => shouldSkipDependency(new Dependency(d, this.#options)) + ? (d) => shouldSkipDependency(new Dependency(d, this.#options)) : undefined, ); } @@ -194,7 +194,7 @@ export default class MutableBundleGraph return Bundle.get(existing.value, this.#graph, this.#options); } - let publicId = getPublicId(bundleId, existing => + let publicId = getPublicId(bundleId, (existing) => this.#bundlePublicIds.has(existing), ); this.#bundlePublicIds.add(publicId); @@ -283,13 +283,13 @@ export default class MutableBundleGraph getDependencyAssets(dependency: IDependency): Array { return this.#graph .getDependencyAssets(dependencyToInternalDependency(dependency)) - .map(asset => assetFromValue(asset, this.#options)); + .map((asset) => assetFromValue(asset, this.#options)); } getBundleGroupsContainingBundle(bundle: IBundle): Array { return this.#graph .getBundleGroupsContainingBundle(bundleToInternalBundle(bundle)) - .map(bundleGroup => new BundleGroup(bundleGroup, this.#options)); + .map((bundleGroup) => new BundleGroup(bundleGroup, this.#options)); } getParentBundlesOfBundleGroup(bundleGroup: IBundleGroup): Array { @@ -297,7 +297,7 @@ export default class MutableBundleGraph .getParentBundlesOfBundleGroup( bundleGroupToInternalBundleGroup(bundleGroup), ) - .map(bundle => Bundle.get(bundle, this.#graph, this.#options)); + .map((bundle) => Bundle.get(bundle, this.#graph, this.#options)); } getTotalSize(asset: IAsset): number { diff --git a/packages/core/core/src/requests/AssetGraphRequest.js b/packages/core/core/src/requests/AssetGraphRequest.js index 109ce8154..3b784363b 100644 --- a/packages/core/core/src/requests/AssetGraphRequest.js +++ b/packages/core/core/src/requests/AssetGraphRequest.js @@ -65,7 +65,7 @@ type RunInput = {| type AssetGraphRequest = {| id: string, +type: typeof requestTypes.asset_graph_request, - run: RunInput => Async, + run: (RunInput) => Async, input: AssetGraphRequestInput, |}; @@ -75,7 +75,7 @@ export default function createAssetGraphRequest( return { type: requestTypes.asset_graph_request, id: requestInput.name, - run: async input => { + run: async (input) => { let prevResult = await input.api.getPreviousResult(); @@ -171,10 +171,10 @@ export class AssetGraphBuilder { this.isSingleChangeRebuild = api .getInvalidSubRequests() - .filter(req => req.requestType === 'asset_request').length === 1; + .filter((req) => req.requestType === 'asset_request').length === 1; this.queue = new PromiseQueue(); - assetGraph.onNodeRemoved = nodeId => { + assetGraph.onNodeRemoved = (nodeId) => { this.assetGroupsWithRemovedParents.delete(nodeId); // This needs to mark all connected nodes that doesn't become orphaned @@ -365,13 +365,13 @@ export class AssetGraphBuilder { // also consider it not lazy (so it gets marked as requested). const relativePath = fromProjectPathRelative(node.value.filePath); if (this.lazyIncludes.length > 0) { - isNodeLazy = this.lazyIncludes.some(lazyIncludeRegex => + isNodeLazy = this.lazyIncludes.some((lazyIncludeRegex) => relativePath.match(lazyIncludeRegex), ); } // Excludes override includes, so a node is _not_ lazy if it is included in the exclude list. if (this.lazyExcludes.length > 0 && isNodeLazy) { - isNodeLazy = !this.lazyExcludes.some(lazyExcludeRegex => + isNodeLazy = !this.lazyExcludes.some((lazyExcludeRegex) => relativePath.match(lazyExcludeRegex), ); } @@ -381,7 +381,7 @@ export class AssetGraphBuilder { } else if (!node.requested) { let isAsyncChild = this.assetGraph .getIncomingDependencies(node.value) - .every(dep => dep.isEntry || dep.priority !== Priority.sync); + .every((dep) => dep.isEntry || dep.priority !== Priority.sync); if (isAsyncChild) { node.requested = !isNodeLazy; } else { @@ -456,7 +456,7 @@ export class AssetGraphBuilder { ); } return this.queue.add(() => - promise.then(null, error => errors.push(error)), + promise.then(null, (error) => errors.push(error)), ); } @@ -464,7 +464,7 @@ export class AssetGraphBuilder { let prevEntries = this.assetGraph.safeToIncrementallyBundle ? this.assetGraph .getEntryAssets() - .map(asset => asset.id) + .map((asset) => asset.id) .sort() : []; @@ -480,7 +480,7 @@ export class AssetGraphBuilder { if (this.assetGraph.safeToIncrementallyBundle) { let currentEntries = this.assetGraph .getEntryAssets() - .map(asset => asset.id) + .map((asset) => asset.id) .sort(); let didEntriesChange = prevEntries.length !== currentEntries.length || diff --git a/packages/core/core/src/requests/AssetGraphRequestRust.js b/packages/core/core/src/requests/AssetGraphRequestRust.js index 9d782e8d2..a7533e47e 100644 --- a/packages/core/core/src/requests/AssetGraphRequestRust.js +++ b/packages/core/core/src/requests/AssetGraphRequestRust.js @@ -25,17 +25,17 @@ type RunInput = {| type AssetGraphRequest = {| id: string, +type: typeof requestTypes.asset_graph_request, - run: RunInput => Async, + run: (RunInput) => Async, input: AssetGraphRequestInput, |}; export function createAssetGraphRequestRust( rustAtlaspack: AtlaspackV3, ): (input: AssetGraphRequestInput) => AssetGraphRequest { - return input => ({ + return (input) => ({ type: requestTypes.asset_graph_request, id: input.name, - run: async input => { + run: async (input) => { let options = input.options; let serializedAssetGraph; try { diff --git a/packages/core/core/src/requests/AssetRequest.js b/packages/core/core/src/requests/AssetRequest.js index a9048071b..8f41b0b86 100644 --- a/packages/core/core/src/requests/AssetRequest.js +++ b/packages/core/core/src/requests/AssetRequest.js @@ -84,8 +84,8 @@ async function run({input, api, farm, invalidateReason, options}) { await Promise.all( api .getSubRequests() - .filter(req => req.requestType === requestTypes.dev_dep_request) - .map(async req => [ + .filter((req) => req.requestType === requestTypes.dev_dep_request) + .map(async (req) => [ req.id, nullthrows(await api.getRequestResult(req.id)), ]), @@ -112,7 +112,7 @@ async function run({input, api, farm, invalidateReason, options}) { specifier: req.specifier, resolveFrom: req.resolveFrom, }, - ...(req.additionalInvalidations ?? []).map(i => ({ + ...(req.additionalInvalidations ?? []).map((i) => ({ specifier: i.specifier, resolveFrom: i.resolveFrom, })), diff --git a/packages/core/core/src/requests/AtlaspackConfigRequest.js b/packages/core/core/src/requests/AtlaspackConfigRequest.js index 8955fd7a0..c8a51748b 100644 --- a/packages/core/core/src/requests/AtlaspackConfigRequest.js +++ b/packages/core/core/src/requests/AtlaspackConfigRequest.js @@ -469,7 +469,9 @@ export async function processConfigChain( if (errors.length > 0) { throw new ThrowableDiagnostic({ - diagnostic: errors.flatMap(e => e.diagnostics ?? errorToDiagnostic(e)), + diagnostic: errors.flatMap( + (e) => e.diagnostics ?? errorToDiagnostic(e), + ), }); } } @@ -641,7 +643,7 @@ export function getResolveFrom( function assertPurePipeline( pipeline: ExtendableAtlaspackConfigPipeline, ): PureAtlaspackConfigPipeline { - return pipeline.map(s => { + return pipeline.map((s) => { invariant(typeof s !== 'string'); return s; }); @@ -655,7 +657,7 @@ export function mergePipelines( return base ?? []; } - if (ext.filter(v => v === '...').length > 1) { + if (ext.filter((v) => v === '...').length > 1) { throw new Error( 'Only one spread element can be included in a config pipeline', ); diff --git a/packages/core/core/src/requests/BundleGraphRequest.js b/packages/core/core/src/requests/BundleGraphRequest.js index 671c7ae93..d96d12ffb 100644 --- a/packages/core/core/src/requests/BundleGraphRequest.js +++ b/packages/core/core/src/requests/BundleGraphRequest.js @@ -82,7 +82,7 @@ export type BundleGraphResult = {| type BundleGraphRequest = {| id: string, +type: typeof requestTypes.bundle_graph_request, - run: RunInput => Async, + run: (RunInput) => Async, input: BundleGraphRequestInput, |}; @@ -92,7 +92,7 @@ export default function createBundleGraphRequest( return { type: requestTypes.bundle_graph_request, id: 'BundleGraph', - run: async input => { + run: async (input) => { let {options, api, invalidateReason} = input; let {optionsRef, requestedAssetIds, signal} = input.input; let measurement = tracer.createMeasurement('building'); @@ -146,7 +146,7 @@ export default function createBundleGraphRequest( Boolean(invalidateReason & OPTION_CHANGE) || input.api .getSubRequests() - .some(req => !input.api.canSkipSubrequest(req.id)); + .some((req) => !input.api.canSkipSubrequest(req.id)); if (subRequestsInvalid) { assetGraph.safeToIncrementallyBundle = false; @@ -342,7 +342,7 @@ class BundlerRunner { if (tracer.enabled) { measurementFilename = graph .getEntryAssets() - .map(asset => fromProjectPathRelative(asset.filePath)) + .map((asset) => fromProjectPathRelative(asset.filePath)) .join(', '); measurement = tracer.createMeasurement( plugin.name, @@ -440,7 +440,7 @@ class BundlerRunner { // can match them to the correct packager/optimizer plugins. let bundles = internalBundleGraph.getBundles({includeInline: true}); await Promise.all( - bundles.map(bundle => + bundles.map((bundle) => this.nameBundle(namers, bundle, internalBundleGraph), ), ); @@ -502,7 +502,7 @@ class BundlerRunner { validateBundles(bundleGraph: InternalBundleGraph): void { let bundles = bundleGraph.getBundles(); - let bundleNames = bundles.map(b => + let bundleNames = bundles.map((b) => joinProjectPath(b.target.distDir, nullthrows(b.name)), ); assert.deepEqual( diff --git a/packages/core/core/src/requests/ConfigRequest.js b/packages/core/core/src/requests/ConfigRequest.js index 33fbb6109..fc8665cb4 100644 --- a/packages/core/core/src/requests/ConfigRequest.js +++ b/packages/core/core/src/requests/ConfigRequest.js @@ -90,7 +90,7 @@ export async function loadPluginConfig( config.result = await loadConfig({ config: new PublicConfig(config, options), options: new PluginOptions( - optionsProxy(options, option => { + optionsProxy(options, (option) => { config.invalidateOnOptionChange.add(option); }), ), @@ -231,7 +231,7 @@ export async function getConfigHash( if (config.invalidateOnFileChange.size > 0) { hash.writeString( await getInvalidationHash( - [...config.invalidateOnFileChange].map(filePath => ({ + [...config.invalidateOnFileChange].map((filePath) => ({ type: 'file', filePath, })), @@ -262,7 +262,7 @@ export function getConfigRequests( configs: Array, ): Array { return configs - .filter(config => { + .filter((config) => { // No need to send to the graph if there are no invalidations. return ( config.invalidateOnFileChange.size > 0 || @@ -274,7 +274,7 @@ export function getConfigRequests( config.invalidateOnBuild ); }) - .map(config => ({ + .map((config) => ({ id: config.id, invalidateOnFileChange: config.invalidateOnFileChange, invalidateOnConfigKeyChange: config.invalidateOnConfigKeyChange, diff --git a/packages/core/core/src/requests/DevDepRequest.js b/packages/core/core/src/requests/DevDepRequest.js index e7e2a9723..035face41 100644 --- a/packages/core/core/src/requests/DevDepRequest.js +++ b/packages/core/core/src/requests/DevDepRequest.js @@ -71,14 +71,14 @@ export async function createDevDependency( let invalidateOnFileChangeProject = [ ...invalidations.invalidateOnFileChange, - ].map(f => toProjectPath(options.projectRoot, f)); + ].map((f) => toProjectPath(options.projectRoot, f)); // It is possible for a transformer to have multiple different hashes due to // different dependencies (e.g. conditional requires) so we must always // recompute the hash and compare rather than only sending a transformer // dev dependency once. hash = await getInvalidationHash( - invalidateOnFileChangeProject.map(f => ({ + invalidateOnFileChangeProject.map((f) => ({ type: 'file', filePath: f, })), @@ -89,7 +89,7 @@ export async function createDevDependency( specifier, resolveFrom, hash, - invalidateOnFileCreate: invalidations.invalidateOnFileCreate.map(i => + invalidateOnFileCreate: invalidations.invalidateOnFileCreate.map((i) => invalidateOnFileCreateToInternal(options.projectRoot, i), ), invalidateOnFileChange: new Set(invalidateOnFileChangeProject), @@ -118,8 +118,8 @@ export async function getDevDepRequests( await Promise.all( api .getSubRequests() - .filter(req => req.requestType === requestTypes.dev_dep_request) - .map(async req => [ + .filter((req) => req.requestType === requestTypes.dev_dep_request) + .map(async (req) => [ req.id, nullthrows(await api.getRequestResult(req.id)), ]), @@ -144,7 +144,7 @@ export async function getDevDepRequests( specifier: req.specifier, resolveFrom: req.resolveFrom, }, - ...(req.additionalInvalidations ?? []).map(i => ({ + ...(req.additionalInvalidations ?? []).map((i) => ({ specifier: i.specifier, resolveFrom: i.resolveFrom, })), @@ -232,7 +232,7 @@ const pluginCache = createBuildCache(); export function getWorkerDevDepRequests( devDepRequests: Array, ): Array { - return devDepRequests.map(devDepRequest => { + return devDepRequests.map((devDepRequest) => { // If we've already sent a matching transformer + hash to the main thread during this build, // there's no need to repeat ourselves. let {specifier, resolveFrom, hash} = devDepRequest; diff --git a/packages/core/core/src/requests/EntryRequest.js b/packages/core/core/src/requests/EntryRequest.js index 59ed3694a..429ad5b25 100644 --- a/packages/core/core/src/requests/EntryRequest.js +++ b/packages/core/core/src/requests/EntryRequest.js @@ -121,7 +121,7 @@ async function assertFile( ]), }, ], - hints: alternatives.map(r => { + hints: alternatives.map((r) => { return md`Did you mean '__${r}__'?`; }), }, @@ -174,7 +174,7 @@ export class EntryResolver { onlyFiles: false, }); let results = await Promise.all( - files.map(f => this.resolveEntry(path.normalize(f))), + files.map((f) => this.resolveEntry(path.normalize(f))), ); return results.reduce( (p, res) => ({ diff --git a/packages/core/core/src/requests/TargetRequest.js b/packages/core/core/src/requests/TargetRequest.js index fbc0a1c00..3964cab50 100644 --- a/packages/core/core/src/requests/TargetRequest.js +++ b/packages/core/core/src/requests/TargetRequest.js @@ -225,14 +225,14 @@ export class TargetResolver { // Only build the intersection of the exclusive target and option targets. if (exclusiveTarget != null) { optionTargets = optionTargets.filter( - target => target === exclusiveTarget, + (target) => target === exclusiveTarget, ); } // If an array of strings is passed, it's a filter on the resolved package // targets. Load them, and find the matching targets. targets = optionTargets - .map(target => { + .map((target) => { // null means skipped. if (!packageTargets.has(target)) { throw new ThrowableDiagnostic({ @@ -326,7 +326,8 @@ export class TargetResolver { return target; }) .filter( - target => !skipTarget(target.name, exclusiveTarget, target.source), + (target) => + !skipTarget(target.name, exclusiveTarget, target.source), ); } @@ -387,7 +388,7 @@ export class TargetResolver { } else { targets = Array.from(packageTargets.values()) .filter(Boolean) - .filter(descriptor => { + .filter((descriptor) => { return ( descriptor && !skipTarget(descriptor.name, exclusiveTarget, descriptor.source) @@ -920,7 +921,7 @@ export class TargetResolver { } let customTargets = (Object.keys(pkgTargets): Array).filter( - targetName => !COMMON_TARGETS[targetName], + (targetName) => !COMMON_TARGETS[targetName], ); // Custom targets @@ -1377,7 +1378,7 @@ function assertNoDuplicateTargets(options, targets, pkgFilePath, pkgContents) { code: pkgContents, codeHighlights: generateJSONCodeHighlights( pkgContents, - targetNames.map(t => ({ + targetNames.map((t) => ({ key: `/${t}`, type: 'value', })), @@ -1580,7 +1581,7 @@ async function debugResolvedTargets(input, targets, targetInfo, options) { includeNodeModules = 'only ' + listFormat.format( - target.env.includeNodeModules.map(m => JSON.stringify(m)), + target.env.includeNodeModules.map((m) => JSON.stringify(m)), ); } else if ( target.env.includeNodeModules && @@ -1595,7 +1596,7 @@ async function debugResolvedTargets(input, targets, targetInfo, options) { ); } - let format = v => (v.message != null ? md.italic(v.message) : ''); + let format = (v) => (v.message != null ? md.italic(v.message) : ''); logger.verbose({ origin: '@atlaspack/core', message: md`**Target** "${target.name}" diff --git a/packages/core/core/src/requests/ValidationRequest.js b/packages/core/core/src/requests/ValidationRequest.js index 6ace75c1b..e1464cb4a 100644 --- a/packages/core/core/src/requests/ValidationRequest.js +++ b/packages/core/core/src/requests/ValidationRequest.js @@ -43,13 +43,13 @@ export default function createValidationRequest( ); let config = new AtlaspackConfig(processedConfig, options); - let trackedRequestsDesc = assetRequests.filter(request => { + let trackedRequestsDesc = assetRequests.filter((request) => { return config.getValidatorNames(request.filePath).length > 0; }); // Schedule validations on workers for all plugins that implement the one-asset-at-a-time "validate" method. let promises = trackedRequestsDesc.map( - async request => + async (request) => ((await farm.createHandle('runValidate'))({ requests: [request], optionsRef: optionsRef, diff --git a/packages/core/core/src/requests/WriteBundleRequest.js b/packages/core/core/src/requests/WriteBundleRequest.js index ac9cccd89..ae54fcc5f 100644 --- a/packages/core/core/src/requests/WriteBundleRequest.js +++ b/packages/core/core/src/requests/WriteBundleRequest.js @@ -139,7 +139,7 @@ async function run({input, options, api}) { } let size = 0; contentStream = contentStream.pipe( - new TapStream(buf => { + new TapStream((buf) => { size += buf.length; }), ); @@ -272,7 +272,7 @@ async function runCompressor( filePath + (res.type != null ? '.' + res.type : ''), writeOptions, ), - err => { + (err) => { if (err) reject(err); else resolve(); }, @@ -355,8 +355,8 @@ function cloneStream(readable) { let res = new Readable(); // $FlowFixMe res._read = () => {}; - readable.on('data', chunk => res.push(chunk)); + readable.on('data', (chunk) => res.push(chunk)); readable.on('end', () => res.push(null)); - readable.on('error', err => res.emit('error', err)); + readable.on('error', (err) => res.emit('error', err)); return res; } diff --git a/packages/core/core/src/requests/WriteBundlesRequest.js b/packages/core/core/src/requests/WriteBundlesRequest.js index 80df90480..e182c53c4 100644 --- a/packages/core/core/src/requests/WriteBundlesRequest.js +++ b/packages/core/core/src/requests/WriteBundlesRequest.js @@ -63,7 +63,7 @@ async function run({input, api, farm, options}) { |} = {}; let writeEarlyPromises = {}; let hashRefToNameHash = new Map(); - let bundles = bundleGraph.getBundles().filter(bundle => { + let bundles = bundleGraph.getBundles().filter((bundle) => { // Do not package and write placeholder bundles to disk. We just // need to update the name so other bundles can reference it. if (bundle.isPlaceholder) { @@ -91,12 +91,12 @@ async function run({input, api, farm, options}) { // This avoids the cost of serializing the bundle graph for single file change builds. let useMainThread = bundles.length === 1 || - bundles.filter(b => !api.canSkipSubrequest(bundleGraph.getHash(b))) + bundles.filter((b) => !api.canSkipSubrequest(bundleGraph.getHash(b))) .length === 1; try { await Promise.all( - bundles.map(async bundle => { + bundles.map(async (bundle) => { let request = createPackageRequest({ bundle, bundleGraph, @@ -142,7 +142,7 @@ async function run({input, api, farm, options}) { ); assignComplexNameHashes(hashRefToNameHash, bundles, bundleInfoMap, options); await Promise.all( - bundles.map(bundle => { + bundles.map((bundle) => { let promise = writeEarlyPromises[bundle.id] ?? api.runRequest( @@ -154,7 +154,7 @@ async function run({input, api, farm, options}) { }), ); - return promise.then(r => res.set(bundle.id, r)); + return promise.then((r) => res.set(bundle.id, r)); }), ); @@ -180,7 +180,7 @@ function assignComplexNameHashes( options.shouldContentHash ? hashString( [...getBundlesIncludedInHash(bundle.id, bundleInfoMap)] - .map(bundleId => bundleInfoMap[bundleId].hash) + .map((bundleId) => bundleInfoMap[bundleId].hash) .join(':'), ).slice(-8) : bundle.id.slice(-8), diff --git a/packages/core/core/src/requests/asset-graph-diff.js b/packages/core/core/src/requests/asset-graph-diff.js index 2bddd9b7f..637a284e2 100644 --- a/packages/core/core/src/requests/asset-graph-diff.js +++ b/packages/core/core/src/requests/asset-graph-diff.js @@ -49,12 +49,12 @@ function compactDeep( }); return copy; } else if (Array.isArray(obj)) { - return obj.map(v => compactDeep(v, ignoredPatterns, `${currentPath}[]`)); + return obj.map((v) => compactDeep(v, ignoredPatterns, `${currentPath}[]`)); } else if (typeof obj === 'object') { const copy = {}; Object.entries(obj ?? {}).forEach(([key, value]) => { const path = `${currentPath}.${key}`; - if (ignoredPatterns.some(pattern => path.includes(pattern))) { + if (ignoredPatterns.some((pattern) => path.includes(pattern))) { return; } // Equivalent false == null @@ -73,10 +73,10 @@ function compactDeep( } function assetGraphDiff(jsAssetGraph: AssetGraph, rustAssetGraph: AssetGraph) { - const getNodes = graph => { + const getNodes = (graph) => { let nodes = {}; - graph.traverse(nodeId => { + graph.traverse((nodeId) => { let node: AssetGraphNode | null = graph.getNode(nodeId) ?? null; if (!node) return; diff --git a/packages/core/core/src/resolveOptions.js b/packages/core/core/src/resolveOptions.js index 071960b0f..f2649c94f 100644 --- a/packages/core/core/src/resolveOptions.js +++ b/packages/core/core/src/resolveOptions.js @@ -42,7 +42,7 @@ function generateInstanceId(entries: Array): string { // Compiles an array of globs to regex - used for lazy include/excludes function compileGlobs(globs: string[]): RegExp[] { - return globs.map(glob => globToRegex(glob)); + return globs.map((glob) => globToRegex(glob)); } export default async function resolveOptions( @@ -58,7 +58,7 @@ export default async function resolveOptions( if (initialOptions.entries == null || initialOptions.entries === '') { entries = []; } else if (Array.isArray(initialOptions.entries)) { - entries = initialOptions.entries.map(entry => + entries = initialOptions.entries.map((entry) => path.resolve(inputCwd, entry), ); } else { @@ -202,7 +202,7 @@ export default async function resolveOptions( watchDir, watchBackend: initialOptions.watchBackend, watchIgnore: initialOptions.watchIgnore, - entries: entries.map(e => toProjectPath(projectRoot, e)), + entries: entries.map((e) => toProjectPath(projectRoot, e)), targets: initialOptions.targets, logLevel: initialOptions.logLevel ?? 'info', projectRoot, diff --git a/packages/core/core/src/serializer.js b/packages/core/core/src/serializer.js index b93fc71b1..735df97d7 100644 --- a/packages/core/core/src/serializer.js +++ b/packages/core/core/src/serializer.js @@ -166,7 +166,7 @@ export function prepareForSerialization(object: any): any { return mapObject( object, - value => { + (value) => { // Add a $$type property with the name of this class, if any is registered. if ( value && @@ -201,7 +201,7 @@ export function prepareForSerialization(object: any): any { } export function restoreDeserializedObject(object: any): any { - return mapObject(object, value => { + return mapObject(object, (value) => { // If the value has a $$type property, use it to restore the object type if (value && value.$$type) { let ctor = nameToCtor.get(value.$$type); diff --git a/packages/core/core/src/serializerCore.browser.js b/packages/core/core/src/serializerCore.browser.js index e58733081..dfb4bf58e 100644 --- a/packages/core/core/src/serializerCore.browser.js +++ b/packages/core/core/src/serializerCore.browser.js @@ -4,5 +4,6 @@ import * as msgpackr from 'msgpackr'; let encoder = new msgpackr.Encoder({structuredClone: true}); -export let serializeRaw: any => Buffer = v => Buffer.from(encoder.encode(v)); -export let deserializeRaw: Buffer => any = v => encoder.decode(v); +export let serializeRaw: (any) => Buffer = (v) => + Buffer.from(encoder.encode(v)); +export let deserializeRaw: (Buffer) => any = (v) => encoder.decode(v); diff --git a/packages/core/core/src/serializerCore.js b/packages/core/core/src/serializerCore.js index 67ddc94c0..66c1a97a9 100644 --- a/packages/core/core/src/serializerCore.js +++ b/packages/core/core/src/serializerCore.js @@ -1,5 +1,5 @@ // @flow import v8 from 'v8'; -export let serializeRaw: any => Buffer = v8.serialize; -export let deserializeRaw: Buffer => any = v8.deserialize; +export let serializeRaw: (any) => Buffer = v8.serialize; +export let deserializeRaw: (Buffer) => any = v8.deserialize; diff --git a/packages/core/core/src/utils.js b/packages/core/core/src/utils.js index cc3dd308f..bc1626dcf 100644 --- a/packages/core/core/src/utils.js +++ b/packages/core/core/src/utils.js @@ -40,7 +40,7 @@ export class BuildAbortError extends Error { export function getPublicId( id: string, - alreadyExists: string => boolean, + alreadyExists: (string) => boolean, ): string { let encoded = base62.encode(Buffer.from(id, 'hex')); for (let end = 5; end <= encoded.length; end++) { @@ -74,7 +74,7 @@ const ignoreOptions = new Set([ export function optionsProxy( options: AtlaspackOptions, - invalidateOnOptionChange: string => void, + invalidateOnOptionChange: (string) => void, addDevDependency?: (devDep: InternalDevDepOptions) => void, ): AtlaspackOptions { let packageManager = addDevDependency diff --git a/packages/core/core/test/AtlaspackConfigRequest.test.js b/packages/core/core/test/AtlaspackConfigRequest.test.js index 3f5f488b8..dd6ff7baf 100644 --- a/packages/core/core/test/AtlaspackConfigRequest.test.js +++ b/packages/core/core/test/AtlaspackConfigRequest.test.js @@ -133,7 +133,7 @@ describe('AtlaspackConfigRequest', () => { '.parcelrc', ); }, - e => { + (e) => { assert.strictEqual( e.diagnostics[0].codeFrames[0].codeHighlights[0].message, `Possible values: "$schema", "bundler", "resolvers", "transformers", "validators", "namers", "packagers", "optimizers", "compressors", "reporters", "runtimes", "filePath", "resolveFrom"`, diff --git a/packages/core/core/test/BundleGraph.test.js b/packages/core/core/test/BundleGraph.test.js index 47b2a8fc0..196c7d221 100644 --- a/packages/core/core/test/BundleGraph.test.js +++ b/packages/core/core/test/BundleGraph.test.js @@ -29,7 +29,7 @@ describe('BundleGraph', () => { false, ); assert.deepEqual( - getAssets(bundleGraph).map(a => bundleGraph.getAssetPublicId(a)), + getAssets(bundleGraph).map((a) => bundleGraph.getAssetPublicId(a)), ['296TI', '4DGUq'], ); }); @@ -40,7 +40,7 @@ describe('BundleGraph', () => { false, ); assert.deepEqual( - getAssets(bundleGraph).map(a => bundleGraph.getAssetPublicId(a)), + getAssets(bundleGraph).map((a) => bundleGraph.getAssetPublicId(a)), ['296TI', '296TII'], ); }); @@ -48,7 +48,7 @@ describe('BundleGraph', () => { function getAssets(bundleGraph) { let assets = []; - bundleGraph.traverse(node => { + bundleGraph.traverse((node) => { if (node.type === 'asset') { assets.push(node.value); } diff --git a/packages/core/core/test/PublicMutableBundleGraph.test.js b/packages/core/core/test/PublicMutableBundleGraph.test.js index c40430d4e..2471a4921 100644 --- a/packages/core/core/test/PublicMutableBundleGraph.test.js +++ b/packages/core/core/test/PublicMutableBundleGraph.test.js @@ -38,7 +38,7 @@ describe('PublicMutableBundleGraph', () => { DEFAULT_OPTIONS, ); - mutableBundleGraph.traverse(node => { + mutableBundleGraph.traverse((node) => { if ( node.type === 'dependency' && mutableBundleGraph.getResolvedAsset(node.value) @@ -59,7 +59,7 @@ describe('PublicMutableBundleGraph', () => { }); assert.deepEqual( - internalBundleGraph.getBundles().map(b => b.publicId), + internalBundleGraph.getBundles().map((b) => b.publicId), ['8LVYC', 'd7Pd5'], ); }); diff --git a/packages/core/core/test/RequestTracker.test.js b/packages/core/core/test/RequestTracker.test.js index 3b5778997..d0e2c0a49 100644 --- a/packages/core/core/test/RequestTracker.test.js +++ b/packages/core/core/test/RequestTracker.test.js @@ -82,7 +82,7 @@ describe('RequestTracker', () => { assert( tracker .getInvalidRequests() - .map(req => req.id) + .map((req) => req.id) .includes('abc'), ); }); @@ -105,7 +105,7 @@ describe('RequestTracker', () => { assert( tracker .getInvalidRequests() - .map(req => req.id) + .map((req) => req.id) .includes('abc'), ); }); @@ -184,7 +184,7 @@ describe('RequestTracker', () => { assert( tracker .getInvalidRequests() - .map(req => req.id) + .map((req) => req.id) .includes('abc'), ); }); @@ -469,7 +469,8 @@ root --- node1 --- node2 ----------- orphan1 --- orphan2 */ - const getNonNullNodes = graph => graph.nodes.filter(node => node != null); + const getNonNullNodes = (graph) => + graph.nodes.filter((node) => node != null); graph.addEdge(root, node1); graph.addEdge(node1, node2); diff --git a/packages/core/core/test/SymbolPropagation.test.js b/packages/core/core/test/SymbolPropagation.test.js index 72e87a756..111dc9c00 100644 --- a/packages/core/core/test/SymbolPropagation.test.js +++ b/packages/core/core/test/SymbolPropagation.test.js @@ -191,14 +191,14 @@ function assertUsedSymbols( _expectedDependency.map(([from, to, sym]) => [ from + ':' + to, // $FlowFixMe[invalid-tuple-index] - sym ? sym.map(v => [v[0], v[1] ?? [to, v[0]]]) : sym, + sym ? sym.map((v) => [v[0], v[1] ?? [to, v[0]]]) : sym, ]), ); if (isLibrary) { let entryDep = nullthrows( [...graph.nodes.values()].find( - n => n?.type === 'dependency' && n.value.sourceAssetId == null, + (n) => n?.type === 'dependency' && n.value.sourceAssetId == null, ), ); invariant(entryDep.type === 'dependency'); @@ -374,13 +374,13 @@ function changeDependency( ): Iterable<[ContentKey, Asset]> { let sourceAssetNode = nullthrowsAssetNode( [...graph.nodes.values()].find( - n => n?.type === 'asset' && n.value.filePath === from, + (n) => n?.type === 'asset' && n.value.filePath === from, ), ); sourceAssetNode.usedSymbolsDownDirty = true; let depNode = nullthrowsDependencyNode( [...graph.nodes.values()].find( - n => + (n) => n?.type === 'dependency' && n.value.sourcePath === from && n.value.specifier === to, @@ -397,7 +397,7 @@ function changeAsset( ): Iterable<[ContentKey, Asset]> { let node = nullthrowsAssetNode( [...graph.nodes.values()].find( - n => n?.type === 'asset' && n.value.filePath === asset, + (n) => n?.type === 'asset' && n.value.filePath === asset, ), ); node.usedSymbolsUpDirty = true; @@ -440,7 +440,7 @@ describe('SymbolPropagation', () => { ); let changedAssets = [ - ...changeDependency(graph, 'index.js', '/lib.js', symbols => { + ...changeDependency(graph, 'index.js', '/lib.js', (symbols) => { symbols.set('b', { local: 'b', isWeak: false, @@ -480,7 +480,7 @@ describe('SymbolPropagation', () => { ); let changedAssets = [ - ...changeDependency(graph, 'index.js', '/lib.js', symbols => { + ...changeDependency(graph, 'index.js', '/lib.js', (symbols) => { symbols.delete('f'); symbols.set('f2', { local: 'f2', @@ -523,7 +523,7 @@ describe('SymbolPropagation', () => { ); let changedAssets = [ - ...changeAsset(graph, 'lib.js', symbols => { + ...changeAsset(graph, 'lib.js', (symbols) => { symbols.delete('f'); symbols.set('f2', { local: 'f2', @@ -570,7 +570,7 @@ describe('SymbolPropagation', () => { ); let changedAssets = [ - ...changeDependency(graph, 'index.js', '/lib.js', symbols => { + ...changeDependency(graph, 'index.js', '/lib.js', (symbols) => { symbols.set('b', { local: 'b', isWeak: false, diff --git a/packages/core/core/test/requests/ConfigRequest.test.js b/packages/core/core/test/requests/ConfigRequest.test.js index d134b9ff0..0827a4979 100644 --- a/packages/core/core/test/requests/ConfigRequest.test.js +++ b/packages/core/core/test/requests/ConfigRequest.test.js @@ -48,7 +48,7 @@ describe('ConfigRequest tests', () => { invalidateOnFileUpdate: sinon.spy(), invalidateOnOptionChange: sinon.spy(), invalidateOnStartup: sinon.spy(), - runRequest: sinon.spy(request => { + runRequest: sinon.spy((request) => { return request.run({ api: mockRunApi, options, diff --git a/packages/core/core/test/utils.test.js b/packages/core/core/test/utils.test.js index 5d7e675ac..d7c80486b 100644 --- a/packages/core/core/test/utils.test.js +++ b/packages/core/core/test/utils.test.js @@ -28,7 +28,7 @@ describe('getPublicId', () => { it('uses more characters if there is a collision', () => { assert.equal( - getPublicId(id, publicId => + getPublicId(id, (publicId) => [fullPublicId.slice(0, 5), fullPublicId.slice(0, 6)].includes(publicId), ), fullPublicId.slice(0, 7), diff --git a/packages/core/diagnostic/src/diagnostic.js b/packages/core/diagnostic/src/diagnostic.js index bc368db72..773488464 100644 --- a/packages/core/diagnostic/src/diagnostic.js +++ b/packages/core/diagnostic/src/diagnostic.js @@ -114,7 +114,7 @@ export type Diagnostifiable = /** Normalize the given value into a diagnostic. */ export function anyToDiagnostic(input: Diagnostifiable): Array { if (Array.isArray(input)) { - return input.flatMap(e => anyToDiagnostic(e)); + return input.flatMap((e) => anyToDiagnostic(e)); } else if (input instanceof ThrowableDiagnostic) { return input.diagnostics; } else if (input instanceof Error) { @@ -148,7 +148,7 @@ export function errorToDiagnostic( } if (error instanceof ThrowableDiagnostic) { - return error.diagnostics.map(d => { + return error.diagnostics.map((d) => { return { ...d, origin: d.origin ?? defaultValues?.origin ?? 'unknown', diff --git a/packages/core/fs/src/MemoryFS.js b/packages/core/fs/src/MemoryFS.js index 54a82b293..b328febfa 100644 --- a/packages/core/fs/src/MemoryFS.js +++ b/packages/core/fs/src/MemoryFS.js @@ -568,11 +568,13 @@ export class MemoryFS implements FileSystem { async _sendWorkerEvent(event: WorkerEvent) { // Wait for worker instances to register their handles while (this._workerHandles.length < this._numWorkerInstances) { - await new Promise(resolve => this._workerRegisterResolves.push(resolve)); + await new Promise((resolve) => + this._workerRegisterResolves.push(resolve), + ); } await Promise.all( - this._workerHandles.map(workerHandle => + this._workerHandles.map((workerHandle) => this.farm.workerApi.runHandle(workerHandle, [event]), ), ); @@ -618,7 +620,7 @@ export class MemoryFS implements FileSystem { let ignore = opts.ignore; if (ignore) { events = events.filter( - event => !ignore.some(i => event.path.startsWith(i + path.sep)), + (event) => !ignore.some((i) => event.path.startsWith(i + path.sep)), ); } @@ -662,7 +664,7 @@ class Watcher { let ignore = this.options.ignore; if (ignore) { events = events.filter( - event => !ignore.some(i => event.path.startsWith(i + path.sep)), + (event) => !ignore.some((i) => event.path.startsWith(i + path.sep)), ); } @@ -704,12 +706,12 @@ class ReadStream extends Readable { this.reading = true; this.fs.readFile(this.filePath).then( - res => { + (res) => { this.bytesRead += res.byteLength; this.push(res); this.push(null); }, - err => { + (err) => { this.emit('error', err); }, ); @@ -965,7 +967,7 @@ class WorkerFS extends MemoryFS { WorkerFarm.getWorkerApi().runHandle(handle, [methodName, args]); this.handleFn('_registerWorker', [ - WorkerFarm.getWorkerApi().createReverseHandle(event => { + WorkerFarm.getWorkerApi().createReverseHandle((event) => { switch (event.type) { case 'writeFile': this.files.set(event.path, event.entry); diff --git a/packages/core/fs/src/NodeFS.js b/packages/core/fs/src/NodeFS.js index 5c39e72c1..ccab933ce 100644 --- a/packages/core/fs/src/NodeFS.js +++ b/packages/core/fs/src/NodeFS.js @@ -56,9 +56,9 @@ export class NodeFS implements FileSystem { createReadStream: (path: string, options?: any) => ReadStream = fs.createReadStream; cwd: () => string = () => process.cwd(); - chdir: (directory: string) => void = directory => process.chdir(directory); + chdir: (directory: string) => void = (directory) => process.chdir(directory); - statSync: (path: string) => Stats = path => fs.statSync(path); + statSync: (path: string) => Stats = (path) => fs.statSync(path); realpathSync: (path: string, cache?: any) => string = process.platform === 'win32' ? fs.realpathSync : fs.realpathSync.native; existsSync: (path: string) => boolean = fs.existsSync; @@ -118,13 +118,13 @@ export class NodeFS implements FileSystem { fs: { ...fs, close: (fd, cb) => { - fs.close(fd, err => { + fs.close(fd, (err) => { if (err) { cb(err); } else { move().then( () => cb(), - err => cb(err), + (err) => cb(err), ); } }); @@ -168,7 +168,7 @@ export class NodeFS implements FileSystem { } exists(filePath: FilePath): Promise { - return new Promise(resolve => { + return new Promise((resolve) => { fs.exists(filePath, resolve); }); } diff --git a/packages/core/graph/src/AdjacencyList.js b/packages/core/graph/src/AdjacencyList.js index 8d9e6229e..124e04b98 100644 --- a/packages/core/graph/src/AdjacencyList.js +++ b/packages/core/graph/src/AdjacencyList.js @@ -301,7 +301,7 @@ export default class AdjacencyList { // Copy the existing edges into the new array. nodes.nextId = this.#nodes.nextId; this.#edges.forEach( - edge => + (edge) => void link( this.#edges.from(edge), this.#edges.to(edge), @@ -570,7 +570,7 @@ export default class AdjacencyList { | NullEdgeType | Array = 1, ): NodeId[] { - let matches = node => + let matches = (node) => type === ALL_EDGE_TYPES || (Array.isArray(type) ? type.includes(this.#nodes.typeOf(node)) @@ -628,7 +628,7 @@ export default class AdjacencyList { | NullEdgeType | Array = 1, ): NodeId[] { - let matches = node => + let matches = (node) => type === ALL_EDGE_TYPES || (Array.isArray(type) ? type.includes(this.#nodes.typeOf(node)) diff --git a/packages/core/graph/src/Graph.js b/packages/core/graph/src/Graph.js index ab1516a06..b8518321f 100644 --- a/packages/core/graph/src/Graph.js +++ b/packages/core/graph/src/Graph.js @@ -293,7 +293,7 @@ export default class Graph { replaceNodeIdsConnectedTo( fromNodeId: NodeId, toNodeIds: $ReadOnlyArray, - replaceFilter?: null | (NodeId => boolean), + replaceFilter?: null | ((NodeId) => boolean), type?: TEdgeType | NullEdgeType = 1, ): void { this._assertHasNodeId(fromNodeId); @@ -301,7 +301,7 @@ export default class Graph { let outboundEdges = this.getNodeIdsConnectedFrom(fromNodeId, type); let childrenToRemove = new Set( replaceFilter - ? outboundEdges.filter(toNodeId => replaceFilter(toNodeId)) + ? outboundEdges.filter((toNodeId) => replaceFilter(toNodeId)) : outboundEdges, ); for (let toNodeId of toNodeIds) { @@ -337,7 +337,7 @@ export default class Graph { return this.dfs({ visit, startNodeId, - getChildren: nodeId => this.getNodeIdsConnectedFrom(nodeId, type), + getChildren: (nodeId) => this.getNodeIdsConnectedFrom(nodeId, type), }); } } @@ -363,7 +363,7 @@ export default class Graph { return this.dfs({ visit, startNodeId, - getChildren: nodeId => this.getNodeIdsConnectedTo(nodeId, type), + getChildren: (nodeId) => this.getNodeIdsConnectedTo(nodeId, type), }); } @@ -421,7 +421,7 @@ export default class Graph { return context; } - this.adjacencyList.forEachNodeIdConnectedFromReverse(nodeId, child => { + this.adjacencyList.forEachNodeIdConnectedFromReverse(nodeId, (child) => { if (!visited.has(child)) { queue.push({nodeId: child, context}); } @@ -473,12 +473,15 @@ export default class Graph { if (!visited.has(nodeId)) { visited.add(nodeId); - this.adjacencyList.forEachNodeIdConnectedFromReverse(nodeId, child => { - if (!visited.has(child)) { - queue.push(child); - } - return false; - }); + this.adjacencyList.forEachNodeIdConnectedFromReverse( + nodeId, + (child) => { + if (!visited.has(child)) { + queue.push(child); + } + return false; + }, + ); } else { queue.pop(); visit(nodeId, null, actions); @@ -633,7 +636,7 @@ export default class Graph { let sorted: Array = []; this.traverse( { - exit: nodeId => { + exit: (nodeId) => { sorted.push(nodeId); }, }, diff --git a/packages/core/graph/test/AdjacencyList.test.js b/packages/core/graph/test/AdjacencyList.test.js index acef303f3..0c739026d 100644 --- a/packages/core/graph/test/AdjacencyList.test.js +++ b/packages/core/graph/test/AdjacencyList.test.js @@ -289,7 +289,7 @@ describe('AdjacencyList', () => { let originalSerialized = graph.serialize(); let originalNodes = [...originalSerialized.nodes]; let originalEdges = [...originalSerialized.edges]; - let work = new Promise(resolve => worker.on('message', resolve)); + let work = new Promise((resolve) => worker.on('message', resolve)); worker.postMessage(originalSerialized); let received = AdjacencyList.deserialize(await work); // eslint-disable-next-line no-unused-vars diff --git a/packages/core/graph/test/BitSet.test.js b/packages/core/graph/test/BitSet.test.js index 47d77875f..81cc95afd 100644 --- a/packages/core/graph/test/BitSet.test.js +++ b/packages/core/graph/test/BitSet.test.js @@ -5,14 +5,14 @@ import {BitSet} from '../src/BitSet'; function assertValues(set: BitSet, values: Array) { let setValues = []; - set.forEach(bit => { + set.forEach((bit) => { setValues.push(bit); }); for (let value of values) { assert(set.has(value), 'Set.has returned false'); assert( - setValues.some(v => v === value), + setValues.some((v) => v === value), 'Set values is missing value', ); } diff --git a/packages/core/graph/test/Graph.test.js b/packages/core/graph/test/Graph.test.js index 0da87df90..9286d1df9 100644 --- a/packages/core/graph/test/Graph.test.js +++ b/packages/core/graph/test/Graph.test.js @@ -312,7 +312,7 @@ describe('Graph', () => { let visited = []; graph.traverse( - nodeId => { + (nodeId) => { visited.push(nodeId); }, null, // use root as startNode diff --git a/packages/core/integration-tests/test/BundleGraph.js b/packages/core/integration-tests/test/BundleGraph.js index 474f624f8..90dcba85c 100644 --- a/packages/core/integration-tests/test/BundleGraph.js +++ b/packages/core/integration-tests/test/BundleGraph.js @@ -18,7 +18,7 @@ describe.v2('BundleGraph', () => { ); let assets = []; - b.traverse(node => { + b.traverse((node) => { if (node.type === 'asset') { assets.push({ type: node.type, @@ -120,7 +120,7 @@ describe.v2('BundleGraph', () => { const bundles = bundleGraph.getBundlesInBundleGroup(bundleGroup); assert.deepEqual( - bundles.map(b => b.bundleBehavior), + bundles.map((b) => b.bundleBehavior), [null], ); }); @@ -131,7 +131,7 @@ describe.v2('BundleGraph', () => { }); assert.deepEqual( - bundles.map(b => b.bundleBehavior), + bundles.map((b) => b.bundleBehavior), [null], ); }); @@ -142,7 +142,7 @@ describe.v2('BundleGraph', () => { }); assert.deepEqual( - bundles.map(b => b.bundleBehavior), + bundles.map((b) => b.bundleBehavior), [null, 'inline'], ); }); diff --git a/packages/core/integration-tests/test/babel.js b/packages/core/integration-tests/test/babel.js index 96415877e..b920439dd 100644 --- a/packages/core/integration-tests/test/babel.js +++ b/packages/core/integration-tests/test/babel.js @@ -102,7 +102,7 @@ describe.v2('babel', function () { it('should support compiling with babel using babel.config.json config without warnings', async function () { let messages = []; - let loggerDisposable = Logger.onLog(message => { + let loggerDisposable = Logger.onLog((message) => { if (message.level !== 'verbose') { messages.push(message); } @@ -402,7 +402,7 @@ describe.v2('babel', function () { let distFile = await fs.readFile(path.join(distDir, 'index.js'), 'utf8'); assert(distFile.includes('hello there')); await fs.copyFile(differentPath, configPath); - await new Promise(resolve => setTimeout(resolve, 100)); + await new Promise((resolve) => setTimeout(resolve, 100)); // On Windows only, `fs.utimes` arguments must be instances of `Date`, // otherwise it fails. For Mac instances on Azure CI, using a Date instance // does not update the utime correctly, so for all other platforms, use a @@ -627,7 +627,7 @@ describe.v2('babel', function () { it('should warn when a babel config contains only redundant plugins', async function () { let messages = []; - let loggerDisposable = Logger.onLog(message => { + let loggerDisposable = Logger.onLog((message) => { if (message.level !== 'verbose') { messages.push(message); } @@ -707,7 +707,7 @@ describe.v2('babel', function () { it('should warn when a babel config contains redundant plugins', async function () { let messages = []; - let loggerDisposable = Logger.onLog(message => { + let loggerDisposable = Logger.onLog((message) => { if (message.level !== 'verbose') { messages.push(message); } @@ -765,7 +765,7 @@ describe.v2('babel', function () { it('should warn when a JSON5 babel config contains redundant plugins', async function () { let messages = []; - let loggerDisposable = Logger.onLog(message => { + let loggerDisposable = Logger.onLog((message) => { if (message.level !== 'verbose') { messages.push(message); } diff --git a/packages/core/integration-tests/test/bundler.js b/packages/core/integration-tests/test/bundler.js index e5df79358..181fa3acb 100644 --- a/packages/core/integration-tests/test/bundler.js +++ b/packages/core/integration-tests/test/bundler.js @@ -118,7 +118,7 @@ describe.v2('bundler', function () { yarn.lock:`; let messages = []; - let loggerDisposable = Logger.onLog(message => { + let loggerDisposable = Logger.onLog((message) => { if (message.level !== 'verbose') { messages.push(message); } @@ -203,7 +203,7 @@ describe.v2('bundler', function () { yarn.lock:`; let messages = []; - let loggerDisposable = Logger.onLog(message => { + let loggerDisposable = Logger.onLog((message) => { if (message.level !== 'verbose') { messages.push(message); } @@ -291,7 +291,7 @@ describe.v2('bundler', function () { yarn.lock:`; let messages = []; - let loggerDisposable = Logger.onLog(message => { + let loggerDisposable = Logger.onLog((message) => { if (message.level !== 'verbose') { messages.push(message); } @@ -378,7 +378,7 @@ describe.v2('bundler', function () { yarn.lock:`; let messages = []; - let loggerDisposable = Logger.onLog(message => { + let loggerDisposable = Logger.onLog((message) => { if (message.level !== 'verbose') { messages.push(message); } @@ -490,7 +490,7 @@ describe.v2('bundler', function () { yarn.lock:`; let messages = []; - let loggerDisposable = Logger.onLog(message => { + let loggerDisposable = Logger.onLog((message) => { if (message.level !== 'verbose') { messages.push(message); } @@ -900,12 +900,12 @@ describe.v2('bundler', function () { let aManifestBundle = b .getBundles() .find( - bundle => !bundle.getMainEntry() && bundle.name.includes('runtime'), + (bundle) => !bundle.getMainEntry() && bundle.name.includes('runtime'), ); let bBundles = b .getBundles() - .filter(bundle => /b\.HASH_REF/.test(bundle.name)); + .filter((bundle) => /b\.HASH_REF/.test(bundle.name)); let aBundleManifestAsset; aManifestBundle.traverseAssets((asset, _, {stop}) => { @@ -1257,7 +1257,7 @@ describe.v2('bundler', function () { await run(b); // Asset should not be inlined - const index = b.getBundles().find(b => b.name.startsWith('index')); + const index = b.getBundles().find((b) => b.name.startsWith('index')); const contents = overlayFS.readFileSync(index.filePath, 'utf8'); assert( !contents.includes('async value'), @@ -1586,7 +1586,7 @@ describe.v2('bundler', function () { let targetDistDir = normalizePath(path.join(__dirname, '../dist')); let hashedIdWithMSB = hashString('bundle:' + 'vendor,js' + targetDistDir); assert( - b.getBundles().find(b => b.id == hashedIdWithMSB), + b.getBundles().find((b) => b.id == hashedIdWithMSB), 'MSB id does not match expected', ); }); @@ -1727,7 +1727,7 @@ describe.v2('bundler', function () { let targetDistDir = normalizePath(path.join(__dirname, '../dist')); let hashedIdWithMSB = hashString('bundle:' + 'vendorjs' + targetDistDir); assert( - b.getBundles().find(b => b.id == hashedIdWithMSB), + b.getBundles().find((b) => b.id == hashedIdWithMSB), 'MSB id does not match expected', ); diff --git a/packages/core/integration-tests/test/cache.js b/packages/core/integration-tests/test/cache.js index d33ea73e1..432e393ec 100644 --- a/packages/core/integration-tests/test/cache.js +++ b/packages/core/integration-tests/test/cache.js @@ -44,7 +44,7 @@ let inputDir: string; let packageManager = new NodePackageManager(inputFS, '/'); function getEntries(entries = 'src/index.js') { - return (Array.isArray(entries) ? entries : [entries]).map(entry => + return (Array.isArray(entries) ? entries : [entries]).map((entry) => path.resolve(inputDir, entry), ); } @@ -63,7 +63,7 @@ function runBundle(entries = 'src/index.js', opts) { return bundler(getEntries(entries), getOptions(opts)).run(); } -type UpdateFn = BuildSuccessEvent => +type UpdateFn = (BuildSuccessEvent) => | ?InitialAtlaspackOptions | Promise; type TestConfig = {| @@ -136,7 +136,7 @@ describe.v2('cache', function () { }); it('should support updating a JS file', async function () { - let b = await testCache(async b => { + let b = await testCache(async (b) => { assert.equal(await run(b.bundleGraph), 4); await overlayFS.writeFile( path.join(inputDir, 'src/nested/test.js'), @@ -148,7 +148,7 @@ describe.v2('cache', function () { }); it('should support adding a dependency', async function () { - let b = await testCache(async b => { + let b = await testCache(async (b) => { assert.equal(await run(b.bundleGraph), 4); await overlayFS.writeFile( path.join(inputDir, 'src/nested/foo.js'), @@ -178,8 +178,10 @@ describe.v2('cache', function () { { entries: ['a.html', 'b.html'], mode: 'production', - update: async b => { - let html = b.bundleGraph.getBundles().filter(b => b.type === 'html'); + update: async (b) => { + let html = b.bundleGraph + .getBundles() + .filter((b) => b.type === 'html'); assert.deepEqual(await exec(b.bundleGraph, html[0]), ['a']); assert.deepEqual(await exec(b.bundleGraph, html[1]), ['b']); await overlayFS.writeFile( @@ -195,7 +197,7 @@ describe.v2('cache', function () { 'cache-add-dep-referenced', ); - let html = b.bundleGraph.getBundles().filter(b => b.type === 'html'); + let html = b.bundleGraph.getBundles().filter((b) => b.type === 'html'); assert.deepEqual(await exec(b.bundleGraph, html[0]), ['c', 'a']); assert.deepEqual(await exec(b.bundleGraph, html[1]), ['c', 'b']); }); @@ -231,8 +233,8 @@ describe.v2('cache', function () { }); describe('babel', function () { - let json = config => JSON.stringify(config); - let cjs = config => `module.exports = ${JSON.stringify(config)}`; + let json = (config) => JSON.stringify(config); + let cjs = (config) => `module.exports = ${JSON.stringify(config)}`; // TODO: not sure how to invalidate the ESM cache in node... // let mjs = (config) => `export default ${JSON.stringify(config)}`; let configs = [ @@ -1006,7 +1008,7 @@ describe.v2('cache', function () { describe('parcel config', function () { it('should support adding a .parcelrc', async function () { - let b = await testCache(async b => { + let b = await testCache(async (b) => { assert.equal(await run(b.bundleGraph), 4); let contents = await overlayFS.readFile( @@ -2907,7 +2909,7 @@ describe.v2('cache', function () { describe('resolver', function () { it('should support updating a package.json#main field', async function () { - let b = await testCache(async b => { + let b = await testCache(async (b) => { assert.equal(await run(b.bundleGraph), 4); await overlayFS.writeFile( path.join(inputDir, 'node_modules/foo/test.js'), @@ -2924,7 +2926,7 @@ describe.v2('cache', function () { }); it('should support adding an alias', async function () { - let b = await testCache(async b => { + let b = await testCache(async (b) => { assert.equal(await run(b.bundleGraph), 4); await overlayFS.writeFile( path.join(inputDir, 'node_modules/foo/test.js'), @@ -3016,7 +3018,7 @@ describe.v2('cache', function () { }); it('should support adding an alias in a closer package.json', async function () { - let b = await testCache(async b => { + let b = await testCache(async (b) => { assert.equal(await run(b.bundleGraph), 4); await overlayFS.writeFile( path.join(inputDir, 'src/nested/foo.js'), @@ -3619,7 +3621,7 @@ describe.v2('cache', function () { async update(b) { let css = await overlayFS.readFile( nullthrows( - b.bundleGraph.getBundles().find(b => b.type === 'css') + b.bundleGraph.getBundles().find((b) => b.type === 'css') ?.filePath, ), 'utf8', @@ -3647,7 +3649,7 @@ describe.v2('cache', function () { let css = await overlayFS.readFile( nullthrows( - b.bundleGraph.getBundles().find(b => b.type === 'css')?.filePath, + b.bundleGraph.getBundles().find((b) => b.type === 'css')?.filePath, ), 'utf8', ); @@ -3701,7 +3703,7 @@ describe.v2('cache', function () { let b = await runBundle('index.js'); let css = await overlayFS.readFile( nullthrows( - b.bundleGraph.getBundles().find(b => b.type === 'css')?.filePath, + b.bundleGraph.getBundles().find((b) => b.type === 'css')?.filePath, ), 'utf8', ); @@ -3726,7 +3728,7 @@ describe.v2('cache', function () { async update(b) { let css = await overlayFS.readFile( nullthrows( - b.bundleGraph.getBundles().find(b => b.type === 'css') + b.bundleGraph.getBundles().find((b) => b.type === 'css') ?.filePath, ), 'utf8', @@ -3746,7 +3748,7 @@ describe.v2('cache', function () { let css = await overlayFS.readFile( nullthrows( - b.bundleGraph.getBundles().find(b => b.type === 'css')?.filePath, + b.bundleGraph.getBundles().find((b) => b.type === 'css')?.filePath, ), 'utf8', ); @@ -3774,7 +3776,7 @@ describe.v2('cache', function () { async update(b) { let css = await overlayFS.readFile( nullthrows( - b.bundleGraph.getBundles().find(b => b.type === 'css') + b.bundleGraph.getBundles().find((b) => b.type === 'css') ?.filePath, ), 'utf8', @@ -3793,7 +3795,7 @@ describe.v2('cache', function () { let css = await overlayFS.readFile( nullthrows( - b.bundleGraph.getBundles().find(b => b.type === 'css')?.filePath, + b.bundleGraph.getBundles().find((b) => b.type === 'css')?.filePath, ), 'utf8', ); @@ -3837,7 +3839,7 @@ describe.v2('cache', function () { let b = await runBundle('index.sass'); let css = await overlayFS.readFile( nullthrows( - b.bundleGraph.getBundles().find(b => b.type === 'css')?.filePath, + b.bundleGraph.getBundles().find((b) => b.type === 'css')?.filePath, ), 'utf8', ); @@ -4257,7 +4259,7 @@ describe.v2('cache', function () { path.join(transformerDir, 'constants.js'), 'export const message = "UPDATED"', ); - await new Promise(resolve => setTimeout(resolve, 20)); + await new Promise((resolve) => setTimeout(resolve, 20)); return { workerFarm, }; @@ -4300,7 +4302,7 @@ describe.v2('cache', function () { path.join(dir, 'foo.js'), 'module.exports = 3', ); - await new Promise(resolve => setTimeout(resolve, 20)); + await new Promise((resolve) => setTimeout(resolve, 20)); return { workerFarm, }; @@ -4347,7 +4349,7 @@ describe.v2('cache', function () { path.join(dir, 'data/a.js'), 'export const value = "updated";', ); - await new Promise(resolve => setTimeout(resolve, 20)); + await new Promise((resolve) => setTimeout(resolve, 20)); return { workerFarm, }; @@ -4409,7 +4411,7 @@ describe.v2('cache', function () { path.join(inputDir, 'node_modules', 'foo', 'foo.js'), 'module.exports = 3', ); - await new Promise(resolve => setTimeout(resolve, 20)); + await new Promise((resolve) => setTimeout(resolve, 20)); return { workerFarm, }; @@ -4845,7 +4847,7 @@ describe.v2('cache', function () { it('should invalidate when adding a namer plugin', async function () { let b = await testCache({ async update(b) { - let bundles = b.bundleGraph.getBundles().map(b => b.name); + let bundles = b.bundleGraph.getBundles().map((b) => b.name); assert.deepEqual(bundles, ['index.js']); await overlayFS.writeFile( @@ -4860,8 +4862,8 @@ describe.v2('cache', function () { let bundles = b.bundleGraph.getBundles(); assert.deepEqual( - bundles.map(b => b.name), - bundles.map(b => `${b.id}.${b.type}`), + bundles.map((b) => b.name), + bundles.map((b) => `${b.id}.${b.type}`), ); }); @@ -4879,8 +4881,8 @@ describe.v2('cache', function () { async update(b) { let bundles = b.bundleGraph.getBundles(); assert.deepEqual( - bundles.map(b => b.name), - bundles.map(b => `${b.id}.${b.type}`), + bundles.map((b) => b.name), + bundles.map((b) => `${b.id}.${b.type}`), ); let namer = path.join( @@ -4900,8 +4902,8 @@ describe.v2('cache', function () { let bundles = b.bundleGraph.getBundles(); assert.deepEqual( - bundles.map(b => b.name), - bundles.map(b => `${b.id.slice(-8)}.${b.type}`), + bundles.map((b) => b.name), + bundles.map((b) => `${b.id.slice(-8)}.${b.type}`), ); }); @@ -6401,7 +6403,7 @@ describe.v2('cache', function () { describe('runtime', () => { it('should support updating files added by runtimes', async function () { - let b = await testCache(async b => { + let b = await testCache(async (b) => { let contents = await overlayFS.readFile( b.bundleGraph.getBundles()[0].filePath, 'utf8', @@ -6426,7 +6428,7 @@ describe.v2('cache', function () { let b = await testCache( { entries: ['reformat.html'], - update: async b => { + update: async (b) => { let bundles = b.bundleGraph.getBundles(); let contents = await overlayFS.readFile( bundles[0].filePath, @@ -6721,7 +6723,7 @@ describe.v2('cache', function () { await inputFS.mkdirp(inputDir); await inputFS.ncp(path.join(__dirname, '/integration/cache'), inputDir); }, - update: async b => { + update: async (b) => { assert.equal(await run(b.bundleGraph), 4); await inputFS.writeFile( diff --git a/packages/core/integration-tests/test/contentHashing.js b/packages/core/integration-tests/test/contentHashing.js index d97dcafa0..24201c0dd 100644 --- a/packages/core/integration-tests/test/contentHashing.js +++ b/packages/core/integration-tests/test/contentHashing.js @@ -110,8 +110,8 @@ describe.v2('content hashing', function () { assert.equal(aBundles.length, 2); assert.equal(bBundles.length, 2); - let aJS = aBundles.find(bundle => bundle.type === 'js'); - let bJS = bBundles.find(bundle => bundle.type === 'js'); + let aJS = aBundles.find((bundle) => bundle.type === 'js'); + let bJS = bBundles.find((bundle) => bundle.type === 'js'); assert(/index\.[a-f0-9]*\.js/.test(path.basename(aJS.filePath))); assert.equal(aJS.name, bJS.name); }); diff --git a/packages/core/integration-tests/test/css-modules.js b/packages/core/integration-tests/test/css-modules.js index 79af5b9cb..ed0f2d942 100644 --- a/packages/core/integration-tests/test/css-modules.js +++ b/packages/core/integration-tests/test/css-modules.js @@ -67,11 +67,11 @@ describe.v2('css modules', () => { assert(/[_0-9a-zA-Z]+_b-2/.test(output)); let css = await outputFS.readFile( - b.getBundles().find(b => b.type === 'css').filePath, + b.getBundles().find((b) => b.type === 'css').filePath, 'utf8', ); let includedRules = new Set(); - postcss.parse(css).walkRules(rule => { + postcss.parse(css).walkRules((rule) => { includedRules.add(rule.selector); }); assert(includedRules.has('.page')); @@ -99,7 +99,7 @@ describe.v2('css modules', () => { ]); let js = await outputFS.readFile( - b.getBundles().find(b => b.type === 'js').filePath, + b.getBundles().find((b) => b.type === 'js').filePath, 'utf8', ); assert(!js.includes('unused')); @@ -108,11 +108,11 @@ describe.v2('css modules', () => { assert(/[_0-9a-zA-Z]+_b-2/.test(output)); let css = await outputFS.readFile( - b.getBundles().find(b => b.type === 'css').filePath, + b.getBundles().find((b) => b.type === 'css').filePath, 'utf8', ); let includedRules = new Set(); - postcss.parse(css).walkRules(rule => { + postcss.parse(css).walkRules((rule) => { includedRules.add(rule.selector); }); assert.deepStrictEqual( @@ -150,11 +150,11 @@ describe.v2('css modules', () => { assert(/[_0-9a-zA-Z]+_b-2/.test(output)); let css = await outputFS.readFile( - b.getBundles().find(b => b.type === 'css').filePath, + b.getBundles().find((b) => b.type === 'css').filePath, 'utf8', ); let includedRules = new Set(); - postcss.parse(css).walkRules(rule => { + postcss.parse(css).walkRules((rule) => { includedRules.add(rule.selector); }); assert(includedRules.has('body')); @@ -183,7 +183,7 @@ describe.v2('css modules', () => { ]); let js = await outputFS.readFile( - b.getBundles().find(b => b.type === 'js').filePath, + b.getBundles().find((b) => b.type === 'js').filePath, 'utf8', ); assert(js.includes('unused')); @@ -193,11 +193,11 @@ describe.v2('css modules', () => { assert(/[_0-9a-zA-Z]+_unused/.test(output['unused'])); let css = await outputFS.readFile( - b.getBundles().find(b => b.type === 'css').filePath, + b.getBundles().find((b) => b.type === 'css').filePath, 'utf8', ); let includedRules = new Set(); - postcss.parse(css).walkRules(rule => { + postcss.parse(css).walkRules((rule) => { includedRules.add(rule.selector); }); assert.deepStrictEqual( @@ -591,9 +591,9 @@ describe.v2('css modules', () => { let res = []; await runBundle( b, - b.getBundles().find(b => b.name === 'page1.html'), + b.getBundles().find((b) => b.name === 'page1.html'), { - sideEffect: s => res.push(s), + sideEffect: (s) => res.push(s), }, ); @@ -602,9 +602,9 @@ describe.v2('css modules', () => { res = []; await runBundle( b, - b.getBundles().find(b => b.name === 'page2.html'), + b.getBundles().find((b) => b.name === 'page2.html'), { - sideEffect: s => res.push(s), + sideEffect: (s) => res.push(s), }, ); @@ -658,7 +658,7 @@ describe.v2('css modules', () => { assert.deepEqual(res, 'C-gzXq_foo'); let contents = await outputFS.readFile( - b.getBundles().find(b => b.type === 'css').filePath, + b.getBundles().find((b) => b.type === 'css').filePath, 'utf8', ); assert(contents.includes('.C-gzXq_foo')); @@ -673,7 +673,7 @@ describe.v2('css modules', () => { let res = await run(b); assert.deepEqual(res, 'C-gzXq_foo'); let contents = await outputFS.readFile( - b.getBundles().find(b => b.type === 'css').filePath, + b.getBundles().find((b) => b.type === 'css').filePath, 'utf8', ); assert(contents.includes('.C-gzXq_foo')); @@ -686,7 +686,7 @@ describe.v2('css modules', () => { {mode: 'production'}, ); let contents = await outputFS.readFile( - b.getBundles().find(b => b.type === 'css').filePath, + b.getBundles().find((b) => b.type === 'css').filePath, 'utf8', ); assert.equal( @@ -705,9 +705,9 @@ describe.v2('css modules', () => { let res = []; await runBundle( b, - b.getBundles().find(b => b.name === 'index.html'), + b.getBundles().find((b) => b.name === 'index.html'), { - sideEffect: s => res.push(s), + sideEffect: (s) => res.push(s), }, ); assert.deepEqual(res, [ @@ -727,9 +727,9 @@ describe.v2('css modules', () => { let res = []; await runBundle( b, - b.getBundles().find(b => b.name === 'index.html'), + b.getBundles().find((b) => b.name === 'index.html'), { - sideEffect: s => res.push(s), + sideEffect: (s) => res.push(s), }, ); // Result is [ 'mainJs', 'SX8vmq_container YpGmra_-expand' ] @@ -812,7 +812,7 @@ describe.v2('css modules', () => { }); let contents = await outputFS.readFile( - b.getBundles().find(b => b.type === 'css').filePath, + b.getBundles().find((b) => b.type === 'css').filePath, 'utf8', ); assert(contents.includes('.foo')); diff --git a/packages/core/integration-tests/test/encodedURI.js b/packages/core/integration-tests/test/encodedURI.js index 9eb849f2d..bb249a2b2 100644 --- a/packages/core/integration-tests/test/encodedURI.js +++ b/packages/core/integration-tests/test/encodedURI.js @@ -13,6 +13,6 @@ describe.v2('encodedURI', function () { assert(html.includes(file)); } } - assert(!!files.find(f => f.startsWith('日本語'))); + assert(!!files.find((f) => f.startsWith('日本語'))); }); }); diff --git a/packages/core/integration-tests/test/glob.js b/packages/core/integration-tests/test/glob.js index 23ec28f9e..9345f40a7 100644 --- a/packages/core/integration-tests/test/glob.js +++ b/packages/core/integration-tests/test/glob.js @@ -66,7 +66,7 @@ describe.v2('glob', function () { assert.equal(output(), 2); let css = await outputFS.readFile( - nullthrows(b.getBundles().find(b => b.type === 'css')).filePath, + nullthrows(b.getBundles().find((b) => b.type === 'css')).filePath, 'utf8', ); assert(css.includes('.local')); @@ -97,10 +97,10 @@ describe.v2('glob', function () { let output = await run(b); assert.deepEqual(output, { a: `http://localhost/${path.basename( - nullthrows(b.getBundles().find(b => b.name.startsWith('a'))).filePath, + nullthrows(b.getBundles().find((b) => b.name.startsWith('a'))).filePath, )}`, b: `http://localhost/${path.basename( - nullthrows(b.getBundles().find(b => b.name.startsWith('b'))).filePath, + nullthrows(b.getBundles().find((b) => b.name.startsWith('b'))).filePath, )}`, }); }); diff --git a/packages/core/integration-tests/test/globals.js b/packages/core/integration-tests/test/globals.js index d8dfa6ee3..2a9bda9bb 100644 --- a/packages/core/integration-tests/test/globals.js +++ b/packages/core/integration-tests/test/globals.js @@ -67,15 +67,15 @@ describe.v2('globals', function () { let bundles = await Promise.all( bundleGraph .getBundles() - .map(b => overlayFS.readFile(b.filePath, 'utf8')), + .map((b) => overlayFS.readFile(b.filePath, 'utf8')), ); let onGlobal = sinon.spy(); await run(bundleGraph, {globalThis: 'global', onGlobal}); - assert(bundles.some(b => b.includes('var global = arguments[3]'))); + assert(bundles.some((b) => b.includes('var global = arguments[3]'))); assert( - bundles.every(b => !b.includes('var $parcel$global = globalThis')), + bundles.every((b) => !b.includes('var $parcel$global = globalThis')), ); assert.equal(onGlobal.callCount, 1); assert.deepEqual(onGlobal.firstCall.args, ['global']); @@ -93,14 +93,16 @@ describe.v2('globals', function () { let bundles = await Promise.all( bundleGraph .getBundles() - .map(b => overlayFS.readFile(b.filePath, 'utf8')), + .map((b) => overlayFS.readFile(b.filePath, 'utf8')), ); let onGlobal = sinon.spy(); await run(bundleGraph, {globalThis: 'global', onGlobal}); - assert(bundles.some(b => b.includes('var $parcel$global = globalThis'))); - assert(bundles.every(b => !b.includes('var global = arguments[3]'))); + assert( + bundles.some((b) => b.includes('var $parcel$global = globalThis')), + ); + assert(bundles.every((b) => !b.includes('var global = arguments[3]'))); assert.equal(onGlobal.callCount, 1); assert.deepEqual(onGlobal.firstCall.args, ['global']); }); diff --git a/packages/core/integration-tests/test/hmr.js b/packages/core/integration-tests/test/hmr.js index 2025a2b41..6156fe342 100644 --- a/packages/core/integration-tests/test/hmr.js +++ b/packages/core/integration-tests/test/hmr.js @@ -28,7 +28,7 @@ const config = path.join( async function closeSocket(ws: WebSocket) { ws.close(); - await new Promise(resolve => { + await new Promise((resolve) => { ws.once('close', resolve); }); } @@ -45,7 +45,9 @@ async function openSocket(uri: string, opts: any) { } async function nextWSMessage(ws: WebSocket) { - return json5.parse(await new Promise(resolve => ws.once('message', resolve))); + return json5.parse( + await new Promise((resolve) => ws.once('message', resolve)), + ); } describe.v2('hmr', function () { @@ -161,7 +163,7 @@ describe.v2('hmr', function () { assert.equal(message.type, 'update'); // Figure out why output doesn't change... - let localAsset = message.assets.find(asset => + let localAsset = message.assets.find((asset) => asset.output.includes('exports.a = 5;\nexports.b = 5;\n'), ); assert(!!localAsset); @@ -371,7 +373,7 @@ describe.v2('hmr', function () { }); it('should support self accepting', async function () { - let {outputs} = await testHMRClient('hmr-accept-self', outputs => { + let {outputs} = await testHMRClient('hmr-accept-self', (outputs) => { assert.deepStrictEqual(outputs, [ ['other', 1], ['local', 1], @@ -393,7 +395,7 @@ describe.v2('hmr', function () { }); it('should bubble through parents', async function () { - let {outputs} = await testHMRClient('hmr-bubble', outputs => { + let {outputs} = await testHMRClient('hmr-bubble', (outputs) => { assert.deepStrictEqual(outputs, [ ['other', 1], ['local', 1], @@ -416,7 +418,7 @@ describe.v2('hmr', function () { }); it('should call dispose callbacks', async function () { - let {outputs} = await testHMRClient('hmr-dispose', outputs => { + let {outputs} = await testHMRClient('hmr-dispose', (outputs) => { assert.deepStrictEqual(outputs, [ ['eval:other', 1, null], ['eval:local', 1, null], @@ -458,7 +460,7 @@ module.hot.dispose((data) => { }); it('should work with circular dependencies', async function () { - let {outputs} = await testHMRClient('hmr-circular', outputs => { + let {outputs} = await testHMRClient('hmr-circular', (outputs) => { assert.deepEqual(outputs, [3]); return { @@ -471,7 +473,7 @@ module.hot.dispose((data) => { }); it('should reload if not accepted', async function () { - let {reloaded} = await testHMRClient('hmr-reload', outputs => { + let {reloaded} = await testHMRClient('hmr-reload', (outputs) => { assert.deepEqual(outputs, [3]); return { 'local.js': 'exports.a = 5; exports.b = 5;', @@ -482,7 +484,7 @@ module.hot.dispose((data) => { }); it('should reload when modifying the entry', async function () { - let {reloaded} = await testHMRClient('hmr-reload', outputs => { + let {reloaded} = await testHMRClient('hmr-reload', (outputs) => { assert.deepEqual(outputs, [3]); return { 'index.js': 'output(5)', @@ -493,7 +495,7 @@ module.hot.dispose((data) => { }); it('should work with multiple parents', async function () { - let {outputs} = await testHMRClient('hmr-multiple-parents', outputs => { + let {outputs} = await testHMRClient('hmr-multiple-parents', (outputs) => { assert.deepEqual(outputs, ['a: fn1 b: fn2']); return { 'fn2.js': 'export function fn2() { return "UPDATED"; }', @@ -506,7 +508,7 @@ module.hot.dispose((data) => { it('should reload if only one parent accepts', async function () { let {reloaded} = await testHMRClient( 'hmr-multiple-parents-reload', - outputs => { + (outputs) => { assert.deepEqual(outputs, ['a: fn1', 'b: fn2']); return { 'fn2.js': 'export function fn2() { return "UPDATED"; }', @@ -518,7 +520,7 @@ module.hot.dispose((data) => { }); it('should work across bundles', async function () { - let {reloaded} = await testHMRClient('hmr-dynamic', outputs => { + let {reloaded} = await testHMRClient('hmr-dynamic', (outputs) => { assert.deepEqual(outputs, [3]); return { 'local.js': 'exports.a = 5; exports.b = 5;', @@ -531,7 +533,7 @@ module.hot.dispose((data) => { it('should work with urls', async function () { let search; - let {outputs} = await testHMRClient('hmr-url', outputs => { + let {outputs} = await testHMRClient('hmr-url', (outputs) => { assert.equal(outputs.length, 1); let url = new URL(outputs[0]); assert(/test\.[0-9a-f]+\.txt/, url.pathname); @@ -552,7 +554,7 @@ module.hot.dispose((data) => { it('should clean up orphaned assets when deleting a dependency', async function () { let search; let {outputs} = await testHMRClient('hmr-url', [ - outputs => { + (outputs) => { assert.equal(outputs.length, 1); let url = new URL(outputs[0]); assert(/test\.[0-9a-f]+\.txt/, url.pathname); @@ -562,7 +564,7 @@ module.hot.dispose((data) => { 'index.js': 'output("yo"); module.hot.accept();', }; }, - outputs => { + (outputs) => { assert.equal(outputs.length, 2); assert.equal(outputs[1], 'yo'); return { @@ -893,7 +895,7 @@ module.hot.dispose((data) => { ); let _window = (window = dom.window); // For Flow window.WebSocket = WebSocket; - await new Promise(res => + await new Promise((res) => dom.window.document.addEventListener('load', () => { res(); }), @@ -956,7 +958,7 @@ module.hot.dispose((data) => { ); let _window = (window = dom.window); // For Flow window.WebSocket = WebSocket; - await new Promise(res => + await new Promise((res) => dom.window.document.addEventListener('load', () => { res(); }), diff --git a/packages/core/integration-tests/test/html.js b/packages/core/integration-tests/test/html.js index 3a5ce473d..f48bf1ead 100644 --- a/packages/core/integration-tests/test/html.js +++ b/packages/core/integration-tests/test/html.js @@ -92,14 +92,14 @@ describe.v2('html', function () { assert(html.includes('tel:+33636757575')); assert(html.includes('https://unpkg.com/parcel-bundler')); - let iconsBundle = b.getBundles().find(b => b.name.startsWith('icons')); + let iconsBundle = b.getBundles().find((b) => b.name.startsWith('icons')); assert( html.includes('/' + path.basename(iconsBundle.filePath) + '#icon-code'), ); let value = null; await run(b, { - alert: v => (value = v), + alert: (v) => (value = v), }); assert.equal(value, 'Hi'); }); @@ -578,7 +578,7 @@ describe.v2('html', function () { let o = []; await run(b, { - output: v => o.push(v), + output: (v) => o.push(v), }); assert.deepEqual(o, ['component-1', 'component-2']); @@ -1119,7 +1119,7 @@ describe.v2('html', function () { let files = await outputFS.readdir(distDir); // assert that the inline js files are not output - assert(!files.some(filename => filename.includes('js'))); + assert(!files.some((filename) => filename.includes('js'))); let html = await outputFS.readFile( path.join(distDir, 'index.html'), @@ -1173,16 +1173,16 @@ describe.v2('html', function () { let bundles = b.getBundles(); let html = await outputFS.readFile( - bundles.find(bundle => bundle.type === 'html').filePath, + bundles.find((bundle) => bundle.type === 'html').filePath, 'utf8', ); - let urls = [...html.matchAll(/url\(([^)]*)\)/g)].map(m => m[1]); + let urls = [...html.matchAll(/url\(([^)]*)\)/g)].map((m) => m[1]); assert.strictEqual(urls.length, 2); for (let url of urls) { assert( bundles.find( - bundle => + (bundle) => bundle.bundleBehavior !== 'inline' && path.basename(bundle.filePath) === url, ), @@ -1650,21 +1650,21 @@ describe.v2('html', function () { let bundles = b.getBundles(); let html = await outputFS.readFile( - bundles.find(b => b.type === 'html').filePath, + bundles.find((b) => b.type === 'html').filePath, 'utf8', ); assert(html.includes('