Skip to content

Commit

Permalink
fix(linter): ensure .cjs config file is handled correctly for generat…
Browse files Browse the repository at this point in the history
…ors #28214
  • Loading branch information
Coly010 committed Oct 29, 2024
1 parent 4b70d1b commit 9639663
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
3 changes: 2 additions & 1 deletion packages/eslint/src/generators/lint-project/lint-project.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
6 changes: 5 additions & 1 deletion packages/eslint/src/generators/utils/eslint-file.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down

0 comments on commit 9639663

Please sign in to comment.