1
1
import type { TSESLint } from '@typescript-eslint/utils' ;
2
2
3
- import tseslint from '../src/index' ;
3
+ import tseslint from '../src/index.js ' ;
4
4
5
5
describe ( 'config helper' , ( ) => {
6
6
it ( 'works without extends' , ( ) => {
@@ -10,7 +10,7 @@ describe('config helper', () => {
10
10
ignores : [ 'ignored' ] ,
11
11
rules : { rule : 'error' } ,
12
12
} ) ,
13
- ) . toEqual ( [
13
+ ) . toStrictEqual ( [
14
14
{
15
15
files : [ 'file' ] ,
16
16
ignores : [ 'ignored' ] ,
@@ -25,7 +25,7 @@ describe('config helper', () => {
25
25
extends : [ { rules : { rule1 : 'error' } } , { rules : { rule2 : 'error' } } ] ,
26
26
rules : { rule : 'error' } ,
27
27
} ) ,
28
- ) . toEqual ( [
28
+ ) . toStrictEqual ( [
29
29
{ rules : { rule1 : 'error' } } ,
30
30
{ rules : { rule2 : 'error' } } ,
31
31
{ rules : { rule : 'error' } } ,
@@ -40,7 +40,7 @@ describe('config helper', () => {
40
40
ignores : [ 'common-ignored' ] ,
41
41
rules : { rule : 'error' } ,
42
42
} ) ,
43
- ) . toEqual ( [
43
+ ) . toStrictEqual ( [
44
44
{
45
45
files : [ 'common-file' ] ,
46
46
ignores : [ 'common-ignored' ] ,
@@ -62,7 +62,7 @@ describe('config helper', () => {
62
62
it ( 'throws error containing config name when some extensions are undefined' , ( ) => {
63
63
const extension : TSESLint . FlatConfig . Config = { rules : { rule1 : 'error' } } ;
64
64
65
- expect ( ( ) =>
65
+ expect ( ( ) => {
66
66
tseslint . config (
67
67
{
68
68
extends : [ extension ] ,
@@ -79,8 +79,8 @@ describe('config helper', () => {
79
79
name : 'my-config-2' ,
80
80
rules : { rule : 'error' } ,
81
81
} ,
82
- ) ,
83
- ) . toThrow (
82
+ ) ;
83
+ } ) . toThrow (
84
84
'tseslint.config(): Config at index 1, named "my-config-2", contains non-object ' +
85
85
'extensions at the following indices: 0, 2' ,
86
86
) ;
@@ -89,7 +89,7 @@ describe('config helper', () => {
89
89
it ( 'throws error without config name when some extensions are undefined' , ( ) => {
90
90
const extension : TSESLint . FlatConfig . Config = { rules : { rule1 : 'error' } } ;
91
91
92
- expect ( ( ) =>
92
+ expect ( ( ) => {
93
93
tseslint . config (
94
94
{
95
95
extends : [ extension ] ,
@@ -105,8 +105,8 @@ describe('config helper', () => {
105
105
ignores : [ 'common-ignored' ] ,
106
106
rules : { rule : 'error' } ,
107
107
} ,
108
- ) ,
109
- ) . toThrow (
108
+ ) ;
109
+ } ) . toThrow (
110
110
'tseslint.config(): Config at index 1 (anonymous) contains non-object extensions at ' +
111
111
'the following indices: 0, 2' ,
112
112
) ;
@@ -121,7 +121,7 @@ describe('config helper', () => {
121
121
name : 'my-config' ,
122
122
rules : { rule : 'error' } ,
123
123
} ) ,
124
- ) . toEqual ( [
124
+ ) . toStrictEqual ( [
125
125
{
126
126
files : [ 'common-file' ] ,
127
127
ignores : [ 'common-ignored' ] ,
@@ -154,7 +154,7 @@ describe('config helper', () => {
154
154
ignores : [ 'common-ignored' ] ,
155
155
rules : { rule : 'error' } ,
156
156
} ) ,
157
- ) . toEqual ( [
157
+ ) . toStrictEqual ( [
158
158
{
159
159
files : [ 'common-file' ] ,
160
160
ignores : [ 'common-ignored' ] ,
@@ -186,7 +186,7 @@ describe('config helper', () => {
186
186
name : 'my-config' ,
187
187
rules : { rule : 'error' } ,
188
188
} ) ,
189
- ) . toEqual ( [
189
+ ) . toStrictEqual ( [
190
190
{
191
191
files : [ 'common-file' ] ,
192
192
ignores : [ 'common-ignored' ] ,
@@ -217,7 +217,7 @@ describe('config helper', () => {
217
217
[ [ [ { rules : { rule4 : 'error' } } ] ] ] ,
218
218
[ [ [ [ { rules : { rule5 : 'error' } } ] ] ] ] ,
219
219
) ,
220
- ) . toEqual ( [
220
+ ) . toStrictEqual ( [
221
221
{ rules : { rule1 : 'error' } } ,
222
222
{ rules : { rule2 : 'error' } } ,
223
223
{ rules : { rule3 : 'error' } } ,
@@ -238,7 +238,7 @@ describe('config helper', () => {
238
238
] ,
239
239
rules : { rule : 'error' } ,
240
240
} ) ,
241
- ) . toEqual ( [
241
+ ) . toStrictEqual ( [
242
242
{ rules : { rule1 : 'error' } } ,
243
243
{ rules : { rule2 : 'error' } } ,
244
244
{ rules : { rule3 : 'error' } } ,
@@ -254,7 +254,7 @@ describe('config helper', () => {
254
254
ignores : [ 'ignored' ] ,
255
255
} ) ;
256
256
257
- expect ( configWithIgnores ) . toEqual ( [
257
+ expect ( configWithIgnores ) . toStrictEqual ( [
258
258
{ ignores : [ 'ignored' ] , rules : { rule1 : 'error' } } ,
259
259
{ ignores : [ 'ignored' ] , rules : { rule2 : 'error' } } ,
260
260
] ) ;
@@ -272,7 +272,7 @@ describe('config helper', () => {
272
272
name : 'my-config' ,
273
273
} ) ;
274
274
275
- expect ( configWithMetadata ) . toEqual ( [
275
+ expect ( configWithMetadata ) . toStrictEqual ( [
276
276
{
277
277
files : [ 'file' ] ,
278
278
ignores : [ 'ignored' ] ,
@@ -301,7 +301,7 @@ describe('config helper', () => {
301
301
extends : [ { rules : { rule1 : 'error' } } , { } ] ,
302
302
ignores : [ 'ignored' ] ,
303
303
} ) ,
304
- ) . toEqual ( [
304
+ ) . toStrictEqual ( [
305
305
{ ignores : [ 'ignored' ] , rules : { rule1 : 'error' } } ,
306
306
// Should not create global ignores
307
307
{ } ,
@@ -314,23 +314,23 @@ describe('config helper', () => {
314
314
extends : [ { ignores : [ 'files/**/*' ] , name : 'global-ignore-stuff' } ] ,
315
315
ignores : [ 'ignored' ] ,
316
316
} ) ,
317
- ) . toEqual ( [ { ignores : [ 'files/**/*' ] , name : 'global-ignore-stuff' } ] ) ;
317
+ ) . toStrictEqual ( [ { ignores : [ 'files/**/*' ] , name : 'global-ignore-stuff' } ] ) ;
318
318
} ) ;
319
319
320
320
it ( 'throws error when extends is not an array' , ( ) => {
321
- expect ( ( ) =>
321
+ expect ( ( ) => {
322
322
tseslint . config ( {
323
323
// @ts -expect-error purposely testing invalid values
324
324
extends : 42 ,
325
- } ) ,
326
- ) . toThrow (
325
+ } ) ;
326
+ } ) . toThrow (
327
327
"tseslint.config(): Config at index 0 (anonymous) has an 'extends' property that is not an array." ,
328
328
) ;
329
329
} ) ;
330
330
331
- it . each ( [ undefined , null , 'not a config object' , 42 ] ) (
331
+ it . for ( [ [ undefined ] , [ null ] , [ 'not a config object' ] , [ 42 ] ] as const ) (
332
332
'passes invalid arguments through unchanged' ,
333
- config => {
333
+ ( [ config ] , { expect } ) => {
334
334
expect (
335
335
tseslint . config (
336
336
// @ts -expect-error purposely testing invalid values
@@ -341,12 +341,12 @@ describe('config helper', () => {
341
341
) ;
342
342
343
343
it ( 'gives a special error message for string extends' , ( ) => {
344
- expect ( ( ) =>
344
+ expect ( ( ) => {
345
345
tseslint . config ( {
346
346
// @ts -expect-error purposely testing invalid values
347
347
extends : [ 'some-string' ] ,
348
- } ) ,
349
- ) . toThrow (
348
+ } ) ;
349
+ } ) . toThrow (
350
350
'tseslint.config(): Config at index 0 (anonymous) has an \'extends\' array that contains a string ("some-string") at index 0. ' +
351
351
"This is a feature of eslint's `defineConfig()` helper and is not supported by typescript-eslint. " +
352
352
'Please provide a config object instead.' ,
@@ -360,17 +360,17 @@ describe('config helper', () => {
360
360
extends : null ,
361
361
files : [ 'files' ] ,
362
362
} ) ,
363
- ) . toEqual ( [ { files : [ 'files' ] } ] ) ;
363
+ ) . toStrictEqual ( [ { files : [ 'files' ] } ] ) ;
364
364
} ) ;
365
365
366
366
it ( 'complains when given an object with an invalid name' , ( ) => {
367
- expect ( ( ) =>
367
+ expect ( ( ) => {
368
368
tseslint . config ( {
369
369
extends : [ ] ,
370
370
// @ts -expect-error purposely testing invalid values
371
371
name : 42 ,
372
- } ) ,
373
- ) . toThrow (
372
+ } ) ;
373
+ } ) . toThrow (
374
374
"tseslint.config(): Config at index 0 has a 'name' property that is not a string." ,
375
375
) ;
376
376
} ) ;
0 commit comments