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 7373 "eslint-plugin-unicorn" : " ~44.0.2" ,
7474 "eslint-plugin-vue" : " ~9.6.0" ,
7575 "eslint-plugin-vue-pug" : " ~0.5.4" ,
76+ "expect-type" : " ~0.15.0" ,
7677 "json-schema" : " ~0.4.0" ,
7778 "json-schema-to-typescript" : " ~11.0.2" ,
7879 "prettier" : " 2.7.1" ,
Original file line number Diff line number Diff line change 11import type { ESLint , Linter } from 'eslint' ;
22import type { Rules } from '../rules' ;
3- import type { LiteralUnion } from '../utility-types' ;
43import type { LanguageOptions } from './language-options' ;
54import type { LinterOptions } from './linter-options' ;
65
@@ -63,12 +62,9 @@ export interface FlatESLintConfigItem {
6362 *
6463 * @see [Using predefined configurations](https://eslint.org/docs/latest/user-guide/configuring/configuration-files-new#using-predefined-configurations)
6564 */
66- export type PredefinedConfig = LiteralUnion <
67- 'eslint:recommended' | 'eslint:all'
68- > ;
65+ export type PredefinedConfig = 'eslint:recommended' | 'eslint:all' ;
6966
7067export type FlatESLintConfig = FlatESLintConfigItem | PredefinedConfig ;
71- export type FlatESLintConfigs = Array < FlatESLintConfig > ;
7268
7369export * from './language-options' ;
7470export * from './linter-options' ;
Original file line number Diff line number Diff line change 11import type { ESLintConfig } from './config' ;
2- import type { FlatESLintConfig , FlatESLintConfigs } from './flat-config' ;
2+ import type { FlatESLintConfig } from './flat-config' ;
33
44/**
55 * Define an ESLint config.
@@ -17,7 +17,7 @@ export function defineConfig(config: ESLintConfig): ESLintConfig;
1717 * @param config an item of Flat ESLint config.
1818 * @returns an item of Flat ESLint config.
1919 */
20- export function defineConfig ( config : FlatESLintConfig ) : FlatESLintConfig ;
20+ export function defineFlatConfig ( config : FlatESLintConfig ) : FlatESLintConfig ;
2121
2222/**
2323 * Define a flat ESLint config.
@@ -27,7 +27,9 @@ export function defineConfig(config: FlatESLintConfig): FlatESLintConfig;
2727 * @param config Flat ESLint config.
2828 * @returns Flat ESLint config.
2929 */
30- export function defineConfig ( config : FlatESLintConfigs ) : FlatESLintConfigs ;
30+ export function defineFlatConfig (
31+ config : readonly FlatESLintConfig [ ] ,
32+ ) : FlatESLintConfig [ ] ;
3133
3234export * from './config' ;
3335export * from './flat-config' ;
Original file line number Diff line number Diff line change 22
33exports . __esModule = true ;
44exports . defineConfig = void 0 ;
5+ exports . defineFlatConfig = void 0 ;
56
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- */
71export function defineConfig ( config ) {
82 return config ;
93}
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