Repository: parcel-bundler/parcel
File: packages/core/core/src/Validation.js (JavaScript)

Code before:
            // 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)),
                options: pluginOptions,
                logger: validatorLogger,
                resolveConfigWithPath: (
                  configNames: Array<string>,
                  assetFilePath: string,
                ) =>
                  resolveConfig(
                    this.options.inputFS,
                    assetFilePath,
                    configNames,
                  ),
              });
            }

            // Otherwise, pass the assets one-at-a-time
            else if (plugin.validate && !this.dedicatedThread) {
              await Promise.all(
                assets.map(async asset => {
                  let config = null;
                  let getConfig = plugin.getConfig?.bind(plugin);
                  if (getConfig) {
                    config = await getConfig({
                      asset: new Asset(asset),
                      options: pluginOptions,
                      logger: validatorLogger,
                      resolveConfig: (configNames: Array<string>) =>
                        resolveConfig(
                          this.options.inputFS,
                          asset.value.filePath,
                          configNames,
                        ),
                    });
                  }

                  let validatorResult = await plugin.validate({
                    asset: new Asset(asset),
                    options: pluginOptions,
                    config,
                    logger: validatorLogger,
                  });
                  validatorResults.push(validatorResult);
                }),
              );
            }
            this.handleResults(validatorResults);
          } catch (e) {
            throw new ThrowableDiagnostic({

Review comment (suggestion):
This can also be worked around by factoring `let publicAsset = new Asset()` out before the if statement

Code after:
            // 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)),
                options: pluginOptions,
                logger: validatorLogger,
                resolveConfigWithPath: (
                  configNames: Array<string>,
                  assetFilePath: string,
                ) =>
                  resolveConfig(
                    this.options.inputFS,
                    assetFilePath,
                    configNames,
                  ),
              });
            }

            // Otherwise, pass the assets one-at-a-time
            else if (plugin.validate && !this.dedicatedThread) {
              await Promise.all(
                assets.map(async input => {
                  let config = null;
                  let asset = new Asset(input);
                  if (plugin.getConfig) {
                    config = await plugin.getConfig({
                      asset,
                      options: pluginOptions,
                      logger: validatorLogger,
                      resolveConfig: (configNames: Array<string>) =>
                        resolveConfig(
                          this.options.inputFS,
                          input.value.filePath,
                          configNames,
                        ),
                    });
                  }

                  let validatorResult = await plugin.validate({
                    asset,
                    options: pluginOptions,
                    config,
                    logger: validatorLogger,
                  });
                  validatorResults.push(validatorResult);
                }),
              );
            }
            this.handleResults(validatorResults);
          } catch (e) {
            throw new ThrowableDiagnostic({