-
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
and *.cjs
extension with …
…flat config (#26637)
- Loading branch information
1 parent
3cbe2ab
commit 81fe132
Showing
5 changed files
with
38 additions
and
14 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
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
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,24 @@ | ||
import { Tree } from '@nx/devkit'; | ||
|
||
// todo: add support for eslint.config.mjs, | ||
export const eslintFlatConfigFilenames = [ | ||
'eslint.config.js', | ||
'eslint.config.cjs', | ||
]; | ||
|
||
export function flatConfigEslintFilename(tree: Tree): string { | ||
for (const file of eslintFlatConfigFilenames) { | ||
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; | ||
} | ||
} |