Skip to content

Commit c13a5d1

Browse files
Copilotkraenhansen
andcommitted
Add test file exception for prefer-arrow-callback rule and update Copilot instructions
Co-authored-by: kraenhansen <1243959+kraenhansen@users.noreply.github.com>
1 parent b7cb726 commit c13a5d1

File tree

2 files changed

+13
-4
lines changed

2 files changed

+13
-4
lines changed

.github/copilot-instructions.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ npm run bootstrap # Build native components (weak-node-api, examples)
6161
**Function Style**:
6262
- Prefer `export function` over `export const fn =`
6363
- Use async/await consistently for asynchronous operations
64-
- Prefer arrow functions for callbacks and inline functions
64+
- Prefer arrow functions for callbacks and inline functions (except in tests where `describe` and `it` use regular functions)
6565

6666
**Error Handling**:
6767
- Prefer `assert()` from `node:assert/strict` over throwing errors directly

eslint.config.js

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// @ts-check
22

3-
import { globalIgnores } from "eslint/config";
3+
// import { globalIgnores } from "eslint/config";
44
import globals from "globals";
55
import eslint from "@eslint/js";
66
import tseslint from "typescript-eslint";
@@ -10,7 +10,8 @@ import nodePlugin from "eslint-plugin-n";
1010
import unusedImports from "eslint-plugin-unused-imports";
1111

1212
export default tseslint.config(
13-
globalIgnores([
13+
{
14+
ignores: [
1415
"**/dist/**",
1516
"**/build/**",
1617
"apps/test-app/ios/**",
@@ -23,7 +24,8 @@ export default tseslint.config(
2324
"packages/node-tests/tests/**",
2425
"packages/node-tests/*.generated.js",
2526
"packages/node-tests/*.generated.d.ts",
26-
]),
27+
],
28+
},
2729
eslint.configs.recommended,
2830
tseslint.configs.recommendedTypeChecked,
2931
{
@@ -140,4 +142,11 @@ export default tseslint.config(
140142
},
141143
},
142144
},
145+
{
146+
// Exception for test files: allow regular functions in describe() and it() callbacks
147+
files: ["**/*.test.ts", "**/*.spec.ts"],
148+
rules: {
149+
"prefer-arrow-callback": "off",
150+
},
151+
},
143152
);

0 commit comments

Comments
 (0)