Skip to content

Commit d5a392c

Browse files
committed
Fix ESLint for K6
1 parent bcbb585 commit d5a392c

File tree

3 files changed

+22
-5
lines changed

3 files changed

+22
-5
lines changed

.eslintrc

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ extends:
88
- prettier
99

1010
globals:
11-
__DEBUG_SERVER_ERRORS__: true
12-
__SERVER_ERRORS__: true
11+
__DEBUG_SERVER_ERRORS__: writable
12+
__SERVER_ERRORS__: writable
1313

1414
parserOptions:
1515
# We have @babel/eslint-parser from eslint-config-shakacode, but don't use Babel in the main project
@@ -77,3 +77,23 @@ overrides:
7777
rules:
7878
# Allows Jest mocks before import
7979
import/first: off
80+
- files: "k6/**/*.{js,ts}"
81+
globals:
82+
# See https://github.com/grafana/k6-docs/blob/65d9f8a9a53f57a4f416763f8020d0c7f40eb976/docs/sources/.eslintrc.js
83+
__ENV: readonly
84+
__VU: readonly
85+
__ITER: readonly
86+
console: readonly
87+
open: readonly
88+
window: readonly
89+
setInterval: readonly
90+
clearInterval: readonly
91+
setTimeout: readonly
92+
clearTimeout: readonly
93+
rules:
94+
"import/extensions":
95+
- error
96+
- ignorePackages
97+
"import/no-unresolved":
98+
- error
99+
- { ignore: ["k6.*"] }

k6/_util.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ export const url = (path) => `${__ENV.BASE_URL ?? "http://localhost:3000"}/${pat
22

33
/** @type {(envVar: string) => boolean} */
44
const envToBoolean = (envVar) => {
5-
// eslint-disable-next-line no-undef -- __ENV is provided by k6
65
const value = __ENV[envVar];
76
return !!value && ['true', '1', 'yes'].includes(value.toLowerCase());
87
};

k6/root.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
1-
/* eslint-disable import/no-unresolved */
21
import { check } from 'k6';
32
import http from 'k6/http';
4-
/* eslint-enable import/no-unresolved */
53
import { defaultOptions, url } from './_util.js';
64

75
export const options = defaultOptions(false);

0 commit comments

Comments
 (0)