From 876a787092cfa1b6f5237f88bb3c6b7b3f4817f6 Mon Sep 17 00:00:00 2001 From: i-am-yongho Date: Tue, 17 Dec 2024 19:38:24 +0900 Subject: [PATCH 1/3] Add `vitest` globals --- data/vitest.mjs | 18 ++++++++++++++++++ globals.json | 18 ++++++++++++++++++ 2 files changed, 36 insertions(+) create mode 100644 data/vitest.mjs diff --git a/data/vitest.mjs b/data/vitest.mjs new file mode 100644 index 0000000..2e9a2b0 --- /dev/null +++ b/data/vitest.mjs @@ -0,0 +1,18 @@ +export default { + afterAll: false, + afterEach: false, + assert: false, + assertType: false, + beforeAll: false, + beforeEach: false, + describe: false, + expect: false, + expectTypeOf: false, + it: false, + onTestFailed: false, + onTestFinished: false, + suite: false, + test: false, + vi: false, + vitest: false, +}; diff --git a/globals.json b/globals.json index 07f5dbf..8a0b08c 100644 --- a/globals.json +++ b/globals.json @@ -2656,6 +2656,24 @@ "uniq": false, "which": false }, + "vitest": { + "afterAll": false, + "afterEach": false, + "assert": false, + "assertType": false, + "beforeAll": false, + "beforeEach": false, + "describe": false, + "expect": false, + "expectTypeOf": false, + "it": false, + "onTestFailed": false, + "onTestFinished": false, + "suite": false, + "test": false, + "vi": false, + "vitest": false + }, "webextensions": { "browser": false, "chrome": false, From b9cc28eb784e3fe1ea5612c921841e3956af9ccb Mon Sep 17 00:00:00 2001 From: i-am-yongho Date: Tue, 17 Dec 2024 20:41:10 +0900 Subject: [PATCH 2/3] Generate vitest globals using environment of @vitest/eslint-plugin --- data/vitest.mjs | 7 +++---- globals.json | 4 ---- package.json | 2 ++ scripts/get-vitest-globals.mjs | 6 ++++++ scripts/update.mjs | 6 ++++++ 5 files changed, 17 insertions(+), 8 deletions(-) create mode 100644 scripts/get-vitest-globals.mjs diff --git a/data/vitest.mjs b/data/vitest.mjs index 2e9a2b0..efc1e9f 100644 --- a/data/vitest.mjs +++ b/data/vitest.mjs @@ -1,16 +1,15 @@ +// This file is autogenerated by scripts +// Do NOT modify this file manually + export default { afterAll: false, afterEach: false, assert: false, - assertType: false, beforeAll: false, beforeEach: false, describe: false, expect: false, - expectTypeOf: false, it: false, - onTestFailed: false, - onTestFinished: false, suite: false, test: false, vi: false, diff --git a/globals.json b/globals.json index 8a0b08c..a78c284 100644 --- a/globals.json +++ b/globals.json @@ -2660,15 +2660,11 @@ "afterAll": false, "afterEach": false, "assert": false, - "assertType": false, "beforeAll": false, "beforeEach": false, "describe": false, "expect": false, - "expectTypeOf": false, "it": false, - "onTestFailed": false, - "onTestFinished": false, "suite": false, "test": false, "vi": false, diff --git a/package.json b/package.json index f5e9714..a4045f3 100644 --- a/package.json +++ b/package.json @@ -24,6 +24,7 @@ "update:worker": "node scripts/update.mjs --environment=worker", "update:shelljs": "node scripts/update.mjs --environment=shelljs", "update:jest": "node scripts/update.mjs --environment=jest", + "update:vitest": "node scripts/update.mjs --environment=vitest", "build": "run-s build:data build:types", "build:data": "node scripts/generate-data.mjs", "build:types": "node scripts/generate-types.mjs" @@ -44,6 +45,7 @@ "environments" ], "devDependencies": { + "@vitest/eslint-plugin": "^1.1.17", "ava": "^6.1.3", "cheerio": "^1.0.0-rc.12", "eslint-plugin-jest": "^28.8.3", diff --git a/scripts/get-vitest-globals.mjs b/scripts/get-vitest-globals.mjs new file mode 100644 index 0000000..5010d38 --- /dev/null +++ b/scripts/get-vitest-globals.mjs @@ -0,0 +1,6 @@ +import vitest from '@vitest/eslint-plugin'; + +// https://github.com/vitest-dev/eslint-plugin-vitest/blob/main/src/index.ts#L269-L285 +export default function getVitestGlobals() { + return Object.fromEntries(Object.keys(vitest.environments.env.globals).map(name => [name, false])); +} diff --git a/scripts/update.mjs b/scripts/update.mjs index ee1d2a5..3de05fc 100644 --- a/scripts/update.mjs +++ b/scripts/update.mjs @@ -7,6 +7,7 @@ import {getBrowserGlobals, getWebWorkerGlobals} from './get-browser-globals.mjs' import getShelljsGlobals from './get-shelljs-globals.mjs'; import getJestGlobals from './get-jest-globals.mjs'; import {updateGlobals} from './utilities.mjs'; +import getVitestGlobals from './get-vitest-globals.mjs'; const ALL_JOBS = [ { @@ -36,6 +37,11 @@ const ALL_JOBS = [ getGlobals: getJestGlobals, incremental: false, }, + { + environment: 'vitest', + getGlobals: getVitestGlobals, + incremental: false, + }, ]; async function run(options) { From dd5cdcb4a1e826528d43efb4228719b14f930ecd Mon Sep 17 00:00:00 2001 From: i-am-yongho Date: Wed, 18 Dec 2024 08:45:16 +0900 Subject: [PATCH 3/3] Update `vitest` globals --- data/vitest.mjs | 4 ++++ globals.json | 4 ++++ package.json | 2 +- 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/data/vitest.mjs b/data/vitest.mjs index efc1e9f..2127d6f 100644 --- a/data/vitest.mjs +++ b/data/vitest.mjs @@ -5,11 +5,15 @@ export default { afterAll: false, afterEach: false, assert: false, + assertType: false, beforeAll: false, beforeEach: false, describe: false, expect: false, + expectTypeOf: false, it: false, + onTestFailed: false, + onTestFinished: false, suite: false, test: false, vi: false, diff --git a/globals.json b/globals.json index a78c284..8a0b08c 100644 --- a/globals.json +++ b/globals.json @@ -2660,11 +2660,15 @@ "afterAll": false, "afterEach": false, "assert": false, + "assertType": false, "beforeAll": false, "beforeEach": false, "describe": false, "expect": false, + "expectTypeOf": false, "it": false, + "onTestFailed": false, + "onTestFinished": false, "suite": false, "test": false, "vi": false, diff --git a/package.json b/package.json index a4045f3..1a146ab 100644 --- a/package.json +++ b/package.json @@ -45,7 +45,7 @@ "environments" ], "devDependencies": { - "@vitest/eslint-plugin": "^1.1.17", + "@vitest/eslint-plugin": "^1.1.18", "ava": "^6.1.3", "cheerio": "^1.0.0-rc.12", "eslint-plugin-jest": "^28.8.3",