1
- import { strictEqual } from 'assert' ;
1
+ import { deepStrictEqual , strictEqual } from 'assert' ;
2
2
import { workspace } from 'vscode' ;
3
3
import { Config } from './Config.js' ;
4
4
5
5
suite ( 'Config' , ( ) => {
6
6
setup ( async ( ) => {
7
7
const wsConfig = workspace . getConfiguration ( 'oxc' ) ;
8
- const keys = [ 'lint.run' , 'enable' , 'trace.server' , 'configPath' , 'path.server' ] ;
8
+ const keys = [ 'lint.run' , 'enable' , 'trace.server' , 'configPath' , 'path.server' , 'flags' ] ;
9
9
10
10
await Promise . all ( keys . map ( key => wsConfig . update ( key , undefined ) ) ) ;
11
11
} ) ;
@@ -18,6 +18,29 @@ suite('Config', () => {
18
18
strictEqual ( config . trace , 'off' ) ;
19
19
strictEqual ( config . configPath , '.oxlintrc.json' ) ;
20
20
strictEqual ( config . binPath , '' ) ;
21
+ deepStrictEqual ( config . flags , { } ) ;
22
+ } ) ;
23
+
24
+ test ( 'configPath defaults to empty string when using nested configs and configPath is empty' , async ( ) => {
25
+ const wsConfig = workspace . getConfiguration ( 'oxc' ) ;
26
+ await wsConfig . update ( 'configPath' , '' ) ;
27
+ await wsConfig . update ( 'flags' , { } ) ;
28
+
29
+ const config = new Config ( ) ;
30
+
31
+ deepStrictEqual ( config . flags , { } ) ;
32
+ strictEqual ( config . configPath , '' ) ;
33
+ } ) ;
34
+
35
+ test ( 'configPath defaults to .oxlintrc.json when not using nested configs and configPath is empty' , async ( ) => {
36
+ const wsConfig = workspace . getConfiguration ( 'oxc' ) ;
37
+ await wsConfig . update ( 'configPath' , '' ) ;
38
+ await wsConfig . update ( 'flags' , { disable_nested_config : '' } ) ;
39
+
40
+ const config = new Config ( ) ;
41
+
42
+ deepStrictEqual ( config . flags , { disable_nested_config : '' } ) ;
43
+ strictEqual ( config . configPath , '.oxlintrc.json' ) ;
21
44
} ) ;
22
45
23
46
test ( 'updating values updates the workspace configuration' , async ( ) => {
@@ -29,6 +52,7 @@ suite('Config', () => {
29
52
config . updateTrace ( 'messages' ) ,
30
53
config . updateConfigPath ( './somewhere' ) ,
31
54
config . updateBinPath ( './binary' ) ,
55
+ config . updateFlags ( { test : 'value' } ) ,
32
56
] ) ;
33
57
34
58
const wsConfig = workspace . getConfiguration ( 'oxc' ) ;
@@ -38,5 +62,6 @@ suite('Config', () => {
38
62
strictEqual ( wsConfig . get ( 'trace.server' ) , 'messages' ) ;
39
63
strictEqual ( wsConfig . get ( 'configPath' ) , './somewhere' ) ;
40
64
strictEqual ( wsConfig . get ( 'path.server' ) , './binary' ) ;
65
+ deepStrictEqual ( wsConfig . get ( 'flags' ) , { test : 'value' } ) ;
41
66
} ) ;
42
67
} ) ;
0 commit comments