From 06a572349b08709b49d8999038961558da4da4e7 Mon Sep 17 00:00:00 2001 From: Yongho Lee Date: Wed, 18 Dec 2024 22:30:15 +0900 Subject: [PATCH] Add `vitest` globals (#274) --- data/vitest.mjs | 21 +++++++++++++++++++++ globals.json | 18 ++++++++++++++++++ package.json | 2 ++ scripts/get-vitest-globals.mjs | 6 ++++++ scripts/update.mjs | 6 ++++++ 5 files changed, 53 insertions(+) create mode 100644 data/vitest.mjs create mode 100644 scripts/get-vitest-globals.mjs diff --git a/data/vitest.mjs b/data/vitest.mjs new file mode 100644 index 0000000..2127d6f --- /dev/null +++ b/data/vitest.mjs @@ -0,0 +1,21 @@ +// 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, + 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, diff --git a/package.json b/package.json index f5e9714..1a146ab 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.18", "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) {