Match xplat/yoga/javascript prettier conventions

Summary:
Match Prettier config to match other Meta OSS projects

Didn't update the test generator to use this form yet.

Reviewed By: yungsters

Differential Revision: D45570415

fbshipit-source-id: d5fd791b047debf41c28aecac75fb8dde16da3e3
This commit is contained in:
Nick Gerleman
2023-05-09 15:35:42 -07:00
committed by Facebook GitHub Bot
parent 0cb4a49d38
commit 0a6a581936
29 changed files with 197 additions and 199 deletions

View File

@@ -8,8 +8,9 @@
*/
module.exports = {
trailingComma: "es5",
tabWidth: 2,
semi: true,
singleQuote: false,
arrowParens: 'avoid',
bracketSameLine: true,
bracketSpacing: false,
singleQuote: true,
trailingComma: 'all',
};

View File

@@ -7,11 +7,11 @@
* @format
*/
import type { Config } from "jest";
import type {Config} from 'jest';
const config: Config = {
setupFiles: ["./jest.setup.ts"],
testRegex: "/tests/.*\\.test\\.[jt]s$",
setupFiles: ['./jest.setup.ts'],
testRegex: '/tests/.*\\.test\\.[jt]s$',
};
export default config;

View File

@@ -8,17 +8,17 @@
*/
module.exports = async () => {
if (process.env["SYNC"] === "1" && process.env["WASM"] === "1") {
globalThis.Yoga = require("./dist/entrypoint/wasm-sync");
} else if (process.env["SYNC"] === "1") {
globalThis.Yoga = require("./dist/entrypoint/asmjs-sync");
} else if (process.env["WASM"] === "1") {
globalThis.Yoga = await require("./dist/entrypoint/wasm-async").loadYoga();
if (process.env['SYNC'] === '1' && process.env['WASM'] === '1') {
globalThis.Yoga = require('./dist/entrypoint/wasm-sync');
} else if (process.env['SYNC'] === '1') {
globalThis.Yoga = require('./dist/entrypoint/asmjs-sync');
} else if (process.env['WASM'] === '1') {
globalThis.Yoga = await require('./dist/entrypoint/wasm-async').loadYoga();
} else {
globalThis.Yoga = await require("./dist/entrypoint/asmjs-async").loadYoga();
globalThis.Yoga = await require('./dist/entrypoint/asmjs-async').loadYoga();
}
};
Object.defineProperty(globalThis, "YGBENCHMARK", {
Object.defineProperty(globalThis, 'YGBENCHMARK', {
get: () => globalThis.test,
});

View File

@@ -20,81 +20,78 @@ import {
spawn,
task,
tscTask,
} from "just-scripts";
} from 'just-scripts';
import glob from "glob";
import path from "path";
import which from "which";
import glob from 'glob';
import path from 'path';
import which from 'which';
const node = process.execPath;
option("fix");
option('fix');
task("clean", cleanTask({ paths: ["build", "dist"] }));
task('clean', cleanTask({paths: ['build', 'dist']}));
task(
"prepare-for-build",
'prepare-for-build',
parallel(
babelTransformTask({ paths: ["src_js"], dest: "dist" }),
copyTask({ paths: ["src_js/**/*.d.ts"], dest: "dist" }),
emcmakeGenerateTask()
)
babelTransformTask({paths: ['src_js'], dest: 'dist'}),
copyTask({paths: ['src_js/**/*.d.ts'], dest: 'dist'}),
emcmakeGenerateTask(),
),
);
function defineFlavor(flavor: string, env: NodeJS.ProcessEnv) {
task(`cmake-build:${flavor}`, cmakeBuildTask({targets: [flavor]}));
task(
`jest:${flavor}`,
jestTask({ config: path.join(__dirname, "jest.config.ts"), env })
jestTask({config: path.join(__dirname, 'jest.config.ts'), env}),
);
task(
`test:${flavor}`,
series("prepare-for-build", `cmake-build:${flavor}`, `jest:${flavor}`)
series('prepare-for-build', `cmake-build:${flavor}`, `jest:${flavor}`),
);
}
defineFlavor("asmjs-async", { WASM: "0", SYNC: "0" });
defineFlavor("asmjs-sync", { WASM: "0", SYNC: "1" });
defineFlavor("wasm-async", { WASM: "1", SYNC: "0" });
defineFlavor("wasm-sync", { WASM: "1", SYNC: "1" });
defineFlavor('asmjs-async', {WASM: '0', SYNC: '0'});
defineFlavor('asmjs-sync', {WASM: '0', SYNC: '1'});
defineFlavor('wasm-async', {WASM: '1', SYNC: '0'});
defineFlavor('wasm-sync', {WASM: '1', SYNC: '1'});
task("cmake-build:all", cmakeBuildTask());
task('cmake-build:all', cmakeBuildTask());
task(
"cmake-build:async",
cmakeBuildTask({ targets: ["asmjs-async", "wasm-async"] })
'cmake-build:async',
cmakeBuildTask({targets: ['asmjs-async', 'wasm-async']}),
);
task(
"cmake-build:sync",
cmakeBuildTask({ targets: ["asmjs-sync", "wasm-sync"] })
'cmake-build:sync',
cmakeBuildTask({targets: ['asmjs-sync', 'wasm-sync']}),
);
task("build", series("prepare-for-build", "cmake-build:all"));
task('build', series('prepare-for-build', 'cmake-build:all'));
task(
"test",
'test',
series(
"prepare-for-build",
series("cmake-build:asmjs-async", "jest:asmjs-async"),
series("cmake-build:asmjs-sync", "jest:asmjs-sync"),
series("cmake-build:wasm-async", "jest:wasm-async"),
series("cmake-build:wasm-sync", "jest:wasm-sync")
)
'prepare-for-build',
series('cmake-build:asmjs-async', 'jest:asmjs-async'),
series('cmake-build:asmjs-sync', 'jest:asmjs-sync'),
series('cmake-build:wasm-async', 'jest:wasm-async'),
series('cmake-build:wasm-sync', 'jest:wasm-sync'),
),
);
task(
"benchmark",
series("prepare-for-build", "cmake-build:sync", runBenchTask())
'benchmark',
series('prepare-for-build', 'cmake-build:sync', runBenchTask()),
);
task(
"lint",
'lint',
parallel(
tscTask(),
series(
eslintTask({ fix: argv().fix }),
clangFormatTask({ fix: argv().fix })
)
)
series(eslintTask({fix: argv().fix}), clangFormatTask({fix: argv().fix})),
),
);
function babelTransformTask(opts: {
@@ -102,39 +99,39 @@ function babelTransformTask(opts: {
dest: string;
}) {
return () => {
const args = [...opts.paths, "--source-maps", "--out-dir", opts.dest];
logger.info(`Transforming [${opts.paths.join(",")}] to '${opts.dest}'`);
const args = [...opts.paths, '--source-maps', '--out-dir', opts.dest];
logger.info(`Transforming [${opts.paths.join(',')}] to '${opts.dest}'`);
return spawn(node, [require.resolve("@babel/cli/bin/babel"), ...args]);
return spawn(node, [require.resolve('@babel/cli/bin/babel'), ...args]);
};
}
function runBenchTask() {
return () => {
const files = glob.sync("./tests/Benchmarks/**/*");
const args = ["./tests/bin/run-bench.ts", ...files];
logger.info(args.join(" "));
const files = glob.sync('./tests/Benchmarks/**/*');
const args = ['./tests/bin/run-bench.ts', ...files];
logger.info(args.join(' '));
return spawn(node, args, {
stdio: "inherit",
env: { NODE_OPTIONS: "-r ts-node/register" },
stdio: 'inherit',
env: {NODE_OPTIONS: '-r ts-node/register'},
});
};
}
function emcmakeGenerateTask() {
return () => {
const emcmake = which.sync("emcmake");
const ninja = which.sync("ninja", { nothrow: true });
const emcmake = which.sync('emcmake');
const ninja = which.sync('ninja', {nothrow: true});
const args = [
"cmake",
"-S",
".",
"-B",
"build",
...(ninja ? ["-G", "Ninja"] : []),
'cmake',
'-S',
'.',
'-B',
'build',
...(ninja ? ['-G', 'Ninja'] : []),
];
logger.info(["emcmake", ...args].join(" "));
logger.info(['emcmake', ...args].join(' '));
return spawn(emcmake, args);
};
@@ -142,28 +139,28 @@ function emcmakeGenerateTask() {
function cmakeBuildTask(opts?: {targets?: ReadonlyArray<string>}) {
return () => {
const cmake = which.sync("cmake");
const cmake = which.sync('cmake');
const args = [
"--build",
"build",
...(opts?.targets ? ["--target", ...opts.targets] : []),
'--build',
'build',
...(opts?.targets ? ['--target', ...opts.targets] : []),
];
logger.info(["cmake", ...args].join(" "));
logger.info(['cmake', ...args].join(' '));
return spawn(cmake, args, { stdio: "inherit" });
return spawn(cmake, args, {stdio: 'inherit'});
};
}
function clangFormatTask(opts?: {fix?: boolean}) {
return () => {
const args = [
...(opts?.fix ? ["-i"] : ["--dry-run", "--Werror"]),
...glob.sync("**/*.{h,hh,hpp,c,cpp,cc,m,mm}"),
...(opts?.fix ? ['-i'] : ['--dry-run', '--Werror']),
...glob.sync('**/*.{h,hh,hpp,c,cpp,cc,m,mm}'),
];
logger.info(["clang-format", ...args].join(" "));
logger.info(['clang-format', ...args].join(' '));
return spawn(node, [require.resolve("clang-format"), ...args], {
stdio: "inherit",
return spawn(node, [require.resolve('clang-format'), ...args], {
stdio: 'inherit',
});
};
}

View File

@@ -7,9 +7,9 @@
* @format
*/
const wrapAsm = require("../wrapAsm");
const wrapAsm = require('../wrapAsm');
module.exports = (loadAsm) => ({
module.exports = loadAsm => ({
loadYoga: () => loadAsm().then(wrapAsm),
...require("../generated/YGEnums"),
...require('../generated/YGEnums'),
});

View File

@@ -7,5 +7,5 @@
* @format
*/
const wrapAsm = require("../wrapAsm");
module.exports = (asm) => wrapAsm(asm());
const wrapAsm = require('../wrapAsm');
module.exports = asm => wrapAsm(asm());

View File

@@ -7,5 +7,5 @@
* @format
*/
const asm = require("../build/asmjs-async");
module.exports = require("./_entryAsync")(asm);
const asm = require('../build/asmjs-async');
module.exports = require('./_entryAsync')(asm);

View File

@@ -7,5 +7,5 @@
* @format
*/
const asm = require("../build/asmjs-sync");
module.exports = require("./_entrySync")(asm);
const asm = require('../build/asmjs-sync');
module.exports = require('./_entrySync')(asm);

View File

@@ -7,5 +7,5 @@
* @format
*/
const asm = require("../build/wasm-async");
module.exports = require("./_entryAsync")(asm);
const asm = require('../build/wasm-async');
module.exports = require('./_entryAsync')(asm);

View File

@@ -7,5 +7,5 @@
* @format
*/
const asm = require("../build/wasm-sync");
module.exports = require("./_entrySync")(asm);
const asm = require('../build/wasm-sync');
module.exports = require('./_entrySync')(asm);

View File

@@ -7,9 +7,9 @@
* @format
*/
import type { Yoga } from "./wrapAsm";
import type {Yoga} from './wrapAsm';
export * from "./generated/YGEnums";
export * from "./wrapAsm";
export * from './generated/YGEnums';
export * from './wrapAsm';
export function loadYoga(): Promise<Yoga>;

View File

@@ -8,4 +8,4 @@
*/
// Fallback for when the export map is not followed
module.exports = require("./entrypoint/asmjs-async");
module.exports = require('./entrypoint/asmjs-async');

View File

@@ -7,10 +7,10 @@
* @format
*/
import type { Yoga } from "./wrapAsm";
import type {Yoga} from './wrapAsm';
export * from "./generated/YGEnums";
export * from "./wrapAsm";
export * from './generated/YGEnums';
export * from './wrapAsm';
declare const yoga: Yoga;
export default yoga;

View File

@@ -8,4 +8,4 @@
*/
// Fallback for when the export map is not followed
module.exports = require("./entrypoint/asmjs-sync");
module.exports = require('./entrypoint/asmjs-sync');

View File

@@ -22,9 +22,9 @@ import type {
PositionType,
Unit,
Wrap,
} from "./generated/YGEnums";
} from './generated/YGEnums';
import type * as YGEnums from "./generated/YGEnums";
import type * as YGEnums from './generated/YGEnums';
type Layout = {
left: number;
@@ -50,7 +50,7 @@ export type Config = {
isExperimentalFeatureEnabled(feature: ExperimentalFeature): boolean;
setExperimentalFeatureEnabled(
feature: ExperimentalFeature,
enabled: boolean
enabled: boolean,
): void;
setPointScaleFactor(factor: number): void;
/**
@@ -77,7 +77,7 @@ export type MeasureFunction = (
width: number,
widthMode: MeasureMode,
height: number,
heightMode: MeasureMode
heightMode: MeasureMode,
) => Size;
export type Node = {
@@ -135,20 +135,20 @@ export type Node = {
setBorder(edge: Edge, borderWidth: number): void;
setDisplay(display: Display): void;
setFlex(flex: number): void;
setFlexBasis(flexBasis: number | "auto" | `${number}%`): void;
setFlexBasis(flexBasis: number | 'auto' | `${number}%`): void;
setFlexBasisPercent(flexBasis: number): void;
setFlexBasisAuto(): void;
setFlexDirection(flexDirection: FlexDirection): void;
setFlexGrow(flexGrow: number): void;
setFlexShrink(flexShrink: number): void;
setFlexWrap(flexWrap: Wrap): void;
setHeight(height: number | "auto" | `${number}%`): void;
setHeight(height: number | 'auto' | `${number}%`): void;
setIsReferenceBaseline(isReferenceBaseline: boolean): void;
setHeightAuto(): void;
setHeightPercent(height: number): void;
setJustifyContent(justifyContent: Justify): void;
setGap(gutter: Gutter, gapLength: number): Value;
setMargin(edge: Edge, margin: number | "auto" | `${number}%`): void;
setMargin(edge: Edge, margin: number | 'auto' | `${number}%`): void;
setMarginAuto(edge: Edge): void;
setMarginPercent(edge: Edge, margin: number): void;
setMaxHeight(maxHeight: number | `${number}%`): void;
@@ -167,7 +167,7 @@ export type Node = {
setPosition(edge: Edge, position: number | `${number}%`): void;
setPositionPercent(edge: Edge, position: number): void;
setPositionType(positionType: PositionType): void;
setWidth(width: number | "auto" | `${number}%`): void;
setWidth(width: number | 'auto' | `${number}%`): void;
setWidthAuto(): void;
setWidthPercent(width: number): void;
unsetDirtiedFunc(): void;

View File

@@ -7,9 +7,9 @@
* @format
*/
const CONSTANTS = require("./generated/YGEnums");
const CONSTANTS = require('./generated/YGEnums');
module.exports = (lib) => {
module.exports = lib => {
function patch(prototype, name, fn) {
const original = prototype[name];
@@ -19,16 +19,16 @@ module.exports = (lib) => {
}
for (const fnName of [
"setPosition",
"setMargin",
"setFlexBasis",
"setWidth",
"setHeight",
"setMinWidth",
"setMinHeight",
"setMaxWidth",
"setMaxHeight",
"setPadding",
'setPosition',
'setMargin',
'setFlexBasis',
'setWidth',
'setHeight',
'setMinWidth',
'setMinHeight',
'setMaxWidth',
'setMaxHeight',
'setPadding',
]) {
const methods = {
[CONSTANTS.UNIT_POINT]: lib.Node.prototype[fnName],
@@ -43,15 +43,15 @@ module.exports = (lib) => {
const value = args.pop();
let unit, asNumber;
if (value === "auto") {
if (value === 'auto') {
unit = CONSTANTS.UNIT_AUTO;
asNumber = undefined;
} else if (typeof value === "object") {
} else if (typeof value === 'object') {
unit = value.unit;
asNumber = value.valueOf();
} else {
unit =
typeof value === "string" && value.endsWith("%")
typeof value === 'string' && value.endsWith('%')
? CONSTANTS.UNIT_PERCENT
: CONSTANTS.UNIT_POINT;
asNumber = parseFloat(value);
@@ -62,7 +62,7 @@ module.exports = (lib) => {
if (!methods[unit])
throw new Error(
`Failed to execute "${fnName}": Unsupported unit '${value}'`
`Failed to execute "${fnName}": Unsupported unit '${value}'`,
);
if (asNumber !== undefined) {
@@ -85,7 +85,7 @@ module.exports = (lib) => {
});
}
patch(lib.Node.prototype, "setMeasureFunc", function (original, measureFunc) {
patch(lib.Node.prototype, 'setMeasureFunc', function (original, measureFunc) {
// This patch is just a convenience patch, since it helps write more
// idiomatic source code (such as .setMeasureFunc(null))
if (measureFunc) {
@@ -99,30 +99,30 @@ module.exports = (lib) => {
return lib.DirtiedCallback.implement({dirtied: dirtiedFunction});
}
patch(lib.Node.prototype, "setDirtiedFunc", function (original, dirtiedFunc) {
patch(lib.Node.prototype, 'setDirtiedFunc', function (original, dirtiedFunc) {
original.call(this, wrapDirtiedFunc(dirtiedFunc));
});
patch(lib.Config.prototype, "free", function () {
patch(lib.Config.prototype, 'free', function () {
// Since we handle the memory allocation ourselves (via lib.Config.create),
// we also need to handle the deallocation
lib.Config.destroy(this);
});
patch(lib.Node, "create", (_, config) => {
patch(lib.Node, 'create', (_, config) => {
// We decide the constructor we want to call depending on the parameters
return config
? lib.Node.createWithConfig(config)
: lib.Node.createDefault();
});
patch(lib.Node.prototype, "free", function () {
patch(lib.Node.prototype, 'free', function () {
// Since we handle the memory allocation ourselves (via lib.Node.create),
// we also need to handle the deallocation
lib.Node.destroy(this);
});
patch(lib.Node.prototype, "freeRecursive", function () {
patch(lib.Node.prototype, 'freeRecursive', function () {
for (let t = 0, T = this.getChildCount(); t < T; ++t) {
this.getChild(0).freeRecursive();
}
@@ -131,16 +131,16 @@ module.exports = (lib) => {
patch(
lib.Node.prototype,
"calculateLayout",
'calculateLayout',
function (
original,
width = NaN,
height = NaN,
direction = CONSTANTS.DIRECTION_LTR
direction = CONSTANTS.DIRECTION_LTR,
) {
// Just a small patch to add support for the function default parameters
return original.call(this, width, height, direction);
}
},
);
return {

View File

@@ -5,12 +5,12 @@
* LICENSE file in the root directory of this source tree.
*/
import { getMeasureCounter } from "../tools/MeasureCounter";
import { Yoga, YGBENCHMARK } from "../tools/globals";
import {getMeasureCounter} from '../tools/MeasureCounter';
import {Yoga, YGBENCHMARK} from '../tools/globals';
const ITERATIONS = 2000;
YGBENCHMARK("Stack with flex", () => {
YGBENCHMARK('Stack with flex', () => {
const root = Yoga.Node.create();
root.setWidth(100);
root.setHeight(100);
@@ -28,7 +28,7 @@ YGBENCHMARK("Stack with flex", () => {
root.freeRecursive();
});
YGBENCHMARK("Align stretch in undefined axis", () => {
YGBENCHMARK('Align stretch in undefined axis', () => {
const root = Yoga.Node.create();
const measureCounter = getMeasureCounter();
@@ -44,7 +44,7 @@ YGBENCHMARK("Align stretch in undefined axis", () => {
root.freeRecursive();
});
YGBENCHMARK("Nested flex", () => {
YGBENCHMARK('Nested flex', () => {
const root = Yoga.Node.create();
const measureCounter = getMeasureCounter();
@@ -68,7 +68,7 @@ YGBENCHMARK("Nested flex", () => {
root.freeRecursive();
});
YGBENCHMARK("Huge nested layout", () => {
YGBENCHMARK('Huge nested layout', () => {
const root = Yoga.Node.create();
const iterations = Math.pow(ITERATIONS, 1 / 4);

View File

@@ -5,9 +5,9 @@
* LICENSE file in the root directory of this source tree.
*/
import { Yoga } from "./tools/globals";
import {Yoga} from './tools/globals';
test("align_baseline_parent_using_child_in_column_as_reference", () => {
test('align_baseline_parent_using_child_in_column_as_reference', () => {
const config = Yoga.Config.create();
let root;
@@ -57,7 +57,7 @@ test("align_baseline_parent_using_child_in_column_as_reference", () => {
expect(root_child1_child1.getComputedLeft()).toBe(0);
expect(root_child1_child1.getComputedTop()).toBe(300);
} finally {
if (typeof root !== "undefined") {
if (typeof root !== 'undefined') {
root.freeRecursive();
}
@@ -65,7 +65,7 @@ test("align_baseline_parent_using_child_in_column_as_reference", () => {
}
});
test("align_baseline_parent_using_child_in_row_as_reference", () => {
test('align_baseline_parent_using_child_in_row_as_reference', () => {
const config = Yoga.Config.create();
let root;
@@ -115,7 +115,7 @@ test("align_baseline_parent_using_child_in_row_as_reference", () => {
expect(root_child1_child1.getComputedLeft()).toBe(500);
expect(root_child1_child1.getComputedTop()).toBe(0);
} finally {
if (typeof root !== "undefined") {
if (typeof root !== 'undefined') {
root.freeRecursive();
}

View File

@@ -5,9 +5,9 @@
* LICENSE file in the root directory of this source tree.
*/
import { Yoga } from "./tools/globals";
import {Yoga} from './tools/globals';
test("border_start", () => {
test('border_start', () => {
const root = Yoga.Node.create();
root.setWidth(100);
root.setHeight(100);

View File

@@ -5,9 +5,9 @@
* LICENSE file in the root directory of this source tree.
*/
import { Yoga } from "./tools/globals";
import {Yoga} from './tools/globals';
test("margin_start", () => {
test('margin_start', () => {
const root = Yoga.Node.create();
root.setWidth(100);
root.setHeight(100);

View File

@@ -5,9 +5,9 @@
* LICENSE file in the root directory of this source tree.
*/
import { Yoga } from "./tools/globals";
import {Yoga} from './tools/globals';
test("padding_start", () => {
test('padding_start', () => {
const root = Yoga.Node.create();
root.setWidth(100);
root.setHeight(100);

View File

@@ -5,9 +5,9 @@
* LICENSE file in the root directory of this source tree.
*/
import { Yoga } from "./tools/globals";
import {Yoga} from './tools/globals';
test("dirtied", () => {
test('dirtied', () => {
const root = Yoga.Node.create();
root.setAlignItems(Yoga.ALIGN_FLEX_START);
root.setWidth(100);
@@ -36,7 +36,7 @@ test("dirtied", () => {
root.freeRecursive();
});
test("dirtied_propagation", () => {
test('dirtied_propagation', () => {
const root = Yoga.Node.create();
root.setAlignItems(Yoga.ALIGN_FLEX_START);
root.setWidth(100);
@@ -75,7 +75,7 @@ test("dirtied_propagation", () => {
root.freeRecursive();
});
test("dirtied_hierarchy", () => {
test('dirtied_hierarchy', () => {
const root = Yoga.Node.create();
root.setAlignItems(Yoga.ALIGN_FLEX_START);
root.setWidth(100);
@@ -118,7 +118,7 @@ test("dirtied_hierarchy", () => {
root.freeRecursive();
});
test("dirtied_reset", () => {
test('dirtied_reset', () => {
const root = Yoga.Node.create();
root.setAlignItems(Yoga.ALIGN_FLEX_START);
root.setWidth(100);

View File

@@ -5,9 +5,9 @@
* LICENSE file in the root directory of this source tree.
*/
import { Yoga } from "./tools/globals";
import {Yoga} from './tools/globals';
test("errata_all_contains_example_errata", () => {
test('errata_all_contains_example_errata', () => {
const config = Yoga.Config.create();
config.setErrata(Yoga.ERRATA_ALL);
@@ -17,7 +17,7 @@ test("errata_all_contains_example_errata", () => {
config.free();
});
test("errata_none_omits_example_errata", () => {
test('errata_none_omits_example_errata', () => {
const config = Yoga.Config.create();
config.setErrata(Yoga.ERRATA_NONE);
@@ -27,7 +27,7 @@ test("errata_none_omits_example_errata", () => {
config.free();
});
test("errata_is_settable", () => {
test('errata_is_settable', () => {
const config = Yoga.Config.create();
config.setErrata(Yoga.ERRATA_ALL);

View File

@@ -5,9 +5,9 @@
* LICENSE file in the root directory of this source tree.
*/
import { Yoga } from "./tools/globals";
import {Yoga} from './tools/globals';
test("flex_basis_auto", () => {
test('flex_basis_auto', () => {
const root = Yoga.Node.create();
expect(root.getFlexBasis().unit).toBe(Yoga.UNIT_AUTO);

View File

@@ -5,11 +5,11 @@
* LICENSE file in the root directory of this source tree.
*/
import { Yoga } from "./tools/globals";
import {Yoga} from './tools/globals';
import { getMeasureCounterMax } from "./tools/MeasureCounter";
import {getMeasureCounterMax} from './tools/MeasureCounter';
test("measure_once_single_flexible_child", () => {
test('measure_once_single_flexible_child', () => {
const root = Yoga.Node.create();
root.setFlexDirection(Yoga.FLEX_DIRECTION_ROW);
root.setAlignItems(Yoga.ALIGN_FLEX_START);

View File

@@ -5,10 +5,10 @@
* LICENSE file in the root directory of this source tree.
*/
import { Yoga } from "./tools/globals";
import { getMeasureCounter } from "./tools/MeasureCounter";
import {Yoga} from './tools/globals';
import {getMeasureCounter} from './tools/MeasureCounter';
test("dont_measure_single_grow_shrink_child", () => {
test('dont_measure_single_grow_shrink_child', () => {
const root = Yoga.Node.create();
root.setWidth(100);
root.setHeight(100);
@@ -27,7 +27,7 @@ test("dont_measure_single_grow_shrink_child", () => {
root.freeRecursive();
});
test("dont_fail_with_incomplete_measure_dimensions", () => {
test('dont_fail_with_incomplete_measure_dimensions', () => {
// @ts-expect-error Testing bad usage
const heightOnlyCallback = getMeasureCounter(() => ({height: 10}));
// @ts-expect-error Testing bad usage

View File

@@ -8,7 +8,7 @@
* @format
*/
import path from "path";
import path from 'path';
const WARMUP_ITERATIONS = 3;
const BENCHMARK_ITERATIONS = 10;
@@ -17,10 +17,10 @@ const testFiles = process.argv.slice(2);
const testResults = new Map<string, Map<string, number>>();
for (const type of ["asmjs", "wasm"]) {
globalThis.Yoga = require(type === "asmjs"
? "../../dist/entrypoint/asmjs-sync"
: "../../dist/entrypoint/wasm-sync");
for (const type of ['asmjs', 'wasm']) {
globalThis.Yoga = require(type === 'asmjs'
? '../../dist/entrypoint/asmjs-sync'
: '../../dist/entrypoint/wasm-sync');
for (const file of testFiles) {
globalThis.YGBENCHMARK = (name: string, fn: () => void) => {
@@ -42,14 +42,14 @@ for (const type of ["asmjs", "wasm"]) {
const modulePath = path.resolve(file);
delete require.cache[require.resolve("../tools/globals")];
delete require.cache[require.resolve('../tools/globals')];
delete require.cache[modulePath];
require(modulePath);
}
}
console.log(
`Note: those tests are independants; there is no time relation to be expected between them`
`Note: those tests are independants; there is no time relation to be expected between them`,
);
for (const [name, results] of testResults) {
@@ -61,7 +61,7 @@ for (const [name, results] of testResults) {
for (const [type, result] of results) {
console.log(
` - ${type}: ${result}ms (${Math.round((result / min) * 10000) / 100}%)`
` - ${type}: ${result}ms (${Math.round((result / min) * 10000) / 100}%)`,
);
}
}

View File

@@ -7,8 +7,8 @@
* @format
*/
import type { MeasureFunction } from "yoga-layout";
import { Yoga } from "./globals";
import type {MeasureFunction} from 'yoga-layout';
import {Yoga} from './globals';
export type MeasureCounter = {
inc: MeasureFunction;
@@ -18,7 +18,7 @@ export type MeasureCounter = {
export function getMeasureCounter(
cb?: MeasureFunction | null,
staticWidth = 0,
staticHeight = 0
staticHeight = 0,
): MeasureCounter {
let counter = 0;

View File

@@ -5,7 +5,7 @@
* LICENSE file in the root directory of this source tree.
*/
import type { Yoga } from "yoga-layout";
import type {Yoga} from 'yoga-layout';
declare global {
// eslint-disable-next-line no-var