Unify ESLint and Prettier across xplat/yoga (#1335)

Summary: Pull Request resolved: https://github.com/facebook/yoga/pull/1335

Reviewed By: christophpurrer

Differential Revision: D47459866

fbshipit-source-id: fd6b4e4e2518d91968ac7180b32129b3f70edf88
This commit is contained in:
Nick Gerleman
2023-07-17 14:27:32 -07:00
committed by Facebook GitHub Bot
parent 05b2edfb85
commit 44507ec62e
35 changed files with 2064 additions and 1559 deletions

View File

@@ -1,72 +0,0 @@
/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @format
*/
const path = require('path');
module.exports = {
root: true,
ignorePatterns: ['binaries/**', 'build/**', 'dist/**', 'tests/generated/**'],
extends: ['eslint:recommended', 'plugin:prettier/recommended'],
plugins: ['prettier'],
rules: {
'no-var': 'error',
'prefer-arrow-callback': 'error',
'prefer-const': 'error',
'prefer-object-spread': 'error',
'prefer-spread': 'error',
'require-await': 'error',
},
env: {
commonjs: true,
es2018: true,
},
overrides: [
{
files: ['**/*.js'],
parser: '@babel/eslint-parser',
parserOptions: {
babelOptions: {
configFile: path.join(__dirname, '.babelrc.js'),
},
},
},
{
files: ['**/*.ts'],
extends: ['plugin:@typescript-eslint/recommended'],
parser: '@typescript-eslint/parser',
parserOptions: {
project: path.join(__dirname, 'tsconfig.json'),
},
plugins: ['@typescript-eslint'],
rules: {
'@typescript-eslint/no-var-requires': 'off',
},
},
{
files: ['**/.eslintrc.js', '**/just.config.js'],
env: {
node: true,
},
},
{
files: ['jest.*', 'tests/**'],
env: {
node: true,
},
extends: ['plugin:jest/recommended'],
globals: {
getMeasureCounter: 'writable',
getMeasureCounterMax: 'writable',
getMeasureCounterMin: 'writable',
Yoga: 'writable',
YGBENCHMARK: 'writable',
},
},
],
};

View File

@@ -1,4 +0,0 @@
binaries/
build/
src/generated/
tests/generated/

View File

@@ -1,16 +0,0 @@
/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @format
*/
module.exports = {
arrowParens: 'avoid',
bracketSameLine: true,
bracketSpacing: false,
singleQuote: true,
trailingComma: 'all',
};

View File

@@ -10,7 +10,6 @@
import {
argv,
cleanTask,
eslintTask,
logger,
jestTask,
option,
@@ -76,13 +75,7 @@ task(
),
);
task(
'lint',
parallel(
tscTask({noEmit: true}),
series(eslintTask({fix: argv().fix}), clangFormatTask({fix: argv().fix})),
),
);
task('clang-format', clangFormatTask({fix: argv().fix}));
task('prepack-package-json', async () => {
const packageJsonPath = path.join(__dirname, 'package.json');

View File

@@ -48,36 +48,30 @@
"scripts": {
"benchmark": "just benchmark",
"build": "just build",
"clang-format": "just clang-format",
"clang-format:fix": "just clang-format --fix",
"clean": "just clean",
"lint": "just lint",
"lint:fix": "just lint --fix",
"lint": "eslint .",
"lint:fix": "eslint . --fix",
"prepack": "just prepack",
"test": "just test"
"test": "just test",
"tsc": "tsc --noEmit"
},
"devDependencies": {
"@babel/cli": "^7.20.7",
"@babel/core": "^7.20.7",
"@babel/eslint-parser": "^7.19.1",
"@babel/node": "^7.20.7",
"@babel/preset-env": "^7.20.2",
"@babel/cli": "^7.21.4",
"@babel/core": "^7.21.4",
"@babel/node": "^7.21.4",
"@babel/preset-env": "^7.21.4",
"@babel/preset-typescript": "^7.21.4",
"@types/glob": "^8.1.0",
"@types/jest": "^29.5.1",
"@types/node": "^16.18.25",
"@types/which": "^3.0.0",
"@typescript-eslint/eslint-plugin": "^5.30.5",
"@typescript-eslint/parser": "^5.30.5",
"clang-format": "^1.8.0",
"eslint": "^8.30.0",
"eslint-config-prettier": "^8.5.0",
"eslint-plugin-jest": "^27.1.7",
"eslint-plugin-prettier": "^4.2.1",
"glob": "^8.0.3",
"jest": "^29.3.1",
"just-scripts": "^2.1.0",
"prettier": "2.8.8",
"ts-node": "^10.9.1",
"typescript": "5.0.4",
"which": "^3.0.0"
}
}

View File

@@ -81,7 +81,11 @@ export type MeasureFunction = (
) => Size;
export type Node = {
calculateLayout(width?: number, height?: number, direction?: Direction): void;
calculateLayout(
width?: number | 'auto',
height?: number | 'auto',
direction?: Direction,
): void;
copyStyle(node: Node): void;
free(): void;
freeRecursive(): void;