Skip to content

Commit e5d3b94

Browse files
committed
refactor(@angular/cli): remove file extension filtering from Prettier utility, passing all files directly
With '--no-error-on-unmatched-pattern' this list is no longer needed.
1 parent 6f29a8c commit e5d3b94

File tree

1 file changed

+2
-30
lines changed

1 file changed

+2
-30
lines changed

packages/angular/cli/src/utilities/prettier.ts

Lines changed: 2 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -9,29 +9,12 @@
99
import { execFile } from 'node:child_process';
1010
import { readFile } from 'node:fs/promises';
1111
import { createRequire } from 'node:module';
12-
import { dirname, extname, join } from 'node:path';
12+
import { dirname, join } from 'node:path';
1313
import { promisify } from 'node:util';
1414

1515
const execFileAsync = promisify(execFile);
1616
let prettierCliPath: string | null | undefined;
1717

18-
/**
19-
* File types that can be formatted using Prettier.
20-
*/
21-
const fileTypes: ReadonlySet<string> = new Set([
22-
'.md',
23-
'.ts',
24-
'.html',
25-
'.js',
26-
'.mjs',
27-
'.cjs',
28-
'.json',
29-
'.css',
30-
'.less',
31-
'.scss',
32-
'.sass',
33-
]);
34-
3518
/**
3619
* Formats files using Prettier.
3720
* @param cwd The current working directory.
@@ -59,20 +42,9 @@ export async function formatFiles(cwd: string, files: Set<string>): Promise<void
5942
return;
6043
}
6144

62-
const filesToFormat: string[] = [];
63-
for (const file of files) {
64-
if (fileTypes.has(extname(file))) {
65-
filesToFormat.push(file);
66-
}
67-
}
68-
69-
if (!filesToFormat.length) {
70-
return;
71-
}
72-
7345
await execFileAsync(
7446
process.execPath,
75-
[prettierCliPath, '--write', '--no-error-on-unmatched-pattern', ...filesToFormat],
47+
[prettierCliPath, '--write', '--no-error-on-unmatched-pattern', ...files],
7648
{
7749
cwd,
7850
shell: false,

0 commit comments

Comments
 (0)