Skip to content

Commit bc1f67c

Browse files
authored
style(*): Automate Code Formatting (#90)
* style(*): add prettier automation * fix(deps): fix issue where new typescript version was causing errors in the build Something breaks in version 2.4.1 of typescript. We are pinning to 2.3.0 till those things can be triaged and fixed * WIP: remove tslint.json Temporarily removing this file as we don't pass the checks * refactor(style): refaactor to prefer single quotes over double quotes * style(*): run prettier on codebase
1 parent d9e0ce9 commit bc1f67c

File tree

217 files changed

+14149
-8992
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

217 files changed

+14149
-8992
lines changed

package.json

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@
2222
"build:package": "gulp build && cd dist/package && npm install --production && npm shrinkwrap && npm pack && shx mv *.tgz ../",
2323
"test": "gulp build && gulp build:tests && gulp test && gulp test:integration",
2424
"dev": "gulp dev",
25-
"commitmsg": "validate-commit-msg"
25+
"commitmsg": "validate-commit-msg",
26+
"precommit": "lint-staged"
2627
},
2728
"main": "index.js",
2829
"devDependencies": {
@@ -69,8 +70,10 @@
6970
"karma-mocha": "^1.3.0",
7071
"karma-spec-reporter": "^0.0.30",
7172
"karma-typescript": "^3.0.4",
73+
"lint-staged": "^4.0.0",
7274
"merge2": "^1.0.3",
7375
"mkdirp": "^0.5.1",
76+
"prettier": "^1.5.1",
7477
"require-dir": "^0.3.1",
7578
"rimraf": "^2.6.1",
7679
"shx": "^0.2.2",
@@ -98,5 +101,11 @@
98101
"cz-customizable": {
99102
"config": "./.cz-config.js"
100103
}
104+
},
105+
"lint-staged": {
106+
"**/*.ts": [
107+
"prettier --write --single-quote",
108+
"git add"
109+
]
101110
}
102111
}

src/app.ts

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,9 @@
1414
* limitations under the License.
1515
*/
1616
// Import the createFirebaseNamespace function
17-
import {
18-
createFirebaseNamespace,
19-
FirebaseNamespace
20-
} from './app/firebase_app';
17+
import { createFirebaseNamespace, FirebaseNamespace } from './app/firebase_app';
2118

2219
// Export a single instance of firebase app
2320
const firebase: FirebaseNamespace = createFirebaseNamespace();
2421

25-
export default firebase;
22+
export default firebase;

src/app/errors.ts

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -53,16 +53,16 @@
5353
* }
5454
* }
5555
*/
56-
export type ErrorList<T> = {[code: string]: string};
56+
export type ErrorList<T> = { [code: string]: string };
5757

5858
const ERROR_NAME = 'FirebaseError';
5959

6060
export interface StringLike {
6161
toString: () => string;
6262
}
6363

64-
let captureStackTrace: (obj: Object, fn?: Function) => void =
65-
(Error as any).captureStackTrace;
64+
let captureStackTrace: (obj: Object, fn?: Function) => void = (Error as any)
65+
.captureStackTrace;
6666

6767
// Export for faking in tests
6868
export function patchCapture(captureFake?: any): any {
@@ -73,24 +73,23 @@ export function patchCapture(captureFake?: any): any {
7373

7474
export interface FirebaseError {
7575
// Unique code for error - format is service/error-code-string
76-
code: string,
76+
code: string;
7777

7878
// Developer-friendly error message.
79-
message: string,
79+
message: string;
8080

8181
// Always 'FirebaseError'
82-
name: string,
82+
name: string;
8383

8484
// Where available - stack backtrace in a string
85-
stack: string,
85+
stack: string;
8686
}
8787

8888
export class FirebaseError implements FirebaseError {
8989
public stack: string;
9090
public name: string;
9191

92-
constructor(public code: string,
93-
public message: string) {
92+
constructor(public code: string, public message: string) {
9493
let stack: string;
9594
// We want the stack value, if implemented by Error
9695
if (captureStackTrace) {
@@ -116,31 +115,32 @@ FirebaseError.prototype.constructor = FirebaseError;
116115

117116
export class ErrorFactory<T extends string> {
118117
// Matches {$name}, by default.
119-
public pattern = /\{\$([^}]+)}/g
118+
public pattern = /\{\$([^}]+)}/g;
120119

121-
constructor(private service: string,
122-
private serviceName: string,
123-
private errors: ErrorList<T>) {
120+
constructor(
121+
private service: string,
122+
private serviceName: string,
123+
private errors: ErrorList<T>
124+
) {
124125
// empty
125126
}
126127

127-
create(code: T, data?: {[prop: string]: StringLike}): FirebaseError {
128+
create(code: T, data?: { [prop: string]: StringLike }): FirebaseError {
128129
if (data === undefined) {
129130
data = {};
130131
}
131132

132-
let template = this.errors[(code as string)];
133+
let template = this.errors[code as string];
133134

134135
let fullCode = this.service + '/' + code;
135136
let message: string;
136137

137138
if (template === undefined) {
138-
message = "Error";
139+
message = 'Error';
139140
} else {
140141
message = template.replace(this.pattern, (match, key) => {
141142
let value = data![key];
142-
return value !== undefined ? value.toString()
143-
: '<' + key + '?>';
143+
return value !== undefined ? value.toString() : '<' + key + '?>';
144144
});
145145
}
146146

@@ -159,4 +159,4 @@ export class ErrorFactory<T extends string> {
159159

160160
return err;
161161
}
162-
}
162+
}

0 commit comments

Comments
 (0)