Skip to content

Commit ec1d5fc

Browse files
committed
[IMP] pre-commit: bypass eslint's typescript compilation
This is done for performance concern closes #8111 Task: 6041446 Signed-off-by: Lucas Lefèvre (lul) <lul@odoo.com>
1 parent ff5d615 commit ec1d5fc

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

.husky/pre-commit

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ fi
1414
. "$(dirname "$0")/_/husky.sh"
1515

1616
if [ "$HUSKY_PRE_COMMIT" != 0 ]; then
17+
export ESLINT_FAST=1
1718
$npx lint-staged
1819

1920
# Check console and debugger leftover statements

eslint.config.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
import tseslint from "typescript-eslint";
44

5+
const fastMode = !!process.env.ESLINT_FAST;
6+
57
export default tseslint.config(
68
{
79
ignores: ["**/dist/**", "**/node_modules/**", "**/build/**", "**/*.js"],
@@ -21,9 +23,9 @@ export default tseslint.config(
2123
// - engine tests: packages/o-spreadsheet-engine/tsconfig.json only
2224
// includes `src/`, so its tests/ directory has no owning project
2325
// (unlike the main tests/ folder which has its own tsconfig.json).
24-
projectService: {
25-
allowDefaultProject: ["global.d.ts", "packages/o-spreadsheet-engine/tests/*.ts"],
26-
},
26+
projectService: fastMode
27+
? false
28+
: { allowDefaultProject: ["global.d.ts", "packages/o-spreadsheet-engine/tests/*.ts"] },
2729
},
2830
},
2931
rules: {
@@ -33,7 +35,7 @@ export default tseslint.config(
3335
eqeqeq: "error", // ban non-strict equal
3436
"@typescript-eslint/no-non-null-asserted-optional-chain": "error", // ban non-null assertion in optional chain
3537
curly: ["error", "all"], // enforce curly braces for all control statements
36-
"@typescript-eslint/no-floating-promises": "error", // ban unawaited promises
38+
...(!fastMode && { "@typescript-eslint/no-floating-promises": "error" }), // ban unawaited promises
3739
},
3840
}
3941
);

0 commit comments

Comments
 (0)