Skip to content

Commit 82aba88

Browse files
committed
Reapply StandardJS rules.
Move GitHub-specific files to .github folder.
1 parent 06ca121 commit 82aba88

16 files changed

+109
-63
lines changed

.claspignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
LICENSE
22
!appsscript.json
3-
*.md
3+
*.md
4+
package*.json
File renamed without changes.

CONTRIBUTING.md renamed to .github/CONTRIBUTING.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,15 @@ Contributions are welcome! To contribute, fork this repository and create a pull
77

88
#### Checklist for your code
99
* Have you tested the code yourself?
10+
* Install [clasp](https://developers.google.com/apps-script/guides/clasp) `npm install --global @google/clasp`
11+
* Log into your Google Account `clasp login`
12+
* Create/Clone Apps Script Project
13+
* Create a Test.js file which creates a Firestore instance (via. `getFirestore()`)
14+
* Debug/Test your code against your database
1015
* Have you [documented your functions and their parameters and return values with JSDoc](http://usejsdoc.org/about-getting-started.html)?
1116
* Have you made all functions that an end user of the library should not see private? (You can make a function private by adding `_` to the end of its name, as in `publicFunction()` and `privateFunction_()`).
17+
* Add new "global" functions to `package.json`
1218
* Does your code follow the [Standard Javascript Style Guide](https://github.com/standard/standard)?
19+
* Install [standard](https://github.com/standard/standard) `npm install --global standard`
20+
* Check code against rules `standard --verbose`
21+
* Autofix most issues `standard --fix`

LICENSE renamed to .github/LICENSE

File renamed without changes.

PULL_REQUEST_TEMPLATE.md renamed to .github/PULL_REQUEST_TEMPLATE.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@ Hi! Thanks for creating a pull request.
22

33
Please make sure you have read the [Contributing](https://github.com/grahamearley/FirestoreGoogleAppsScript/blob/master/CONTRIBUTING.md) guidelines before submitting.
44

5-
(You can delete this text).
5+
(You can delete this text).

README.md renamed to .github/README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
# Firestore for Google Apps Scripts
2+
3+
[![JavaScript Style Guide](https://img.shields.io/badge/code_style-standard-brightgreen.svg)](https://standardjs.com)
4+
25
### A Google Apps Script library for accessing Google Cloud Firestore.
36

7+
48
This library allows a user (or service account) to authenticate with Firestore and edit their Firestore database within a Google Apps Script.
59

610
Read how this project was started [here](http://grahamearley.website/blog/2017/10/18/firestore-in-google-apps-script.html).

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
gapps.config.json
22
appsscript.json
33
.clasp.json
4+
.vs

Authenticate.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/* eslint no-unused-vars: ["error", { "varsIgnorePattern": "_" }] */
2-
/* global FirestoreRequest_, Utilities, base64EncodeSafe_ */
2+
/* eslint quote-props: ["error", "always"] */
33

44
/**
55
* Auth token is formatted to {@link https://developers.google.com/identity/protocols/OAuth2ServiceAccount#authorizingrequests}
@@ -14,7 +14,7 @@ function getAuthToken_ (email, key, authUrl) {
1414
const jwt = createJwt_(email, key, authUrl)
1515

1616
var options = {
17-
payload: 'grant_type=' + decodeURIComponent('urn:ietf:params:oauth:grant-type:jwt-bearer') + '&assertion=' + jwt
17+
'payload': 'grant_type=' + decodeURIComponent('urn:ietf:params:oauth:grant-type:jwt-bearer') + '&assertion=' + jwt
1818
}
1919
const responseObj = new FirestoreRequest_(authUrl, null, options).post()
2020
return responseObj.access_token

Firestore.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
/* eslint no-unused-vars: ["error", { "varsIgnorePattern": "_|Fire|get" }] */
2-
/* globals FirestoreRequest_, createDocument_, deleteDocument_, getAuthToken_, getDocument_, getDocumentIds_, query_, updateDocument_ */
32

43
/**
54
* Get an object that acts as an authenticated interface with a Firestore project.

FirestoreDocument.js

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/* eslint no-unused-vars: ["error", { "varsIgnorePattern": "_" }] */
2-
/* globals isInt_, regexPath_, regexBinary_ */
2+
/* eslint quote-props: ["error", "always"] */
33

44
/**
55
* Create a Firestore documents with the corresponding fields.
@@ -14,7 +14,7 @@ function createFirestoreDocument_ (fields) {
1414
return o
1515
}, {})
1616

17-
return {fields: fieldsObj}
17+
return { 'fields': fieldsObj }
1818
}
1919

2020
/**
@@ -24,11 +24,11 @@ function createFirestoreDocument_ (fields) {
2424
* @return {object} an object with the given document's fields and values
2525
*/
2626
function getFieldsFromFirestoreDocument_ (firestoreDoc) {
27-
if (!firestoreDoc || !firestoreDoc['fields']) {
27+
if (!firestoreDoc || !firestoreDoc.fields) {
2828
return {}
2929
}
3030

31-
const fields = firestoreDoc['fields']
31+
const fields = firestoreDoc.fields
3232
const keys = Object.keys(fields)
3333
const object = keys.reduce(function (o, key) {
3434
o[key] = unwrapValue_(fields[key])
@@ -87,7 +87,7 @@ function unwrapValue_ (value) {
8787
case 'mapValue':
8888
return getFieldsFromFirestoreDocument_(value)
8989
case 'arrayValue':
90-
return unwrapArray_(value['values'])
90+
return unwrapArray_(value.values)
9191
case 'timestampValue':
9292
return new Date(value)
9393
case 'nullValue':
@@ -107,7 +107,7 @@ function wrapString_ (string) {
107107
return wrapBytes_(string)
108108
}
109109

110-
return {'stringValue': string}
110+
return { 'stringValue': string }
111111
}
112112

113113
function wrapObject_ (object) {
@@ -127,19 +127,19 @@ function wrapObject_ (object) {
127127
return wrapLatLong_(object)
128128
}
129129

130-
return {'mapValue': createFirestoreDocument_(object)}
130+
return { 'mapValue': createFirestoreDocument_(object) }
131131
}
132132

133133
function wrapNull_ () {
134-
return {'nullValue': null}
134+
return { 'nullValue': null }
135135
}
136136

137137
function wrapBytes_ (bytes) {
138-
return {'bytesValue': bytes}
138+
return { 'bytesValue': bytes }
139139
}
140140

141141
function wrapRef_ (ref) {
142-
return {'referenceValue': ref}
142+
return { 'referenceValue': ref }
143143
}
144144

145145
function wrapNumber_ (num) {
@@ -151,28 +151,28 @@ function wrapNumber_ (num) {
151151
}
152152

153153
function wrapInt_ (int) {
154-
return {'integerValue': int}
154+
return { 'integerValue': int }
155155
}
156156

157157
function wrapDouble_ (double) {
158-
return {'doubleValue': double}
158+
return { 'doubleValue': double }
159159
}
160160

161161
function wrapBoolean_ (boolean) {
162-
return {'booleanValue': boolean}
162+
return { 'booleanValue': boolean }
163163
}
164164

165165
function wrapDate_ (date) {
166-
return {'timestampValue': date}
166+
return { 'timestampValue': date }
167167
}
168168

169169
function wrapLatLong_ (latLong) {
170-
return {'geoPointValue': latLong}
170+
return { 'geoPointValue': latLong }
171171
}
172172

173173
function wrapArray_ (array) {
174174
const wrappedArray = array.map(wrapValue_)
175-
return {'arrayValue': {'values': wrappedArray}}
175+
return { 'arrayValue': { 'values': wrappedArray } }
176176
}
177177

178178
function unwrapArray_ (wrappedArray) {

0 commit comments

Comments
 (0)