Skip to content

Commit

Permalink
refactor(ts): enable noImplicitThis (#316)
Browse files Browse the repository at this point in the history
  • Loading branch information
JustinBeckwith authored Nov 5, 2018
1 parent 6c74961 commit bb357fc
Show file tree
Hide file tree
Showing 30 changed files with 250 additions and 263 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@

```javascript
// Imports the Google Cloud client library
const PubSub = require('@google-cloud/pubsub');
const {PubSub} = require('@google-cloud/pubsub');

// Your Google Cloud Platform project ID
const projectId = 'YOUR_PROJECT_ID';
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@
"devDependencies": {
"@google-cloud/nodejs-repo-tools": "^2.3.3",
"@types/arrify": "^1.0.4",
"@types/async": "^2.0.50",
"@types/extend": "^3.0.0",
"@types/is": "0.0.20",
"@types/mocha": "^5.2.5",
Expand Down
2 changes: 1 addition & 1 deletion samples/quickstart.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

// [START pubsub_quickstart_create_topic]
// Imports the Google Cloud client library
const PubSub = require('@google-cloud/pubsub');
const {PubSub} = require('@google-cloud/pubsub');

// Your Google Cloud Platform project ID
const projectId = 'YOUR_PROJECT_ID';
Expand Down
28 changes: 14 additions & 14 deletions samples/subscriptions.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
function listSubscriptions() {
// [START pubsub_list_subscriptions]
// Imports the Google Cloud client library
const PubSub = require(`@google-cloud/pubsub`);
const {PubSub} = require('@google-cloud/pubsub');

// Creates a client
const pubsub = new PubSub();
Expand All @@ -49,7 +49,7 @@ function listSubscriptions() {
function listTopicSubscriptions(topicName) {
// [START pubsub_list_topic_subscriptions]
// Imports the Google Cloud client library
const PubSub = require(`@google-cloud/pubsub`);
const {PubSub} = require('@google-cloud/pubsub');

// Creates a client
const pubsub = new PubSub();
Expand Down Expand Up @@ -78,7 +78,7 @@ function listTopicSubscriptions(topicName) {
function createSubscription(topicName, subscriptionName) {
// [START pubsub_create_pull_subscription]
// Imports the Google Cloud client library
const PubSub = require(`@google-cloud/pubsub`);
const {PubSub} = require('@google-cloud/pubsub');

// Creates a client
const pubsub = new PubSub();
Expand Down Expand Up @@ -111,7 +111,7 @@ function createFlowControlledSubscription(
) {
// [START pubsub_subscriber_flow_settings]
// Imports the Google Cloud client library
const PubSub = require(`@google-cloud/pubsub`);
const {PubSub} = require('@google-cloud/pubsub');

// Creates a client
const pubsub = new PubSub();
Expand Down Expand Up @@ -159,7 +159,7 @@ function createFlowControlledSubscription(
function createPushSubscription(topicName, subscriptionName) {
// [START pubsub_create_push_subscription]
// Imports the Google Cloud client library
const PubSub = require(`@google-cloud/pubsub`);
const {PubSub} = require('@google-cloud/pubsub');

// Creates a client
const pubsub = new PubSub();
Expand Down Expand Up @@ -195,7 +195,7 @@ function createPushSubscription(topicName, subscriptionName) {
function modifyPushConfig(topicName, subscriptionName) {
// [START pubsub_update_push_configuration]
// Imports the Google Cloud client library
const PubSub = require(`@google-cloud/pubsub`);
const {PubSub} = require('@google-cloud/pubsub');

// Creates a client
const pubsub = new PubSub();
Expand Down Expand Up @@ -228,7 +228,7 @@ function modifyPushConfig(topicName, subscriptionName) {
function deleteSubscription(subscriptionName) {
// [START pubsub_delete_subscription]
// Imports the Google Cloud client library
const PubSub = require(`@google-cloud/pubsub`);
const {PubSub} = require('@google-cloud/pubsub');

// Creates a client
const pubsub = new PubSub();
Expand All @@ -253,7 +253,7 @@ function deleteSubscription(subscriptionName) {

function getSubscription(subscriptionName) {
// Imports the Google Cloud client library
const PubSub = require(`@google-cloud/pubsub`);
const {PubSub} = require('@google-cloud/pubsub');

// Creates a client
const pubsub = new PubSub();
Expand Down Expand Up @@ -284,7 +284,7 @@ function listenForMessages(subscriptionName, timeout) {
// [START pubsub_subscriber_async_pull]
// [START pubsub_quickstart_subscriber]
// Imports the Google Cloud client library
const PubSub = require(`@google-cloud/pubsub`);
const {PubSub} = require('@google-cloud/pubsub');

// Creates a client
const pubsub = new PubSub();
Expand Down Expand Up @@ -441,7 +441,7 @@ const outstandingMessages = {};

function listenForOrderedMessages(subscriptionName, timeout) {
// Imports the Google Cloud client library
const PubSub = require(`@google-cloud/pubsub`);
const {PubSub} = require('@google-cloud/pubsub');

// Creates a client
const pubsub = new PubSub();
Expand Down Expand Up @@ -504,7 +504,7 @@ function listenForOrderedMessages(subscriptionName, timeout) {
function listenForErrors(subscriptionName, timeout) {
// [START pubsub_subscriber_error_listener]
// Imports the Google Cloud client library
const PubSub = require(`@google-cloud/pubsub`);
const {PubSub} = require('@google-cloud/pubsub');

// Creates a client
const pubsub = new PubSub();
Expand Down Expand Up @@ -547,7 +547,7 @@ function listenForErrors(subscriptionName, timeout) {
function getSubscriptionPolicy(subscriptionName) {
// [START pubsub_get_subscription_policy]
// Imports the Google Cloud client library
const PubSub = require(`@google-cloud/pubsub`);
const {PubSub} = require('@google-cloud/pubsub');

// Creates a client
const pubsub = new PubSub();
Expand All @@ -574,7 +574,7 @@ function getSubscriptionPolicy(subscriptionName) {
function setSubscriptionPolicy(subscriptionName) {
// [START pubsub_set_subscription_policy]
// Imports the Google Cloud client library
const PubSub = require(`@google-cloud/pubsub`);
const {PubSub} = require('@google-cloud/pubsub');

// Creates a client
const pubsub = new PubSub();
Expand Down Expand Up @@ -620,7 +620,7 @@ function setSubscriptionPolicy(subscriptionName) {
function testSubscriptionPermissions(subscriptionName) {
// [START pubsub_test_subscription_permissions]
// Imports the Google Cloud client library
const PubSub = require(`@google-cloud/pubsub`);
const {PubSub} = require('@google-cloud/pubsub');

// Creates a client
const pubsub = new PubSub();
Expand Down
16 changes: 9 additions & 7 deletions samples/system-test/quickstart.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@

'use strict';

const proxyquire = require(`proxyquire`).noPreserveCache();
const PubSub = proxyquire(`@google-cloud/pubsub`, {});
const sinon = require(`sinon`);
const test = require(`ava`);
const tools = require(`@google-cloud/nodejs-repo-tools`);
const uuid = require(`uuid`);
const proxyquire = require('proxyquire').noPreserveCache();
const {PubSub} = proxyquire('@google-cloud/pubsub', {});
const sinon = require('sinon');
const test = require('ava');
const tools = require('@google-cloud/nodejs-repo-tools');
const uuid = require('uuid');

const projectId = process.env.GCLOUD_PROJECT;
const pubsub = new PubSub({projectId});
Expand Down Expand Up @@ -61,6 +61,8 @@ test.cb(`should create a topic`, t => {
};

proxyquire(`../quickstart`, {
'@google-cloud/pubsub': sinon.stub().returns(pubsubMock),
'@google-cloud/pubsub': {
PubSub: sinon.stub().returns(pubsubMock),
},
});
});
2 changes: 1 addition & 1 deletion samples/system-test/subscriptions.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
'use strict';

const path = require(`path`);
const PubSub = require(`@google-cloud/pubsub`);
const {PubSub} = require('@google-cloud/pubsub');
const test = require(`ava`);
const tools = require(`@google-cloud/nodejs-repo-tools`);
const uuid = require(`uuid`);
Expand Down
2 changes: 1 addition & 1 deletion samples/system-test/topics.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
'use strict';

const path = require(`path`);
const PubSub = require(`@google-cloud/pubsub`);
const {PubSub} = require('@google-cloud/pubsub');
const test = require(`ava`);
const tools = require(`@google-cloud/nodejs-repo-tools`);
const uuid = require(`uuid`);
Expand Down
20 changes: 10 additions & 10 deletions samples/topics.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
function listAllTopics() {
// [START pubsub_list_topics]
// Imports the Google Cloud client library
const PubSub = require(`@google-cloud/pubsub`);
const {PubSub} = require('@google-cloud/pubsub');

// Creates a client
const pubsub = new PubSub();
Expand All @@ -49,7 +49,7 @@ function listAllTopics() {
function createTopic(topicName) {
// [START pubsub_create_topic]
// Imports the Google Cloud client library
const PubSub = require(`@google-cloud/pubsub`);
const {PubSub} = require('@google-cloud/pubsub');

// Creates a client
const pubsub = new PubSub();
Expand All @@ -75,7 +75,7 @@ function createTopic(topicName) {
function deleteTopic(topicName) {
// [START pubsub_delete_topic]
// Imports the Google Cloud client library
const PubSub = require(`@google-cloud/pubsub`);
const {PubSub} = require('@google-cloud/pubsub');

// Creates a client
const pubsub = new PubSub();
Expand All @@ -102,7 +102,7 @@ function publishMessage(topicName, data) {
// [START pubsub_publish]
// [START pubsub_quickstart_publisher]
// Imports the Google Cloud client library
const PubSub = require(`@google-cloud/pubsub`);
const {PubSub} = require('@google-cloud/pubsub');

// Creates a client
const pubsub = new PubSub();
Expand Down Expand Up @@ -133,7 +133,7 @@ function publishMessage(topicName, data) {
function publishMessageWithCustomAttributes(topicName, data) {
// [START pubsub_publish_custom_attributes]
// Imports the Google Cloud client library
const PubSub = require(`@google-cloud/pubsub`);
const {PubSub} = require('@google-cloud/pubsub');

// Creates a client
const pubsub = new PubSub();
Expand Down Expand Up @@ -168,7 +168,7 @@ function publishMessageWithCustomAttributes(topicName, data) {
function publishBatchedMessages(topicName, data, maxMessages, maxWaitTime) {
// [START pubsub_publisher_batch_settings]
// Imports the Google Cloud client library
const PubSub = require(`@google-cloud/pubsub`);
const {PubSub} = require('@google-cloud/pubsub');

// Creates a client
const pubsub = new PubSub();
Expand Down Expand Up @@ -216,7 +216,7 @@ function setPublishCounterValue(value) {
function publishOrderedMessage(topicName, data) {
// [START pubsub_publish_ordered_message]
// Imports the Google Cloud client library
const PubSub = require(`@google-cloud/pubsub`);
const {PubSub} = require('@google-cloud/pubsub');

// Creates a client
const pubsub = new PubSub();
Expand Down Expand Up @@ -259,7 +259,7 @@ function publishOrderedMessage(topicName, data) {
function getTopicPolicy(topicName) {
// [START pubsub_get_topic_policy]
// Imports the Google Cloud client library
const PubSub = require(`@google-cloud/pubsub`);
const {PubSub} = require('@google-cloud/pubsub');

// Creates a client
const pubsub = new PubSub();
Expand All @@ -286,7 +286,7 @@ function getTopicPolicy(topicName) {
function setTopicPolicy(topicName) {
// [START pubsub_set_topic_policy]
// Imports the Google Cloud client library
const PubSub = require(`@google-cloud/pubsub`);
const {PubSub} = require('@google-cloud/pubsub');

// Creates a client
const pubsub = new PubSub();
Expand Down Expand Up @@ -329,7 +329,7 @@ function setTopicPolicy(topicName) {
function testTopicPermissions(topicName) {
// [START pubsub_test_topic_permissions]
// Imports the Google Cloud client library
const PubSub = require(`@google-cloud/pubsub`);
const {PubSub} = require('@google-cloud/pubsub');

// Creates a client
const pubsub = new PubSub();
Expand Down
2 changes: 0 additions & 2 deletions smoke-test/publisher_smoke_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@
// See the License for the specific language governing permissions and
// limitations under the License.

'use strict';

describe('PublisherSmokeTest', () => {
if (!process.env.GCLOUD_PROJECT) {
throw new Error('Usage: GCLOUD_PROJECT=<project_id> node #{$0}');
Expand Down
4 changes: 1 addition & 3 deletions src/connection-pool.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ const RETRY_CODES = [
* @param {number} [options.ackDeadline] The ack deadline to send when
* creating a connection.
*/
class ConnectionPool extends EventEmitter {
export class ConnectionPool extends EventEmitter {
subscription;
pubsub;
connections;
Expand Down Expand Up @@ -458,5 +458,3 @@ class ConnectionPool extends EventEmitter {
return true;
}
}

module.exports = ConnectionPool;
6 changes: 2 additions & 4 deletions src/histogram.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@ import * as extend from 'extend';
* @private
* @class
*/
class Histogram {
export class Histogram {
options;
data;
length;
constructor(options) {
constructor(options?) {
this.options = extend(
{
min: 10000,
Expand Down Expand Up @@ -78,5 +78,3 @@ class Histogram {
return this.options.min;
}
}

module.exports = Histogram;
Loading

0 comments on commit bb357fc

Please sign in to comment.