Skip to content

Commit c0eadbe

Browse files
clydinmgechev
authored andcommitted
build: integrate prettier code formatting
1 parent a1402d9 commit c0eadbe

File tree

6 files changed

+324
-72
lines changed

6 files changed

+324
-72
lines changed

.circleci/config.yml

+7-1
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,13 @@ jobs:
106106
<<: *defaults
107107
steps:
108108
- attach_workspace: *attach_options
109-
- run: yarn validate -- --ci
109+
- run: yarn validate --ci
110+
- run:
111+
name: Validate Code Formatting
112+
command: |
113+
if [[ -n "${CIRCLE_PR_NUMBER}" ]]; then
114+
npx prettier --check ".prettierrc" $(git log $CIRCLE_BRANCH --name-only --diff-filter=ACM --pretty="format:" --not $(git for-each-ref --format='%(refname)' refs/heads/ | grep -v "refs/heads/$CIRCLE_BRANCH") -- "*.js" "*.ts")
115+
fi
110116
111117
test:
112118
<<: *defaults

.lintstagedrc

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"*.{js,ts}": ["prettier --write", "git add"]
3+
}

.prettierrc

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"printWidth": 100,
3+
"singleQuote": true,
4+
"trailingComma": "all"
5+
}

package.json

+3
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@
7272
"debug": "^4.1.1",
7373
"glob": "^7.0.3",
7474
"node-fetch": "^2.2.0",
75+
"prettier": "^1.16.4",
7576
"puppeteer": "1.12.2",
7677
"quicktype-core": "^6.0.15",
7778
"temp": "^0.9.0",
@@ -121,6 +122,7 @@
121122
"karma-jasmine": "^2.0.1",
122123
"karma-jasmine-html-reporter": "^1.4.0",
123124
"license-checker": "^20.1.0",
125+
"lint-staged": "^8.1.5",
124126
"minimatch": "^3.0.4",
125127
"minimist": "^1.2.0",
126128
"npm-registry-client": "8.6.0",
@@ -142,6 +144,7 @@
142144
},
143145
"husky": {
144146
"hooks": {
147+
"pre-commit": "lint-staged",
145148
"pre-push": "node ./bin/devkit-admin hooks/pre-push"
146149
}
147150
}

tslint.json

-59
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
"defocus": true,
1616
"import-groups": true,
1717
"no-global-tslint-disable": true,
18-
"single-eof-line": true,
1918
// ==================================================================================================
2019
// tslint-sonarts rules. See https://github.com/SonarSource/SonarTS
2120
// These rules are part of the bug detection section of tslint-sonarts
@@ -52,45 +51,21 @@
5251
"no-floating-promises": true,
5352
"no-implicit-dependencies": true,
5453
"no-import-side-effect": [true, {"ignore-module": "^(?!rxjs\/)"}],
55-
"align": [
56-
true,
57-
"elements",
58-
"members",
59-
"parameters",
60-
"statements"
61-
],
62-
"max-line-length": [true, 100],
6354
"no-inferrable-types": true,
6455
"class-name": true,
6556
"comment-format": [
6657
true,
6758
"check-space"
6859
],
69-
"indent": [
70-
true,
71-
"spaces"
72-
],
73-
"eofline": true,
74-
"import-spacing": true,
7560
"match-default-export-name": true,
7661
"newline-before-return": true,
77-
"no-consecutive-blank-lines": [true, 2],
7862
"no-duplicate-variable": true,
7963
"no-eval": true,
8064
"no-any": true,
8165
"no-arg": true,
8266
"no-internal-module": true,
83-
"no-trailing-whitespace": true,
8467
"no-unused-expression": true,
8568
"no-var-keyword": true,
86-
"one-line": [
87-
true,
88-
"check-catch",
89-
"check-else",
90-
"check-finally",
91-
"check-open-brace",
92-
"check-whitespace"
93-
],
9469
"ordered-imports": [
9570
true,
9671
{
@@ -99,29 +74,6 @@
9974
}
10075
],
10176
"prefer-const": true,
102-
"quotemark": [
103-
true,
104-
"single",
105-
"avoid-escape"
106-
],
107-
"semicolon": [true, "always"],
108-
"trailing-comma": [
109-
true,
110-
{
111-
"multiline": "always",
112-
"singleline": "never"
113-
}
114-
],
115-
"typedef-whitespace": [
116-
true,
117-
{
118-
"call-signature": "nospace",
119-
"index-signature": "nospace",
120-
"parameter": "nospace",
121-
"property-declaration": "nospace",
122-
"variable-declaration": "nospace"
123-
}
124-
],
12577
"curly": true,
12678
"file-header": [
12779
true,
@@ -133,17 +85,6 @@
13385
"check-format",
13486
"allow-leading-underscore",
13587
"allow-pascal-case"
136-
],
137-
"whitespace": [
138-
true,
139-
"check-branch",
140-
"check-decl",
141-
"check-module",
142-
"check-preblock",
143-
"check-operator",
144-
"check-separator",
145-
"check-type",
146-
"check-typecast"
14788
]
14889
}
14990
}

0 commit comments

Comments
 (0)