-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(linter): support eslint.config.cjs with flat config
- Loading branch information
1 parent
963f753
commit 65edf38
Showing
2 changed files
with
23 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,19 @@ | ||
import { Tree } from '@nx/devkit'; | ||
|
||
export function flatConfigEslintFilename(tree: Tree): string { | ||
const configFiles = ['eslint.config.js', 'eslint.config.cjs']; | ||
for (const file of configFiles) { | ||
if (tree.exists(file)) { | ||
return file; | ||
} | ||
} | ||
throw new Error('Could not find flat config file'); | ||
} | ||
|
||
export function useFlatConfig(tree: Tree): boolean { | ||
return tree.exists('eslint.config.js'); | ||
try { | ||
return !!flatConfigEslintFilename(tree); | ||
} catch { | ||
return false; | ||
} | ||
} |