diff --git a/.prettierrc b/.prettierrc index c957da40809..6e76d2a1a1e 100644 --- a/.prettierrc +++ b/.prettierrc @@ -3,6 +3,7 @@ "endOfLine": "lf", "singleQuote": true, "trailingComma": "all", + "arrowParens": "avoid", "overrides": [ { "files": [ diff --git a/package.json b/package.json index 2670e8f35e9..e8252a79015 100644 --- a/package.json +++ b/package.json @@ -53,7 +53,7 @@ "mocha": "^8.3.0", "mocha-junit-reporter": "^2.0.0", "mocha-multi-reporters": "^1.5.1", - "prettier": "1.19.1", + "prettier": "2.4.1", "rimraf": "^2.6.3", "semver": "^5.4.1", "sinon": "^7.3.1" diff --git a/packages/bundlers/default/src/DefaultBundler.js b/packages/bundlers/default/src/DefaultBundler.js index c7c834b4e8e..aa3a00320a6 100644 --- a/packages/bundlers/default/src/DefaultBundler.js +++ b/packages/bundlers/default/src/DefaultBundler.js @@ -246,9 +246,8 @@ export default (new Bundler({ ); for (let candidate of candidates) { - let bundleGroups = bundleGraph.getBundleGroupsContainingBundle( - candidate, - ); + let bundleGroups = + bundleGraph.getBundleGroupsContainingBundle(candidate); if ( Array.from(bundleGroups).every( group => diff --git a/packages/core/codeframe/src/codeframe.js b/packages/core/codeframe/src/codeframe.js index 5f60794a376..3eca8729395 100644 --- a/packages/core/codeframe/src/codeframe.js +++ b/packages/core/codeframe/src/codeframe.js @@ -121,9 +121,8 @@ export default function codeFrame( // Split input into lines and highlight syntax let lines = code.split(NEWLINE); - let syntaxHighlightedLines = (opts.syntaxHighlighting - ? highlightSyntax(code, opts.language) - : code + let syntaxHighlightedLines = ( + opts.syntaxHighlighting ? highlightSyntax(code, opts.language) : code ) .replace(TAB_REPLACE_REGEX, TAB_REPLACEMENT) .split(NEWLINE); diff --git a/packages/core/core/src/PackagerRunner.js b/packages/core/core/src/PackagerRunner.js index 4789b63269d..c062edc9da4 100644 --- a/packages/core/core/src/PackagerRunner.js +++ b/packages/core/core/src/PackagerRunner.js @@ -589,9 +589,7 @@ export default class PackagerRunner { return devDepHashes; } - async readFromCache( - cacheKey: string, - ): Promise { diff --git a/packages/core/core/src/Parcel.js b/packages/core/core/src/Parcel.js index 70b3b24d79f..60d7a2cbb2d 100644 --- a/packages/core/core/src/Parcel.js +++ b/packages/core/core/src/Parcel.js @@ -109,10 +109,8 @@ export default class Parcel { await resolvedOptions.cache.ensure(); - let { - dispose: disposeOptions, - ref: optionsRef, - } = await this.#farm.createSharedReference(resolvedOptions); + let {dispose: disposeOptions, ref: optionsRef} = + await this.#farm.createSharedReference(resolvedOptions); this.#optionsRef = optionsRef; this.#disposable = new Disposable(); @@ -268,12 +266,8 @@ export default class Parcel { signal, }); - let { - bundleGraph, - bundleInfo, - changedAssets, - assetRequests, - } = await this.#requestTracker.runRequest(request, {force: true}); + let {bundleGraph, bundleInfo, changedAssets, assetRequests} = + await this.#requestTracker.runRequest(request, {force: true}); this.#requestedAssetIds.clear(); diff --git a/packages/core/core/src/ParcelConfig.js b/packages/core/core/src/ParcelConfig.js index 6650485bcf8..2ace49e0344 100644 --- a/packages/core/core/src/ParcelConfig.js +++ b/packages/core/core/src/ParcelConfig.js @@ -116,9 +116,7 @@ export default class ParcelConfig { }; } - _loadPlugin( - node: ParcelPluginNode, - ): Promise<{| + _loadPlugin(node: ParcelPluginNode): Promise<{| plugin: T, version: Semver, resolveFrom: ProjectPath, @@ -179,9 +177,8 @@ export default class ParcelConfig { } getValidatorNames(filePath: ProjectPath): Array { - let validators: PureParcelConfigPipeline = this._getValidatorNodes( - filePath, - ); + let validators: PureParcelConfigPipeline = + this._getValidatorNodes(filePath); return validators.map(v => v.packageName); } @@ -203,11 +200,8 @@ export default class ParcelConfig { pipeline?: ?string, allowEmpty?: boolean, ): Promise>>> { - let transformers: PureParcelConfigPipeline | null = this.matchGlobMapPipelines( - filePath, - this.transformers, - pipeline, - ); + let transformers: PureParcelConfigPipeline | null = + this.matchGlobMapPipelines(filePath, this.transformers, pipeline); if (!transformers || transformers.length === 0) { if (allowEmpty) { return []; diff --git a/packages/core/core/src/RequestTracker.js b/packages/core/core/src/RequestTracker.js index 755459b48be..de505da8a31 100644 --- a/packages/core/core/src/RequestTracker.js +++ b/packages/core/core/src/RequestTracker.js @@ -783,9 +783,10 @@ export default class RequestTracker { this.signal = signal; } - startRequest( - request: StoredRequest, - ): {|requestNodeId: NodeId, deferred: Deferred|} { + startRequest(request: StoredRequest): {| + requestNodeId: NodeId, + deferred: Deferred, + |} { let didPreviouslyExist = this.graph.hasContentKey(request.id); let requestNodeId; if (didPreviouslyExist) { diff --git a/packages/core/core/src/applyRuntimes.js b/packages/core/core/src/applyRuntimes.js index c567ea10247..34cc00e0cc5 100644 --- a/packages/core/core/src/applyRuntimes.js +++ b/packages/core/core/src/applyRuntimes.js @@ -138,10 +138,8 @@ export default async function applyRuntimes({ await runDevDepRequest(api, devDepRequest); } - let { - assetGraph: runtimesAssetGraph, - changedAssets, - } = await reconcileNewRuntimes(api, connections, optionsRef); + let {assetGraph: runtimesAssetGraph, changedAssets} = + await reconcileNewRuntimes(api, connections, optionsRef); let runtimesGraph = InternalBundleGraph.fromAssetGraph( runtimesAssetGraph, diff --git a/packages/core/core/src/public/Asset.js b/packages/core/core/src/public/Asset.js index 88da55b1558..88372c2f0c2 100644 --- a/packages/core/core/src/public/Asset.js +++ b/packages/core/core/src/public/Asset.js @@ -41,10 +41,8 @@ const inspect = Symbol.for('nodejs.util.inspect.custom'); const uncommittedAssetValueToAsset: WeakMap = new WeakMap(); const committedAssetValueToAsset: WeakMap = new WeakMap(); -const assetValueToMutableAsset: WeakMap< - AssetValue, - MutableAsset, -> = new WeakMap(); +const assetValueToMutableAsset: WeakMap = + new WeakMap(); const _assetToAssetValue: WeakMap< IAsset | IMutableAsset | BaseAsset, diff --git a/packages/core/core/src/public/Bundle.js b/packages/core/core/src/public/Bundle.js index 00793ad4c66..1c9ae0a2bc7 100644 --- a/packages/core/core/src/public/Bundle.js +++ b/packages/core/core/src/public/Bundle.js @@ -51,10 +51,8 @@ const _bundleToInternalBundle: WeakMap = new WeakMap(); export function bundleToInternalBundle(bundle: IBundle): InternalBundle { return nullthrows(_bundleToInternalBundle.get(bundle)); } -const _bundleToInternalBundleGraph: WeakMap< - IBundle, - BundleGraph, -> = new WeakMap(); +const _bundleToInternalBundleGraph: WeakMap = + new WeakMap(); export function bundleToInternalBundleGraph(bundle: IBundle): BundleGraph { return nullthrows(_bundleToInternalBundleGraph.get(bundle)); } diff --git a/packages/core/core/src/public/BundleGraph.js b/packages/core/core/src/public/BundleGraph.js index d6da6ba49bb..47372f53c08 100644 --- a/packages/core/core/src/public/BundleGraph.js +++ b/packages/core/core/src/public/BundleGraph.js @@ -47,7 +47,8 @@ type BundleFactory = ( ) => TBundle; export default class BundleGraph - implements IBundleGraph { + implements IBundleGraph +{ #graph: InternalBundleGraph; #options: ParcelOptions; #createBundle: BundleFactory; diff --git a/packages/core/core/src/public/Dependency.js b/packages/core/core/src/public/Dependency.js index 60cc46042d1..950bb54249a 100644 --- a/packages/core/core/src/public/Dependency.js +++ b/packages/core/core/src/public/Dependency.js @@ -26,10 +26,8 @@ const PriorityNames = Object.keys(Priority); const inspect = Symbol.for('nodejs.util.inspect.custom'); -const internalDependencyToDependency: WeakMap< - InternalDependency, - Dependency, -> = new WeakMap(); +const internalDependencyToDependency: WeakMap = + new WeakMap(); const _dependencyToInternalDependency: WeakMap< IDependency, InternalDependency, diff --git a/packages/core/core/src/public/MutableBundleGraph.js b/packages/core/core/src/public/MutableBundleGraph.js index 59a8028bd5d..65c174fb8c5 100644 --- a/packages/core/core/src/public/MutableBundleGraph.js +++ b/packages/core/core/src/public/MutableBundleGraph.js @@ -27,8 +27,10 @@ import {fromProjectPathRelative} from '../projectPath'; import {BundleBehavior} from '../types'; import BundleGroup, {bundleGroupToInternalBundleGroup} from './BundleGroup'; -export default class MutableBundleGraph extends BundleGraph - implements IMutableBundleGraph { +export default class MutableBundleGraph + extends BundleGraph + implements IMutableBundleGraph +{ #graph /*: InternalBundleGraph */; #options /*: ParcelOptions */; #bundlePublicIds /*: Set */ = new Set(); @@ -102,9 +104,8 @@ export default class MutableBundleGraph extends BundleGraph dependencyNode.id, ); let resolvedNodeId = this.#graph._graph.getNodeIdByContentKey(resolved.id); - let assetNodes = this.#graph._graph.getNodeIdsConnectedFrom( - dependencyNodeId, - ); + let assetNodes = + this.#graph._graph.getNodeIdsConnectedFrom(dependencyNodeId); this.#graph._graph.addEdge(dependencyNodeId, bundleGroupNodeId); this.#graph._graph.replaceNodeIdsConnectedTo(bundleGroupNodeId, assetNodes); this.#graph._graph.addEdge( diff --git a/packages/core/core/src/public/PluginOptions.js b/packages/core/core/src/public/PluginOptions.js index 41688e0f859..7ae8fdff268 100644 --- a/packages/core/core/src/public/PluginOptions.js +++ b/packages/core/core/src/public/PluginOptions.js @@ -13,10 +13,8 @@ import type {FileSystem} from '@parcel/fs'; import type {PackageManager} from '@parcel/package-manager'; import type {ParcelOptions} from '../types'; -let parcelOptionsToPluginOptions: WeakMap< - ParcelOptions, - PluginOptions, -> = new WeakMap(); +let parcelOptionsToPluginOptions: WeakMap = + new WeakMap(); export default class PluginOptions implements IPluginOptions { #options /*: ParcelOptions */; diff --git a/packages/core/core/src/public/Symbols.js b/packages/core/core/src/public/Symbols.js index 32ae9ca92be..cca19f14c0d 100644 --- a/packages/core/core/src/public/Symbols.js +++ b/packages/core/core/src/public/Symbols.js @@ -97,10 +97,8 @@ export class AssetSymbols implements IAssetSymbols { } } -let valueToMutableAssetSymbols: WeakMap< - Asset, - MutableAssetSymbols, -> = new WeakMap(); +let valueToMutableAssetSymbols: WeakMap = + new WeakMap(); export class MutableAssetSymbols implements IMutableAssetSymbols { /*:: @@iterator(): Iterator<[ISymbol, {|local: ISymbol, loc: ?SourceLocation, meta?: ?Meta|}]> { return ({}: any); } diff --git a/packages/core/core/src/requests/AssetGraphRequest.js b/packages/core/core/src/requests/AssetGraphRequest.js index 95b8b32ba2e..37896f780f2 100644 --- a/packages/core/core/src/requests/AssetGraphRequest.js +++ b/packages/core/core/src/requests/AssetGraphRequest.js @@ -79,7 +79,8 @@ export default function createAssetGraphRequest( type: 'asset_graph_request', id: input.name, run: async input => { - let prevResult = await input.api.getPreviousResult(); + let prevResult = + await input.api.getPreviousResult(); let builder = new AssetGraphBuilder(input, prevResult); return builder.build(); }, @@ -778,9 +779,8 @@ export class AssetGraphBuilder { } } } else { - let connectedNodes = this.assetGraph.getNodeIdsConnectedTo( - queuedNodeId, - ); + let connectedNodes = + this.assetGraph.getNodeIdsConnectedTo(queuedNodeId); if (connectedNodes.length > 0) { queue.add(...connectedNodes); } diff --git a/packages/core/core/src/requests/EntryRequest.js b/packages/core/core/src/requests/EntryRequest.js index 91f8d3cfddc..0c3b75d64cb 100644 --- a/packages/core/core/src/requests/EntryRequest.js +++ b/packages/core/core/src/requests/EntryRequest.js @@ -314,9 +314,7 @@ export class EntryResolver { }); } - async readPackage( - entry: FilePath, - ): Promise(createParcelConfigRequest()), ); - let { - devDepRequests, - configRequests, - bundleInfo, - invalidations, - } = await runPackage({ - bundle, - bundleGraphReference, - optionsRef, - configCachePath: cachePath, - previousDevDeps: devDeps, - invalidDevDeps, - previousInvalidations: api.getInvalidations(), - }); + let {devDepRequests, configRequests, bundleInfo, invalidations} = + await runPackage({ + bundle, + bundleGraphReference, + optionsRef, + configCachePath: cachePath, + previousDevDeps: devDeps, + invalidDevDeps, + previousInvalidations: api.getInvalidations(), + }); for (let devDepRequest of devDepRequests) { await runDevDepRequest(api, devDepRequest); diff --git a/packages/core/core/src/requests/ParcelConfigRequest.js b/packages/core/core/src/requests/ParcelConfigRequest.js index d4c8d44078e..546d59854f3 100644 --- a/packages/core/core/src/requests/ParcelConfigRequest.js +++ b/packages/core/core/src/requests/ParcelConfigRequest.js @@ -443,16 +443,8 @@ export async function processConfigChain( : '/extends'; let resolved = await resolveExtends(ext, filePath, key, options); extendedFiles.push(resolved); - let { - extendedFiles: moreExtendedFiles, - config: nextConfig, - } = await processExtendedConfig( - filePath, - key, - ext, - resolved, - options, - ); + let {extendedFiles: moreExtendedFiles, config: nextConfig} = + await processExtendedConfig(filePath, key, ext, resolved, options); extendedFiles = extendedFiles.concat(moreExtendedFiles); extStartConfig = extStartConfig ? mergeConfigs(extStartConfig, nextConfig) diff --git a/packages/core/core/src/requests/TargetRequest.js b/packages/core/core/src/requests/TargetRequest.js index ece93ebf6fe..e4ed1429dde 100644 --- a/packages/core/core/src/requests/TargetRequest.js +++ b/packages/core/core/src/requests/TargetRequest.js @@ -154,10 +154,8 @@ export class TargetResolver { optionTargets = [exclusiveTarget]; } - let packageTargets: Map< - string, - Target | null, - > = await this.resolvePackageTargets(rootDir, exclusiveTarget); + let packageTargets: Map = + await this.resolvePackageTargets(rootDir, exclusiveTarget); let targets: Array; if (optionTargets) { if (Array.isArray(optionTargets)) { @@ -322,8 +320,8 @@ export class TargetResolver { engines: {}, shouldOptimize: this.options.defaultTargetOptions.shouldOptimize, outputFormat: this.options.defaultTargetOptions.outputFormat, - shouldScopeHoist: this.options.defaultTargetOptions - .shouldScopeHoist, + shouldScopeHoist: + this.options.defaultTargetOptions.shouldScopeHoist, sourceMap: this.options.defaultTargetOptions.sourceMaps ? {} : undefined, diff --git a/packages/core/core/src/types.js b/packages/core/core/src/types.js index 5f1f5ddb585..6c498c47385 100644 --- a/packages/core/core/src/types.js +++ b/packages/core/core/src/types.js @@ -148,9 +148,8 @@ export const BundleBehavior = { isolated: 1, }; -export const BundleBehaviorNames: Array< - $Keys, -> = Object.keys(BundleBehavior); +export const BundleBehaviorNames: Array<$Keys> = + Object.keys(BundleBehavior); export type Asset = {| id: ContentKey, diff --git a/packages/core/core/src/worker.js b/packages/core/core/src/worker.js index 6fdb6db46e6..bb1467076f5 100644 --- a/packages/core/core/src/worker.js +++ b/packages/core/core/src/worker.js @@ -150,7 +150,8 @@ export async function childInit() { await initHash; } -const PKG_RE = /node_modules[/\\]((?:@[^/\\]+[/\\][^/\\]+)|[^/\\]+)(?!.*[/\\]node_modules[/\\])/; +const PKG_RE = + /node_modules[/\\]((?:@[^/\\]+[/\\][^/\\]+)|[^/\\]+)(?!.*[/\\]node_modules[/\\])/; export function invalidateRequireCache(workerApi: WorkerApi, file: string) { if (process.env.PARCEL_BUILD_ENV === 'test') { // Delete this module and all children in the same node_modules folder diff --git a/packages/core/core/test/EntryRequest.test.js b/packages/core/core/test/EntryRequest.test.js index ccc870a7a02..6b5ca40a6f7 100644 --- a/packages/core/core/test/EntryRequest.test.js +++ b/packages/core/core/test/EntryRequest.test.js @@ -33,10 +33,10 @@ const INVALID_TARGET_SOURCE_NOT_FILE_FIXTURE_PATH = path.join( 'fixtures/invalid-target-source-not-file', ); -describe('EntryResolver', function() { +describe('EntryResolver', function () { let entryResolver = new EntryResolver({...DEFAULT_OPTIONS}); - it('rejects missing source in package.json', async function() { + it('rejects missing source in package.json', async function () { this.timeout(10000); // $FlowFixMe assert.rejects is Node 10+ await assert.rejects( @@ -76,7 +76,7 @@ describe('EntryResolver', function() { }, ); }); - it('rejects non-file source in package.json', async function() { + it('rejects non-file source in package.json', async function () { this.timeout(10000); // $FlowFixMe assert.rejects is Node 10+ await assert.rejects( @@ -115,7 +115,7 @@ describe('EntryResolver', function() { }, ); }); - it('rejects missing target source in package.json', async function() { + it('rejects missing target source in package.json', async function () { this.timeout(10000); // $FlowFixMe assert.rejects is Node 10+ await assert.rejects( @@ -159,7 +159,7 @@ describe('EntryResolver', function() { }, ); }); - it('rejects non-file target source in package.json', async function() { + it('rejects non-file target source in package.json', async function () { this.timeout(10000); // $FlowFixMe assert.rejects is Node 10+ await assert.rejects( diff --git a/packages/core/core/test/Parcel.test.js b/packages/core/core/test/Parcel.test.js index ac3025d671b..2419cbaef9e 100644 --- a/packages/core/core/test/Parcel.test.js +++ b/packages/core/core/test/Parcel.test.js @@ -8,7 +8,7 @@ import assert from 'assert'; import path from 'path'; import Parcel, {createWorkerFarm} from '../src/Parcel'; -describe('Parcel', function() { +describe('Parcel', function () { this.timeout(75000); let workerFarm; diff --git a/packages/core/diagnostic/src/diagnostic.js b/packages/core/diagnostic/src/diagnostic.js index 95251b40979..cc8b05331ae 100644 --- a/packages/core/diagnostic/src/diagnostic.js +++ b/packages/core/diagnostic/src/diagnostic.js @@ -313,22 +313,22 @@ export function md( return result.join('') + strings[strings.length - 1]; } -md.bold = function(s: TemplateInput): TemplateInput { +md.bold = function (s: TemplateInput): TemplateInput { // $FlowFixMe[invalid-computed-prop] return {[mdVerbatim]: '**' + escapeMarkdown(`${s}`) + '**'}; }; -md.italic = function(s: TemplateInput): TemplateInput { +md.italic = function (s: TemplateInput): TemplateInput { // $FlowFixMe[invalid-computed-prop] return {[mdVerbatim]: '_' + escapeMarkdown(`${s}`) + '_'}; }; -md.underline = function(s: TemplateInput): TemplateInput { +md.underline = function (s: TemplateInput): TemplateInput { // $FlowFixMe[invalid-computed-prop] return {[mdVerbatim]: '__' + escapeMarkdown(`${s}`) + '__'}; }; -md.strikethrough = function(s: TemplateInput): TemplateInput { +md.strikethrough = function (s: TemplateInput): TemplateInput { // $FlowFixMe[invalid-computed-prop] return {[mdVerbatim]: '~~' + escapeMarkdown(`${s}`) + '~~'}; }; diff --git a/packages/core/fs/src/MemoryFS.js b/packages/core/fs/src/MemoryFS.js index 890ff79d23d..93e25fe701b 100644 --- a/packages/core/fs/src/MemoryFS.js +++ b/packages/core/fs/src/MemoryFS.js @@ -138,10 +138,7 @@ export class MemoryFS implements FileSystem { // get realpath by following symlinks if (realpath) { let {root, dir, base} = path.parse(filePath); - let parts = dir - .slice(root.length) - .split(path.sep) - .concat(base); + let parts = dir.slice(root.length).split(path.sep).concat(base); let res = root; for (let part of parts) { res = path.join(res, part); diff --git a/packages/core/fs/src/OverlayFS.js b/packages/core/fs/src/OverlayFS.js index 375c0dffc3a..1dd40800a18 100644 --- a/packages/core/fs/src/OverlayFS.js +++ b/packages/core/fs/src/OverlayFS.js @@ -14,7 +14,7 @@ import packageJSON from '../package.json'; import {findAncestorFile, findNodeModule, findFirstFile} from './find'; function read(method) { - return async function(...args: Array) { + return async function (...args: Array) { try { return await this.writable[method](...args); } catch (err) { @@ -24,7 +24,7 @@ function read(method) { } function readSync(method) { - return function(...args: Array) { + return function (...args: Array) { try { return this.writable[method](...args); } catch (err) { @@ -34,13 +34,13 @@ function readSync(method) { } function write(method) { - return function(...args: Array) { + return function (...args: Array) { return this.writable[method](...args); }; } function checkExists(method) { - return function(filePath: FilePath, ...args: Array) { + return function (filePath: FilePath, ...args: Array) { if (this.writable.existsSync(filePath)) { return this.writable[method](filePath, ...args); } @@ -69,9 +69,8 @@ export class OverlayFS implements FileSystem { }; } - readFile: ( - ...args: Array - ) => Promise> = read('readFile'); + readFile: (...args: Array) => Promise> = + read('readFile'); writeFile: (...args: Array) => any = write('writeFile'); async copyFile(source: FilePath, destination: FilePath) { if (await this.writable.exists(source)) { @@ -86,30 +85,25 @@ export class OverlayFS implements FileSystem { ); } } - stat: ( - ...args: Array - ) => Promise> = read('stat'); + stat: (...args: Array) => Promise> = + read('stat'); unlink: (...args: Array) => any = write('unlink'); mkdirp: (...args: Array) => any = write('mkdirp'); rimraf: (...args: Array) => any = write('rimraf'); ncp: (...args: Array) => any = write('ncp'); - createReadStream: ( - filePath: FilePath, - ...args: Array - ) => any = checkExists('createReadStream'); + createReadStream: (filePath: FilePath, ...args: Array) => any = + checkExists('createReadStream'); createWriteStream: (...args: Array) => any = write('createWriteStream'); cwd: (...args: Array) => any = readSync('cwd'); chdir: (...args: Array) => any = readSync('chdir'); - realpath: (filePath: FilePath, ...args: Array) => any = checkExists( - 'realpath', - ); + realpath: (filePath: FilePath, ...args: Array) => any = + checkExists('realpath'); readFileSync: (...args: Array) => any = readSync('readFileSync'); statSync: (...args: Array) => any = readSync('statSync'); existsSync: (...args: Array) => any = readSync('existsSync'); - realpathSync: (filePath: FilePath, ...args: Array) => any = checkExists( - 'realpathSync', - ); + realpathSync: (filePath: FilePath, ...args: Array) => any = + checkExists('realpathSync'); async exists(filePath: FilePath): Promise { return ( diff --git a/packages/core/graph/src/Graph.js b/packages/core/graph/src/Graph.js index d68ced59065..d6fc0879fe7 100644 --- a/packages/core/graph/src/Graph.js +++ b/packages/core/graph/src/Graph.js @@ -596,12 +596,7 @@ class AdjacencyList { } hasEdge(from: NodeId, to: NodeId, type: TEdgeType): boolean { - return Boolean( - this._listMap - .get(from) - ?.get(type) - ?.has(to), - ); + return Boolean(this._listMap.get(from)?.get(type)?.has(to)); } addEdge(from: NodeId, to: NodeId, type: TEdgeType): void { @@ -620,9 +615,6 @@ class AdjacencyList { } removeEdge(from: NodeId, to: NodeId, type: TEdgeType): void { - this._listMap - .get(from) - ?.get(type) - ?.delete(to); + this._listMap.get(from)?.get(type)?.delete(to); } } diff --git a/packages/core/integration-tests/test/api.js b/packages/core/integration-tests/test/api.js index 97ecfd92002..b2327e9d708 100644 --- a/packages/core/integration-tests/test/api.js +++ b/packages/core/integration-tests/test/api.js @@ -3,8 +3,8 @@ import path from 'path'; import assert from 'assert'; import {distDir, bundle, assertBundles, outputFS} from '@parcel/test-utils'; -describe('JS API', function() { - it('should respect distEntry', async function() { +describe('JS API', function () { + it('should respect distEntry', async function () { const NAME = 'custom-name.js'; let b = await bundle( @@ -27,7 +27,7 @@ describe('JS API', function() { assert(await outputFS.exists(path.join(distDir, NAME))); }); - it('should run additional reports from the options', async function() { + it('should run additional reports from the options', async function () { let b = await bundle( path.join(__dirname, '/integration/js-comment/index.js'), { diff --git a/packages/core/integration-tests/test/babel.js b/packages/core/integration-tests/test/babel.js index d0ab06dcb26..53c2f3d912a 100644 --- a/packages/core/integration-tests/test/babel.js +++ b/packages/core/integration-tests/test/babel.js @@ -21,9 +21,9 @@ import {md} from '@parcel/diagnostic'; const parcelCli = require.resolve('parcel/src/bin.js'); const inputDir = path.join(__dirname, '/input'); -describe('babel', function() { +describe('babel', function () { let subscription; - beforeEach(async function() { + beforeEach(async function () { // TODO maybe don't do this for all tests await sleep(100); await outputFS.rimraf(inputDir); @@ -38,7 +38,7 @@ describe('babel', function() { } }); - it.skip('should auto install @babel/core v7', async function() { + it.skip('should auto install @babel/core v7', async function () { let originalPkg = await fs.readFile( __dirname + '/integration/babel-7-autoinstall/package.json', ); @@ -61,7 +61,7 @@ describe('babel', function() { ); }); - it.skip('should auto install babel plugins', async function() { + it.skip('should auto install babel plugins', async function () { let originalPkg = await fs.readFile( __dirname + '/integration/babel-plugin-autoinstall/package.json', ); @@ -89,7 +89,7 @@ describe('babel', function() { ); }); - it('should support compiling with babel using .babelrc config', async function() { + it('should support compiling with babel using .babelrc config', async function () { await bundle(path.join(__dirname, '/integration/babelrc-custom/index.js')); let file = await outputFS.readFile(path.join(distDir, 'index.js'), 'utf8'); @@ -97,7 +97,7 @@ describe('babel', function() { assert(file.includes('hello there')); }); - it('should support compiling with babel using babel.config.json config without warnings', async function() { + it('should support compiling with babel using babel.config.json config without warnings', async function () { let messages = []; let loggerDisposable = Logger.onLog(message => { messages.push(message); @@ -116,12 +116,14 @@ describe('babel', function() { assert.deepEqual(messages, []); }); - it.skip('should support compiling with babel using browserslist for different environments', async function() { + it.skip('should support compiling with babel using browserslist for different environments', async function () { async function testBrowserListMultipleEnv(projectBasePath) { // Transpiled destructuring, like r = p.prop1, o = p.prop2, a = p.prop3; - const prodRegExp = /\S+ ?= ?\S+\.prop1,\s*?\S+ ?= ?\S+\.prop2,\s*?\S+ ?= ?\S+\.prop3;/; + const prodRegExp = + /\S+ ?= ?\S+\.prop1,\s*?\S+ ?= ?\S+\.prop2,\s*?\S+ ?= ?\S+\.prop3;/; // ES6 Destructuring, like in the source; - const devRegExp = /const ?{\s*prop1(:.+)?,\s*prop2(:.+)?,\s*prop3(:.+)?\s*} ?= ?.*/; + const devRegExp = + /const ?{\s*prop1(:.+)?,\s*prop2(:.+)?,\s*prop3(:.+)?\s*} ?= ?.*/; let file; // Dev build test await bundle(path.join(__dirname, projectBasePath, '/index.js')); @@ -147,7 +149,7 @@ describe('babel', function() { ); }); - it.skip('should compile node_modules with browserslist to app target', async function() { + it.skip('should compile node_modules with browserslist to app target', async function () { await bundle( path.join( __dirname, @@ -160,7 +162,7 @@ describe('babel', function() { assert(file.includes('function Bar')); }); - it('should strip away flow types', async function() { + it('should strip away flow types', async function () { let b = await bundle( path.join(__dirname, '/integration/babel-strip-flow-types/index.js'), ); @@ -173,7 +175,7 @@ describe('babel', function() { assert(!file.includes('OptionsType')); }); - it('should support compiling with babel using babel.config.js config', async function() { + it('should support compiling with babel using babel.config.js config', async function () { await bundle( path.join(__dirname, '/integration/babel-config-js/src/index.js'), ); @@ -183,7 +185,7 @@ describe('babel', function() { assert(file.match(/return \d+;/)); }); - it('should support compiling with babel using babel.config.js config with a require in it', async function() { + it('should support compiling with babel using babel.config.js config with a require in it', async function () { await bundle( path.join(__dirname, '/integration/babel-config-js-require/src/index.js'), ); @@ -193,7 +195,7 @@ describe('babel', function() { assert(file.match(/return \d+;/)); }); - it('should support multitarget builds using a custom babel config with @parcel/babel-preset-env', async function() { + it('should support multitarget builds using a custom babel config with @parcel/babel-preset-env', async function () { let fixtureDir = path.join( __dirname, '/integration/babel-config-js-multitarget', @@ -215,7 +217,7 @@ describe('babel', function() { await outputFS.rimraf(path.join(fixtureDir, 'dist')); }); - it('should support multitarget builds using a custom babel config with @parcel/babel-plugin-transform-runtime', async function() { + it('should support multitarget builds using a custom babel config with @parcel/babel-plugin-transform-runtime', async function () { let fixtureDir = path.join( __dirname, '/integration/babel-config-js-multitarget-transform-runtime', @@ -240,7 +242,7 @@ describe('babel', function() { await outputFS.rimraf(path.join(fixtureDir, 'dist')); }); - it('should support building with custom babel config when running parcel globally', async function() { + it('should support building with custom babel config when running parcel globally', async function () { let tmpDir = tempy.directory(); let distDir = path.join(tmpDir, 'dist'); await fs.ncp( @@ -263,7 +265,7 @@ describe('babel', function() { assert(file.includes('hello there')); }); - it('should support merging .babelrc and babel.config.json in a monorepo', async function() { + it('should support merging .babelrc and babel.config.json in a monorepo', async function () { await bundle( path.join( __dirname, @@ -373,7 +375,7 @@ describe('babel', function() { } }); - it('should rebuild when .babelrc changes', async function() { + it('should rebuild when .babelrc changes', async function () { let inputDir = tempy.directory(); let differentPath = path.join(inputDir, 'differentConfig'); let configPath = path.join(inputDir, '.babelrc'); @@ -407,7 +409,7 @@ describe('babel', function() { assert(distFile.includes('something different')); }); - it('should invalidate babel.config.js across runs', async function() { + it('should invalidate babel.config.js across runs', async function () { let dateRe = /return (\d+);/; let fixtureDir = path.join(__dirname, '/integration/babel-config-js'); @@ -452,7 +454,7 @@ describe('babel', function() { assert.notEqual(firstDatestamp, secondDatestamp); }); - it('should invalidate when babel plugins are upgraded across runs', async function() { + it('should invalidate when babel plugins are upgraded across runs', async function () { let fixtureDir = path.join( __dirname, '/integration/babel-plugin-upgrade', @@ -502,7 +504,7 @@ describe('babel', function() { }); }); - it('should enable shippedProposals with @parcel/babel-preset-env in custom babelrc', async function() { + it('should enable shippedProposals with @parcel/babel-preset-env in custom babelrc', async function () { let b = await bundle( path.join( __dirname, @@ -518,7 +520,7 @@ describe('babel', function() { assert.strictEqual(output.default, 123); }); - it('should compile with custom babel plugin plus default transforms', async function() { + it('should compile with custom babel plugin plus default transforms', async function () { let b = await bundle( path.join(__dirname, '/integration/babel-custom/index.js'), ); @@ -533,7 +535,7 @@ describe('babel', function() { assert.strictEqual(output.default, 'hello'); }); - it('should compile with custom babel plugin and jsx', async function() { + it('should compile with custom babel plugin and jsx', async function () { let b = await bundle( path.join(__dirname, '/integration/babel-custom/jsx.js'), ); @@ -543,7 +545,7 @@ describe('babel', function() { assert(file.includes('React.createElement')); }); - it('should compile with custom babel plugin and typescript', async function() { + it('should compile with custom babel plugin and typescript', async function () { let b = await bundle( path.join(__dirname, '/integration/babel-custom/ts.ts'), ); @@ -559,7 +561,7 @@ describe('babel', function() { assert.strictEqual(output.default, 'hello'); }); - it('should compile with custom babel plugin and tsx', async function() { + it('should compile with custom babel plugin and tsx', async function () { let b = await bundle( path.join(__dirname, '/integration/babel-custom/tsx.tsx'), ); @@ -570,7 +572,7 @@ describe('babel', function() { assert(file.includes('React.createElement')); }); - it('should warn when a babel config contains only redundant plugins', async function() { + it('should warn when a babel config contains only redundant plugins', async function () { let messages = []; let loggerDisposable = Logger.onLog(message => { messages.push(message); @@ -648,7 +650,7 @@ describe('babel', function() { ]); }); - it('should warn when a babel config contains redundant plugins', async function() { + it('should warn when a babel config contains redundant plugins', async function () { let messages = []; let loggerDisposable = Logger.onLog(message => { messages.push(message); diff --git a/packages/core/integration-tests/test/bundler.js b/packages/core/integration-tests/test/bundler.js index 87929278e1e..13c1cca56f9 100644 --- a/packages/core/integration-tests/test/bundler.js +++ b/packages/core/integration-tests/test/bundler.js @@ -8,8 +8,8 @@ import { nextBundle, } from '@parcel/test-utils'; -describe.skip('bundler', function() { - it('should bundle once before exporting middleware', async function() { +describe.skip('bundler', function () { + it('should bundle once before exporting middleware', async function () { let b = bundler( path.join(__dirname, '/integration/bundler-middleware/index.js'), ); @@ -58,7 +58,7 @@ describe.skip('bundler', function() { }, 'before bundling'); }); - it('should support multiple entry points', async function() { + it('should support multiple entry points', async function () { let b = await bundle([ path.join(__dirname, '/integration/multi-entry/one.html'), path.join(__dirname, '/integration/multi-entry/two.html'), @@ -83,7 +83,7 @@ describe.skip('bundler', function() { ]); }); - it('should support multiple entry points as a glob', async function() { + it('should support multiple entry points as a glob', async function () { let b = await bundle( path.join(__dirname, '/integration/multi-entry/*.html'), ); diff --git a/packages/core/integration-tests/test/cache.js b/packages/core/integration-tests/test/cache.js index c63a97cf7d6..817f6c1f5ba 100644 --- a/packages/core/integration-tests/test/cache.js +++ b/packages/core/integration-tests/test/cache.js @@ -107,7 +107,7 @@ async function testCache(update: UpdateFn | TestConfig, integration) { return b; } -describe('cache', function() { +describe('cache', function () { before(async () => { await inputFS.rimraf(path.join(__dirname, 'input')); }); @@ -116,13 +116,11 @@ describe('cache', function() { inputDir = path.join( __dirname, '/input', - Math.random() - .toString(36) - .slice(2), + Math.random().toString(36).slice(2), ); }); - it('should support updating a JS file', async function() { + it('should support updating a JS file', async function () { let b = await testCache(async b => { assert.equal(await run(b.bundleGraph), 4); await overlayFS.writeFile( @@ -134,7 +132,7 @@ describe('cache', function() { assert.equal(await run(b.bundleGraph), 6); }); - it('should support adding a dependency', async function() { + it('should support adding a dependency', async function () { let b = await testCache(async b => { assert.equal(await run(b.bundleGraph), 4); await overlayFS.writeFile( @@ -150,7 +148,7 @@ describe('cache', function() { assert.equal(await run(b.bundleGraph), 8); }); - it('should support adding a dependency which changes the referenced bundles of a parent bundle', async function() { + it('should support adding a dependency which changes the referenced bundles of a parent bundle', async function () { async function exec(bundleGraph) { let calls = []; await run(bundleGraph, { @@ -178,7 +176,7 @@ describe('cache', function() { assert.deepEqual(await exec(b.bundleGraph), ['b', 'a']); }); - it('should error when deleting a file', async function() { + it('should error when deleting a file', async function () { // $FlowFixMe await assert.rejects( async () => { @@ -190,7 +188,7 @@ describe('cache', function() { ); }); - it('should error when starting parcel from a broken state with no changes', async function() { + it('should error when starting parcel from a broken state with no changes', async function () { // $FlowFixMe await assert.rejects(async () => { await testCache(async () => { @@ -208,7 +206,7 @@ describe('cache', function() { ); }); - describe('babel', function() { + describe('babel', function () { 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... @@ -235,8 +233,8 @@ describe('cache', function() { }); for (let {name, formatter, nesting} of configs) { - describe(name, function() { - it(`should support adding a ${name}`, async function() { + describe(name, function () { + it(`should support adding a ${name}`, async function () { let b = await testCache({ // Babel's config loader only works with the node filesystem inputFS, @@ -283,7 +281,7 @@ describe('cache', function() { ); }); - it(`should support updating a ${name}`, async function() { + it(`should support updating a ${name}`, async function () { let b = await testCache({ // Babel's config loader only works with the node filesystem inputFS, @@ -334,7 +332,7 @@ describe('cache', function() { ); }); - it(`should support deleting a ${name}`, async function() { + it(`should support deleting a ${name}`, async function () { let b = await testCache({ // Babel's config loader only works with the node filesystem inputFS, @@ -377,7 +375,7 @@ describe('cache', function() { ); }); - it(`should support updating an extended ${name}`, async function() { + it(`should support updating an extended ${name}`, async function () { let extendedName = '.babelrc-extended' + path.extname(name); let b = await testCache({ // Babel's config loader only works with the node filesystem @@ -436,7 +434,7 @@ describe('cache', function() { }); if (nesting) { - it(`should support adding a nested ${name}`, async function() { + it(`should support adding a nested ${name}`, async function () { let b = await testCache({ // Babel's config loader only works with the node filesystem inputFS, @@ -491,7 +489,7 @@ describe('cache', function() { ); }); - it(`should support updating a nested ${name}`, async function() { + it(`should support updating a nested ${name}`, async function () { let b = await testCache({ // Babel's config loader only works with the node filesystem inputFS, @@ -550,7 +548,7 @@ describe('cache', function() { ); }); - it(`should support deleting a nested ${name}`, async function() { + it(`should support deleting a nested ${name}`, async function () { let b = await testCache({ // Babel's config loader only works with the node filesystem inputFS, @@ -604,8 +602,8 @@ describe('cache', function() { }); } - describe('.babelignore', function() { - it('should support adding a .babelignore', async function() { + describe('.babelignore', function () { + it('should support adding a .babelignore', async function () { let b = await testCache({ // Babel's config loader only works with the node filesystem inputFS, @@ -660,7 +658,7 @@ describe('cache', function() { ); }); - it('should support updating a .babelignore', async function() { + it('should support updating a .babelignore', async function () { let b = await testCache({ // Babel's config loader only works with the node filesystem inputFS, @@ -715,7 +713,7 @@ describe('cache', function() { ); }); - it('should support deleting a .babelignore', async function() { + it('should support deleting a .babelignore', async function () { let b = await testCache({ // Babel's config loader only works with the node filesystem inputFS, @@ -768,8 +766,8 @@ describe('cache', function() { }); }); - describe('plugins', function() { - it('should invalidate when plugins are updated', async function() { + describe('plugins', function () { + it('should invalidate when plugins are updated', async function () { let b = await testCache({ // Babel's config loader only works with the node filesystem inputFS, @@ -842,7 +840,7 @@ describe('cache', function() { assert(contents.includes('replaced'), 'string should be replaced'); }); - it('should invalidate when there are relative plugins', async function() { + it('should invalidate when there are relative plugins', async function () { let b = await testCache({ // Babel's config loader only works with the node filesystem inputFS, @@ -899,7 +897,7 @@ describe('cache', function() { assert(contents.includes('replaced'), 'string should be replaced'); }); - it('should invalidate when there are symlinked plugins', async function() { + it('should invalidate when there are symlinked plugins', async function () { // Symlinks don't work consistently on windows. Skip this test. if (process.platform === 'win32') { this.skip(); @@ -982,8 +980,8 @@ describe('cache', function() { }); }); - describe('parcel config', function() { - it('should support adding a .parcelrc', async function() { + describe('parcel config', function () { + it('should support adding a .parcelrc', async function () { let b = await testCache(async b => { assert.equal(await run(b.bundleGraph), 4); @@ -1011,7 +1009,7 @@ describe('cache', function() { assert(contents.includes('TRANSFORMED CODE')); }); - it('should support updating a .parcelrc', async function() { + it('should support updating a .parcelrc', async function () { let b = await testCache({ async setup() { await overlayFS.writeFile( @@ -1049,7 +1047,7 @@ describe('cache', function() { assert.equal(await run(b.bundleGraph), 4); }); - it('should support updating an extended .parcelrc', async function() { + it('should support updating an extended .parcelrc', async function () { let b = await testCache({ async setup() { await overlayFS.writeFile( @@ -1094,7 +1092,7 @@ describe('cache', function() { assert.equal(await run(b.bundleGraph), 4); }); - it('should error when deleting an extended parcelrc', async function() { + it('should error when deleting an extended parcelrc', async function () { // $FlowFixMe await assert.rejects( async () => { @@ -1132,7 +1130,7 @@ describe('cache', function() { ); }); - it('should support deleting a .parcelrc', async function() { + it('should support deleting a .parcelrc', async function () { let b = await testCache({ async setup() { await overlayFS.writeFile( @@ -1166,8 +1164,8 @@ describe('cache', function() { }); }); - describe('transformations', function() { - it('should invalidate when included files changes', async function() { + describe('transformations', function () { + it('should invalidate when included files changes', async function () { let b = await testCache({ // TODO: update when the fs transform supports the MemoryFS inputFS, @@ -1273,7 +1271,7 @@ describe('cache', function() { assert.equal(await run(b.bundleGraph), undefined); }); - it('should invalidate when environment variables change', async function() { + it('should invalidate when environment variables change', async function () { let b = await testCache({ async setup() { await overlayFS.writeFile(path.join(inputDir, '.env'), 'TEST=hi'); @@ -1297,8 +1295,8 @@ describe('cache', function() { }); }); - describe('entries', function() { - it('should support adding an entry that matches a glob', async function() { + describe('entries', function () { + it('should support adding an entry that matches a glob', async function () { let b = await testCache({ entries: ['src/entries/*.js'], async update(b) { @@ -1336,7 +1334,7 @@ describe('cache', function() { ]); }); - it('should support deleting an entry that matches a glob', async function() { + it('should support deleting an entry that matches a glob', async function () { let b = await testCache({ entries: ['src/entries/*.js'], async update(b) { @@ -1363,7 +1361,7 @@ describe('cache', function() { ]); }); - it('should error when deleting a file entry', async function() { + it('should error when deleting a file entry', async function () { // $FlowFixMe await assert.rejects( async () => { @@ -1380,7 +1378,7 @@ describe('cache', function() { ); }); - it('should recover from errors when adding a missing entry', async function() { + it('should recover from errors when adding a missing entry', async function () { // $FlowFixMe await assert.rejects( async () => { @@ -1406,8 +1404,8 @@ describe('cache', function() { }); }); - describe('target config', function() { - it('should support adding a target config', async function() { + describe('target config', function () { + it('should support adding a target config', async function () { let b = await testCache({ defaultTargetOptions: { shouldScopeHoist: true, @@ -1443,7 +1441,7 @@ describe('cache', function() { assert(contents.includes('export '), 'should include export'); }); - it('should support adding a second target', async function() { + it('should support adding a second target', async function () { let pkgFile = path.join(inputDir, 'package.json'); let b = await testCache({ defaultTargetOptions: { @@ -1507,7 +1505,7 @@ describe('cache', function() { ]); }); - it('should support changing target output location', async function() { + it('should support changing target output location', async function () { let pkgFile = path.join(inputDir, 'package.json'); await testCache({ defaultTargetOptions: { @@ -1576,7 +1574,7 @@ describe('cache', function() { ); }); - it('should support updating target config options', async function() { + it('should support updating target config options', async function () { let pkgFile = path.join(inputDir, 'package.json'); let b = await testCache({ defaultTargetOptions: { @@ -1629,7 +1627,7 @@ describe('cache', function() { ); }); - it('should support deleting a target', async function() { + it('should support deleting a target', async function () { let pkgFile = path.join(inputDir, 'package.json'); let b = await testCache({ defaultTargetOptions: { @@ -1693,7 +1691,7 @@ describe('cache', function() { ]); }); - it('should support deleting all targets', async function() { + it('should support deleting all targets', async function () { let pkgFile = path.join(inputDir, 'package.json'); let b = await testCache({ defaultTargetOptions: { @@ -1773,7 +1771,7 @@ describe('cache', function() { ); }); - it('should update when sourcemap options change', async function() { + it('should update when sourcemap options change', async function () { let pkgFile = path.join(inputDir, 'package.json'); let b = await testCache({ defaultTargetOptions: { @@ -1830,7 +1828,7 @@ describe('cache', function() { ); }); - it('should update when publicUrl changes', async function() { + it('should update when publicUrl changes', async function () { let pkgFile = path.join(inputDir, 'package.json'); let b = await testCache({ entries: ['src/index.html'], @@ -1888,7 +1886,7 @@ describe('cache', function() { ); }); - it('should update when a package.json is created', async function() { + it('should update when a package.json is created', async function () { let pkgFile = path.join(inputDir, 'package.json'); let pkg; let b = await testCache({ @@ -1928,7 +1926,7 @@ describe('cache', function() { assert(contents.includes('export '), 'should include export'); }); - it('should update when a package.json is deleted', async function() { + it('should update when a package.json is deleted', async function () { let pkgFile = path.join(inputDir, 'package.json'); let b = await testCache({ defaultTargetOptions: { @@ -1966,8 +1964,8 @@ describe('cache', function() { assert(!contents.includes('export '), 'does not include export'); }); - describe('browserslist', function() { - it('should update when a browserslist file is added', async function() { + describe('browserslist', function () { + it('should update when a browserslist file is added', async function () { let b = await testCache({ defaultTargetOptions: { shouldScopeHoist: true, @@ -1998,7 +1996,7 @@ describe('cache', function() { ); }); - it('should update when a .browserslistrc file is added', async function() { + it('should update when a .browserslistrc file is added', async function () { let b = await testCache({ defaultTargetOptions: { shouldScopeHoist: true, @@ -2029,7 +2027,7 @@ describe('cache', function() { ); }); - it('should update when a browserslist is updated', async function() { + it('should update when a browserslist is updated', async function () { let b = await testCache({ defaultTargetOptions: { shouldScopeHoist: true, @@ -2066,7 +2064,7 @@ describe('cache', function() { ); }); - it('should update when a browserslist is deleted', async function() { + it('should update when a browserslist is deleted', async function () { let b = await testCache({ defaultTargetOptions: { shouldScopeHoist: true, @@ -2100,7 +2098,7 @@ describe('cache', function() { ); }); - it('should update when BROWSERSLIST_ENV changes', async function() { + it('should update when BROWSERSLIST_ENV changes', async function () { let b = await testCache({ defaultTargetOptions: { shouldScopeHoist: true, @@ -2146,7 +2144,7 @@ describe('cache', function() { delete process.env.BROWSERSLIST_ENV; }); - it('should update when NODE_ENV changes', async function() { + it('should update when NODE_ENV changes', async function () { let env = process.env.NODE_ENV; let b = await testCache({ defaultTargetOptions: { @@ -2195,8 +2193,8 @@ describe('cache', function() { }); }); - describe('options', function() { - it('should update when publicUrl changes', async function() { + describe('options', function () { + it('should update when publicUrl changes', async function () { let b = await testCache({ entries: ['src/index.html'], defaultTargetOptions: { @@ -2233,7 +2231,7 @@ describe('cache', function() { ); }); - it('should update when minify changes', async function() { + it('should update when minify changes', async function () { let b = await testCache({ entries: ['src/index.html'], defaultTargetOptions: { @@ -2263,7 +2261,7 @@ describe('cache', function() { assert(!contents.includes('Test'), 'should not include Test'); }); - it('should update when scopeHoist changes', async function() { + it('should update when scopeHoist changes', async function () { let b = await testCache({ defaultTargetOptions: { shouldScopeHoist: false, @@ -2293,7 +2291,7 @@ describe('cache', function() { assert(!contents.includes('parcelRequire'), 'should not include Test'); }); - it('should update when sourceMaps changes', async function() { + it('should update when sourceMaps changes', async function () { let b = await testCache({ defaultTargetOptions: { sourceMaps: false, @@ -2326,7 +2324,7 @@ describe('cache', function() { ); }); - it('should update when distDir changes', async function() { + it('should update when distDir changes', async function () { let b = await testCache({ defaultTargetOptions: { shouldScopeHoist: true, @@ -2353,7 +2351,7 @@ describe('cache', function() { ); }); - it('should update when targets changes', async function() { + it('should update when targets changes', async function () { let b = await testCache({ defaultTargetOptions: { shouldScopeHoist: true, @@ -2421,7 +2419,7 @@ describe('cache', function() { ); }); - it('should update when defaultEngines changes', async function() { + it('should update when defaultEngines changes', async function () { let b = await testCache({ defaultTargetOptions: { shouldScopeHoist: true, @@ -2460,7 +2458,7 @@ describe('cache', function() { ); }); - it('should update when shouldContentHash changes', async function() { + it('should update when shouldContentHash changes', async function () { let b = await testCache({ entries: ['src/index.html'], defaultTargetOptions: { @@ -2481,7 +2479,7 @@ describe('cache', function() { assert(bundle.filePath.includes(bundle.id.slice(-8))); }); - it('should update when hmr options change', async function() { + it('should update when hmr options change', async function () { let b = await testCache({ hmrOptions: { host: 'localhost', @@ -2536,7 +2534,7 @@ describe('cache', function() { ); }); - it('should invalidate react refresh hot options change', async function() { + it('should invalidate react refresh hot options change', async function () { let b = await testCache({ async setup() { let pkgFile = path.join(inputDir, 'package.json'); @@ -2589,7 +2587,7 @@ describe('cache', function() { ); }); - it('should update when the config option changes', async function() { + it('should update when the config option changes', async function () { let b = await testCache({ async update(b) { let contents = await overlayFS.readFile( @@ -2621,7 +2619,7 @@ describe('cache', function() { assert(contents.includes('TRANSFORMED CODE')); }); - it('should update when the defaultConfig option changes', async function() { + it('should update when the defaultConfig option changes', async function () { let b = await testCache({ async update(b) { let contents = await overlayFS.readFile( @@ -2653,7 +2651,7 @@ describe('cache', function() { assert(contents.includes('TRANSFORMED CODE')); }); - it('should update env browserslist in package.json when mode changes', async function() { + it('should update env browserslist in package.json when mode changes', async function () { let env = process.env.NODE_ENV; delete process.env.NODE_ENV; try { @@ -2703,8 +2701,8 @@ describe('cache', function() { }); }); - describe('resolver', function() { - it('should support updating a package.json#main field', async function() { + describe('resolver', function () { + it('should support updating a package.json#main field', async function () { let b = await testCache(async b => { assert.equal(await run(b.bundleGraph), 4); await overlayFS.writeFile( @@ -2721,7 +2719,7 @@ describe('cache', function() { assert.equal(await run(b.bundleGraph), 8); }); - it('should support adding an alias', async function() { + it('should support adding an alias', async function () { let b = await testCache(async b => { assert.equal(await run(b.bundleGraph), 4); await overlayFS.writeFile( @@ -2743,7 +2741,7 @@ describe('cache', function() { assert.equal(await run(b.bundleGraph), 8); }); - it('should support updating an alias', async function() { + it('should support updating an alias', async function () { let b = await testCache({ async setup() { await overlayFS.writeFile( @@ -2783,7 +2781,7 @@ describe('cache', function() { assert.equal(await run(b.bundleGraph), 12); }); - it('should support deleting an alias', async function() { + it('should support deleting an alias', async function () { let b = await testCache({ async setup() { await overlayFS.writeFile( @@ -2813,7 +2811,7 @@ describe('cache', function() { assert.equal(await run(b.bundleGraph), 4); }); - it('should support adding an alias in a closer package.json', async function() { + it('should support adding an alias in a closer package.json', async function () { let b = await testCache(async b => { assert.equal(await run(b.bundleGraph), 4); await overlayFS.writeFile( @@ -2834,7 +2832,7 @@ describe('cache', function() { assert.equal(await run(b.bundleGraph), 6); }); - it('should support adding a file with a higher priority extension', async function() { + it('should support adding a file with a higher priority extension', async function () { let b = await testCache({ async setup() { // Start out pointing to a .ts file from a .js file @@ -2865,7 +2863,7 @@ describe('cache', function() { assert.equal(await run(b.bundleGraph), 4); }); - it('should support renaming a file to a different extension', async function() { + it('should support renaming a file to a different extension', async function () { let b = await testCache({ async setup() { // Start out pointing to a .js file @@ -2898,7 +2896,7 @@ describe('cache', function() { assert.equal(await run(b.bundleGraph), 4); }); - it('should resolve to a file over a directory with an index.js', async function() { + it('should resolve to a file over a directory with an index.js', async function () { let b = await testCache({ async setup() { let contents = await overlayFS.readFile( @@ -2927,7 +2925,7 @@ describe('cache', function() { assert.equal(await run(b.bundleGraph), 4); }); - it('should resolve to package.json#main over an index.js', async function() { + it('should resolve to package.json#main over an index.js', async function () { let b = await testCache({ async setup() { let contents = await overlayFS.readFile( @@ -2958,7 +2956,7 @@ describe('cache', function() { assert.equal(await run(b.bundleGraph), 4); }); - it('should recover from errors when adding a missing dependency', async function() { + it('should recover from errors when adding a missing dependency', async function () { // $FlowFixMe await assert.rejects( async () => { @@ -2983,7 +2981,7 @@ describe('cache', function() { assert.equal(await run(b.bundleGraph), 6); }); - it('should recover from a missing package.json#main', async function() { + it('should recover from a missing package.json#main', async function () { let b = await testCache({ async setup() { let contents = await overlayFS.readFile( @@ -3020,7 +3018,7 @@ describe('cache', function() { assert.equal(await run(b.bundleGraph), 10); }); - it('should recover from an invalid package.json', async function() { + it('should recover from an invalid package.json', async function () { // $FlowFixMe await assert.rejects(async () => { await testCache({ @@ -3059,7 +3057,7 @@ describe('cache', function() { assert.equal(await run(b.bundleGraph), 4); }); - it('should support adding a deeper node_modules folder', async function() { + it('should support adding a deeper node_modules folder', async function () { let b = await testCache({ async update(b) { assert.equal(await run(b.bundleGraph), 4); @@ -3078,8 +3076,8 @@ describe('cache', function() { assert.equal(await run(b.bundleGraph), 6); }); - describe('pnp', function() { - it('should invalidate when the .pnp.js file changes', async function() { + describe('pnp', function () { + it('should invalidate when the .pnp.js file changes', async function () { let Module = require('module'); let origPnpVersion = process.versions.pnp; // $FlowFixMe[prop-missing] @@ -3142,8 +3140,8 @@ describe('cache', function() { }); }); - describe('stylus', function() { - it('should support resolver inside stylus file', async function() { + describe('stylus', function () { + it('should support resolver inside stylus file', async function () { let b = await testCache( { entries: ['index.js'], @@ -3197,7 +3195,7 @@ describe('cache', function() { assert(css.includes('.c {')); }); - it('should support stylus default resolver', async function() { + it('should support stylus default resolver', async function () { let b = await testCache( { entries: ['index.js'], @@ -3238,7 +3236,7 @@ describe('cache', function() { assert(css.includes('.b {')); }); - it('should support glob imports in stylus files', async function() { + it('should support glob imports in stylus files', async function () { let b = await testCache( { entries: ['index.js'], @@ -3285,7 +3283,7 @@ describe('cache', function() { assert(css.includes('.foo-test')); }); - it('should support glob imports under stylus paths', async function() { + it('should support glob imports under stylus paths', async function () { let b = await testCache( { entries: ['index.js'], @@ -3351,8 +3349,8 @@ describe('cache', function() { }); }); - describe('less', function() { - it('should support adding higher priority less include paths', async function() { + describe('less', function () { + it('should support adding higher priority less include paths', async function () { let b = await testCache( { entries: ['index.js'], @@ -3401,7 +3399,7 @@ describe('cache', function() { assert(css.includes('.d')); }); - it('should recover from missing import errors', async function() { + it('should recover from missing import errors', async function () { // $FlowFixMe await assert.rejects( async () => { @@ -3452,8 +3450,8 @@ describe('cache', function() { }); }); - describe('sass', function() { - it('should support adding higher priority sass include paths', async function() { + describe('sass', function () { + it('should support adding higher priority sass include paths', async function () { let b = await testCache( { entries: ['index.sass'], @@ -3492,7 +3490,7 @@ describe('cache', function() { assert(css.includes('.test')); }); - it('should the SASS_PATH environment variable', async function() { + it('should the SASS_PATH environment variable', async function () { let b = await testCache( { entries: ['index.sass'], @@ -3534,7 +3532,7 @@ describe('cache', function() { assert(css.includes('.test')); }); - it('should recover from missing import errors', async function() { + it('should recover from missing import errors', async function () { // $FlowFixMe await assert.rejects(async () => { await testCache( @@ -3577,8 +3575,8 @@ describe('cache', function() { }); }); - describe('dev deps', function() { - it('should invalidate when updating a parcel transformer plugin', async function() { + describe('dev deps', function () { + it('should invalidate when updating a parcel transformer plugin', async function () { let b = await testCache({ async setup() { await overlayFS.writeFile( @@ -3617,7 +3615,7 @@ describe('cache', function() { assert(output.includes('UPDATED')); }); - it('should invalidate when updating a file required via options.packageManager.require', async function() { + it('should invalidate when updating a file required via options.packageManager.require', async function () { let b = await testCache({ async setup() { await overlayFS.writeFile( @@ -3670,7 +3668,7 @@ describe('cache', function() { assert(output.includes('FOO: 3')); }); - it('should resolve to package.json#main over an index.js', async function() { + it('should resolve to package.json#main over an index.js', async function () { let b = await testCache({ async setup() { await overlayFS.writeFile( @@ -3726,7 +3724,7 @@ describe('cache', function() { assert(output.includes('UPDATED')); }); - it('should resolve to a file over a directory with an index.js', async function() { + it('should resolve to a file over a directory with an index.js', async function () { let transformerDir = path.join( inputDir, 'node_modules', @@ -3772,9 +3770,9 @@ describe('cache', function() { assert(output.includes('UPDATED')); }); - it('should support adding a deeper node_modules folder', async function() {}); + it('should support adding a deeper node_modules folder', async function () {}); - it('should support yarn pnp', async function() { + it('should support yarn pnp', async function () { let Module = require('module'); // $FlowFixMe[incompatible-type] let origPnpVersion = process.versions.pnp; @@ -3927,8 +3925,8 @@ describe('cache', function() { } }); - describe('postcss', function() { - it('should invalidate when a postcss plugin changes', async function() { + describe('postcss', function () { + it('should invalidate when a postcss plugin changes', async function () { let b = await testCache( { entries: ['index.css'], @@ -3976,7 +3974,7 @@ describe('cache', function() { assert(output.includes('background: blue')); }); - it('should invalidate when a JS postcss config changes', async function() { + it('should invalidate when a JS postcss config changes', async function () { let b = await testCache( { entries: ['style.css'], @@ -4015,7 +4013,7 @@ describe('cache', function() { assert(output.includes('background-color: blue')); }); - it('should invalidate when a JSON postcss config changes', async function() { + it('should invalidate when a JSON postcss config changes', async function () { let b = await testCache( { entries: ['nested/index.css'], @@ -4046,7 +4044,7 @@ describe('cache', function() { assert(output.includes('background-color: blue')); }); - it('should invalidate when a closer postcss config is added', async function() { + it('should invalidate when a closer postcss config is added', async function () { let b = await testCache( { entries: ['nested/index.css'], @@ -4078,8 +4076,8 @@ describe('cache', function() { }); }); - describe('posthtml', function() { - it('should invalidate when a posthtml plugin changes', async function() { + describe('posthtml', function () { + it('should invalidate when a posthtml plugin changes', async function () { let b = await testCache( { entries: ['index.html'], @@ -4127,7 +4125,7 @@ describe('cache', function() { assert(output.includes('
Test
')); }); - it('should invalidate when a JS postcss config changes', async function() { + it('should invalidate when a JS postcss config changes', async function () { let b = await testCache( { entries: ['index.html'], @@ -4174,8 +4172,8 @@ describe('cache', function() { }); }); - describe('bundling', function() { - it('should invalidate when switching to a different bundler plugin', async function() { + describe('bundling', function () { + it('should invalidate when switching to a different bundler plugin', async function () { let b = await testCache({ async update(b) { assert.equal(b.bundleGraph.getBundles().length, 1); @@ -4193,7 +4191,7 @@ describe('cache', function() { assert.equal(b.bundleGraph.getBundles().length, 4); }); - it('should invalidate when a bundler plugin is updated', async function() { + it('should invalidate when a bundler plugin is updated', async function () { let b = await testCache({ async setup() { await overlayFS.writeFile( @@ -4216,10 +4214,9 @@ describe('cache', function() { ); await overlayFS.writeFile( bundler, - (await overlayFS.readFile(bundler, 'utf8')).replace( - 'Boolean(dependency.isEntry)', - 'false', - ), + ( + await overlayFS.readFile(bundler, 'utf8') + ).replace('Boolean(dependency.isEntry)', 'false'), ); }, }); @@ -4228,7 +4225,7 @@ describe('cache', function() { assert(b.bundleGraph.getBundles()[0].name.includes('HASH_REF')); }); - it('should invalidate when adding a namer plugin', async 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); @@ -4251,7 +4248,7 @@ describe('cache', function() { ); }); - it('should invalidate when a namer plugin is updated', async function() { + it('should invalidate when a namer plugin is updated', async function () { let b = await testCache({ async setup() { await overlayFS.writeFile( @@ -4277,10 +4274,9 @@ describe('cache', function() { ); await overlayFS.writeFile( namer, - (await overlayFS.readFile(namer, 'utf8')).replace( - 'bundle.id', - 'bundle.id.slice(-8)', - ), + ( + await overlayFS.readFile(namer, 'utf8') + ).replace('bundle.id', 'bundle.id.slice(-8)'), ); }, }); @@ -4292,7 +4288,7 @@ describe('cache', function() { ); }); - it('should invalidate when adding a runtime plugin', async function() { + it('should invalidate when adding a runtime plugin', async function () { let b = await testCache({ async update(b) { let res = await run(b.bundleGraph, null, {require: false}); @@ -4312,7 +4308,7 @@ describe('cache', function() { assert.equal(res.runtime_test, true); }); - it('should invalidate when a runtime is updated', async function() { + it('should invalidate when a runtime is updated', async function () { let b = await testCache({ async setup() { await overlayFS.writeFile( @@ -4336,10 +4332,9 @@ describe('cache', function() { ); await overlayFS.writeFile( namer, - (await overlayFS.readFile(namer, 'utf8')).replace( - 'runtime_test', - 'test_runtime', - ), + ( + await overlayFS.readFile(namer, 'utf8') + ).replace('runtime_test', 'test_runtime'), ); }, }); @@ -4349,8 +4344,8 @@ describe('cache', function() { assert.equal(res.test_runtime, true); }); - describe('bundler config', function() { - it('should support adding bundler config', async function() { + describe('bundler config', function () { + it('should support adding bundler config', async function () { let b = await testCache( { entries: ['*.html'], @@ -4397,7 +4392,7 @@ describe('cache', function() { assert.equal(html.match(/