Skip to content

Commit aa7381e

Browse files
committed
feat(@schematics/angular): add a '.prettierrc' file to generated workspaces and add Prettier as dev dependency
The config was added as JSON, as this is the preferred format over executable configuration. '.prettierignore' was not added as the '.gitignore' rules are applied by default. Closes #32216 and closes #32222
1 parent 0126984 commit aa7381e

File tree

4 files changed

+14
-18
lines changed

4 files changed

+14
-18
lines changed

packages/schematics/angular/utility/latest-versions/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
"jsdom": "^27.1.0",
1919
"less": "^4.2.0",
2020
"postcss": "^8.5.3",
21+
"prettier": "^3.8.1",
2122
"protractor": "~7.0.0",
2223
"rxjs": "~7.8.0",
2324
"tailwindcss": "^4.1.12",
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"printWidth": 100,
3+
"singleQuote": true,
4+
"overrides": [
5+
{
6+
"files": "*.html",
7+
"options": {
8+
"parser": "angular"
9+
}
10+
}
11+
]
12+
}

packages/schematics/angular/workspace/files/package.json.template

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,18 +8,6 @@
88
"watch": "ng build --watch --configuration development"<% if (!minimal) { %>,
99
"test": "ng test"<% } %>
1010
},
11-
"prettier": {
12-
"printWidth": 100,
13-
"singleQuote": true,
14-
"overrides": [
15-
{
16-
"files": "*.html",
17-
"options": {
18-
"parser": "angular"
19-
}
20-
}
21-
]
22-
},
2311
"private": true,
2412
<% if (packageManagerWithVersion) { %>"packageManager": "<%= packageManagerWithVersion %>",<% } %>
2513
"dependencies": {
@@ -35,6 +23,7 @@
3523
"devDependencies": {
3624
"@angular/cli": "<%= '^' + version %>",
3725
"@angular/compiler-cli": "<%= latestVersions.Angular %>",
26+
"prettier": "<%= latestVersions['prettier'] %>",
3827
"typescript": "<%= latestVersions['typescript'] %>"
3928
}
4029
}

packages/schematics/angular/workspace/index_spec.ts

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -134,10 +134,4 @@ describe('Workspace Schematic', () => {
134134
const { tasks } = parseJson(tree.readContent('.vscode/tasks.json').toString());
135135
expect(tasks).not.toContain(jasmine.objectContaining({ type: 'npm', script: 'test' }));
136136
});
137-
138-
it('should include prettier config overrides for Angular templates', async () => {
139-
const tree = await schematicRunner.runSchematic('workspace', defaultOptions);
140-
const pkg = JSON.parse(tree.readContent('/package.json'));
141-
expect(pkg.prettier).withContext('package.json#prettier is present').toBeTruthy();
142-
});
143137
});

0 commit comments

Comments
 (0)