Skip to content

Commit ece73e5

Browse files
devversionandrewseguin
authored andcommitted
build: setup prettier in ng-dev format tool
Sets up prettier in the `yarn ng-dev format` command so that we can format the code consistently.
1 parent 6c9025c commit ece73e5

File tree

6 files changed

+32
-91
lines changed

6 files changed

+32
-91
lines changed

.ng-dev/format.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,5 @@ import {FormatConfig} from '@angular/dev-infra-private/ng-dev/format/config';
66
*/
77
export const format: FormatConfig = {
88
buildifier: true,
9+
prettier: true,
910
};

.prettierignore

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# These schematic ng-generate files are template files that cannot be formatted.
2+
src/material/schematics/ng-generate/*/files/**/*
3+
src/cdk/schematics/ng-generate/*/files/**/*
4+
5+
# Schematic ng-update test cases should not be formatted as that could break the
6+
# expected output tests. Generated code does is not formatted according to prettier.
7+
src/cdk/schematics/ng-update/test-cases/**/*_input.ts
8+
src/cdk/schematics/ng-update/test-cases/**/*_expected_output.ts
9+
src/material/schematics/ng-update/test-cases/**/*_input.ts
10+
src/material/schematics/ng-update/test-cases/**/*_expected_output.ts

.prettierrc

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"printWidth": 100,
3+
"singleQuote": true,
4+
"trailingComma": "all",
5+
"quoteProps": "preserve",
6+
"bracketSpacing": false,
7+
"arrowParens": "avoid",
8+
"embeddedLanguageFormatting": "off",
9+
}

scripts/check-mdc-tests.ts

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -90,15 +90,18 @@ function getTestNames(files: string[]): string[] {
9090
// Note that this is a little naive since it'll take the literal text of the test
9191
// name expression which could include things like string concatenation. It's fine
9292
// for the limited use cases of the script.
93-
testNames.push(node.arguments[0].getText(sourceFile)
94-
// Replace the quotes around the test name.
95-
.replace(/^['`]|['`]$/g, '')
96-
// Strip newlines followed by indentation.
97-
.replace(/\n\s+/g, ' ')
98-
// Strip escape characters.
99-
.replace(/\\/g, '')
100-
// Collapse concatenated strings.
101-
.replace(/['`]\s+\+\s+['`]/g, ''));
93+
testNames.push(
94+
node.arguments[0]
95+
.getText(sourceFile)
96+
// Replace the quotes around the test name.
97+
.replace(/^['"`]|['"`]$/g, '')
98+
// Strip newlines followed by indentation.
99+
.replace(/\n\s+/g, ' ')
100+
// Strip escape characters.
101+
.replace(/\\/g, '')
102+
// Collapse concatenated strings.
103+
.replace(/['"`]\s+\+\s+['"`]/g, ''),
104+
);
102105
} else {
103106
node.forEachChild(walk);
104107
}

tools/tslint-rules/noImportExportSpacingRule.ts

Lines changed: 0 additions & 37 deletions
This file was deleted.

tslint.json

Lines changed: 0 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,6 @@
1515
"Use 'readonly T[]' instead."
1616
]
1717
],
18-
"max-line-length": [true, {
19-
"limit": 100,
20-
"check-strings": true,
21-
"check-regex": true,
22-
"ignore-pattern": "//\\s+https?://"
23-
}
24-
],
2518
// Disable this flag because of SHA tslint#48b0c597f9257712c7d1f04b55ed0aa60e333f6a
2619
// TSLint now shows warnings if types for properties are inferred. This rule needs to be
2720
// disabled because all properties need to have explicit types set to work for Dgeni.
@@ -30,10 +23,6 @@
3023
true,
3124
"check-space"
3225
],
33-
"indent": [
34-
true,
35-
"spaces"
36-
],
3726
"eofline": true,
3827
"no-construct": true,
3928
"prefer-literal": [true, "object"],
@@ -49,46 +38,13 @@
4938
"no-var-keyword": true,
5039
"member-access": [true, "no-public"],
5140
"no-debugger": true,
52-
"one-line": [
53-
true,
54-
"check-catch",
55-
"check-else",
56-
"check-open-brace",
57-
"check-whitespace"
58-
],
59-
"quotemark": [
60-
true,
61-
"single",
62-
"avoid-escape"
63-
],
64-
"semicolon": true,
65-
"typedef-whitespace": [
66-
true,
67-
{
68-
"call-signature": "nospace",
69-
"index-signature": "nospace",
70-
"parameter": "nospace",
71-
"property-declaration": "nospace",
72-
"variable-declaration": "nospace"
73-
}
74-
],
75-
"curly": true,
7641
"variable-name": [
7742
true,
7843
"ban-keywords",
7944
"check-format",
8045
"allow-leading-underscore",
8146
"allow-snake-case"
8247
],
83-
"whitespace": [
84-
true,
85-
"check-branch",
86-
"check-decl",
87-
"check-operator",
88-
"check-separator",
89-
"check-type",
90-
"check-preblock"
91-
],
9248
// Bans jasmine helper functions that will prevent the CI from properly running tests.
9349
"ban": [
9450
true,
@@ -127,7 +83,6 @@
12783
// Custom Rules
12884
"ts-loader": true,
12985
"no-exposed-todo": true,
130-
"no-import-export-spacing": true,
13186
"no-private-getters": [true, "^_"],
13287
"no-undecorated-base-class-di": true,
13388
"no-undecorated-class-with-angular-features": true,

0 commit comments

Comments
 (0)