Files
yoga/javascript/.eslintrc.js
Nick Gerleman 0d2a3a92ac Lint and typecheck TypeScript (#1276)
Summary:
Pull Request resolved: https://github.com/facebook/yoga/pull/1276

This change starts to enlighten linting and other repo configuration to TypeScript. This was previously special-cased out of linting, and meant we were not linting everything. It is also a precondition to do real typechecking and linting our definitions with type information.

1. Add TypeScript dependencies
1. Configure ESLint, Babel, tsc for TypeScript
1. Run tsc as part of linting (OSS only for now)

This is continued in another change with adding types to scripts and config files, but more importantly converting hand-written tests and test generation to TypeScript, so we get real-world usage to typecheck against for testing.

Differential Revision: D45508576

fbshipit-source-id: ef5344b52c851d075194645d01d40b7507392a3c
2023-05-02 16:44:39 -07:00

73 lines
1.7 KiB
JavaScript

/**
* 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: ["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",
},
},
],
};