This repository was archived by the owner on Mar 7, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 7 files changed +69
-25
lines changed Expand file tree Collapse file tree 7 files changed +69
-25
lines changed Original file line number Diff line number Diff line change 73
73
"eslint-plugin-unicorn" : " ~44.0.2" ,
74
74
"eslint-plugin-vue" : " ~9.6.0" ,
75
75
"eslint-plugin-vue-pug" : " ~0.5.4" ,
76
+ "expect-type" : " ~0.15.0" ,
76
77
"json-schema" : " ~0.4.0" ,
77
78
"json-schema-to-typescript" : " ~11.0.2" ,
78
79
"prettier" : " 2.7.1" ,
Original file line number Diff line number Diff line change 1
1
import type { ESLint , Linter } from 'eslint' ;
2
2
import type { Rules } from '../rules' ;
3
- import type { LiteralUnion } from '../utility-types' ;
4
3
import type { LanguageOptions } from './language-options' ;
5
4
import type { LinterOptions } from './linter-options' ;
6
5
@@ -63,12 +62,9 @@ export interface FlatESLintConfigItem {
63
62
*
64
63
* @see [Using predefined configurations](https://eslint.org/docs/latest/user-guide/configuring/configuration-files-new#using-predefined-configurations)
65
64
*/
66
- export type PredefinedConfig = LiteralUnion <
67
- 'eslint:recommended' | 'eslint:all'
68
- > ;
65
+ export type PredefinedConfig = 'eslint:recommended' | 'eslint:all' ;
69
66
70
67
export type FlatESLintConfig = FlatESLintConfigItem | PredefinedConfig ;
71
- export type FlatESLintConfigs = Array < FlatESLintConfig > ;
72
68
73
69
export * from './language-options' ;
74
70
export * from './linter-options' ;
Original file line number Diff line number Diff line change 1
1
import type { ESLintConfig } from './config' ;
2
- import type { FlatESLintConfig , FlatESLintConfigs } from './flat-config' ;
2
+ import type { FlatESLintConfig } from './flat-config' ;
3
3
4
4
/**
5
5
* Define an ESLint config.
@@ -17,7 +17,7 @@ export function defineConfig(config: ESLintConfig): ESLintConfig;
17
17
* @param config an item of Flat ESLint config.
18
18
* @returns an item of Flat ESLint config.
19
19
*/
20
- export function defineConfig ( config : FlatESLintConfig ) : FlatESLintConfig ;
20
+ export function defineFlatConfig ( config : FlatESLintConfig ) : FlatESLintConfig ;
21
21
22
22
/**
23
23
* Define a flat ESLint config.
@@ -27,7 +27,9 @@ export function defineConfig(config: FlatESLintConfig): FlatESLintConfig;
27
27
* @param config Flat ESLint config.
28
28
* @returns Flat ESLint config.
29
29
*/
30
- export function defineConfig ( config : FlatESLintConfigs ) : FlatESLintConfigs ;
30
+ export function defineFlatConfig (
31
+ config : readonly FlatESLintConfig [ ] ,
32
+ ) : FlatESLintConfig [ ] ;
31
33
32
34
export * from './config' ;
33
35
export * from './flat-config' ;
Original file line number Diff line number Diff line change 2
2
3
3
exports . __esModule = true ;
4
4
exports . defineConfig = void 0 ;
5
+ exports . defineFlatConfig = void 0 ;
5
6
6
- /**
7
- * Define an ESLint config.
8
- *
9
- * @param config ESLint config.
10
- * @returns ESLint config.
11
- */
12
- function defineConfig ( config ) {
13
- return config ;
14
- }
15
-
16
- exports . defineConfig = defineConfig ;
7
+ exports . defineConfig = ( config ) => config ;
8
+ exports . defineFlatConfig = ( config ) => config ;
Original file line number Diff line number Diff line change 1
- /**
2
- * Define an eslint config.
3
- *
4
- * @param config Eslint config.
5
- * @returns Eslint config.
6
- */
7
1
export function defineConfig ( config ) {
8
2
return config ;
9
3
}
4
+
5
+ export function defineFlatConfig ( config ) {
6
+ return config ;
7
+ }
Original file line number Diff line number Diff line change
1
+ import { expectTypeOf } from 'expect-type' ;
2
+ import { describe , test } from 'vitest' ;
3
+ import type { ESLintConfig , FlatESLintConfig } from '../src' ;
4
+ import { defineConfig , defineFlatConfig } from '../src' ;
5
+
6
+ describe ( 'define' , ( ) => {
7
+ test ( 'define empty config' , ( ) => {
8
+ expectTypeOf ( defineConfig ( { } ) ) . toEqualTypeOf < ESLintConfig > ( ) ;
9
+ } ) ;
10
+
11
+ test ( 'define ESLint config' , ( ) => {
12
+ expectTypeOf (
13
+ defineConfig ( {
14
+ env : { } ,
15
+ extends : [ ] ,
16
+ rules : { } ,
17
+ } ) ,
18
+ ) . toEqualTypeOf < ESLintConfig > ( ) ;
19
+ } ) ;
20
+
21
+ test ( 'define an item of flat ESLint config' , ( ) => {
22
+ expectTypeOf (
23
+ defineFlatConfig ( {
24
+ ignores : [ ] ,
25
+ plugins : { } ,
26
+ rules : { } ,
27
+ } ) ,
28
+ ) . toEqualTypeOf < FlatESLintConfig > ( ) ;
29
+ } ) ;
30
+
31
+ test ( 'define predefined flat ESLint config' , ( ) => {
32
+ expectTypeOf (
33
+ defineFlatConfig ( 'eslint:recommended' ) ,
34
+ ) . toEqualTypeOf < FlatESLintConfig > ( ) ;
35
+ } ) ;
36
+
37
+ test ( 'define flat ESLint config' , ( ) => {
38
+ expectTypeOf (
39
+ defineFlatConfig ( [
40
+ 'eslint:recommended' ,
41
+ {
42
+ ignores : [ ] ,
43
+ plugins : { } ,
44
+ rules : { } ,
45
+ } ,
46
+ ] ) ,
47
+ ) . toEqualTypeOf < FlatESLintConfig [ ] > ( ) ;
48
+ } ) ;
49
+ } ) ;
You can’t perform that action at this time.
0 commit comments