Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update to prettier 2 #7209

Merged
merged 2 commits into from Nov 1, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions .prettierrc
Expand Up @@ -3,6 +3,7 @@
"endOfLine": "lf",
"singleQuote": true,
"trailingComma": "all",
"arrowParens": "avoid",
"overrides": [
{
"files": [
Expand Down
2 changes: 1 addition & 1 deletion package.json
Expand Up @@ -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"
Expand Down
5 changes: 2 additions & 3 deletions packages/bundlers/default/src/DefaultBundler.js
Expand Up @@ -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 =>
Expand Down
5 changes: 2 additions & 3 deletions packages/core/codeframe/src/codeframe.js
Expand Up @@ -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);
Expand Down
4 changes: 1 addition & 3 deletions packages/core/core/src/PackagerRunner.js
Expand Up @@ -589,9 +589,7 @@ export default class PackagerRunner {
return devDepHashes;
}

async readFromCache(
cacheKey: string,
): Promise<?{|
async readFromCache(cacheKey: string): Promise<?{|
contents: Readable,
map: ?Readable,
|}> {
Expand Down
14 changes: 4 additions & 10 deletions packages/core/core/src/Parcel.js
Expand Up @@ -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();
Expand Down Expand Up @@ -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();

Expand Down
16 changes: 5 additions & 11 deletions packages/core/core/src/ParcelConfig.js
Expand Up @@ -116,9 +116,7 @@ export default class ParcelConfig {
};
}

_loadPlugin<T>(
node: ParcelPluginNode,
): Promise<{|
_loadPlugin<T>(node: ParcelPluginNode): Promise<{|
plugin: T,
version: Semver,
resolveFrom: ProjectPath,
Expand Down Expand Up @@ -179,9 +177,8 @@ export default class ParcelConfig {
}

getValidatorNames(filePath: ProjectPath): Array<string> {
let validators: PureParcelConfigPipeline = this._getValidatorNodes(
filePath,
);
let validators: PureParcelConfigPipeline =
this._getValidatorNodes(filePath);
return validators.map(v => v.packageName);
}

Expand All @@ -203,11 +200,8 @@ export default class ParcelConfig {
pipeline?: ?string,
allowEmpty?: boolean,
): Promise<Array<LoadedPlugin<Transformer<mixed>>>> {
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 [];
Expand Down
7 changes: 4 additions & 3 deletions packages/core/core/src/RequestTracker.js
Expand Up @@ -783,9 +783,10 @@ export default class RequestTracker {
this.signal = signal;
}

startRequest(
request: StoredRequest,
): {|requestNodeId: NodeId, deferred: Deferred<boolean>|} {
startRequest(request: StoredRequest): {|
requestNodeId: NodeId,
deferred: Deferred<boolean>,
|} {
let didPreviouslyExist = this.graph.hasContentKey(request.id);
let requestNodeId;
if (didPreviouslyExist) {
Expand Down
6 changes: 2 additions & 4 deletions packages/core/core/src/applyRuntimes.js
Expand Up @@ -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,
Expand Down
6 changes: 2 additions & 4 deletions packages/core/core/src/public/Asset.js
Expand Up @@ -41,10 +41,8 @@ const inspect = Symbol.for('nodejs.util.inspect.custom');

const uncommittedAssetValueToAsset: WeakMap<AssetValue, Asset> = new WeakMap();
const committedAssetValueToAsset: WeakMap<AssetValue, Asset> = new WeakMap();
const assetValueToMutableAsset: WeakMap<
AssetValue,
MutableAsset,
> = new WeakMap();
const assetValueToMutableAsset: WeakMap<AssetValue, MutableAsset> =
new WeakMap();

const _assetToAssetValue: WeakMap<
IAsset | IMutableAsset | BaseAsset,
Expand Down
6 changes: 2 additions & 4 deletions packages/core/core/src/public/Bundle.js
Expand Up @@ -51,10 +51,8 @@ const _bundleToInternalBundle: WeakMap<IBundle, InternalBundle> = new WeakMap();
export function bundleToInternalBundle(bundle: IBundle): InternalBundle {
return nullthrows(_bundleToInternalBundle.get(bundle));
}
const _bundleToInternalBundleGraph: WeakMap<
IBundle,
BundleGraph,
> = new WeakMap();
const _bundleToInternalBundleGraph: WeakMap<IBundle, BundleGraph> =
new WeakMap();
export function bundleToInternalBundleGraph(bundle: IBundle): BundleGraph {
return nullthrows(_bundleToInternalBundleGraph.get(bundle));
}
Expand Down
3 changes: 2 additions & 1 deletion packages/core/core/src/public/BundleGraph.js
Expand Up @@ -47,7 +47,8 @@ type BundleFactory<TBundle: IBundle> = (
) => TBundle;

export default class BundleGraph<TBundle: IBundle>
implements IBundleGraph<TBundle> {
implements IBundleGraph<TBundle>
{
#graph: InternalBundleGraph;
#options: ParcelOptions;
#createBundle: BundleFactory<TBundle>;
Expand Down
6 changes: 2 additions & 4 deletions packages/core/core/src/public/Dependency.js
Expand Up @@ -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<InternalDependency, Dependency> =
new WeakMap();
const _dependencyToInternalDependency: WeakMap<
IDependency,
InternalDependency,
Expand Down
11 changes: 6 additions & 5 deletions packages/core/core/src/public/MutableBundleGraph.js
Expand Up @@ -27,8 +27,10 @@ import {fromProjectPathRelative} from '../projectPath';
import {BundleBehavior} from '../types';
import BundleGroup, {bundleGroupToInternalBundleGroup} from './BundleGroup';

export default class MutableBundleGraph extends BundleGraph<IBundle>
implements IMutableBundleGraph {
export default class MutableBundleGraph
extends BundleGraph<IBundle>
implements IMutableBundleGraph
{
#graph /*: InternalBundleGraph */;
#options /*: ParcelOptions */;
#bundlePublicIds /*: Set<string> */ = new Set<string>();
Expand Down Expand Up @@ -102,9 +104,8 @@ export default class MutableBundleGraph extends BundleGraph<IBundle>
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(
Expand Down
6 changes: 2 additions & 4 deletions packages/core/core/src/public/PluginOptions.js
Expand Up @@ -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<ParcelOptions, PluginOptions> =
new WeakMap();

export default class PluginOptions implements IPluginOptions {
#options /*: ParcelOptions */;
Expand Down
6 changes: 2 additions & 4 deletions packages/core/core/src/public/Symbols.js
Expand Up @@ -97,10 +97,8 @@ export class AssetSymbols implements IAssetSymbols {
}
}

let valueToMutableAssetSymbols: WeakMap<
Asset,
MutableAssetSymbols,
> = new WeakMap();
let valueToMutableAssetSymbols: WeakMap<Asset, MutableAssetSymbols> =
new WeakMap();
export class MutableAssetSymbols implements IMutableAssetSymbols {
/*::
@@iterator(): Iterator<[ISymbol, {|local: ISymbol, loc: ?SourceLocation, meta?: ?Meta|}]> { return ({}: any); }
Expand Down
8 changes: 4 additions & 4 deletions packages/core/core/src/requests/AssetGraphRequest.js
Expand Up @@ -79,7 +79,8 @@ export default function createAssetGraphRequest(
type: 'asset_graph_request',
id: input.name,
run: async input => {
let prevResult = await input.api.getPreviousResult<AssetGraphRequestResult>();
let prevResult =
await input.api.getPreviousResult<AssetGraphRequestResult>();
let builder = new AssetGraphBuilder(input, prevResult);
return builder.build();
},
Expand Down Expand Up @@ -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);
}
Expand Down
4 changes: 1 addition & 3 deletions packages/core/core/src/requests/EntryRequest.js
Expand Up @@ -314,9 +314,7 @@ export class EntryResolver {
});
}

async readPackage(
entry: FilePath,
): Promise<?{
async readPackage(entry: FilePath): Promise<?{
...PackageJSON,
filePath: FilePath,
map: {|data: mixed, pointers: {|[string]: Mapping|}|},
Expand Down
24 changes: 10 additions & 14 deletions packages/core/core/src/requests/PackageRequest.js
Expand Up @@ -54,20 +54,16 @@ async function run({input, api, farm}: RunInput) {
let {cachePath} = nullthrows(
await api.runRequest<null, ConfigAndCachePath>(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);
Expand Down
12 changes: 2 additions & 10 deletions packages/core/core/src/requests/ParcelConfigRequest.js
Expand Up @@ -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)
Expand Down
10 changes: 4 additions & 6 deletions packages/core/core/src/requests/TargetRequest.js
Expand Up @@ -154,10 +154,8 @@ export class TargetResolver {
optionTargets = [exclusiveTarget];
}

let packageTargets: Map<
string,
Target | null,
> = await this.resolvePackageTargets(rootDir, exclusiveTarget);
let packageTargets: Map<string, Target | null> =
await this.resolvePackageTargets(rootDir, exclusiveTarget);
let targets: Array<Target>;
if (optionTargets) {
if (Array.isArray(optionTargets)) {
Expand Down Expand Up @@ -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,
Expand Down
5 changes: 2 additions & 3 deletions packages/core/core/src/types.js
Expand Up @@ -148,9 +148,8 @@ export const BundleBehavior = {
isolated: 1,
};

export const BundleBehaviorNames: Array<
$Keys<typeof BundleBehavior>,
> = Object.keys(BundleBehavior);
export const BundleBehaviorNames: Array<$Keys<typeof BundleBehavior>> =
Object.keys(BundleBehavior);

export type Asset = {|
id: ContentKey,
Expand Down
3 changes: 2 additions & 1 deletion packages/core/core/src/worker.js
Expand Up @@ -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
Expand Down