Skip to content

Commit f64a8ab

Browse files
authored
fix!: remove default include and exclude (#241)
* fix!: remove default include and exclude * fix: remove obsolete settings from manifest * fix: lockfile out of date
1 parent bdaf3bd commit f64a8ab

File tree

6 files changed

+8
-55
lines changed

6 files changed

+8
-55
lines changed

README.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@
2929

3030
# Config
3131

32-
- `vitest.include` and `vitest.exclude`` are deprecated. The extension now loads the include and exclude paths from your vitest config file.
3332
- `vitest.enable`: This plugin will try to detect whether the current project is
3433
set up with Vitest to activate itself. If detection fails, you can enable the plugin manually.
3534
- `vitest.nodeEnv`: The env passed to runner process in addition to

package.json

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -101,25 +101,6 @@
101101
"scope": "resource",
102102
"default": ""
103103
},
104-
"vitest.include": {
105-
"markdownDescription": "Include glob for test files. Default: `[\"**/*.{test,spec}.{js,mjs,cjs,ts,mts,cts,jsx,tsx}\"]`",
106-
"type": "array",
107-
"default": [
108-
"**/*.{test,spec}.{js,mjs,cjs,ts,mts,cts,jsx,tsx}"
109-
],
110-
"scope": "resource"
111-
},
112-
"vitest.exclude": {
113-
"markdownDescription": "Exclude globs for test files. \nDefault: `[\"**/node_modules/**\", \"**/dist/**\", \"**/cypress/**\", \"**/.{idea,git,cache,output,temp}/**\"]`",
114-
"type": "array",
115-
"default": [
116-
"**/node_modules/**",
117-
"**/dist/**",
118-
"**/cypress/**",
119-
"**/.{idea,git,cache,output,temp}/**"
120-
],
121-
"scope": "resource"
122-
},
123104
"vitest.debugExclude": {
124105
"markdownDescription": "Automatically skip files covered by these glob patterns. \nDefault: `[\"<node_internals>/**\", \"**/node_modules/**\"]`",
125106
"type": "array",

samples/basic/.vscode/settings.json

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,5 @@
11
{
22
"vitest.nodeEnv": {},
3-
"vitest.include": [
4-
"**/*.{test,spec}.{js,mjs,cjs,ts,mts,cts,jsx,tsx}",
5-
"**/src/should_included_test.ts"
6-
],
73
"vitest.exclude": [
84
"**/node_modules/**",
95
"**/dist/**",

src/config.ts

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,11 @@
11
import semver from 'semver'
2-
import type { ResolvedConfig } from 'vitest'
32
import type { WorkspaceConfiguration, WorkspaceFolder } from 'vscode'
43
import * as vscode from 'vscode'
54
import { log } from './log'
65
import { isDefinitelyVitestEnv, mayBeVitestEnv } from './pure/isVitestEnv'
76
import { getVitestCommand, getVitestVersion, isNodeAvailable } from './pure/utils'
87
export const extensionId = 'zxch3n.vitest-explorer'
98

10-
// Copied from https://github.com/vitest-dev/vitest/blob/main/packages/vitest/src/defaults.ts
11-
// "import { configDefaults } from 'vitest'" throws unexpected URL error
12-
const defaultInclude = ['**/*.{test,spec}.?(c|m)[jt]s?(x)']
13-
const defaultExclude = [
14-
'**/node_modules/**',
15-
'**/dist/**',
16-
'**/cypress/**',
17-
'**/.{idea,git,cache,output,temp}/**',
18-
'**/{karma,rollup,webpack,vite,vitest,jest,ava,babel,nyc,cypress,tsup,build,eslint,prettier}.config.*',
19-
]
20-
219
export function getConfigValue<T>(
2210
rootConfig: WorkspaceConfiguration,
2311
folderConfig: WorkspaceConfiguration,
@@ -43,21 +31,11 @@ export function getConfig(workspaceFolder?: WorkspaceFolder | vscode.Uri | strin
4331
env: get<null | Record<string, string>>('nodeEnv', null),
4432
commandLine: get<string | undefined>('commandLine', undefined),
4533
watchOnStartup: get<boolean>('watchOnStartup', false),
46-
include: get<string[]>('include'),
47-
exclude: get<string[]>('exclude'),
4834
enable: get<boolean>('enable', false),
4935
debugExclude: get<string[]>('debugExclude', []),
5036
}
5137
}
5238

53-
export function getCombinedConfig(config: ResolvedConfig, workspaceFolder?: WorkspaceFolder | vscode.Uri | string) {
54-
const vitestConfig = getConfig(workspaceFolder)
55-
return {
56-
exclude: vitestConfig.exclude?.concat(config.exclude) || defaultExclude,
57-
include: vitestConfig.include?.concat(config.include) || defaultInclude,
58-
}
59-
}
60-
6139
export function getRootConfig() {
6240
const rootConfig = vscode.workspace.getConfiguration('vitest')
6341

src/discover.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import parse from './pure/parsers'
1414
import type { NamedBlock } from './pure/parsers/parser_nodes'
1515
import { shouldIncludeFile } from './vscodeUtils'
1616

17-
import { getCombinedConfig, vitestEnvironmentFolders } from './config'
17+
import { vitestEnvironmentFolders } from './config'
1818
import { log } from './log'
1919
import { openTestTag } from './tags'
2020

@@ -53,8 +53,8 @@ export class TestFileDiscoverer extends vscode.Disposable {
5353
const watchers = [] as vscode.FileSystemWatcher[]
5454
await Promise.all(
5555
vitestEnvironmentFolders.map(async (workspaceFolder) => {
56-
const exclude = getCombinedConfig(this.config, workspaceFolder).exclude
57-
for (const include of getCombinedConfig(this.config, workspaceFolder).include) {
56+
const exclude = this.config.exclude
57+
for (const include of this.config.include) {
5858
const pattern = new vscode.RelativePattern(
5959
workspaceFolder.uri,
6060
include,
@@ -108,8 +108,8 @@ export class TestFileDiscoverer extends vscode.Disposable {
108108
await Promise.all(
109109
vscode.workspace.workspaceFolders.map(async (workspaceFolder) => {
110110
const workspacePath = workspaceFolder.uri.fsPath
111-
const exclude = getCombinedConfig(this.config, workspaceFolder).exclude
112-
for (const include of getCombinedConfig(this.config, workspaceFolder).include) {
111+
const exclude = this.config.exclude
112+
for (const include of this.config.include) {
113113
const pattern = new vscode.RelativePattern(
114114
workspaceFolder.uri,
115115
include,

src/vscodeUtils.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
1+
import minimatch from 'minimatch'
12
import { TextDecoder } from 'util'
3+
import type { ResolvedConfig } from 'vitest'
24
import type { Uri } from 'vscode'
35
import { workspace } from 'vscode'
4-
import minimatch from 'minimatch'
5-
import type { ResolvedConfig } from 'vitest'
6-
import { getCombinedConfig } from './config'
76

87
const textDecoder = new TextDecoder('utf-8')
98

@@ -19,7 +18,7 @@ export const getContentFromFilesystem = async (uri: Uri) => {
1918
}
2019

2120
export function shouldIncludeFile(path: string, config: ResolvedConfig) {
22-
const { include, exclude } = getCombinedConfig(config)
21+
const { include, exclude } = config
2322
return (
2423
include.some(x => minimatch(path, x))
2524
&& exclude.every(x => !minimatch(path, x, { dot: true }))

0 commit comments

Comments
 (0)