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

@@ -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);
@@ -21,7 +21,7 @@ test("dirtied", () => {
});
// only nodes with a measure function can be marked dirty
root.setMeasureFunc(() => ({ width: 0, height: 0 }));
root.setMeasureFunc(() => ({width: 0, height: 0}));
expect(dirtied).toBe(0);
@@ -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);
@@ -46,7 +46,7 @@ test("dirtied_propagation", () => {
root_child0.setAlignItems(Yoga.ALIGN_FLEX_START);
root_child0.setWidth(50);
root_child0.setHeight(20);
root_child0.setMeasureFunc(() => ({ width: 0, height: 0 }));
root_child0.setMeasureFunc(() => ({width: 0, height: 0}));
root.insertChild(root_child0, 0);
const root_child1 = Yoga.Node.create();
@@ -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);
@@ -85,14 +85,14 @@ test("dirtied_hierarchy", () => {
root_child0.setAlignItems(Yoga.ALIGN_FLEX_START);
root_child0.setWidth(50);
root_child0.setHeight(20);
root_child0.setMeasureFunc(() => ({ width: 0, height: 0 }));
root_child0.setMeasureFunc(() => ({width: 0, height: 0}));
root.insertChild(root_child0, 0);
const root_child1 = Yoga.Node.create();
root_child1.setAlignItems(Yoga.ALIGN_FLEX_START);
root_child1.setWidth(50);
root_child1.setHeight(20);
root_child0.setMeasureFunc(() => ({ width: 0, height: 0 }));
root_child0.setMeasureFunc(() => ({width: 0, height: 0}));
root.insertChild(root_child1, 0);
root.calculateLayout(undefined, undefined, Yoga.DIRECTION_LTR);
@@ -118,12 +118,12 @@ 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);
root.setHeight(100);
root.setMeasureFunc(() => ({ width: 0, height: 0 }));
root.setMeasureFunc(() => ({width: 0, height: 0}));
root.calculateLayout(undefined, undefined, Yoga.DIRECTION_LTR);
@@ -145,7 +145,7 @@ test("dirtied_reset", () => {
root.setAlignItems(Yoga.ALIGN_FLEX_START);
root.setWidth(100);
root.setHeight(100);
root.setMeasureFunc(() => ({ width: 0, height: 0 }));
root.setMeasureFunc(() => ({width: 0, height: 0}));
root.markDirty();

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,11 +27,11 @@ 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 }));
const heightOnlyCallback = getMeasureCounter(() => ({height: 10}));
// @ts-expect-error Testing bad usage
const widthOnlyCallback = getMeasureCounter(() => ({ width: 10 }));
const widthOnlyCallback = getMeasureCounter(() => ({width: 10}));
// @ts-expect-error Testing bad usage
const emptyCallback = getMeasureCounter(() => ({}));

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;
@@ -28,7 +28,7 @@ export function getMeasureCounter(
return cb
? cb(width, widthMode, height, heightMode)
: { width: staticWidth, height: staticHeight };
: {width: staticWidth, height: staticHeight};
},
get: function () {
@@ -44,7 +44,7 @@ export function getMeasureCounterMax(): MeasureCounter {
const measuredHeight =
heightMode === Yoga.MEASURE_MODE_UNDEFINED ? 10 : height;
return { width: measuredWidth, height: measuredHeight };
return {width: measuredWidth, height: measuredHeight};
});
}
@@ -61,6 +61,6 @@ export function getMeasureCounterMin(): MeasureCounter {
? 10
: height;
return { width: measuredWidth, height: measuredHeight };
return {width: measuredWidth, height: measuredHeight};
});
}

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
@@ -24,4 +24,4 @@ if (globalThis.YGBENCHMARK === undefined) {
const yoga = globalThis.Yoga;
const benchmark = globalThis.YGBENCHMARK;
export { yoga as Yoga, benchmark as YGBENCHMARK };
export {yoga as Yoga, benchmark as YGBENCHMARK};