From 4c82160f563e6efd36383ed0b6884ff883b8f2f0 Mon Sep 17 00:00:00 2001 From: Lukas Stracke Date: Wed, 3 Jan 2024 11:32:03 +0100 Subject: [PATCH] chore(biome): Add `useRegexLiterals` rule (#10010) Add the [useRegexLiterals](https://biomejs.dev/linter/rules/use-regex-literals/) rule to our biome config which will flag unnecessary usage of the `RegExp` constructor where a static regex could be used instead. --- biome.json | 5 +++-- packages/serverless/test/google-cloud-http.test.ts | 4 ++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/biome.json b/biome.json index ee621463f01c..8d1b11d84859 100644 --- a/biome.json +++ b/biome.json @@ -22,7 +22,8 @@ "noControlCharactersInRegex": "error" }, "nursery": { - "noUnusedImports": "error" + "noUnusedImports": "error", + "useRegexLiterals": "error" }, "performance": { "all": true, @@ -30,7 +31,7 @@ "noDelete": "off" } }, - "ignore": [".vscode/*", "**/*.json"] + "ignore": [".vscode/*", "**/*.json", ".next/**/*", ".svelte-kit/**/*"] }, "files": { "ignoreUnknown": true diff --git a/packages/serverless/test/google-cloud-http.test.ts b/packages/serverless/test/google-cloud-http.test.ts index 8296ab4e1d88..b285a9a862c8 100644 --- a/packages/serverless/test/google-cloud-http.test.ts +++ b/packages/serverless/test/google-cloud-http.test.ts @@ -49,7 +49,7 @@ describe('GoogleCloudHttp tracing', () => { '{"kind":"bigquery#job","configuration":{"query":{"query":"SELECT true AS foo","destinationTable":{"projectId":"project-id","datasetId":"_7b1eed9bef45ab5fb7345c3d6f662cd767e5ab3e","tableId":"anon101ee25adad33d4f09179679ae9144ad436a210e"},"writeDisposition":"WRITE_TRUNCATE","priority":"INTERACTIVE","useLegacySql":false},"jobType":"QUERY"},"jobReference":{"projectId":"project-id","jobId":"8874c5d5-9cfe-4daa-8390-b0504b97b429","location":"US"},"statistics":{"creationTime":"1603072686488","startTime":"1603072686756","query":{"statementType":"SELECT"}},"status":{"state":"RUNNING"}}', ); nock('https://bigquery.googleapis.com') - .get(new RegExp('^/bigquery/v2/projects/project-id/queries/.+$')) + .get(/^\/bigquery\/v2\/projects\/project-id\/queries\/.+$/) .query(true) .reply( 200, @@ -67,7 +67,7 @@ describe('GoogleCloudHttp tracing', () => { expect(SentryNode.fakeTransaction.startChild).toBeCalledWith({ op: 'http.client.bigquery', origin: 'auto.http.serverless', - description: expect.stringMatching(new RegExp('^GET /queries/.+')), + description: expect.stringMatching(/^GET \/queries\/.+/), }); }); });