From 9bebb12c46fb75b1bfd567da154ba14cf565cabe Mon Sep 17 00:00:00 2001 From: Cedric Kemp Date: Sat, 4 Nov 2017 12:19:54 -0400 Subject: [PATCH] Fixed linter issues --- types/parse/index.d.ts | 18 ++++---- types/parse/parse-tests.ts | 90 +++++++++++++++++++------------------- 2 files changed, 54 insertions(+), 54 deletions(-) diff --git a/types/parse/index.d.ts b/types/parse/index.d.ts index c606a2a6f9..3ad8e6c15d 100644 --- a/types/parse/index.d.ts +++ b/types/parse/index.d.ts @@ -13,11 +13,11 @@ declare namespace Parse { - var applicationId: string; - var javaScriptKey: string | undefined; - var masterKey: string | undefined; - var serverURL: string; - var VERSION: string; + let applicationId: string; + let javaScriptKey: string | undefined; + let masterKey: string | undefined; + let serverURL: string; + let VERSION: string; interface SuccessOption { success?: Function; @@ -97,11 +97,11 @@ declare namespace Parse { reject(error: any): void; resolve(result: any): void; then(resolvedCallback: (...values: T[]) => IPromise, - rejectedCallback?: (reason: any) => IPromise): IPromise; + rejectedCallback?: (reason: any) => IPromise): IPromise; then(resolvedCallback: (...values: T[]) => U, - rejectedCallback?: (reason: any) => IPromise): IPromise; + rejectedCallback?: (reason: any) => IPromise): IPromise; then(resolvedCallback: (...values: T[]) => U, - rejectedCallback?: (reason: any) => U): IPromise; + rejectedCallback?: (reason: any) => U): IPromise; } interface Pointer { @@ -933,7 +933,7 @@ declare namespace Parse { * * import Buffer = require("buffer").Buffer; */ - var HTTPOptions: new () => HTTPOptions; + let HTTPOptions: new () => HTTPOptions; interface HTTPOptions { /** * The body of the request. diff --git a/types/parse/parse-tests.ts b/types/parse/parse-tests.ts index 76440e46d3..8b3962c627 100644 --- a/types/parse/parse-tests.ts +++ b/types/parse/parse-tests.ts @@ -2,13 +2,13 @@ function test_events() { - var object = new Parse.Events(); + const object = new Parse.Events(); object.on("alert", (eventName: string) => alert("Triggered " + eventName)); object.trigger("alert", "an event"); - var onChange = () => console.log('whatever'); - var context: any; + const onChange = () => console.log('whatever'); + let context: any; object.off("change", onChange); object.off("change"); @@ -29,29 +29,29 @@ class Game extends Parse.Object { constructor(options?: any) { - super("GameScore", options); + super("Game", options); } } function test_object() { - var game = new Game(); + const game = new Game(); game.fetch({ success(g: Game) { } }); // Create a new instance of that class. - var gameScore = new GameScore(); + const gameScore = new GameScore(); gameScore.set("score", 1337); gameScore.set("playerName", "Sean Plott"); gameScore.set("cheatMode", false); - var score = gameScore.get("score"); - var playerName = gameScore.get("playerName"); - var cheatMode = gameScore.get("cheatMode"); + const score = gameScore.get("score"); + const playerName = gameScore.get("playerName"); + const cheatMode = gameScore.get("cheatMode"); gameScore.increment("score"); gameScore.addUnique("skills", "flying"); @@ -59,14 +59,14 @@ function test_object() { game.set("gameScore", gameScore); - var gameCopy = Game.fromJSON(JSON.parse(JSON.stringify(game)), true); + const gameCopy = Game.fromJSON(JSON.parse(JSON.stringify(game)), true); } function test_query() { - var gameScore = new GameScore(); + const gameScore = new GameScore(); - var query = new Parse.Query(GameScore); + const query = new Parse.Query(GameScore); query.equalTo("playerName", "Dan Stemkoski"); query.notEqualTo("playerName", "Michael Yabuti"); query.greaterThan("playerAge", 18); @@ -120,7 +120,7 @@ function test_query() { query.include("score"); query.include(["score.team"]); - var testQuery = Parse.Query.or(query, query); + const testQuery = Parse.Query.or(query, query); } class TestCollection extends Parse.Collection { @@ -141,9 +141,9 @@ function return_a_query(): Parse.Query { function test_collections() { - var collection = new TestCollection(); + let collection = new TestCollection(); - var query = new Parse.Query(Game); + const query = new Parse.Query(Game); query.equalTo("temperature", "hot"); query.greaterThan("degreesF", 100); @@ -167,10 +167,10 @@ function test_collections() { } ); - var model = collection.at(0); + const model = collection.at(0); // Or you can get it by Parse objectId. - var modelAgain = collection.get(model.id); + const modelAgain = collection.get(model.id); // Remove "Duke" from the collection. collection.remove(model); @@ -184,15 +184,15 @@ function test_collections() { function test_file() { - var base64 = "V29ya2luZyBhdCBQYXJzZSBpcyBncmVhdCE="; - var file = new Parse.File("myfile.txt", { base64: base64 }); + const base64 = "V29ya2luZyBhdCBQYXJzZSBpcyBncmVhdCE="; + let file = new Parse.File("myfile.txt", { base64: base64 }); - var bytes = [0xBE, 0xEF, 0xCA, 0xFE]; - var file = new Parse.File("myfile.txt", bytes); + const bytes = [0xBE, 0xEF, 0xCA, 0xFE]; + file = new Parse.File("myfile.txt", bytes); - var file = new Parse.File("myfile.zzz", {}, "image/png"); + file = new Parse.File("myfile.zzz", {}, "image/png"); - var src = file.url(); + const src = file.url(); file.save().then( () => { @@ -211,7 +211,7 @@ function test_file() { function test_analytics() { - var dimensions = { + const dimensions = { // Define ranges to bucket data points into meaningful segments priceRange: '1000-1500', // Did the user filter the query? @@ -222,7 +222,7 @@ function test_analytics() { // Send the dimensions to Parse along with the 'search' event Parse.Analytics.track('search', dimensions); - var codeString = '404'; + const codeString = '404'; Parse.Analytics.track('error', { code: codeString }) } @@ -232,7 +232,7 @@ function test_relation() { function test_user_acl_roles() { - var user = new Parse.User(); + const user = new Parse.User(); user.set("username", "my name"); user.set("password", "my pass"); user.set("email", "email@example.com"); @@ -240,7 +240,7 @@ function test_user_acl_roles() { // other fields can be set just like with Parse.Object user.set("phone", "415-392-0202"); - var currentUser = Parse.User.current(); + const currentUser = Parse.User.current(); if (currentUser) { // do stuff with the user } else { @@ -253,17 +253,17 @@ function test_user_acl_roles() { // The token could not be validated. }); - var game = new Game(); + const game = new Game(); game.set("score", new GameScore()); game.setACL(new Parse.ACL(Parse.User.current())); game.save().then((game: Game) => { }); game.save(null, { useMasterKey: true }); - var groupACL = new Parse.ACL(); + const groupACL = new Parse.ACL(); - var userList: Parse.User[] = [Parse.User.current()!]; + const userList: Parse.User[] = [Parse.User.current()!]; // userList is an array with the users we are sending this message to. - for (var i = 0; i < userList.length; i++) { + for (let i = 0; i < userList.length; i++) { groupACL.setReadAccess(userList[i], true); groupACL.setWriteAccess(userList[i], true); } @@ -279,7 +279,7 @@ function test_user_acl_roles() { }); // By specifying no write privileges for the ACL, we can ensure the role cannot be altered. - var role = new Parse.Role("Administrator", groupACL); + const role = new Parse.Role("Administrator", groupACL); role.getUsers().add(userList[0]); role.getRoles().add(role); role.save(); @@ -311,7 +311,7 @@ function test_facebook_util() { } }); - var user = Parse.User.current()!; + const user = Parse.User.current()!; if (!Parse.FacebookUtils.isLinked(user)) { Parse.FacebookUtils.link(user, null, { @@ -350,7 +350,7 @@ function test_cloud_functions() { }); Parse.Cloud.beforeDelete('MyCustomClass', (request: Parse.Cloud.BeforeDeleteRequest, - response: Parse.Cloud.BeforeDeleteResponse) => { + response: Parse.Cloud.BeforeDeleteResponse) => { // result }); @@ -366,27 +366,27 @@ class PlaceObject extends Parse.Object { } function test_geo_points() { - var point = new Parse.GeoPoint({ latitude: 40.0, longitude: -30.0 }); + const point = new Parse.GeoPoint({ latitude: 40.0, longitude: -30.0 }); - var userObject = Parse.User.current()!; + const userObject = Parse.User.current()!; // User's location - var userGeoPoint = userObject.get("location"); + const userGeoPoint = userObject.get("location"); // Create a query for places - var query = new Parse.Query(Parse.User); + const query = new Parse.Query(Parse.User); // Interested in locations near user. query.near("location", userGeoPoint); // Limit what could be a lot of points. query.limit(10); - var southwestOfSF = new Parse.GeoPoint(37.708813, -122.526398); - var northeastOfSF = new Parse.GeoPoint(37.822802, -122.373962); + const southwestOfSF = new Parse.GeoPoint(37.708813, -122.526398); + const northeastOfSF = new Parse.GeoPoint(37.822802, -122.373962); - var query2 = new Parse.Query(PlaceObject); + const query2 = new Parse.Query(PlaceObject); query2.withinGeoBox("location", southwestOfSF, northeastOfSF); - var query3 = new Parse.Query("PlaceObject").find().then((o: Parse.Object[]) => { }); + const query3 = new Parse.Query("PlaceObject").find().then((o: Parse.Object[]) => { }); } function test_push() { @@ -405,7 +405,7 @@ function test_push() { } }); - var query = new Parse.Query(Parse.Installation); + const query = new Parse.Query(Parse.Installation); query.equalTo('injuryReports', true); Parse.Push.send({ @@ -425,8 +425,8 @@ function test_push() { function test_view() { - var model = Parse.User.current(); - var view = new Parse.View(); + const model = Parse.User.current(); + const view = new Parse.View(); } function test_promise() {