Skip to content

Commit d74fba8

Browse files
GiteaBotsilverwind
andauthored
Use vitest globals (go-gitea#27102) (go-gitea#27311)
Backport go-gitea#27102 by @silverwind Enable [globals](https://vitest.dev/config/#globals) in vitest, reducing the noise in test files. Co-authored-by: silverwind <[email protected]>
1 parent e4cf9d2 commit d74fba8

15 files changed

+13
-11
lines changed

.eslintrc.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ plugins:
1818
- eslint-plugin-regexp
1919
- eslint-plugin-sonarjs
2020
- eslint-plugin-unicorn
21+
- eslint-plugin-vitest-globals
2122
- eslint-plugin-wc
2223

2324
env:
@@ -45,6 +46,9 @@ overrides:
4546
- files: ["*.config.*"]
4647
rules:
4748
import/no-unused-modules: [0]
49+
- files: ["**/*.test.*", "web_src/js/test/setup.js"]
50+
env:
51+
vitest-globals/env: true
4852
- files: ["web_src/js/modules/fetch.js", "web_src/js/standalone/**/*"]
4953
rules:
5054
no-restricted-syntax: [2, WithStatement, ForInStatement, LabeledStatement, SequenceExpression]

package-lock.json

Lines changed: 7 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@
6666
"eslint-plugin-regexp": "1.15.0",
6767
"eslint-plugin-sonarjs": "0.21.0",
6868
"eslint-plugin-unicorn": "48.0.1",
69+
"eslint-plugin-vitest-globals": "1.4.0",
6970
"eslint-plugin-vue": "9.17.0",
7071
"eslint-plugin-vue-scoped-css": "2.5.0",
7172
"eslint-plugin-wc": "2.0.3",

vitest.config.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ export default defineConfig({
1111
open: false,
1212
allowOnly: true,
1313
passWithNoTests: true,
14+
globals: true,
1415
watch: false,
1516
},
1617
plugins: [

web_src/js/features/common-issue-list.test.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import {test, expect} from 'vitest';
21
import {parseIssueListQuickGotoLink} from './common-issue-list.js';
32

43
test('parseIssueListQuickGotoLink', () => {

web_src/js/features/repo-code.test.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import {test, expect} from 'vitest';
21
import {singleAnchorRegex, rangeAnchorRegex} from './repo-code.js';
32

43
test('singleAnchorRegex', () => {

web_src/js/features/repo-findfile.test.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import {describe, expect, test} from 'vitest';
21
import {strSubMatch, calcMatchedWeight, filterRepoFilesWeighted} from './repo-findfile.js';
32

43
describe('Repo Find Files', () => {

web_src/js/modules/fetch.test.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import {test, expect} from 'vitest';
21
import {GET, POST, PATCH, PUT, DELETE} from './fetch.js';
32

43
// tests here are only to satisfy the linter for unused functions

web_src/js/modules/toast.test.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import {test, expect} from 'vitest';
21
import {showInfoToast, showErrorToast, showWarningToast} from './toast.js';
32

43
test('showInfoToast', async () => {

web_src/js/render/ansi.test.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import {expect, test} from 'vitest';
21
import {renderAnsi} from './ansi.js';
32

43
test('renderAnsi', () => {

web_src/js/svg.test.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import {expect, test} from 'vitest';
21
import {svg, SvgIcon, svgParseOuterInner} from './svg.js';
32
import {createApp, h} from 'vue';
43

web_src/js/utils.test.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import {expect, test} from 'vitest';
21
import {
32
basename, extname, isObject, stripTags, parseIssueHref,
43
parseUrl, translateMonth, translateDay, blobToDataURI,

web_src/js/utils/color.test.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import {test, expect} from 'vitest';
21
import {useLightTextOnBackground} from './color.js';
32

43
test('useLightTextOnBackground', () => {

web_src/js/utils/match.test.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import {test, expect} from 'vitest';
21
import {matchEmoji, matchMention} from './match.js';
32

43
test('matchEmoji', () => {

web_src/js/utils/url.test.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import {expect, test} from 'vitest';
21
import {pathEscapeSegments} from './url.js';
32

43
test('pathEscapeSegments', () => {

0 commit comments

Comments
 (0)