Lint and typecheck TypeScript

Summary:
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: 1917c2785d5a0df5348158abd3f0551869c93d7e
This commit is contained in:
Nick Gerleman
2023-05-02 17:56:08 -07:00
committed by Facebook GitHub Bot
parent b958b647d4
commit 940ac559b4
6 changed files with 361 additions and 12 deletions

View File

@@ -7,15 +7,13 @@
* @format
*/
const path = require("path");
module.exports = {
root: true,
ignorePatterns: ["dist/**", "**/*.d.ts"],
parser: "@babel/eslint-parser",
extends: [
"eslint:recommended",
"plugin:jest/recommended",
"plugin:prettier/recommended",
],
ignorePatterns: ["dist/**", "tests/generated/**"],
extends: ["eslint:recommended", "plugin:prettier/recommended"],
plugins: ["prettier"],
rules: {
"no-var": "error",
"prefer-arrow-callback": "error",
@@ -26,14 +24,42 @@ module.exports = {
},
env: {
commonjs: true,
es6: true,
es2018: true,
},
overrides: [
{
files: ["jest.*", "just.config.js", "tests/**"],
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",