Skip to content

Commit

Permalink
[autofix.ci] apply automated fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
autofix-ci[bot] authored Dec 10, 2024
1 parent 10f0b87 commit 9891385
Showing 1 changed file with 23 additions and 27 deletions.
50 changes: 23 additions & 27 deletions tasks/transform_conformance/update_fixtures.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,33 +12,33 @@
// 2. Skip the fixtures which are marked "SKIP_babel7plugins_babel8core"
// (or maybe don't - what does this option mean?)

import { transformFileAsync } from "@babel/core";
import { readFileSync } from "fs";
import { readdir, readFile, rename, writeFile } from "fs/promises";
import { extname, join as pathJoin } from "path";
import { transformFileAsync } from '@babel/core';
import { readFileSync } from 'fs';
import { readdir, readFile, rename, writeFile } from 'fs/promises';
import { extname, join as pathJoin } from 'path';

const PACKAGES = [
"babel-plugin-transform-class-properties",
"babel-plugin-transform-logical-assignment-operators",
'babel-plugin-transform-class-properties',
'babel-plugin-transform-logical-assignment-operators',
];
const FILTER_OUT_PRESETS = ["env"];
const FILTER_OUT_PRESETS = ['env'];
const FILTER_OUT_PLUGINS = [
"transform-classes",
"transform-block-scoping",
"transform-destructuring",
'transform-classes',
'transform-block-scoping',
'transform-destructuring',
];

const PACKAGES_PATH = pathJoin(
import.meta.dirname,
"../coverage/babel/packages",
'../coverage/babel/packages',
);
const OVERRIDES_PATH = pathJoin(import.meta.dirname, "overrides");
const OVERRIDES_PATH = pathJoin(import.meta.dirname, 'overrides');

// Copied from `@babel/helper-transform-fixture-test-runner`
const EXTERNAL_HELPERS_VERSION = "7.100.0";
const EXTERNAL_HELPERS_VERSION = '7.100.0';

for (const packageName of PACKAGES) {
const dirPath = pathJoin(PACKAGES_PATH, packageName, "test/fixtures");
const dirPath = pathJoin(PACKAGES_PATH, packageName, 'test/fixtures');
await updateDir(dirPath, {}, false);
}

Expand Down Expand Up @@ -69,19 +69,19 @@ async function updateDir(dirPath, options, hasChangedOptions) {
dirFiles.push(filename);
} else {
const ext = extname(filename),
type = ext === "" ? filename : filename.slice(0, -ext.length);
type = ext === '' ? filename : filename.slice(0, -ext.length);
if (Object.hasOwn(filenames, type)) filenames[type] = filename;
}
}

// Update options, save to file, and merge options with parent
if (filenames.options) {
const path = pathJoin(dirPath, filenames.options);
const localOptions = JSON.parse(await readFile(path, "utf8"));
const localOptions = JSON.parse(await readFile(path, 'utf8'));
if (!overrides.options && updateOptions(localOptions)) {
hasChangedOptions = true;
await backupFile(path);
await writeFile(path, JSON.stringify(localOptions, null, 2) + "\n");
await writeFile(path, JSON.stringify(localOptions, null, 2) + '\n');
}
options = { ...options, ...localOptions };
}
Expand Down Expand Up @@ -129,8 +129,8 @@ function updateOptions(options) {
if (options[key].length === 0) delete options[key];
}

filter("presets", FILTER_OUT_PRESETS);
filter("plugins", FILTER_OUT_PLUGINS);
filter('presets', FILTER_OUT_PRESETS);
filter('plugins', FILTER_OUT_PLUGINS);

return hasChangedOptions;
}
Expand Down Expand Up @@ -163,24 +163,20 @@ async function transform(inputPath, outputPath, options) {
}

if (options.presets) {
options.presets = options.presets.map((preset) =>
prefixName(preset, "preset"),
);
options.presets = options.presets.map((preset) => prefixName(preset, 'preset'));
}

options.plugins = (options.plugins || []).map((plugin) =>
prefixName(plugin, "plugin"),
);
options.plugins = (options.plugins || []).map((plugin) => prefixName(plugin, 'plugin'));

let addExternalHelpersPlugin = true;
if (Object.hasOwn(options, "externalHelpers")) {
if (Object.hasOwn(options, 'externalHelpers')) {
if (!options.externalHelpers) addExternalHelpersPlugin = false;
delete options.externalHelpers;
}

if (addExternalHelpersPlugin) {
options.plugins.push([
"@babel/plugin-external-helpers",
'@babel/plugin-external-helpers',
{ helperVersion: EXTERNAL_HELPERS_VERSION },
]);
}
Expand Down

0 comments on commit 9891385

Please sign in to comment.