Commit ce9cef4
# Backport
This will backport the following commits from `main` to `9.2`:
- [[@kbn/eslint-plugin-eslint] Add ESLint rule that requires `apiClient`
usage in Scout `apiTest`
(#245172)](#245172)
<!--- Backport version: 9.6.6 -->
### Questions ?
Please refer to the [Backport tool
documentation](https://github.com/sorenlouv/backport)
<!--BACKPORT [{"author":{"name":"Stelios
Mavro","email":"81311181+steliosmavro@users.noreply.github.com"},"sourceCommit":{"committedDate":"2025-12-09T17:39:31Z","message":"[@kbn/eslint-plugin-eslint]
Add ESLint rule that requires `apiClient` usage in Scout `apiTest`
(#245172)\n\n## Summary\n\nAdds a new ESLint rule
`scout_require_api_client_in_api_test` that\nenforces the use of the
`apiClient` fixture in `apiTest` functions to\nensure API endpoints are
properly tested.\n\n## What it does\n\nWhen writing API tests with
`apiTest`, developers must use the\n`apiClient` fixture to make HTTP
calls. The rule reports an error if\n`apiClient` is destructured but
never used.\n**Invalid:**\n```\napiTest('test', async ({ apiClient }) =>
{\n console.log('no api call'); // ❌ apiClient not
used\n});\n```\n**Valid:**\n```\napiTest('test', async ({ apiClient })
=> {\n await apiClient.get('/foo'); // ✅ apiClient used\n});\n```\n\n##
Features\n\n- Detects direct usage, aliases, and variable assignments\n-
Tracks usage through helper functions and closures\n- Supports
`eslint-disable-next-line` overrides\n\n## Changes\n\n- Added rule
implementation and comprehensive test suite (21 test cases)\n-
Registered rule in plugin and enabled as error for Scout test
files","sha":"c700c870bc5c738c5e6de452fe6f423b6ec19bab","branchLabelMapping":{"^v9.3.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:skip","backport:all-open","test:scout","v9.3.0"],"title":"[@kbn/eslint-plugin-eslint]
Add ESLint rule that requires `apiClient` usage in Scout
`apiTest`","number":245172,"url":"https://github.com/elastic/kibana/pull/245172","mergeCommit":{"message":"[@kbn/eslint-plugin-eslint]
Add ESLint rule that requires `apiClient` usage in Scout `apiTest`
(#245172)\n\n## Summary\n\nAdds a new ESLint rule
`scout_require_api_client_in_api_test` that\nenforces the use of the
`apiClient` fixture in `apiTest` functions to\nensure API endpoints are
properly tested.\n\n## What it does\n\nWhen writing API tests with
`apiTest`, developers must use the\n`apiClient` fixture to make HTTP
calls. The rule reports an error if\n`apiClient` is destructured but
never used.\n**Invalid:**\n```\napiTest('test', async ({ apiClient }) =>
{\n console.log('no api call'); // ❌ apiClient not
used\n});\n```\n**Valid:**\n```\napiTest('test', async ({ apiClient })
=> {\n await apiClient.get('/foo'); // ✅ apiClient used\n});\n```\n\n##
Features\n\n- Detects direct usage, aliases, and variable assignments\n-
Tracks usage through helper functions and closures\n- Supports
`eslint-disable-next-line` overrides\n\n## Changes\n\n- Added rule
implementation and comprehensive test suite (21 test cases)\n-
Registered rule in plugin and enabled as error for Scout test
files","sha":"c700c870bc5c738c5e6de452fe6f423b6ec19bab"}},"sourceBranch":"main","suggestedTargetBranches":[],"targetPullRequestStates":[{"branch":"main","label":"v9.3.0","branchLabelMappingKey":"^v9.3.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/245172","number":245172,"mergeCommit":{"message":"[@kbn/eslint-plugin-eslint]
Add ESLint rule that requires `apiClient` usage in Scout `apiTest`
(#245172)\n\n## Summary\n\nAdds a new ESLint rule
`scout_require_api_client_in_api_test` that\nenforces the use of the
`apiClient` fixture in `apiTest` functions to\nensure API endpoints are
properly tested.\n\n## What it does\n\nWhen writing API tests with
`apiTest`, developers must use the\n`apiClient` fixture to make HTTP
calls. The rule reports an error if\n`apiClient` is destructured but
never used.\n**Invalid:**\n```\napiTest('test', async ({ apiClient }) =>
{\n console.log('no api call'); // ❌ apiClient not
used\n});\n```\n**Valid:**\n```\napiTest('test', async ({ apiClient })
=> {\n await apiClient.get('/foo'); // ✅ apiClient used\n});\n```\n\n##
Features\n\n- Detects direct usage, aliases, and variable assignments\n-
Tracks usage through helper functions and closures\n- Supports
`eslint-disable-next-line` overrides\n\n## Changes\n\n- Added rule
implementation and comprehensive test suite (21 test cases)\n-
Registered rule in plugin and enabled as error for Scout test
files","sha":"c700c870bc5c738c5e6de452fe6f423b6ec19bab"}}]}] BACKPORT-->
Co-authored-by: Stelios Mavro <81311181+steliosmavro@users.noreply.github.com>
1 parent 374c88b commit ce9cef4
4 files changed
Lines changed: 437 additions & 0 deletions
File tree
- packages/kbn-eslint-plugin-eslint
- rules
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2469 | 2469 | | |
2470 | 2470 | | |
2471 | 2471 | | |
| 2472 | + | |
2472 | 2473 | | |
2473 | 2474 | | |
2474 | 2475 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
24 | 24 | | |
25 | 25 | | |
26 | 26 | | |
| 27 | + | |
27 | 28 | | |
28 | 29 | | |
29 | 30 | | |
| |||
Lines changed: 205 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
0 commit comments