From 19b040fc69b13c53e287cf08d04345f75a4fdb75 Mon Sep 17 00:00:00 2001 From: Brian Gough Date: Mon, 8 Jun 2026 14:59:09 +0100 Subject: [PATCH] add ELINT_FAST environment variable in pre-commit hook (#34396) * add ELINT_FAST environment variable in pre-commit hook skips slow type-aware linting in pre-commit hook, full lint still runs in CI GitOrigin-RevId: d4b6fde1c5010ba0f61aed03972b745af0f55b9b --- services/web/eslint.config.mjs | 30 ++++++++++++++++++++---------- 1 file changed, 20 insertions(+), 10 deletions(-) diff --git a/services/web/eslint.config.mjs b/services/web/eslint.config.mjs index 9f8a313ca0..50ea20a0f7 100644 --- a/services/web/eslint.config.mjs +++ b/services/web/eslint.config.mjs @@ -43,6 +43,12 @@ const reactFlatRecommended = { import _ from 'lodash' import confusingBrowserGlobals from 'confusing-browser-globals' +// Type-aware linting is expensive: setting `parserOptions.project` makes +// @typescript-eslint build a full TypeScript program from tsconfig.backend.json +// on every ESLint invocation, even when linting a single file. +// Set ESLINT_FAST=1 to skip type-aware checks; the full lint still runs in CI. +const TYPE_AWARE = process.env.ESLINT_FAST !== '1' + export default defineConfig([ // Declare which file extensions ESLint should consider in this workspace. // Replaces the previous `--ext .js,.jsx,.mjs,.ts,.tsx` CLI flag, which is @@ -302,10 +308,12 @@ export default defineConfig([ files: ['**/app/src/**/*.{js,mjs}', 'app.{js,mjs}'], languageOptions: { - parserOptions: { - tsconfigRootDir: import.meta.dirname, - project: './tsconfig.backend.json', - }, + parserOptions: TYPE_AWARE + ? { + tsconfigRootDir: import.meta.dirname, + project: './tsconfig.backend.json', + } + : {}, }, rules: { @@ -357,12 +365,14 @@ export default defineConfig([ }, ], - '@typescript-eslint/no-floating-promises': [ - 'error', - { - checkThenables: true, - }, - ], + '@typescript-eslint/no-floating-promises': TYPE_AWARE + ? [ + 'error', + { + checkThenables: true, + }, + ] + : 'off', }, }, {