Skip to content

Commit

Permalink
Generate vitest globals using environment of @vitest/eslint-plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
yongholeeme committed Dec 17, 2024
1 parent 876a787 commit b9cc28e
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 8 deletions.
7 changes: 3 additions & 4 deletions data/vitest.mjs
Original file line number Diff line number Diff line change
@@ -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,
Expand Down
4 changes: 0 additions & 4 deletions globals.json
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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",
Expand Down
6 changes: 6 additions & 0 deletions scripts/get-vitest-globals.mjs
Original file line number Diff line number Diff line change
@@ -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]));
}
6 changes: 6 additions & 0 deletions scripts/update.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [
{
Expand Down Expand Up @@ -36,6 +37,11 @@ const ALL_JOBS = [
getGlobals: getJestGlobals,
incremental: false,
},
{
environment: 'vitest',
getGlobals: getVitestGlobals,
incremental: false,
},
];

async function run(options) {
Expand Down

0 comments on commit b9cc28e

Please sign in to comment.