Skip to content

Commit 1a7189d

Browse files
authored
chore(eslint): Add eslint-plugin-regexp rule (dev-packages) (#18063)
Enabling eslint rules for RegEx in `dev-packages`. This is a part of this (now closed) PR: #18053 The first commit contains all changes that were automatically made with `--fix`, the second commit contains the manual changes.
1 parent de5c5cb commit 1a7189d

File tree

137 files changed

+542
-439
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

137 files changed

+542
-439
lines changed

dev-packages/browser-integration-tests/.eslintrc.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@ module.exports = {
33
browser: true,
44
node: true,
55
},
6-
extends: ['../../.eslintrc.js'],
6+
// todo: remove regexp plugin from here once we add it to base.js eslint config for the whole project
7+
extends: ['../../.eslintrc.js', 'plugin:regexp/recommended'],
8+
plugins: ['regexp'],
79
ignorePatterns: [
810
'suites/**/subject.js',
911
'suites/**/dist/*',

dev-packages/browser-integration-tests/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@
5454
"devDependencies": {
5555
"@types/glob": "8.0.0",
5656
"@types/node": "^18.19.1",
57+
"eslint-plugin-regexp": "^1.15.0",
5758
"glob": "8.0.3"
5859
},
5960
"volta": {

dev-packages/browser-integration-tests/suites/manual-client/browser-context/test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ sentryTest('allows to setup a client manually & capture exceptions', async ({ ge
4646
},
4747
},
4848
contexts: {
49-
trace: { trace_id: expect.stringMatching(/[a-f0-9]{32}/), span_id: expect.stringMatching(/[a-f0-9]{16}/) },
49+
trace: { trace_id: expect.stringMatching(/[a-f\d]{32}/), span_id: expect.stringMatching(/[a-f\d]{16}/) },
5050
},
5151
});
5252
});

dev-packages/browser-integration-tests/suites/profiling/traceLifecycleMode_multiple-chunks/test.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,9 +58,9 @@ sentryTest(
5858

5959
// Required profile metadata (Sample Format V2)
6060
expect(typeof envelopeItemPayload1.profiler_id).toBe('string');
61-
expect(envelopeItemPayload1.profiler_id).toMatch(/^[a-f0-9]{32}$/);
61+
expect(envelopeItemPayload1.profiler_id).toMatch(/^[a-f\d]{32}$/);
6262
expect(typeof envelopeItemPayload1.chunk_id).toBe('string');
63-
expect(envelopeItemPayload1.chunk_id).toMatch(/^[a-f0-9]{32}$/);
63+
expect(envelopeItemPayload1.chunk_id).toMatch(/^[a-f\d]{32}$/);
6464
expect(envelopeItemPayload1.client_sdk).toBeDefined();
6565
expect(typeof envelopeItemPayload1.client_sdk.name).toBe('string');
6666
expect(typeof envelopeItemPayload1.client_sdk.version).toBe('string');
@@ -170,9 +170,9 @@ sentryTest(
170170
// Required profile metadata (Sample Format V2)
171171
// https://develop.sentry.dev/sdk/telemetry/profiles/sample-format-v2/
172172
expect(typeof envelopeItemPayload2.profiler_id).toBe('string');
173-
expect(envelopeItemPayload2.profiler_id).toMatch(/^[a-f0-9]{32}$/);
173+
expect(envelopeItemPayload2.profiler_id).toMatch(/^[a-f\d]{32}$/);
174174
expect(typeof envelopeItemPayload2.chunk_id).toBe('string');
175-
expect(envelopeItemPayload2.chunk_id).toMatch(/^[a-f0-9]{32}$/);
175+
expect(envelopeItemPayload2.chunk_id).toMatch(/^[a-f\d]{32}$/);
176176
expect(envelopeItemPayload2.client_sdk).toBeDefined();
177177
expect(typeof envelopeItemPayload2.client_sdk.name).toBe('string');
178178
expect(typeof envelopeItemPayload2.client_sdk.version).toBe('string');

dev-packages/browser-integration-tests/suites/profiling/traceLifecycleMode_overlapping-spans/test.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,9 +60,9 @@ sentryTest(
6060
// Required profile metadata (Sample Format V2)
6161
// https://develop.sentry.dev/sdk/telemetry/profiles/sample-format-v2/
6262
expect(typeof envelopeItemPayload.profiler_id).toBe('string');
63-
expect(envelopeItemPayload.profiler_id).toMatch(/^[a-f0-9]{32}$/);
63+
expect(envelopeItemPayload.profiler_id).toMatch(/^[a-f\d]{32}$/);
6464
expect(typeof envelopeItemPayload.chunk_id).toBe('string');
65-
expect(envelopeItemPayload.chunk_id).toMatch(/^[a-f0-9]{32}$/);
65+
expect(envelopeItemPayload.chunk_id).toMatch(/^[a-f\d]{32}$/);
6666
expect(envelopeItemPayload.client_sdk).toBeDefined();
6767
expect(typeof envelopeItemPayload.client_sdk.name).toBe('string');
6868
expect(typeof envelopeItemPayload.client_sdk.version).toBe('string');
@@ -175,7 +175,7 @@ sentryTest('attaches thread data to child spans (trace mode)', async ({ page, ge
175175
const profilerId = rootSpan?.contexts?.profile?.profiler_id as string | undefined;
176176
expect(typeof profilerId).toBe('string');
177177

178-
expect(profilerId).toMatch(/^[a-f0-9]{32}$/);
178+
expect(profilerId).toMatch(/^[a-f\d]{32}$/);
179179

180180
const spans = (rootSpan?.spans ?? []) as Array<{ data?: Record<string, unknown> }>;
181181
expect(spans.length).toBeGreaterThan(0);

dev-packages/browser-integration-tests/suites/public-api/startSpan/standalone-mixed-transaction/test.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,8 @@ sentryTest(
3434
const traceId = transactionEnvelopeHeader.trace!.trace_id!;
3535
const parentSpanId = transactionEnvelopeItem.contexts?.trace?.span_id;
3636

37-
expect(traceId).toMatch(/[a-f0-9]{32}/);
38-
expect(parentSpanId).toMatch(/[a-f0-9]{16}/);
37+
expect(traceId).toMatch(/[a-f\d]{32}/);
38+
expect(parentSpanId).toMatch(/[a-f\d]{16}/);
3939

4040
expect(spanEnvelopeHeader).toEqual({
4141
sent_at: expect.any(String),
@@ -76,7 +76,7 @@ sentryTest(
7676
segment_id: transactionEnvelopeItem.contexts?.trace?.span_id,
7777
parent_span_id: parentSpanId,
7878
origin: 'manual',
79-
span_id: expect.stringMatching(/[a-f0-9]{16}/),
79+
span_id: expect.stringMatching(/[a-f\d]{16}/),
8080
start_timestamp: expect.any(Number),
8181
timestamp: expect.any(Number),
8282
trace_id: traceId,
@@ -111,7 +111,7 @@ sentryTest(
111111
description: 'inner',
112112
origin: 'manual',
113113
parent_span_id: parentSpanId,
114-
span_id: expect.stringMatching(/[a-f0-9]{16}/),
114+
span_id: expect.stringMatching(/[a-f\d]{16}/),
115115
start_timestamp: expect.any(Number),
116116
timestamp: expect.any(Number),
117117
trace_id: traceId,

dev-packages/browser-integration-tests/suites/public-api/startSpan/standalone/test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,10 +48,10 @@ sentryTest('sends a segment span envelope', async ({ getLocalTestUrl, page }) =>
4848
},
4949
description: 'standalone_segment_span',
5050
origin: 'manual',
51-
span_id: expect.stringMatching(/^[0-9a-f]{16}$/),
51+
span_id: expect.stringMatching(/^[\da-f]{16}$/),
5252
start_timestamp: expect.any(Number),
5353
timestamp: expect.any(Number),
54-
trace_id: expect.stringMatching(/^[0-9a-f]{32}$/),
54+
trace_id: expect.stringMatching(/^[\da-f]{32}$/),
5555
is_segment: true,
5656
segment_id: spanJson.span_id,
5757
});

dev-packages/browser-integration-tests/suites/replay/dsc/test.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ sentryTest(
5757
expect(envHeader.trace).toEqual({
5858
environment: 'production',
5959
sample_rate: '1',
60-
trace_id: expect.stringMatching(/[a-f0-9]{32}/),
60+
trace_id: expect.stringMatching(/[a-f\d]{32}/),
6161
public_key: 'public',
6262
replay_id: replay.session?.id,
6363
sampled: 'true',
@@ -105,7 +105,7 @@ sentryTest(
105105
expect(envHeader.trace).toEqual({
106106
environment: 'production',
107107
sample_rate: '1',
108-
trace_id: expect.stringMatching(/[a-f0-9]{32}/),
108+
trace_id: expect.stringMatching(/[a-f\d]{32}/),
109109
public_key: 'public',
110110
sampled: 'true',
111111
sample_rand: expect.any(String),
@@ -158,7 +158,7 @@ sentryTest(
158158
expect(envHeader.trace).toEqual({
159159
environment: 'production',
160160
sample_rate: '1',
161-
trace_id: expect.stringMatching(/[a-f0-9]{32}/),
161+
trace_id: expect.stringMatching(/[a-f\d]{32}/),
162162
public_key: 'public',
163163
replay_id: replay.session?.id,
164164
sampled: 'true',
@@ -201,7 +201,7 @@ sentryTest(
201201
expect(envHeader.trace).toEqual({
202202
environment: 'production',
203203
sample_rate: '1',
204-
trace_id: expect.stringMatching(/[a-f0-9]{32}/),
204+
trace_id: expect.stringMatching(/[a-f\d]{32}/),
205205
public_key: 'public',
206206
sampled: 'true',
207207
sample_rand: expect.any(String),
@@ -243,7 +243,7 @@ sentryTest('should add replay_id to error DSC while replay is active', async ({
243243
expect(error1Header.trace).toBeDefined();
244244
expect(error1Header.trace).toEqual({
245245
environment: 'production',
246-
trace_id: expect.stringMatching(/[a-f0-9]{32}/),
246+
trace_id: expect.stringMatching(/[a-f\d]{32}/),
247247
public_key: 'public',
248248
replay_id: replay.session?.id,
249249
...(hasTracing
@@ -265,7 +265,7 @@ sentryTest('should add replay_id to error DSC while replay is active', async ({
265265
expect(error2Header.trace).toBeDefined();
266266
expect(error2Header.trace).toEqual({
267267
environment: 'production',
268-
trace_id: expect.stringMatching(/[a-f0-9]{32}/),
268+
trace_id: expect.stringMatching(/[a-f\d]{32}/),
269269
public_key: 'public',
270270
...(hasTracing
271271
? {

dev-packages/browser-integration-tests/suites/tracing/browserTracingIntegration/http-timings/test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ sentryTest('creates fetch spans with http timing', async ({ browserName, getLoca
3434
expect(span).toMatchObject({
3535
description: `GET http://sentry-test-site.example/${index}`,
3636
parent_span_id: tracingEvent.contexts?.trace?.span_id,
37-
span_id: expect.stringMatching(/[a-f0-9]{16}/),
37+
span_id: expect.stringMatching(/[a-f\d]{16}/),
3838
start_timestamp: expect.any(Number),
3939
timestamp: expect.any(Number),
4040
trace_id: tracingEvent.contexts?.trace?.trace_id,

dev-packages/browser-integration-tests/suites/tracing/browserTracingIntegration/linked-traces/consistent-sampling/meta-negative/test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ sentryTest.describe('When `consistentTraceSampling` is `true` and page contains
6060

6161
expect(extractTraceparentData(sentryTrace)).toEqual({
6262
traceId: expect.not.stringContaining(metaTagTraceId),
63-
parentSpanId: expect.stringMatching(/^[0-9a-f]{16}$/),
63+
parentSpanId: expect.stringMatching(/^[\da-f]{16}$/),
6464
parentSampled: false,
6565
});
6666

0 commit comments

Comments
 (0)