diff --git a/packages/eslint/src/generators/lint-project/lint-project.ts b/packages/eslint/src/generators/lint-project/lint-project.ts index 6ff40663bb8d8..545b0dcbcc47a 100644 --- a/packages/eslint/src/generators/lint-project/lint-project.ts +++ b/packages/eslint/src/generators/lint-project/lint-project.ts @@ -273,7 +273,8 @@ function createEsLintConfiguration( }); const nodeList = createNodeList(importMap, nodes); const content = stringifyNodeList(nodeList); - tree.write(join(projectConfig.root, 'eslint.config.js'), content); + const ext = extendedRootConfig?.endsWith('.cjs') ? '.cjs' : '.js'; + tree.write(join(projectConfig.root, `eslint.config${ext}`), content); } else { writeJson(tree, join(projectConfig.root, `.eslintrc.json`), { extends: extendedRootConfig ? [pathToRootConfig] : undefined, diff --git a/packages/eslint/src/generators/utils/eslint-file.ts b/packages/eslint/src/generators/utils/eslint-file.ts index 2db5e49f3f469..ee7e052ed253f 100644 --- a/packages/eslint/src/generators/utils/eslint-file.ts +++ b/packages/eslint/src/generators/utils/eslint-file.ts @@ -64,7 +64,11 @@ export function isEslintConfigSupported(tree: Tree, projectRoot = ''): boolean { if (!eslintFile) { return false; } - return eslintFile.endsWith('.json') || eslintFile.endsWith('.config.js'); + return ( + eslintFile.endsWith('.json') || + eslintFile.endsWith('.config.js') || + eslintFile.endsWith('.config.cjs') + ); } export function updateRelativePathsInConfig(