File tree Expand file tree Collapse file tree 1 file changed +20
-2
lines changed
packages/plugin-eslint/src/lib/meta/versions Expand file tree Collapse file tree 1 file changed +20
-2
lines changed Original file line number Diff line number Diff line change
1
+ import { ESLint } from 'eslint' ;
2
+ import { fileExists } from '@code-pushup/utils' ;
1
3
import type { ConfigFormat } from './formats' ;
2
4
5
+ // relevant ESLint docs:
6
+ // - https://eslint.org/docs/latest/use/configure/configuration-files
7
+ // - https://eslint.org/docs/latest/use/configure/configuration-files-deprecated
8
+ // - https://eslint.org/docs/v8.x/use/configure/configuration-files-new
9
+
3
10
export async function detectConfigVersion ( ) : Promise < ConfigFormat > {
4
- // TODO: detect flat config
5
- return 'legacy' ;
11
+ if ( process . env [ 'ESLINT_USE_FLAT_CONFIG' ] === 'true' ) {
12
+ return 'flat' ;
13
+ }
14
+ if ( process . env [ 'ESLINT_USE_FLAT_CONFIG' ] === 'false' ) {
15
+ return 'legacy' ;
16
+ }
17
+ if ( ESLint . version . startsWith ( '8.' ) ) {
18
+ if ( await fileExists ( 'eslint.config.js' ) ) {
19
+ return 'flat' ;
20
+ }
21
+ return 'legacy' ;
22
+ }
23
+ return 'flat' ;
6
24
}
You can’t perform that action at this time.
0 commit comments